@dodoex/wallet-web3 0.0.40-2 → 0.0.40-4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{DefaultJsonRpcProvider-364a16a2.js → DefaultJsonRpcProvider-0d7925ff.js} +1 -1
- package/dist/__node-resolve_empty-261d59ac.js +1 -0
- package/dist/__tslib-0e83d985.js +1 -0
- package/dist/{alchemy-provider-5870b6fa-8fbacf61.js → alchemy-provider-5870b6fa-e395a256.js} +1 -1
- package/dist/{alchemy-websocket-provider-213da986-0121b03d.js → alchemy-websocket-provider-213da986-313bda01.js} +1 -1
- package/dist/{blocto-34243ed4.js → blocto-edcf7e9c.js} +1 -1
- package/dist/{bn-b7624e9d.js → bn-92d59440.js} +1 -1
- package/dist/{browser-ponyfill-3b79f0e4.js → browser-ponyfill-d3098539.js} +1 -1
- package/dist/{ccip-016a1f59.js → ccip-579ffb0a.js} +1 -1
- package/dist/cjs/{DefaultJsonRpcProvider-a94708b3.cjs → DefaultJsonRpcProvider-bca8f91d.cjs} +1 -1
- package/dist/cjs/{__node-resolve_empty-26284176.cjs → __node-resolve_empty-265d1c49.cjs} +1 -1
- package/dist/cjs/__tslib-23f33cbc.cjs +1 -0
- package/dist/cjs/{alchemy-provider-5870b6fa-b4296005.cjs → alchemy-provider-5870b6fa-96ba77e7.cjs} +1 -1
- package/dist/cjs/{alchemy-websocket-provider-213da986-a6830135.cjs → alchemy-websocket-provider-213da986-6aab7eae.cjs} +1 -1
- package/dist/cjs/{blocto-1d0d2893.cjs → blocto-d87e4c02.cjs} +1 -1
- package/dist/cjs/{bn-f89c8fd2.cjs → bn-70ac244c.cjs} +1 -1
- package/dist/cjs/{browser-ponyfill-d62ef4bf.cjs → browser-ponyfill-71fb8794.cjs} +1 -1
- package/dist/cjs/{ccip-b4e734fd.cjs → ccip-e892e984.cjs} +1 -1
- package/dist/cjs/{draggabilly-57e73b82.cjs → draggabilly-14f61cef.cjs} +1 -1
- package/dist/cjs/{ethers-772b1cf3.cjs → ethers-70b6183e.cjs} +1 -1
- package/dist/cjs/{id-80cf99a8.cjs → id-64cfc377.cjs} +1 -1
- package/dist/cjs/{index-ddb7482e.cjs → index-0ed73dc0.cjs} +1 -1
- package/dist/cjs/{index-88f00c83.cjs → index-106a55ec.cjs} +1 -1
- package/dist/cjs/{index-a60557e5.cjs → index-18b9efa9.cjs} +5 -5
- package/dist/cjs/{index-a5d1fc7d.cjs → index-2d21ff5b.cjs} +1 -1
- package/dist/cjs/{index-a61f4ed4.cjs → index-2ddcd00d.cjs} +1 -1
- package/dist/cjs/{index-495da4ae.cjs → index-8a737425.cjs} +1 -1
- package/dist/cjs/{index-f56317c4.cjs → index-94459054.cjs} +1 -1
- package/dist/cjs/{index-a5ded8c9.cjs → index-9ce25397.cjs} +1 -1
- package/dist/cjs/{index-3b1c3d83.cjs → index-a4ac3bd5.cjs} +1 -1
- package/dist/cjs/{index-3ec270bc.cjs → index-b92a55b8.cjs} +1 -1
- package/dist/cjs/{index-dd3eb942.cjs → index-d0ceb723.cjs} +1 -1
- package/dist/cjs/{index-ba947a0e.cjs → index-d16b6756.cjs} +2 -2
- package/dist/cjs/{index-4925f240.cjs → index-f63cfc3f.cjs} +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/{index.es-6457f876.cjs → index.es-091ee5b4.cjs} +1 -1
- package/dist/cjs/{interface-a86a59a0.cjs → interface-885a5be0.cjs} +1 -1
- package/dist/cjs/{lib-typedarrays-73f7411c.cjs → lib-typedarrays-88b4f6fa.cjs} +1 -1
- package/dist/cjs/{portis-ccffc275.cjs → portis-838df928.cjs} +1 -1
- package/dist/cjs/{provider-62b688fe.cjs → provider-4c7501d6.cjs} +1 -1
- package/dist/cjs/providers/connector/types.d.ts +1 -1
- package/dist/cjs/{rainbow-d4b2160c.cjs → rainbow-7d2fe1e2.cjs} +1 -1
- package/dist/cjs/{sha224-59d7c2f4.cjs → sha224-158bd458.cjs} +1 -1
- package/dist/cjs/{sha256-583ac6ee.cjs → sha256-6071af96.cjs} +1 -1
- package/dist/cjs/{uAuth-e3b2e493.cjs → uAuth-921a815b.cjs} +1 -1
- package/dist/cjs/{walletConnect-d7cad7d8.cjs → walletConnect-70d89c92.cjs} +1 -1
- package/dist/cjs/{walletLink-84b36969.cjs → walletLink-7fe3af33.cjs} +1 -1
- package/dist/{draggabilly-d415e35d.js → draggabilly-2580bf5b.js} +1 -1
- package/dist/{ethers-1ae3e4fa.js → ethers-833b2300.js} +1 -1
- package/dist/{id-6feb8a9a.js → id-3aece8c0.js} +1 -1
- package/dist/index-14387775.js +1 -0
- package/dist/{index-ee62f708.js → index-1a005328.js} +2 -2
- package/dist/{index-4bb05276.js → index-21722c04.js} +1 -1
- package/dist/{index-846c4ffa.js → index-33f10a1b.js} +1 -1
- package/dist/{index-515f54ab.js → index-3dfcceec.js} +5 -5
- package/dist/{index-9f927876.js → index-767c26b7.js} +1 -1
- package/dist/{index-33028157.js → index-7decf620.js} +1 -1
- package/dist/{index-ca6d18a2.js → index-9a4379d7.js} +1 -1
- package/dist/{index-8bd78414.js → index-9cc0c074.js} +1 -1
- package/dist/{index-24cfd57b.js → index-b09fd06f.js} +1 -1
- package/dist/{index-85ba09c2.js → index-b5d79167.js} +1 -1
- package/dist/{index-b271e5c1.js → index-cd6bd2ce.js} +1 -1
- package/dist/{index-1c4edfc7.js → index-e75a363b.js} +1 -1
- package/dist/{index.es-aded1b18.js → index.es-e8743b8d.js} +1 -1
- package/dist/index.js +1 -1
- package/dist/{interface-1e8541e5.js → interface-c94b78af.js} +1 -1
- package/dist/{lib-typedarrays-633d9f0c.js → lib-typedarrays-a8bb783b.js} +1 -1
- package/dist/{portis-9a642930.js → portis-2205d07c.js} +1 -1
- package/dist/{provider-f66474d9.js → provider-4d3d7268.js} +1 -1
- package/dist/providers/connector/types.d.ts +1 -1
- package/dist/{rainbow-ee8fcc0b.js → rainbow-27aaabde.js} +1 -1
- package/dist/sha224-7c9278b8.js +1 -0
- package/dist/{sha256-6dd71d49.js → sha256-fe7bb483.js} +1 -1
- package/dist/{uAuth-15130e34.js → uAuth-6044680b.js} +1 -1
- package/dist/{walletConnect-7bb7a1f1.js → walletConnect-9e745470.js} +1 -1
- package/dist/{walletLink-15c06b7d.js → walletLink-26ad7eac.js} +1 -1
- package/package.json +3 -3
- package/dist/__node-resolve_empty-483b15e9.js +0 -1
- package/dist/__tslib-52669014.js +0 -1
- package/dist/cjs/__tslib-25766973.cjs +0 -1
- package/dist/index-bf6567c3.js +0 -1
- package/dist/sha224-4e5611c9.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as t}from"./index-33028157.js";import{r as i}from"./__node-resolve_empty-483b15e9.js";var r={exports:{}};!function(t,r){function h(t,i){if(!t)throw new Error(i||"Assertion failed")}function n(t,i){t.super_=i;var r=function(){};r.prototype=i.prototype,t.prototype=new r,t.prototype.constructor=t}function e(t,i,r){if(e.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==i&&"be"!==i||(r=i,i=10),this._init(t||0,i||10,r||"be"))}var o;"object"==typeof t?t.exports=e:r.BN=e,e.BN=e,e.wordSize=26;try{o="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:i.Buffer}catch(t){}function s(t,i){var r=t.charCodeAt(i);return r>=48&&r<=57?r-48:r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:void h(!1,"Invalid character in "+t)}function u(t,i,r){var h=s(t,r);return r-1>=i&&(h|=s(t,r-1)<<4),h}function l(t,i,r,n){for(var e=0,o=0,s=Math.min(t.length,r),u=i;u<s;u++){var l=t.charCodeAt(u)-48;e*=n,o=l>=49?l-49+10:l>=17?l-17+10:l,h(l>=0&&o<n,"Invalid character"),e+=o}return e}function a(t,i){t.words=i.words,t.length=i.length,t.negative=i.negative,t.red=i.red}if(e.isBN=function(t){return t instanceof e||null!==t&&"object"==typeof t&&t.constructor.wordSize===e.wordSize&&Array.isArray(t.words)},e.max=function(t,i){return t.cmp(i)>0?t:i},e.min=function(t,i){return t.cmp(i)<0?t:i},e.prototype._init=function(t,i,r){if("number"==typeof t)return this._initNumber(t,i,r);if("object"==typeof t)return this._initArray(t,i,r);"hex"===i&&(i=16),h(i===(0|i)&&i>=2&&i<=36);var n=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&(n++,this.negative=1),n<t.length&&(16===i?this._parseHex(t,n,r):(this._parseBase(t,i,n),"le"===r&&this._initArray(this.toArray(),i,r)))},e.prototype._initNumber=function(t,i,r){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(h(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===r&&this._initArray(this.toArray(),i,r)},e.prototype._initArray=function(t,i,r){if(h("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var n=0;n<this.length;n++)this.words[n]=0;var e,o,s=0;if("be"===r)for(n=t.length-1,e=0;n>=0;n-=3)o=t[n]|t[n-1]<<8|t[n-2]<<16,this.words[e]|=o<<s&67108863,this.words[e+1]=o>>>26-s&67108863,(s+=24)>=26&&(s-=26,e++);else if("le"===r)for(n=0,e=0;n<t.length;n+=3)o=t[n]|t[n+1]<<8|t[n+2]<<16,this.words[e]|=o<<s&67108863,this.words[e+1]=o>>>26-s&67108863,(s+=24)>=26&&(s-=26,e++);return this._strip()},e.prototype._parseHex=function(t,i,r){this.length=Math.ceil((t.length-i)/6),this.words=new Array(this.length);for(var h=0;h<this.length;h++)this.words[h]=0;var n,e=0,o=0;if("be"===r)for(h=t.length-1;h>=i;h-=2)n=u(t,i,h)<<e,this.words[o]|=67108863&n,e>=18?(e-=18,o+=1,this.words[o]|=n>>>26):e+=8;else for(h=(t.length-i)%2==0?i+1:i;h<t.length;h+=2)n=u(t,i,h)<<e,this.words[o]|=67108863&n,e>=18?(e-=18,o+=1,this.words[o]|=n>>>26):e+=8;this._strip()},e.prototype._parseBase=function(t,i,r){this.words=[0],this.length=1;for(var h=0,n=1;n<=67108863;n*=i)h++;h--,n=n/i|0;for(var e=t.length-r,o=e%h,s=Math.min(e,e-o)+r,u=0,a=r;a<s;a+=h)u=l(t,a,a+h,i),this.imuln(n),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u);if(0!==o){var m=1;for(u=l(t,a,t.length,i),a=0;a<o;a++)m*=i;this.imuln(m),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u)}this._strip()},e.prototype.copy=function(t){t.words=new Array(this.length);for(var i=0;i<this.length;i++)t.words[i]=this.words[i];t.length=this.length,t.negative=this.negative,t.red=this.red},e.prototype._move=function(t){a(t,this)},e.prototype.clone=function(){var t=new e(null);return this.copy(t),t},e.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this},e.prototype._strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},e.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},"undefined"!=typeof Symbol&&"function"==typeof Symbol.for)try{e.prototype[Symbol.for("nodejs.util.inspect.custom")]=m}catch(t){e.prototype.inspect=m}else e.prototype.inspect=m;function m(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var f=["","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"],d=[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],p=[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 M(t,i,r){r.negative=i.negative^t.negative;var h=t.length+i.length|0;r.length=h,h=h-1|0;var n=0|t.words[0],e=0|i.words[0],o=n*e,s=67108863&o,u=o/67108864|0;r.words[0]=s;for(var l=1;l<h;l++){for(var a=u>>>26,m=67108863&u,f=Math.min(l,i.length-1),d=Math.max(0,l-t.length+1);d<=f;d++){var p=l-d|0;a+=(o=(n=0|t.words[p])*(e=0|i.words[d])+m)/67108864|0,m=67108863&o}r.words[l]=0|m,u=0|a}return 0!==u?r.words[l]=0|u:r.length--,r._strip()}e.prototype.toString=function(t,i){var r;if(i=0|i||1,16===(t=t||10)||"hex"===t){r="";for(var n=0,e=0,o=0;o<this.length;o++){var s=this.words[o],u=(16777215&(s<<n|e)).toString(16);e=s>>>24-n&16777215,(n+=2)>=26&&(n-=26,o--),r=0!==e||o!==this.length-1?f[6-u.length]+u+r:u+r}for(0!==e&&(r=e.toString(16)+r);r.length%i!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(t===(0|t)&&t>=2&&t<=36){var l=d[t],a=p[t];r="";var m=this.clone();for(m.negative=0;!m.isZero();){var M=m.modrn(a).toString(t);r=(m=m.idivn(a)).isZero()?M+r:f[l-M.length]+M+r}for(this.isZero()&&(r="0"+r);r.length%i!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}h(!1,"Base should be between 2 and 36")},e.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&h(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},e.prototype.toJSON=function(){return this.toString(16,2)},o&&(e.prototype.toBuffer=function(t,i){return this.toArrayLike(o,t,i)}),e.prototype.toArray=function(t,i){return this.toArrayLike(Array,t,i)},e.prototype.toArrayLike=function(t,i,r){this._strip();var n=this.byteLength(),e=r||Math.max(1,n);h(n<=e,"byte array longer than desired length"),h(e>0,"Requested array length <= 0");var o=function(t,i){return t.allocUnsafe?t.allocUnsafe(i):new t(i)}(t,e);return this["_toArrayLike"+("le"===i?"LE":"BE")](o,n),o},e.prototype._toArrayLikeLE=function(t,i){for(var r=0,h=0,n=0,e=0;n<this.length;n++){var o=this.words[n]<<e|h;t[r++]=255&o,r<t.length&&(t[r++]=o>>8&255),r<t.length&&(t[r++]=o>>16&255),6===e?(r<t.length&&(t[r++]=o>>24&255),h=0,e=0):(h=o>>>24,e+=2)}if(r<t.length)for(t[r++]=h;r<t.length;)t[r++]=0},e.prototype._toArrayLikeBE=function(t,i){for(var r=t.length-1,h=0,n=0,e=0;n<this.length;n++){var o=this.words[n]<<e|h;t[r--]=255&o,r>=0&&(t[r--]=o>>8&255),r>=0&&(t[r--]=o>>16&255),6===e?(r>=0&&(t[r--]=o>>24&255),h=0,e=0):(h=o>>>24,e+=2)}if(r>=0)for(t[r--]=h;r>=0;)t[r--]=0},Math.clz32?e.prototype._countBits=function(t){return 32-Math.clz32(t)}:e.prototype._countBits=function(t){var i=t,r=0;return i>=4096&&(r+=13,i>>>=13),i>=64&&(r+=7,i>>>=7),i>=8&&(r+=4,i>>>=4),i>=2&&(r+=2,i>>>=2),r+i},e.prototype._zeroBits=function(t){if(0===t)return 26;var i=t,r=0;return 0==(8191&i)&&(r+=13,i>>>=13),0==(127&i)&&(r+=7,i>>>=7),0==(15&i)&&(r+=4,i>>>=4),0==(3&i)&&(r+=2,i>>>=2),0==(1&i)&&r++,r},e.prototype.bitLength=function(){var t=this.words[this.length-1],i=this._countBits(t);return 26*(this.length-1)+i},e.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,i=0;i<this.length;i++){var r=this._zeroBits(this.words[i]);if(t+=r,26!==r)break}return t},e.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},e.prototype.toTwos=function(t){return 0!==this.negative?this.abs().inotn(t).iaddn(1):this.clone()},e.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},e.prototype.isNeg=function(){return 0!==this.negative},e.prototype.neg=function(){return this.clone().ineg()},e.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},e.prototype.iuor=function(t){for(;this.length<t.length;)this.words[this.length++]=0;for(var i=0;i<t.length;i++)this.words[i]=this.words[i]|t.words[i];return this._strip()},e.prototype.ior=function(t){return h(0==(this.negative|t.negative)),this.iuor(t)},e.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},e.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},e.prototype.iuand=function(t){var i;i=this.length>t.length?t:this;for(var r=0;r<i.length;r++)this.words[r]=this.words[r]&t.words[r];return this.length=i.length,this._strip()},e.prototype.iand=function(t){return h(0==(this.negative|t.negative)),this.iuand(t)},e.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},e.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},e.prototype.iuxor=function(t){var i,r;this.length>t.length?(i=this,r=t):(i=t,r=this);for(var h=0;h<r.length;h++)this.words[h]=i.words[h]^r.words[h];if(this!==i)for(;h<i.length;h++)this.words[h]=i.words[h];return this.length=i.length,this._strip()},e.prototype.ixor=function(t){return h(0==(this.negative|t.negative)),this.iuxor(t)},e.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},e.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},e.prototype.inotn=function(t){h("number"==typeof t&&t>=0);var i=0|Math.ceil(t/26),r=t%26;this._expand(i),r>0&&i--;for(var n=0;n<i;n++)this.words[n]=67108863&~this.words[n];return r>0&&(this.words[n]=~this.words[n]&67108863>>26-r),this._strip()},e.prototype.notn=function(t){return this.clone().inotn(t)},e.prototype.setn=function(t,i){h("number"==typeof t&&t>=0);var r=t/26|0,n=t%26;return this._expand(r+1),this.words[r]=i?this.words[r]|1<<n:this.words[r]&~(1<<n),this._strip()},e.prototype.iadd=function(t){var i,r,h;if(0!==this.negative&&0===t.negative)return this.negative=0,i=this.isub(t),this.negative^=1,this._normSign();if(0===this.negative&&0!==t.negative)return t.negative=0,i=this.isub(t),t.negative=1,i._normSign();this.length>t.length?(r=this,h=t):(r=t,h=this);for(var n=0,e=0;e<h.length;e++)i=(0|r.words[e])+(0|h.words[e])+n,this.words[e]=67108863&i,n=i>>>26;for(;0!==n&&e<r.length;e++)i=(0|r.words[e])+n,this.words[e]=67108863&i,n=i>>>26;if(this.length=r.length,0!==n)this.words[this.length]=n,this.length++;else if(r!==this)for(;e<r.length;e++)this.words[e]=r.words[e];return this},e.prototype.add=function(t){var i;return 0!==t.negative&&0===this.negative?(t.negative=0,i=this.sub(t),t.negative^=1,i):0===t.negative&&0!==this.negative?(this.negative=0,i=t.sub(this),this.negative=1,i):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this)},e.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var i=this.iadd(t);return t.negative=1,i._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,h,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(r=this,h=t):(r=t,h=this);for(var e=0,o=0;o<h.length;o++)e=(i=(0|r.words[o])-(0|h.words[o])+e)>>26,this.words[o]=67108863&i;for(;0!==e&&o<r.length;o++)e=(i=(0|r.words[o])+e)>>26,this.words[o]=67108863&i;if(0===e&&o<r.length&&r!==this)for(;o<r.length;o++)this.words[o]=r.words[o];return this.length=Math.max(this.length,o),r!==this&&(this.negative=1),this._strip()},e.prototype.sub=function(t){return this.clone().isub(t)};var v=function(t,i,r){var h,n,e,o=t.words,s=i.words,u=r.words,l=0,a=0|o[0],m=8191&a,f=a>>>13,d=0|o[1],p=8191&d,M=d>>>13,v=0|o[2],g=8191&v,c=v>>>13,w=0|o[3],y=8191&w,b=w>>>13,_=0|o[4],k=8191&_,A=_>>>13,S=0|o[5],x=8191&S,q=S>>>13,Z=0|o[6],B=8191&Z,R=Z>>>13,L=0|o[7],N=8191&L,E=L>>>13,I=0|o[8],z=8191&I,O=I>>>13,T=0|o[9],j=8191&T,K=T>>>13,F=0|s[0],U=8191&F,C=F>>>13,D=0|s[1],H=8191&D,P=D>>>13,J=0|s[2],G=8191&J,Q=J>>>13,V=0|s[3],W=8191&V,X=V>>>13,Y=0|s[4],$=8191&Y,tt=Y>>>13,it=0|s[5],rt=8191&it,ht=it>>>13,nt=0|s[6],et=8191&nt,ot=nt>>>13,st=0|s[7],ut=8191&st,lt=st>>>13,at=0|s[8],mt=8191&at,ft=at>>>13,dt=0|s[9],pt=8191&dt,Mt=dt>>>13;r.negative=t.negative^i.negative,r.length=19;var vt=(l+(h=Math.imul(m,U))|0)+((8191&(n=(n=Math.imul(m,C))+Math.imul(f,U)|0))<<13)|0;l=((e=Math.imul(f,C))+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,h=Math.imul(p,U),n=(n=Math.imul(p,C))+Math.imul(M,U)|0,e=Math.imul(M,C);var gt=(l+(h=h+Math.imul(m,H)|0)|0)+((8191&(n=(n=n+Math.imul(m,P)|0)+Math.imul(f,H)|0))<<13)|0;l=((e=e+Math.imul(f,P)|0)+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,h=Math.imul(g,U),n=(n=Math.imul(g,C))+Math.imul(c,U)|0,e=Math.imul(c,C),h=h+Math.imul(p,H)|0,n=(n=n+Math.imul(p,P)|0)+Math.imul(M,H)|0,e=e+Math.imul(M,P)|0;var ct=(l+(h=h+Math.imul(m,G)|0)|0)+((8191&(n=(n=n+Math.imul(m,Q)|0)+Math.imul(f,G)|0))<<13)|0;l=((e=e+Math.imul(f,Q)|0)+(n>>>13)|0)+(ct>>>26)|0,ct&=67108863,h=Math.imul(y,U),n=(n=Math.imul(y,C))+Math.imul(b,U)|0,e=Math.imul(b,C),h=h+Math.imul(g,H)|0,n=(n=n+Math.imul(g,P)|0)+Math.imul(c,H)|0,e=e+Math.imul(c,P)|0,h=h+Math.imul(p,G)|0,n=(n=n+Math.imul(p,Q)|0)+Math.imul(M,G)|0,e=e+Math.imul(M,Q)|0;var wt=(l+(h=h+Math.imul(m,W)|0)|0)+((8191&(n=(n=n+Math.imul(m,X)|0)+Math.imul(f,W)|0))<<13)|0;l=((e=e+Math.imul(f,X)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,h=Math.imul(k,U),n=(n=Math.imul(k,C))+Math.imul(A,U)|0,e=Math.imul(A,C),h=h+Math.imul(y,H)|0,n=(n=n+Math.imul(y,P)|0)+Math.imul(b,H)|0,e=e+Math.imul(b,P)|0,h=h+Math.imul(g,G)|0,n=(n=n+Math.imul(g,Q)|0)+Math.imul(c,G)|0,e=e+Math.imul(c,Q)|0,h=h+Math.imul(p,W)|0,n=(n=n+Math.imul(p,X)|0)+Math.imul(M,W)|0,e=e+Math.imul(M,X)|0;var yt=(l+(h=h+Math.imul(m,$)|0)|0)+((8191&(n=(n=n+Math.imul(m,tt)|0)+Math.imul(f,$)|0))<<13)|0;l=((e=e+Math.imul(f,tt)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,h=Math.imul(x,U),n=(n=Math.imul(x,C))+Math.imul(q,U)|0,e=Math.imul(q,C),h=h+Math.imul(k,H)|0,n=(n=n+Math.imul(k,P)|0)+Math.imul(A,H)|0,e=e+Math.imul(A,P)|0,h=h+Math.imul(y,G)|0,n=(n=n+Math.imul(y,Q)|0)+Math.imul(b,G)|0,e=e+Math.imul(b,Q)|0,h=h+Math.imul(g,W)|0,n=(n=n+Math.imul(g,X)|0)+Math.imul(c,W)|0,e=e+Math.imul(c,X)|0,h=h+Math.imul(p,$)|0,n=(n=n+Math.imul(p,tt)|0)+Math.imul(M,$)|0,e=e+Math.imul(M,tt)|0;var bt=(l+(h=h+Math.imul(m,rt)|0)|0)+((8191&(n=(n=n+Math.imul(m,ht)|0)+Math.imul(f,rt)|0))<<13)|0;l=((e=e+Math.imul(f,ht)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,h=Math.imul(B,U),n=(n=Math.imul(B,C))+Math.imul(R,U)|0,e=Math.imul(R,C),h=h+Math.imul(x,H)|0,n=(n=n+Math.imul(x,P)|0)+Math.imul(q,H)|0,e=e+Math.imul(q,P)|0,h=h+Math.imul(k,G)|0,n=(n=n+Math.imul(k,Q)|0)+Math.imul(A,G)|0,e=e+Math.imul(A,Q)|0,h=h+Math.imul(y,W)|0,n=(n=n+Math.imul(y,X)|0)+Math.imul(b,W)|0,e=e+Math.imul(b,X)|0,h=h+Math.imul(g,$)|0,n=(n=n+Math.imul(g,tt)|0)+Math.imul(c,$)|0,e=e+Math.imul(c,tt)|0,h=h+Math.imul(p,rt)|0,n=(n=n+Math.imul(p,ht)|0)+Math.imul(M,rt)|0,e=e+Math.imul(M,ht)|0;var _t=(l+(h=h+Math.imul(m,et)|0)|0)+((8191&(n=(n=n+Math.imul(m,ot)|0)+Math.imul(f,et)|0))<<13)|0;l=((e=e+Math.imul(f,ot)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,h=Math.imul(N,U),n=(n=Math.imul(N,C))+Math.imul(E,U)|0,e=Math.imul(E,C),h=h+Math.imul(B,H)|0,n=(n=n+Math.imul(B,P)|0)+Math.imul(R,H)|0,e=e+Math.imul(R,P)|0,h=h+Math.imul(x,G)|0,n=(n=n+Math.imul(x,Q)|0)+Math.imul(q,G)|0,e=e+Math.imul(q,Q)|0,h=h+Math.imul(k,W)|0,n=(n=n+Math.imul(k,X)|0)+Math.imul(A,W)|0,e=e+Math.imul(A,X)|0,h=h+Math.imul(y,$)|0,n=(n=n+Math.imul(y,tt)|0)+Math.imul(b,$)|0,e=e+Math.imul(b,tt)|0,h=h+Math.imul(g,rt)|0,n=(n=n+Math.imul(g,ht)|0)+Math.imul(c,rt)|0,e=e+Math.imul(c,ht)|0,h=h+Math.imul(p,et)|0,n=(n=n+Math.imul(p,ot)|0)+Math.imul(M,et)|0,e=e+Math.imul(M,ot)|0;var kt=(l+(h=h+Math.imul(m,ut)|0)|0)+((8191&(n=(n=n+Math.imul(m,lt)|0)+Math.imul(f,ut)|0))<<13)|0;l=((e=e+Math.imul(f,lt)|0)+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,h=Math.imul(z,U),n=(n=Math.imul(z,C))+Math.imul(O,U)|0,e=Math.imul(O,C),h=h+Math.imul(N,H)|0,n=(n=n+Math.imul(N,P)|0)+Math.imul(E,H)|0,e=e+Math.imul(E,P)|0,h=h+Math.imul(B,G)|0,n=(n=n+Math.imul(B,Q)|0)+Math.imul(R,G)|0,e=e+Math.imul(R,Q)|0,h=h+Math.imul(x,W)|0,n=(n=n+Math.imul(x,X)|0)+Math.imul(q,W)|0,e=e+Math.imul(q,X)|0,h=h+Math.imul(k,$)|0,n=(n=n+Math.imul(k,tt)|0)+Math.imul(A,$)|0,e=e+Math.imul(A,tt)|0,h=h+Math.imul(y,rt)|0,n=(n=n+Math.imul(y,ht)|0)+Math.imul(b,rt)|0,e=e+Math.imul(b,ht)|0,h=h+Math.imul(g,et)|0,n=(n=n+Math.imul(g,ot)|0)+Math.imul(c,et)|0,e=e+Math.imul(c,ot)|0,h=h+Math.imul(p,ut)|0,n=(n=n+Math.imul(p,lt)|0)+Math.imul(M,ut)|0,e=e+Math.imul(M,lt)|0;var At=(l+(h=h+Math.imul(m,mt)|0)|0)+((8191&(n=(n=n+Math.imul(m,ft)|0)+Math.imul(f,mt)|0))<<13)|0;l=((e=e+Math.imul(f,ft)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,h=Math.imul(j,U),n=(n=Math.imul(j,C))+Math.imul(K,U)|0,e=Math.imul(K,C),h=h+Math.imul(z,H)|0,n=(n=n+Math.imul(z,P)|0)+Math.imul(O,H)|0,e=e+Math.imul(O,P)|0,h=h+Math.imul(N,G)|0,n=(n=n+Math.imul(N,Q)|0)+Math.imul(E,G)|0,e=e+Math.imul(E,Q)|0,h=h+Math.imul(B,W)|0,n=(n=n+Math.imul(B,X)|0)+Math.imul(R,W)|0,e=e+Math.imul(R,X)|0,h=h+Math.imul(x,$)|0,n=(n=n+Math.imul(x,tt)|0)+Math.imul(q,$)|0,e=e+Math.imul(q,tt)|0,h=h+Math.imul(k,rt)|0,n=(n=n+Math.imul(k,ht)|0)+Math.imul(A,rt)|0,e=e+Math.imul(A,ht)|0,h=h+Math.imul(y,et)|0,n=(n=n+Math.imul(y,ot)|0)+Math.imul(b,et)|0,e=e+Math.imul(b,ot)|0,h=h+Math.imul(g,ut)|0,n=(n=n+Math.imul(g,lt)|0)+Math.imul(c,ut)|0,e=e+Math.imul(c,lt)|0,h=h+Math.imul(p,mt)|0,n=(n=n+Math.imul(p,ft)|0)+Math.imul(M,mt)|0,e=e+Math.imul(M,ft)|0;var St=(l+(h=h+Math.imul(m,pt)|0)|0)+((8191&(n=(n=n+Math.imul(m,Mt)|0)+Math.imul(f,pt)|0))<<13)|0;l=((e=e+Math.imul(f,Mt)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,h=Math.imul(j,H),n=(n=Math.imul(j,P))+Math.imul(K,H)|0,e=Math.imul(K,P),h=h+Math.imul(z,G)|0,n=(n=n+Math.imul(z,Q)|0)+Math.imul(O,G)|0,e=e+Math.imul(O,Q)|0,h=h+Math.imul(N,W)|0,n=(n=n+Math.imul(N,X)|0)+Math.imul(E,W)|0,e=e+Math.imul(E,X)|0,h=h+Math.imul(B,$)|0,n=(n=n+Math.imul(B,tt)|0)+Math.imul(R,$)|0,e=e+Math.imul(R,tt)|0,h=h+Math.imul(x,rt)|0,n=(n=n+Math.imul(x,ht)|0)+Math.imul(q,rt)|0,e=e+Math.imul(q,ht)|0,h=h+Math.imul(k,et)|0,n=(n=n+Math.imul(k,ot)|0)+Math.imul(A,et)|0,e=e+Math.imul(A,ot)|0,h=h+Math.imul(y,ut)|0,n=(n=n+Math.imul(y,lt)|0)+Math.imul(b,ut)|0,e=e+Math.imul(b,lt)|0,h=h+Math.imul(g,mt)|0,n=(n=n+Math.imul(g,ft)|0)+Math.imul(c,mt)|0,e=e+Math.imul(c,ft)|0;var xt=(l+(h=h+Math.imul(p,pt)|0)|0)+((8191&(n=(n=n+Math.imul(p,Mt)|0)+Math.imul(M,pt)|0))<<13)|0;l=((e=e+Math.imul(M,Mt)|0)+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,h=Math.imul(j,G),n=(n=Math.imul(j,Q))+Math.imul(K,G)|0,e=Math.imul(K,Q),h=h+Math.imul(z,W)|0,n=(n=n+Math.imul(z,X)|0)+Math.imul(O,W)|0,e=e+Math.imul(O,X)|0,h=h+Math.imul(N,$)|0,n=(n=n+Math.imul(N,tt)|0)+Math.imul(E,$)|0,e=e+Math.imul(E,tt)|0,h=h+Math.imul(B,rt)|0,n=(n=n+Math.imul(B,ht)|0)+Math.imul(R,rt)|0,e=e+Math.imul(R,ht)|0,h=h+Math.imul(x,et)|0,n=(n=n+Math.imul(x,ot)|0)+Math.imul(q,et)|0,e=e+Math.imul(q,ot)|0,h=h+Math.imul(k,ut)|0,n=(n=n+Math.imul(k,lt)|0)+Math.imul(A,ut)|0,e=e+Math.imul(A,lt)|0,h=h+Math.imul(y,mt)|0,n=(n=n+Math.imul(y,ft)|0)+Math.imul(b,mt)|0,e=e+Math.imul(b,ft)|0;var qt=(l+(h=h+Math.imul(g,pt)|0)|0)+((8191&(n=(n=n+Math.imul(g,Mt)|0)+Math.imul(c,pt)|0))<<13)|0;l=((e=e+Math.imul(c,Mt)|0)+(n>>>13)|0)+(qt>>>26)|0,qt&=67108863,h=Math.imul(j,W),n=(n=Math.imul(j,X))+Math.imul(K,W)|0,e=Math.imul(K,X),h=h+Math.imul(z,$)|0,n=(n=n+Math.imul(z,tt)|0)+Math.imul(O,$)|0,e=e+Math.imul(O,tt)|0,h=h+Math.imul(N,rt)|0,n=(n=n+Math.imul(N,ht)|0)+Math.imul(E,rt)|0,e=e+Math.imul(E,ht)|0,h=h+Math.imul(B,et)|0,n=(n=n+Math.imul(B,ot)|0)+Math.imul(R,et)|0,e=e+Math.imul(R,ot)|0,h=h+Math.imul(x,ut)|0,n=(n=n+Math.imul(x,lt)|0)+Math.imul(q,ut)|0,e=e+Math.imul(q,lt)|0,h=h+Math.imul(k,mt)|0,n=(n=n+Math.imul(k,ft)|0)+Math.imul(A,mt)|0,e=e+Math.imul(A,ft)|0;var Zt=(l+(h=h+Math.imul(y,pt)|0)|0)+((8191&(n=(n=n+Math.imul(y,Mt)|0)+Math.imul(b,pt)|0))<<13)|0;l=((e=e+Math.imul(b,Mt)|0)+(n>>>13)|0)+(Zt>>>26)|0,Zt&=67108863,h=Math.imul(j,$),n=(n=Math.imul(j,tt))+Math.imul(K,$)|0,e=Math.imul(K,tt),h=h+Math.imul(z,rt)|0,n=(n=n+Math.imul(z,ht)|0)+Math.imul(O,rt)|0,e=e+Math.imul(O,ht)|0,h=h+Math.imul(N,et)|0,n=(n=n+Math.imul(N,ot)|0)+Math.imul(E,et)|0,e=e+Math.imul(E,ot)|0,h=h+Math.imul(B,ut)|0,n=(n=n+Math.imul(B,lt)|0)+Math.imul(R,ut)|0,e=e+Math.imul(R,lt)|0,h=h+Math.imul(x,mt)|0,n=(n=n+Math.imul(x,ft)|0)+Math.imul(q,mt)|0,e=e+Math.imul(q,ft)|0;var Bt=(l+(h=h+Math.imul(k,pt)|0)|0)+((8191&(n=(n=n+Math.imul(k,Mt)|0)+Math.imul(A,pt)|0))<<13)|0;l=((e=e+Math.imul(A,Mt)|0)+(n>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,h=Math.imul(j,rt),n=(n=Math.imul(j,ht))+Math.imul(K,rt)|0,e=Math.imul(K,ht),h=h+Math.imul(z,et)|0,n=(n=n+Math.imul(z,ot)|0)+Math.imul(O,et)|0,e=e+Math.imul(O,ot)|0,h=h+Math.imul(N,ut)|0,n=(n=n+Math.imul(N,lt)|0)+Math.imul(E,ut)|0,e=e+Math.imul(E,lt)|0,h=h+Math.imul(B,mt)|0,n=(n=n+Math.imul(B,ft)|0)+Math.imul(R,mt)|0,e=e+Math.imul(R,ft)|0;var Rt=(l+(h=h+Math.imul(x,pt)|0)|0)+((8191&(n=(n=n+Math.imul(x,Mt)|0)+Math.imul(q,pt)|0))<<13)|0;l=((e=e+Math.imul(q,Mt)|0)+(n>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,h=Math.imul(j,et),n=(n=Math.imul(j,ot))+Math.imul(K,et)|0,e=Math.imul(K,ot),h=h+Math.imul(z,ut)|0,n=(n=n+Math.imul(z,lt)|0)+Math.imul(O,ut)|0,e=e+Math.imul(O,lt)|0,h=h+Math.imul(N,mt)|0,n=(n=n+Math.imul(N,ft)|0)+Math.imul(E,mt)|0,e=e+Math.imul(E,ft)|0;var Lt=(l+(h=h+Math.imul(B,pt)|0)|0)+((8191&(n=(n=n+Math.imul(B,Mt)|0)+Math.imul(R,pt)|0))<<13)|0;l=((e=e+Math.imul(R,Mt)|0)+(n>>>13)|0)+(Lt>>>26)|0,Lt&=67108863,h=Math.imul(j,ut),n=(n=Math.imul(j,lt))+Math.imul(K,ut)|0,e=Math.imul(K,lt),h=h+Math.imul(z,mt)|0,n=(n=n+Math.imul(z,ft)|0)+Math.imul(O,mt)|0,e=e+Math.imul(O,ft)|0;var Nt=(l+(h=h+Math.imul(N,pt)|0)|0)+((8191&(n=(n=n+Math.imul(N,Mt)|0)+Math.imul(E,pt)|0))<<13)|0;l=((e=e+Math.imul(E,Mt)|0)+(n>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,h=Math.imul(j,mt),n=(n=Math.imul(j,ft))+Math.imul(K,mt)|0,e=Math.imul(K,ft);var Et=(l+(h=h+Math.imul(z,pt)|0)|0)+((8191&(n=(n=n+Math.imul(z,Mt)|0)+Math.imul(O,pt)|0))<<13)|0;l=((e=e+Math.imul(O,Mt)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863;var It=(l+(h=Math.imul(j,pt))|0)+((8191&(n=(n=Math.imul(j,Mt))+Math.imul(K,pt)|0))<<13)|0;return l=((e=Math.imul(K,Mt))+(n>>>13)|0)+(It>>>26)|0,It&=67108863,u[0]=vt,u[1]=gt,u[2]=ct,u[3]=wt,u[4]=yt,u[5]=bt,u[6]=_t,u[7]=kt,u[8]=At,u[9]=St,u[10]=xt,u[11]=qt,u[12]=Zt,u[13]=Bt,u[14]=Rt,u[15]=Lt,u[16]=Nt,u[17]=Et,u[18]=It,0!==l&&(u[19]=l,r.length++),r};function g(t,i,r){r.negative=i.negative^t.negative,r.length=t.length+i.length;for(var h=0,n=0,e=0;e<r.length-1;e++){var o=n;n=0;for(var s=67108863&h,u=Math.min(e,i.length-1),l=Math.max(0,e-t.length+1);l<=u;l++){var a=e-l,m=(0|t.words[a])*(0|i.words[l]),f=67108863&m;s=67108863&(f=f+s|0),n+=(o=(o=o+(m/67108864|0)|0)+(f>>>26)|0)>>>26,o&=67108863}r.words[e]=s,h=o,o=n}return 0!==h?r.words[e]=h:r.length--,r._strip()}function c(t,i,r){return g(t,i,r)}Math.imul||(v=M),e.prototype.mulTo=function(t,i){var r=this.length+t.length;return 10===this.length&&10===t.length?v(this,t,i):r<63?M(this,t,i):r<1024?g(this,t,i):c(this,t,i)},e.prototype.mul=function(t){var i=new e(null);return i.words=new Array(this.length+t.length),this.mulTo(t,i)},e.prototype.mulf=function(t){var i=new e(null);return i.words=new Array(this.length+t.length),c(this,t,i)},e.prototype.imul=function(t){return this.clone().mulTo(t,this)},e.prototype.imuln=function(t){var i=t<0;i&&(t=-t),h("number"==typeof t),h(t<67108864);for(var r=0,n=0;n<this.length;n++){var e=(0|this.words[n])*t,o=(67108863&e)+(67108863&r);r>>=26,r+=e/67108864|0,r+=o>>>26,this.words[n]=67108863&o}return 0!==r&&(this.words[n]=r,this.length++),i?this.ineg():this},e.prototype.muln=function(t){return this.clone().imuln(t)},e.prototype.sqr=function(){return this.mul(this)},e.prototype.isqr=function(){return this.imul(this.clone())},e.prototype.pow=function(t){var i=function(t){for(var i=new Array(t.bitLength()),r=0;r<i.length;r++){var h=r/26|0,n=r%26;i[r]=t.words[h]>>>n&1}return i}(t);if(0===i.length)return new e(1);for(var r=this,h=0;h<i.length&&0===i[h];h++,r=r.sqr());if(++h<i.length)for(var n=r.sqr();h<i.length;h++,n=n.sqr())0!==i[h]&&(r=r.mul(n));return r},e.prototype.iushln=function(t){h("number"==typeof t&&t>=0);var i,r=t%26,n=(t-r)/26,e=67108863>>>26-r<<26-r;if(0!==r){var o=0;for(i=0;i<this.length;i++){var s=this.words[i]&e,u=(0|this.words[i])-s<<r;this.words[i]=u|o,o=s>>>26-r}o&&(this.words[i]=o,this.length++)}if(0!==n){for(i=this.length-1;i>=0;i--)this.words[i+n]=this.words[i];for(i=0;i<n;i++)this.words[i]=0;this.length+=n}return this._strip()},e.prototype.ishln=function(t){return h(0===this.negative),this.iushln(t)},e.prototype.iushrn=function(t,i,r){var n;h("number"==typeof t&&t>=0),n=i?(i-i%26)/26:0;var e=t%26,o=Math.min((t-e)/26,this.length),s=67108863^67108863>>>e<<e,u=r;if(n-=o,n=Math.max(0,n),u){for(var l=0;l<o;l++)u.words[l]=this.words[l];u.length=o}if(0===o);else if(this.length>o)for(this.length-=o,l=0;l<this.length;l++)this.words[l]=this.words[l+o];else this.words[0]=0,this.length=1;var a=0;for(l=this.length-1;l>=0&&(0!==a||l>=n);l--){var m=0|this.words[l];this.words[l]=a<<26-e|m>>>e,a=m&s}return u&&0!==a&&(u.words[u.length++]=a),0===this.length&&(this.words[0]=0,this.length=1),this._strip()},e.prototype.ishrn=function(t,i,r){return h(0===this.negative),this.iushrn(t,i,r)},e.prototype.shln=function(t){return this.clone().ishln(t)},e.prototype.ushln=function(t){return this.clone().iushln(t)},e.prototype.shrn=function(t){return this.clone().ishrn(t)},e.prototype.ushrn=function(t){return this.clone().iushrn(t)},e.prototype.testn=function(t){h("number"==typeof t&&t>=0);var i=t%26,r=(t-i)/26,n=1<<i;return!(this.length<=r||!(this.words[r]&n))},e.prototype.imaskn=function(t){h("number"==typeof t&&t>=0);var i=t%26,r=(t-i)/26;if(h(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==i&&r++,this.length=Math.min(r,this.length),0!==i){var n=67108863^67108863>>>i<<i;this.words[this.length-1]&=n}return this._strip()},e.prototype.maskn=function(t){return this.clone().imaskn(t)},e.prototype.iaddn=function(t){return h("number"==typeof t),h(t<67108864),t<0?this.isubn(-t):0!==this.negative?1===this.length&&(0|this.words[0])<=t?(this.words[0]=t-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(t),this.negative=1,this):this._iaddn(t)},e.prototype._iaddn=function(t){this.words[0]+=t;for(var i=0;i<this.length&&this.words[i]>=67108864;i++)this.words[i]-=67108864,i===this.length-1?this.words[i+1]=1:this.words[i+1]++;return this.length=Math.max(this.length,i+1),this},e.prototype.isubn=function(t){if(h("number"==typeof t),h(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var i=0;i<this.length&&this.words[i]<0;i++)this.words[i]+=67108864,this.words[i+1]-=1;return this._strip()},e.prototype.addn=function(t){return this.clone().iaddn(t)},e.prototype.subn=function(t){return this.clone().isubn(t)},e.prototype.iabs=function(){return this.negative=0,this},e.prototype.abs=function(){return this.clone().iabs()},e.prototype._ishlnsubmul=function(t,i,r){var n,e,o=t.length+r;this._expand(o);var s=0;for(n=0;n<t.length;n++){e=(0|this.words[n+r])+s;var u=(0|t.words[n])*i;s=((e-=67108863&u)>>26)-(u/67108864|0),this.words[n+r]=67108863&e}for(;n<this.length-r;n++)s=(e=(0|this.words[n+r])+s)>>26,this.words[n+r]=67108863&e;if(0===s)return this._strip();for(h(-1===s),s=0,n=0;n<this.length;n++)s=(e=-(0|this.words[n])+s)>>26,this.words[n]=67108863&e;return this.negative=1,this._strip()},e.prototype._wordDiv=function(t,i){var r=(this.length,t.length),h=this.clone(),n=t,o=0|n.words[n.length-1];0!=(r=26-this._countBits(o))&&(n=n.ushln(r),h.iushln(r),o=0|n.words[n.length-1]);var s,u=h.length-n.length;if("mod"!==i){(s=new e(null)).length=u+1,s.words=new Array(s.length);for(var l=0;l<s.length;l++)s.words[l]=0}var a=h.clone()._ishlnsubmul(n,1,u);0===a.negative&&(h=a,s&&(s.words[u]=1));for(var m=u-1;m>=0;m--){var f=67108864*(0|h.words[n.length+m])+(0|h.words[n.length+m-1]);for(f=Math.min(f/o|0,67108863),h._ishlnsubmul(n,f,m);0!==h.negative;)f--,h.negative=0,h._ishlnsubmul(n,1,m),h.isZero()||(h.negative^=1);s&&(s.words[m]=f)}return s&&s._strip(),h._strip(),"div"!==i&&0!==r&&h.iushrn(r),{div:s||null,mod:h}},e.prototype.divmod=function(t,i,r){return h(!t.isZero()),this.isZero()?{div:new e(0),mod:new e(0)}:0!==this.negative&&0===t.negative?(s=this.neg().divmod(t,i),"mod"!==i&&(n=s.div.neg()),"div"!==i&&(o=s.mod.neg(),r&&0!==o.negative&&o.iadd(t)),{div:n,mod:o}):0===this.negative&&0!==t.negative?(s=this.divmod(t.neg(),i),"mod"!==i&&(n=s.div.neg()),{div:n,mod:s.mod}):0!=(this.negative&t.negative)?(s=this.neg().divmod(t.neg(),i),"div"!==i&&(o=s.mod.neg(),r&&0!==o.negative&&o.isub(t)),{div:s.div,mod:o}):t.length>this.length||this.cmp(t)<0?{div:new e(0),mod:this}:1===t.length?"div"===i?{div:this.divn(t.words[0]),mod:null}:"mod"===i?{div:null,mod:new e(this.modrn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new e(this.modrn(t.words[0]))}:this._wordDiv(t,i);var n,o,s},e.prototype.div=function(t){return this.divmod(t,"div",!1).div},e.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},e.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},e.prototype.divRound=function(t){var i=this.divmod(t);if(i.mod.isZero())return i.div;var r=0!==i.div.negative?i.mod.isub(t):i.mod,h=t.ushrn(1),n=t.andln(1),e=r.cmp(h);return e<0||1===n&&0===e?i.div:0!==i.div.negative?i.div.isubn(1):i.div.iaddn(1)},e.prototype.modrn=function(t){var i=t<0;i&&(t=-t),h(t<=67108863);for(var r=(1<<26)%t,n=0,e=this.length-1;e>=0;e--)n=(r*n+(0|this.words[e]))%t;return i?-n:n},e.prototype.modn=function(t){return this.modrn(t)},e.prototype.idivn=function(t){var i=t<0;i&&(t=-t),h(t<=67108863);for(var r=0,n=this.length-1;n>=0;n--){var e=(0|this.words[n])+67108864*r;this.words[n]=e/t|0,r=e%t}return this._strip(),i?this.ineg():this},e.prototype.divn=function(t){return this.clone().idivn(t)},e.prototype.egcd=function(t){h(0===t.negative),h(!t.isZero());var i=this,r=t.clone();i=0!==i.negative?i.umod(t):i.clone();for(var n=new e(1),o=new e(0),s=new e(0),u=new e(1),l=0;i.isEven()&&r.isEven();)i.iushrn(1),r.iushrn(1),++l;for(var a=r.clone(),m=i.clone();!i.isZero();){for(var f=0,d=1;0==(i.words[0]&d)&&f<26;++f,d<<=1);if(f>0)for(i.iushrn(f);f-- >0;)(n.isOdd()||o.isOdd())&&(n.iadd(a),o.isub(m)),n.iushrn(1),o.iushrn(1);for(var p=0,M=1;0==(r.words[0]&M)&&p<26;++p,M<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(s.isOdd()||u.isOdd())&&(s.iadd(a),u.isub(m)),s.iushrn(1),u.iushrn(1);i.cmp(r)>=0?(i.isub(r),n.isub(s),o.isub(u)):(r.isub(i),s.isub(n),u.isub(o))}return{a:s,b:u,gcd:r.iushln(l)}},e.prototype._invmp=function(t){h(0===t.negative),h(!t.isZero());var i=this,r=t.clone();i=0!==i.negative?i.umod(t):i.clone();for(var n,o=new e(1),s=new e(0),u=r.clone();i.cmpn(1)>0&&r.cmpn(1)>0;){for(var l=0,a=1;0==(i.words[0]&a)&&l<26;++l,a<<=1);if(l>0)for(i.iushrn(l);l-- >0;)o.isOdd()&&o.iadd(u),o.iushrn(1);for(var m=0,f=1;0==(r.words[0]&f)&&m<26;++m,f<<=1);if(m>0)for(r.iushrn(m);m-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);i.cmp(r)>=0?(i.isub(r),o.isub(s)):(r.isub(i),s.isub(o))}return(n=0===i.cmpn(1)?o:s).cmpn(0)<0&&n.iadd(t),n},e.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var i=this.clone(),r=t.clone();i.negative=0,r.negative=0;for(var h=0;i.isEven()&&r.isEven();h++)i.iushrn(1),r.iushrn(1);for(;;){for(;i.isEven();)i.iushrn(1);for(;r.isEven();)r.iushrn(1);var n=i.cmp(r);if(n<0){var e=i;i=r,r=e}else if(0===n||0===r.cmpn(1))break;i.isub(r)}return r.iushln(h)},e.prototype.invm=function(t){return this.egcd(t).a.umod(t)},e.prototype.isEven=function(){return 0==(1&this.words[0])},e.prototype.isOdd=function(){return 1==(1&this.words[0])},e.prototype.andln=function(t){return this.words[0]&t},e.prototype.bincn=function(t){h("number"==typeof t);var i=t%26,r=(t-i)/26,n=1<<i;if(this.length<=r)return this._expand(r+1),this.words[r]|=n,this;for(var e=n,o=r;0!==e&&o<this.length;o++){var s=0|this.words[o];e=(s+=e)>>>26,s&=67108863,this.words[o]=s}return 0!==e&&(this.words[o]=e,this.length++),this},e.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},e.prototype.cmpn=function(t){var i,r=t<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this._strip(),this.length>1)i=1;else{r&&(t=-t),h(t<=67108863,"Number is too big");var n=0|this.words[0];i=n===t?0:n<t?-1:1}return 0!==this.negative?0|-i:i},e.prototype.cmp=function(t){if(0!==this.negative&&0===t.negative)return-1;if(0===this.negative&&0!==t.negative)return 1;var i=this.ucmp(t);return 0!==this.negative?0|-i:i},e.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var i=0,r=this.length-1;r>=0;r--){var h=0|this.words[r],n=0|t.words[r];if(h!==n){h<n?i=-1:h>n&&(i=1);break}}return i},e.prototype.gtn=function(t){return 1===this.cmpn(t)},e.prototype.gt=function(t){return 1===this.cmp(t)},e.prototype.gten=function(t){return this.cmpn(t)>=0},e.prototype.gte=function(t){return this.cmp(t)>=0},e.prototype.ltn=function(t){return-1===this.cmpn(t)},e.prototype.lt=function(t){return-1===this.cmp(t)},e.prototype.lten=function(t){return this.cmpn(t)<=0},e.prototype.lte=function(t){return this.cmp(t)<=0},e.prototype.eqn=function(t){return 0===this.cmpn(t)},e.prototype.eq=function(t){return 0===this.cmp(t)},e.red=function(t){return new S(t)},e.prototype.toRed=function(t){return h(!this.red,"Already a number in reduction context"),h(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},e.prototype.fromRed=function(){return h(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},e.prototype._forceRed=function(t){return this.red=t,this},e.prototype.forceRed=function(t){return h(!this.red,"Already a number in reduction context"),this._forceRed(t)},e.prototype.redAdd=function(t){return h(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},e.prototype.redIAdd=function(t){return h(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},e.prototype.redSub=function(t){return h(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},e.prototype.redISub=function(t){return h(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},e.prototype.redShl=function(t){return h(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},e.prototype.redMul=function(t){return h(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},e.prototype.redIMul=function(t){return h(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},e.prototype.redSqr=function(){return h(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},e.prototype.redISqr=function(){return h(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},e.prototype.redSqrt=function(){return h(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},e.prototype.redInvm=function(){return h(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},e.prototype.redNeg=function(){return h(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},e.prototype.redPow=function(t){return h(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var w={k256:null,p224:null,p192:null,p25519:null};function y(t,i){this.name=t,this.p=new e(i,16),this.n=this.p.bitLength(),this.k=new e(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function b(){y.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function _(){y.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function k(){y.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function A(){y.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function S(t){if("string"==typeof t){var i=e._prime(t);this.m=i.p,this.prime=i}else h(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function x(t){S.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new e(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)}y.prototype._tmp=function(){var t=new e(null);return t.words=new Array(Math.ceil(this.n/13)),t},y.prototype.ireduce=function(t){var i,r=t;do{this.split(r,this.tmp),i=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(i>this.n);var h=i<this.n?-1:r.ucmp(this.p);return 0===h?(r.words[0]=0,r.length=1):h>0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},y.prototype.split=function(t,i){t.iushrn(this.n,0,i)},y.prototype.imulK=function(t){return t.imul(this.k)},n(b,y),b.prototype.split=function(t,i){for(var r=4194303,h=Math.min(t.length,9),n=0;n<h;n++)i.words[n]=t.words[n];if(i.length=h,t.length<=9)return t.words[0]=0,void(t.length=1);var e=t.words[9];for(i.words[i.length++]=e&r,n=10;n<t.length;n++){var o=0|t.words[n];t.words[n-10]=(o&r)<<4|e>>>22,e=o}e>>>=22,t.words[n-10]=e,0===e&&t.length>10?t.length-=10:t.length-=9},b.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var i=0,r=0;r<t.length;r++){var h=0|t.words[r];i+=977*h,t.words[r]=67108863&i,i=64*h+(i/67108864|0)}return 0===t.words[t.length-1]&&(t.length--,0===t.words[t.length-1]&&t.length--),t},n(_,y),n(k,y),n(A,y),A.prototype.imulK=function(t){for(var i=0,r=0;r<t.length;r++){var h=19*(0|t.words[r])+i,n=67108863&h;h>>>=26,t.words[r]=n,i=h}return 0!==i&&(t.words[t.length++]=i),t},e._prime=function(t){if(w[t])return w[t];var i;if("k256"===t)i=new b;else if("p224"===t)i=new _;else if("p192"===t)i=new k;else{if("p25519"!==t)throw new Error("Unknown prime "+t);i=new A}return w[t]=i,i},S.prototype._verify1=function(t){h(0===t.negative,"red works only with positives"),h(t.red,"red works only with red numbers")},S.prototype._verify2=function(t,i){h(0==(t.negative|i.negative),"red works only with positives"),h(t.red&&t.red===i.red,"red works only with red numbers")},S.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):(a(t,t.umod(this.m)._forceRed(this)),t)},S.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},S.prototype.add=function(t,i){this._verify2(t,i);var r=t.add(i);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},S.prototype.iadd=function(t,i){this._verify2(t,i);var r=t.iadd(i);return r.cmp(this.m)>=0&&r.isub(this.m),r},S.prototype.sub=function(t,i){this._verify2(t,i);var r=t.sub(i);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},S.prototype.isub=function(t,i){this._verify2(t,i);var r=t.isub(i);return r.cmpn(0)<0&&r.iadd(this.m),r},S.prototype.shl=function(t,i){return this._verify1(t),this.imod(t.ushln(i))},S.prototype.imul=function(t,i){return this._verify2(t,i),this.imod(t.imul(i))},S.prototype.mul=function(t,i){return this._verify2(t,i),this.imod(t.mul(i))},S.prototype.isqr=function(t){return this.imul(t,t.clone())},S.prototype.sqr=function(t){return this.mul(t,t)},S.prototype.sqrt=function(t){if(t.isZero())return t.clone();var i=this.m.andln(3);if(h(i%2==1),3===i){var r=this.m.add(new e(1)).iushrn(2);return this.pow(t,r)}for(var n=this.m.subn(1),o=0;!n.isZero()&&0===n.andln(1);)o++,n.iushrn(1);h(!n.isZero());var s=new e(1).toRed(this),u=s.redNeg(),l=this.m.subn(1).iushrn(1),a=this.m.bitLength();for(a=new e(2*a*a).toRed(this);0!==this.pow(a,l).cmp(u);)a.redIAdd(u);for(var m=this.pow(a,n),f=this.pow(t,n.addn(1).iushrn(1)),d=this.pow(t,n),p=o;0!==d.cmp(s);){for(var M=d,v=0;0!==M.cmp(s);v++)M=M.redSqr();h(v<p);var g=this.pow(m,new e(1).iushln(p-v-1));f=f.redMul(g),m=g.redSqr(),d=d.redMul(m),p=v}return f},S.prototype.invm=function(t){var i=t._invmp(this.m);return 0!==i.negative?(i.negative=0,this.imod(i).redNeg()):this.imod(i)},S.prototype.pow=function(t,i){if(i.isZero())return new e(1).toRed(this);if(0===i.cmpn(1))return t.clone();var r=new Array(16);r[0]=new e(1).toRed(this),r[1]=t;for(var h=2;h<r.length;h++)r[h]=this.mul(r[h-1],t);var n=r[0],o=0,s=0,u=i.bitLength()%26;for(0===u&&(u=26),h=i.length-1;h>=0;h--){for(var l=i.words[h],a=u-1;a>=0;a--){var m=l>>a&1;n!==r[0]&&(n=this.sqr(n)),0!==m||0!==o?(o<<=1,o|=m,(4==++s||0===h&&0===a)&&(n=this.mul(n,r[o]),s=0,o=0)):s=0}u=26}return n},S.prototype.convertTo=function(t){var i=t.umod(this.m);return i===t?i.clone():i},S.prototype.convertFrom=function(t){var i=t.clone();return i.red=null,i},e.mont=function(t){return new x(t)},n(x,S),x.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},x.prototype.convertFrom=function(t){var i=this.imod(t.mul(this.rinv));return i.red=null,i},x.prototype.imul=function(t,i){if(t.isZero()||i.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(i),h=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(h).iushrn(this.shift),e=n;return n.cmp(this.m)>=0?e=n.isub(this.m):n.cmpn(0)<0&&(e=n.iadd(this.m)),e._forceRed(this)},x.prototype.mul=function(t,i){if(t.isZero()||i.isZero())return new e(0)._forceRed(this);var r=t.mul(i),h=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(h).iushrn(this.shift),o=n;return n.cmp(this.m)>=0?o=n.isub(this.m):n.cmpn(0)<0&&(o=n.iadd(this.m)),o._forceRed(this)},x.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(r,t);var h=r.exports;export{h as B,r as b};
|
|
1
|
+
import{c as t}from"./index-7decf620.js";import{r as i}from"./__node-resolve_empty-261d59ac.js";var r={exports:{}};!function(t,r){function h(t,i){if(!t)throw new Error(i||"Assertion failed")}function n(t,i){t.super_=i;var r=function(){};r.prototype=i.prototype,t.prototype=new r,t.prototype.constructor=t}function e(t,i,r){if(e.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==i&&"be"!==i||(r=i,i=10),this._init(t||0,i||10,r||"be"))}var o;"object"==typeof t?t.exports=e:r.BN=e,e.BN=e,e.wordSize=26;try{o="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:i.Buffer}catch(t){}function s(t,i){var r=t.charCodeAt(i);return r>=48&&r<=57?r-48:r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:void h(!1,"Invalid character in "+t)}function u(t,i,r){var h=s(t,r);return r-1>=i&&(h|=s(t,r-1)<<4),h}function l(t,i,r,n){for(var e=0,o=0,s=Math.min(t.length,r),u=i;u<s;u++){var l=t.charCodeAt(u)-48;e*=n,o=l>=49?l-49+10:l>=17?l-17+10:l,h(l>=0&&o<n,"Invalid character"),e+=o}return e}function a(t,i){t.words=i.words,t.length=i.length,t.negative=i.negative,t.red=i.red}if(e.isBN=function(t){return t instanceof e||null!==t&&"object"==typeof t&&t.constructor.wordSize===e.wordSize&&Array.isArray(t.words)},e.max=function(t,i){return t.cmp(i)>0?t:i},e.min=function(t,i){return t.cmp(i)<0?t:i},e.prototype._init=function(t,i,r){if("number"==typeof t)return this._initNumber(t,i,r);if("object"==typeof t)return this._initArray(t,i,r);"hex"===i&&(i=16),h(i===(0|i)&&i>=2&&i<=36);var n=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&(n++,this.negative=1),n<t.length&&(16===i?this._parseHex(t,n,r):(this._parseBase(t,i,n),"le"===r&&this._initArray(this.toArray(),i,r)))},e.prototype._initNumber=function(t,i,r){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(h(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===r&&this._initArray(this.toArray(),i,r)},e.prototype._initArray=function(t,i,r){if(h("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var n=0;n<this.length;n++)this.words[n]=0;var e,o,s=0;if("be"===r)for(n=t.length-1,e=0;n>=0;n-=3)o=t[n]|t[n-1]<<8|t[n-2]<<16,this.words[e]|=o<<s&67108863,this.words[e+1]=o>>>26-s&67108863,(s+=24)>=26&&(s-=26,e++);else if("le"===r)for(n=0,e=0;n<t.length;n+=3)o=t[n]|t[n+1]<<8|t[n+2]<<16,this.words[e]|=o<<s&67108863,this.words[e+1]=o>>>26-s&67108863,(s+=24)>=26&&(s-=26,e++);return this._strip()},e.prototype._parseHex=function(t,i,r){this.length=Math.ceil((t.length-i)/6),this.words=new Array(this.length);for(var h=0;h<this.length;h++)this.words[h]=0;var n,e=0,o=0;if("be"===r)for(h=t.length-1;h>=i;h-=2)n=u(t,i,h)<<e,this.words[o]|=67108863&n,e>=18?(e-=18,o+=1,this.words[o]|=n>>>26):e+=8;else for(h=(t.length-i)%2==0?i+1:i;h<t.length;h+=2)n=u(t,i,h)<<e,this.words[o]|=67108863&n,e>=18?(e-=18,o+=1,this.words[o]|=n>>>26):e+=8;this._strip()},e.prototype._parseBase=function(t,i,r){this.words=[0],this.length=1;for(var h=0,n=1;n<=67108863;n*=i)h++;h--,n=n/i|0;for(var e=t.length-r,o=e%h,s=Math.min(e,e-o)+r,u=0,a=r;a<s;a+=h)u=l(t,a,a+h,i),this.imuln(n),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u);if(0!==o){var m=1;for(u=l(t,a,t.length,i),a=0;a<o;a++)m*=i;this.imuln(m),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u)}this._strip()},e.prototype.copy=function(t){t.words=new Array(this.length);for(var i=0;i<this.length;i++)t.words[i]=this.words[i];t.length=this.length,t.negative=this.negative,t.red=this.red},e.prototype._move=function(t){a(t,this)},e.prototype.clone=function(){var t=new e(null);return this.copy(t),t},e.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this},e.prototype._strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},e.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},"undefined"!=typeof Symbol&&"function"==typeof Symbol.for)try{e.prototype[Symbol.for("nodejs.util.inspect.custom")]=m}catch(t){e.prototype.inspect=m}else e.prototype.inspect=m;function m(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var f=["","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"],d=[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],p=[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 M(t,i,r){r.negative=i.negative^t.negative;var h=t.length+i.length|0;r.length=h,h=h-1|0;var n=0|t.words[0],e=0|i.words[0],o=n*e,s=67108863&o,u=o/67108864|0;r.words[0]=s;for(var l=1;l<h;l++){for(var a=u>>>26,m=67108863&u,f=Math.min(l,i.length-1),d=Math.max(0,l-t.length+1);d<=f;d++){var p=l-d|0;a+=(o=(n=0|t.words[p])*(e=0|i.words[d])+m)/67108864|0,m=67108863&o}r.words[l]=0|m,u=0|a}return 0!==u?r.words[l]=0|u:r.length--,r._strip()}e.prototype.toString=function(t,i){var r;if(i=0|i||1,16===(t=t||10)||"hex"===t){r="";for(var n=0,e=0,o=0;o<this.length;o++){var s=this.words[o],u=(16777215&(s<<n|e)).toString(16);e=s>>>24-n&16777215,(n+=2)>=26&&(n-=26,o--),r=0!==e||o!==this.length-1?f[6-u.length]+u+r:u+r}for(0!==e&&(r=e.toString(16)+r);r.length%i!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(t===(0|t)&&t>=2&&t<=36){var l=d[t],a=p[t];r="";var m=this.clone();for(m.negative=0;!m.isZero();){var M=m.modrn(a).toString(t);r=(m=m.idivn(a)).isZero()?M+r:f[l-M.length]+M+r}for(this.isZero()&&(r="0"+r);r.length%i!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}h(!1,"Base should be between 2 and 36")},e.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&h(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},e.prototype.toJSON=function(){return this.toString(16,2)},o&&(e.prototype.toBuffer=function(t,i){return this.toArrayLike(o,t,i)}),e.prototype.toArray=function(t,i){return this.toArrayLike(Array,t,i)},e.prototype.toArrayLike=function(t,i,r){this._strip();var n=this.byteLength(),e=r||Math.max(1,n);h(n<=e,"byte array longer than desired length"),h(e>0,"Requested array length <= 0");var o=function(t,i){return t.allocUnsafe?t.allocUnsafe(i):new t(i)}(t,e);return this["_toArrayLike"+("le"===i?"LE":"BE")](o,n),o},e.prototype._toArrayLikeLE=function(t,i){for(var r=0,h=0,n=0,e=0;n<this.length;n++){var o=this.words[n]<<e|h;t[r++]=255&o,r<t.length&&(t[r++]=o>>8&255),r<t.length&&(t[r++]=o>>16&255),6===e?(r<t.length&&(t[r++]=o>>24&255),h=0,e=0):(h=o>>>24,e+=2)}if(r<t.length)for(t[r++]=h;r<t.length;)t[r++]=0},e.prototype._toArrayLikeBE=function(t,i){for(var r=t.length-1,h=0,n=0,e=0;n<this.length;n++){var o=this.words[n]<<e|h;t[r--]=255&o,r>=0&&(t[r--]=o>>8&255),r>=0&&(t[r--]=o>>16&255),6===e?(r>=0&&(t[r--]=o>>24&255),h=0,e=0):(h=o>>>24,e+=2)}if(r>=0)for(t[r--]=h;r>=0;)t[r--]=0},Math.clz32?e.prototype._countBits=function(t){return 32-Math.clz32(t)}:e.prototype._countBits=function(t){var i=t,r=0;return i>=4096&&(r+=13,i>>>=13),i>=64&&(r+=7,i>>>=7),i>=8&&(r+=4,i>>>=4),i>=2&&(r+=2,i>>>=2),r+i},e.prototype._zeroBits=function(t){if(0===t)return 26;var i=t,r=0;return 0==(8191&i)&&(r+=13,i>>>=13),0==(127&i)&&(r+=7,i>>>=7),0==(15&i)&&(r+=4,i>>>=4),0==(3&i)&&(r+=2,i>>>=2),0==(1&i)&&r++,r},e.prototype.bitLength=function(){var t=this.words[this.length-1],i=this._countBits(t);return 26*(this.length-1)+i},e.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,i=0;i<this.length;i++){var r=this._zeroBits(this.words[i]);if(t+=r,26!==r)break}return t},e.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},e.prototype.toTwos=function(t){return 0!==this.negative?this.abs().inotn(t).iaddn(1):this.clone()},e.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},e.prototype.isNeg=function(){return 0!==this.negative},e.prototype.neg=function(){return this.clone().ineg()},e.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},e.prototype.iuor=function(t){for(;this.length<t.length;)this.words[this.length++]=0;for(var i=0;i<t.length;i++)this.words[i]=this.words[i]|t.words[i];return this._strip()},e.prototype.ior=function(t){return h(0==(this.negative|t.negative)),this.iuor(t)},e.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},e.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},e.prototype.iuand=function(t){var i;i=this.length>t.length?t:this;for(var r=0;r<i.length;r++)this.words[r]=this.words[r]&t.words[r];return this.length=i.length,this._strip()},e.prototype.iand=function(t){return h(0==(this.negative|t.negative)),this.iuand(t)},e.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},e.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},e.prototype.iuxor=function(t){var i,r;this.length>t.length?(i=this,r=t):(i=t,r=this);for(var h=0;h<r.length;h++)this.words[h]=i.words[h]^r.words[h];if(this!==i)for(;h<i.length;h++)this.words[h]=i.words[h];return this.length=i.length,this._strip()},e.prototype.ixor=function(t){return h(0==(this.negative|t.negative)),this.iuxor(t)},e.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},e.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},e.prototype.inotn=function(t){h("number"==typeof t&&t>=0);var i=0|Math.ceil(t/26),r=t%26;this._expand(i),r>0&&i--;for(var n=0;n<i;n++)this.words[n]=67108863&~this.words[n];return r>0&&(this.words[n]=~this.words[n]&67108863>>26-r),this._strip()},e.prototype.notn=function(t){return this.clone().inotn(t)},e.prototype.setn=function(t,i){h("number"==typeof t&&t>=0);var r=t/26|0,n=t%26;return this._expand(r+1),this.words[r]=i?this.words[r]|1<<n:this.words[r]&~(1<<n),this._strip()},e.prototype.iadd=function(t){var i,r,h;if(0!==this.negative&&0===t.negative)return this.negative=0,i=this.isub(t),this.negative^=1,this._normSign();if(0===this.negative&&0!==t.negative)return t.negative=0,i=this.isub(t),t.negative=1,i._normSign();this.length>t.length?(r=this,h=t):(r=t,h=this);for(var n=0,e=0;e<h.length;e++)i=(0|r.words[e])+(0|h.words[e])+n,this.words[e]=67108863&i,n=i>>>26;for(;0!==n&&e<r.length;e++)i=(0|r.words[e])+n,this.words[e]=67108863&i,n=i>>>26;if(this.length=r.length,0!==n)this.words[this.length]=n,this.length++;else if(r!==this)for(;e<r.length;e++)this.words[e]=r.words[e];return this},e.prototype.add=function(t){var i;return 0!==t.negative&&0===this.negative?(t.negative=0,i=this.sub(t),t.negative^=1,i):0===t.negative&&0!==this.negative?(this.negative=0,i=t.sub(this),this.negative=1,i):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this)},e.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var i=this.iadd(t);return t.negative=1,i._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,h,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(r=this,h=t):(r=t,h=this);for(var e=0,o=0;o<h.length;o++)e=(i=(0|r.words[o])-(0|h.words[o])+e)>>26,this.words[o]=67108863&i;for(;0!==e&&o<r.length;o++)e=(i=(0|r.words[o])+e)>>26,this.words[o]=67108863&i;if(0===e&&o<r.length&&r!==this)for(;o<r.length;o++)this.words[o]=r.words[o];return this.length=Math.max(this.length,o),r!==this&&(this.negative=1),this._strip()},e.prototype.sub=function(t){return this.clone().isub(t)};var v=function(t,i,r){var h,n,e,o=t.words,s=i.words,u=r.words,l=0,a=0|o[0],m=8191&a,f=a>>>13,d=0|o[1],p=8191&d,M=d>>>13,v=0|o[2],g=8191&v,c=v>>>13,w=0|o[3],y=8191&w,b=w>>>13,_=0|o[4],k=8191&_,A=_>>>13,S=0|o[5],x=8191&S,q=S>>>13,Z=0|o[6],B=8191&Z,R=Z>>>13,L=0|o[7],N=8191&L,E=L>>>13,I=0|o[8],z=8191&I,O=I>>>13,T=0|o[9],j=8191&T,K=T>>>13,F=0|s[0],U=8191&F,C=F>>>13,D=0|s[1],H=8191&D,P=D>>>13,J=0|s[2],G=8191&J,Q=J>>>13,V=0|s[3],W=8191&V,X=V>>>13,Y=0|s[4],$=8191&Y,tt=Y>>>13,it=0|s[5],rt=8191&it,ht=it>>>13,nt=0|s[6],et=8191&nt,ot=nt>>>13,st=0|s[7],ut=8191&st,lt=st>>>13,at=0|s[8],mt=8191&at,ft=at>>>13,dt=0|s[9],pt=8191&dt,Mt=dt>>>13;r.negative=t.negative^i.negative,r.length=19;var vt=(l+(h=Math.imul(m,U))|0)+((8191&(n=(n=Math.imul(m,C))+Math.imul(f,U)|0))<<13)|0;l=((e=Math.imul(f,C))+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,h=Math.imul(p,U),n=(n=Math.imul(p,C))+Math.imul(M,U)|0,e=Math.imul(M,C);var gt=(l+(h=h+Math.imul(m,H)|0)|0)+((8191&(n=(n=n+Math.imul(m,P)|0)+Math.imul(f,H)|0))<<13)|0;l=((e=e+Math.imul(f,P)|0)+(n>>>13)|0)+(gt>>>26)|0,gt&=67108863,h=Math.imul(g,U),n=(n=Math.imul(g,C))+Math.imul(c,U)|0,e=Math.imul(c,C),h=h+Math.imul(p,H)|0,n=(n=n+Math.imul(p,P)|0)+Math.imul(M,H)|0,e=e+Math.imul(M,P)|0;var ct=(l+(h=h+Math.imul(m,G)|0)|0)+((8191&(n=(n=n+Math.imul(m,Q)|0)+Math.imul(f,G)|0))<<13)|0;l=((e=e+Math.imul(f,Q)|0)+(n>>>13)|0)+(ct>>>26)|0,ct&=67108863,h=Math.imul(y,U),n=(n=Math.imul(y,C))+Math.imul(b,U)|0,e=Math.imul(b,C),h=h+Math.imul(g,H)|0,n=(n=n+Math.imul(g,P)|0)+Math.imul(c,H)|0,e=e+Math.imul(c,P)|0,h=h+Math.imul(p,G)|0,n=(n=n+Math.imul(p,Q)|0)+Math.imul(M,G)|0,e=e+Math.imul(M,Q)|0;var wt=(l+(h=h+Math.imul(m,W)|0)|0)+((8191&(n=(n=n+Math.imul(m,X)|0)+Math.imul(f,W)|0))<<13)|0;l=((e=e+Math.imul(f,X)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,h=Math.imul(k,U),n=(n=Math.imul(k,C))+Math.imul(A,U)|0,e=Math.imul(A,C),h=h+Math.imul(y,H)|0,n=(n=n+Math.imul(y,P)|0)+Math.imul(b,H)|0,e=e+Math.imul(b,P)|0,h=h+Math.imul(g,G)|0,n=(n=n+Math.imul(g,Q)|0)+Math.imul(c,G)|0,e=e+Math.imul(c,Q)|0,h=h+Math.imul(p,W)|0,n=(n=n+Math.imul(p,X)|0)+Math.imul(M,W)|0,e=e+Math.imul(M,X)|0;var yt=(l+(h=h+Math.imul(m,$)|0)|0)+((8191&(n=(n=n+Math.imul(m,tt)|0)+Math.imul(f,$)|0))<<13)|0;l=((e=e+Math.imul(f,tt)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,h=Math.imul(x,U),n=(n=Math.imul(x,C))+Math.imul(q,U)|0,e=Math.imul(q,C),h=h+Math.imul(k,H)|0,n=(n=n+Math.imul(k,P)|0)+Math.imul(A,H)|0,e=e+Math.imul(A,P)|0,h=h+Math.imul(y,G)|0,n=(n=n+Math.imul(y,Q)|0)+Math.imul(b,G)|0,e=e+Math.imul(b,Q)|0,h=h+Math.imul(g,W)|0,n=(n=n+Math.imul(g,X)|0)+Math.imul(c,W)|0,e=e+Math.imul(c,X)|0,h=h+Math.imul(p,$)|0,n=(n=n+Math.imul(p,tt)|0)+Math.imul(M,$)|0,e=e+Math.imul(M,tt)|0;var bt=(l+(h=h+Math.imul(m,rt)|0)|0)+((8191&(n=(n=n+Math.imul(m,ht)|0)+Math.imul(f,rt)|0))<<13)|0;l=((e=e+Math.imul(f,ht)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,h=Math.imul(B,U),n=(n=Math.imul(B,C))+Math.imul(R,U)|0,e=Math.imul(R,C),h=h+Math.imul(x,H)|0,n=(n=n+Math.imul(x,P)|0)+Math.imul(q,H)|0,e=e+Math.imul(q,P)|0,h=h+Math.imul(k,G)|0,n=(n=n+Math.imul(k,Q)|0)+Math.imul(A,G)|0,e=e+Math.imul(A,Q)|0,h=h+Math.imul(y,W)|0,n=(n=n+Math.imul(y,X)|0)+Math.imul(b,W)|0,e=e+Math.imul(b,X)|0,h=h+Math.imul(g,$)|0,n=(n=n+Math.imul(g,tt)|0)+Math.imul(c,$)|0,e=e+Math.imul(c,tt)|0,h=h+Math.imul(p,rt)|0,n=(n=n+Math.imul(p,ht)|0)+Math.imul(M,rt)|0,e=e+Math.imul(M,ht)|0;var _t=(l+(h=h+Math.imul(m,et)|0)|0)+((8191&(n=(n=n+Math.imul(m,ot)|0)+Math.imul(f,et)|0))<<13)|0;l=((e=e+Math.imul(f,ot)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,h=Math.imul(N,U),n=(n=Math.imul(N,C))+Math.imul(E,U)|0,e=Math.imul(E,C),h=h+Math.imul(B,H)|0,n=(n=n+Math.imul(B,P)|0)+Math.imul(R,H)|0,e=e+Math.imul(R,P)|0,h=h+Math.imul(x,G)|0,n=(n=n+Math.imul(x,Q)|0)+Math.imul(q,G)|0,e=e+Math.imul(q,Q)|0,h=h+Math.imul(k,W)|0,n=(n=n+Math.imul(k,X)|0)+Math.imul(A,W)|0,e=e+Math.imul(A,X)|0,h=h+Math.imul(y,$)|0,n=(n=n+Math.imul(y,tt)|0)+Math.imul(b,$)|0,e=e+Math.imul(b,tt)|0,h=h+Math.imul(g,rt)|0,n=(n=n+Math.imul(g,ht)|0)+Math.imul(c,rt)|0,e=e+Math.imul(c,ht)|0,h=h+Math.imul(p,et)|0,n=(n=n+Math.imul(p,ot)|0)+Math.imul(M,et)|0,e=e+Math.imul(M,ot)|0;var kt=(l+(h=h+Math.imul(m,ut)|0)|0)+((8191&(n=(n=n+Math.imul(m,lt)|0)+Math.imul(f,ut)|0))<<13)|0;l=((e=e+Math.imul(f,lt)|0)+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,h=Math.imul(z,U),n=(n=Math.imul(z,C))+Math.imul(O,U)|0,e=Math.imul(O,C),h=h+Math.imul(N,H)|0,n=(n=n+Math.imul(N,P)|0)+Math.imul(E,H)|0,e=e+Math.imul(E,P)|0,h=h+Math.imul(B,G)|0,n=(n=n+Math.imul(B,Q)|0)+Math.imul(R,G)|0,e=e+Math.imul(R,Q)|0,h=h+Math.imul(x,W)|0,n=(n=n+Math.imul(x,X)|0)+Math.imul(q,W)|0,e=e+Math.imul(q,X)|0,h=h+Math.imul(k,$)|0,n=(n=n+Math.imul(k,tt)|0)+Math.imul(A,$)|0,e=e+Math.imul(A,tt)|0,h=h+Math.imul(y,rt)|0,n=(n=n+Math.imul(y,ht)|0)+Math.imul(b,rt)|0,e=e+Math.imul(b,ht)|0,h=h+Math.imul(g,et)|0,n=(n=n+Math.imul(g,ot)|0)+Math.imul(c,et)|0,e=e+Math.imul(c,ot)|0,h=h+Math.imul(p,ut)|0,n=(n=n+Math.imul(p,lt)|0)+Math.imul(M,ut)|0,e=e+Math.imul(M,lt)|0;var At=(l+(h=h+Math.imul(m,mt)|0)|0)+((8191&(n=(n=n+Math.imul(m,ft)|0)+Math.imul(f,mt)|0))<<13)|0;l=((e=e+Math.imul(f,ft)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,h=Math.imul(j,U),n=(n=Math.imul(j,C))+Math.imul(K,U)|0,e=Math.imul(K,C),h=h+Math.imul(z,H)|0,n=(n=n+Math.imul(z,P)|0)+Math.imul(O,H)|0,e=e+Math.imul(O,P)|0,h=h+Math.imul(N,G)|0,n=(n=n+Math.imul(N,Q)|0)+Math.imul(E,G)|0,e=e+Math.imul(E,Q)|0,h=h+Math.imul(B,W)|0,n=(n=n+Math.imul(B,X)|0)+Math.imul(R,W)|0,e=e+Math.imul(R,X)|0,h=h+Math.imul(x,$)|0,n=(n=n+Math.imul(x,tt)|0)+Math.imul(q,$)|0,e=e+Math.imul(q,tt)|0,h=h+Math.imul(k,rt)|0,n=(n=n+Math.imul(k,ht)|0)+Math.imul(A,rt)|0,e=e+Math.imul(A,ht)|0,h=h+Math.imul(y,et)|0,n=(n=n+Math.imul(y,ot)|0)+Math.imul(b,et)|0,e=e+Math.imul(b,ot)|0,h=h+Math.imul(g,ut)|0,n=(n=n+Math.imul(g,lt)|0)+Math.imul(c,ut)|0,e=e+Math.imul(c,lt)|0,h=h+Math.imul(p,mt)|0,n=(n=n+Math.imul(p,ft)|0)+Math.imul(M,mt)|0,e=e+Math.imul(M,ft)|0;var St=(l+(h=h+Math.imul(m,pt)|0)|0)+((8191&(n=(n=n+Math.imul(m,Mt)|0)+Math.imul(f,pt)|0))<<13)|0;l=((e=e+Math.imul(f,Mt)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,h=Math.imul(j,H),n=(n=Math.imul(j,P))+Math.imul(K,H)|0,e=Math.imul(K,P),h=h+Math.imul(z,G)|0,n=(n=n+Math.imul(z,Q)|0)+Math.imul(O,G)|0,e=e+Math.imul(O,Q)|0,h=h+Math.imul(N,W)|0,n=(n=n+Math.imul(N,X)|0)+Math.imul(E,W)|0,e=e+Math.imul(E,X)|0,h=h+Math.imul(B,$)|0,n=(n=n+Math.imul(B,tt)|0)+Math.imul(R,$)|0,e=e+Math.imul(R,tt)|0,h=h+Math.imul(x,rt)|0,n=(n=n+Math.imul(x,ht)|0)+Math.imul(q,rt)|0,e=e+Math.imul(q,ht)|0,h=h+Math.imul(k,et)|0,n=(n=n+Math.imul(k,ot)|0)+Math.imul(A,et)|0,e=e+Math.imul(A,ot)|0,h=h+Math.imul(y,ut)|0,n=(n=n+Math.imul(y,lt)|0)+Math.imul(b,ut)|0,e=e+Math.imul(b,lt)|0,h=h+Math.imul(g,mt)|0,n=(n=n+Math.imul(g,ft)|0)+Math.imul(c,mt)|0,e=e+Math.imul(c,ft)|0;var xt=(l+(h=h+Math.imul(p,pt)|0)|0)+((8191&(n=(n=n+Math.imul(p,Mt)|0)+Math.imul(M,pt)|0))<<13)|0;l=((e=e+Math.imul(M,Mt)|0)+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,h=Math.imul(j,G),n=(n=Math.imul(j,Q))+Math.imul(K,G)|0,e=Math.imul(K,Q),h=h+Math.imul(z,W)|0,n=(n=n+Math.imul(z,X)|0)+Math.imul(O,W)|0,e=e+Math.imul(O,X)|0,h=h+Math.imul(N,$)|0,n=(n=n+Math.imul(N,tt)|0)+Math.imul(E,$)|0,e=e+Math.imul(E,tt)|0,h=h+Math.imul(B,rt)|0,n=(n=n+Math.imul(B,ht)|0)+Math.imul(R,rt)|0,e=e+Math.imul(R,ht)|0,h=h+Math.imul(x,et)|0,n=(n=n+Math.imul(x,ot)|0)+Math.imul(q,et)|0,e=e+Math.imul(q,ot)|0,h=h+Math.imul(k,ut)|0,n=(n=n+Math.imul(k,lt)|0)+Math.imul(A,ut)|0,e=e+Math.imul(A,lt)|0,h=h+Math.imul(y,mt)|0,n=(n=n+Math.imul(y,ft)|0)+Math.imul(b,mt)|0,e=e+Math.imul(b,ft)|0;var qt=(l+(h=h+Math.imul(g,pt)|0)|0)+((8191&(n=(n=n+Math.imul(g,Mt)|0)+Math.imul(c,pt)|0))<<13)|0;l=((e=e+Math.imul(c,Mt)|0)+(n>>>13)|0)+(qt>>>26)|0,qt&=67108863,h=Math.imul(j,W),n=(n=Math.imul(j,X))+Math.imul(K,W)|0,e=Math.imul(K,X),h=h+Math.imul(z,$)|0,n=(n=n+Math.imul(z,tt)|0)+Math.imul(O,$)|0,e=e+Math.imul(O,tt)|0,h=h+Math.imul(N,rt)|0,n=(n=n+Math.imul(N,ht)|0)+Math.imul(E,rt)|0,e=e+Math.imul(E,ht)|0,h=h+Math.imul(B,et)|0,n=(n=n+Math.imul(B,ot)|0)+Math.imul(R,et)|0,e=e+Math.imul(R,ot)|0,h=h+Math.imul(x,ut)|0,n=(n=n+Math.imul(x,lt)|0)+Math.imul(q,ut)|0,e=e+Math.imul(q,lt)|0,h=h+Math.imul(k,mt)|0,n=(n=n+Math.imul(k,ft)|0)+Math.imul(A,mt)|0,e=e+Math.imul(A,ft)|0;var Zt=(l+(h=h+Math.imul(y,pt)|0)|0)+((8191&(n=(n=n+Math.imul(y,Mt)|0)+Math.imul(b,pt)|0))<<13)|0;l=((e=e+Math.imul(b,Mt)|0)+(n>>>13)|0)+(Zt>>>26)|0,Zt&=67108863,h=Math.imul(j,$),n=(n=Math.imul(j,tt))+Math.imul(K,$)|0,e=Math.imul(K,tt),h=h+Math.imul(z,rt)|0,n=(n=n+Math.imul(z,ht)|0)+Math.imul(O,rt)|0,e=e+Math.imul(O,ht)|0,h=h+Math.imul(N,et)|0,n=(n=n+Math.imul(N,ot)|0)+Math.imul(E,et)|0,e=e+Math.imul(E,ot)|0,h=h+Math.imul(B,ut)|0,n=(n=n+Math.imul(B,lt)|0)+Math.imul(R,ut)|0,e=e+Math.imul(R,lt)|0,h=h+Math.imul(x,mt)|0,n=(n=n+Math.imul(x,ft)|0)+Math.imul(q,mt)|0,e=e+Math.imul(q,ft)|0;var Bt=(l+(h=h+Math.imul(k,pt)|0)|0)+((8191&(n=(n=n+Math.imul(k,Mt)|0)+Math.imul(A,pt)|0))<<13)|0;l=((e=e+Math.imul(A,Mt)|0)+(n>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,h=Math.imul(j,rt),n=(n=Math.imul(j,ht))+Math.imul(K,rt)|0,e=Math.imul(K,ht),h=h+Math.imul(z,et)|0,n=(n=n+Math.imul(z,ot)|0)+Math.imul(O,et)|0,e=e+Math.imul(O,ot)|0,h=h+Math.imul(N,ut)|0,n=(n=n+Math.imul(N,lt)|0)+Math.imul(E,ut)|0,e=e+Math.imul(E,lt)|0,h=h+Math.imul(B,mt)|0,n=(n=n+Math.imul(B,ft)|0)+Math.imul(R,mt)|0,e=e+Math.imul(R,ft)|0;var Rt=(l+(h=h+Math.imul(x,pt)|0)|0)+((8191&(n=(n=n+Math.imul(x,Mt)|0)+Math.imul(q,pt)|0))<<13)|0;l=((e=e+Math.imul(q,Mt)|0)+(n>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,h=Math.imul(j,et),n=(n=Math.imul(j,ot))+Math.imul(K,et)|0,e=Math.imul(K,ot),h=h+Math.imul(z,ut)|0,n=(n=n+Math.imul(z,lt)|0)+Math.imul(O,ut)|0,e=e+Math.imul(O,lt)|0,h=h+Math.imul(N,mt)|0,n=(n=n+Math.imul(N,ft)|0)+Math.imul(E,mt)|0,e=e+Math.imul(E,ft)|0;var Lt=(l+(h=h+Math.imul(B,pt)|0)|0)+((8191&(n=(n=n+Math.imul(B,Mt)|0)+Math.imul(R,pt)|0))<<13)|0;l=((e=e+Math.imul(R,Mt)|0)+(n>>>13)|0)+(Lt>>>26)|0,Lt&=67108863,h=Math.imul(j,ut),n=(n=Math.imul(j,lt))+Math.imul(K,ut)|0,e=Math.imul(K,lt),h=h+Math.imul(z,mt)|0,n=(n=n+Math.imul(z,ft)|0)+Math.imul(O,mt)|0,e=e+Math.imul(O,ft)|0;var Nt=(l+(h=h+Math.imul(N,pt)|0)|0)+((8191&(n=(n=n+Math.imul(N,Mt)|0)+Math.imul(E,pt)|0))<<13)|0;l=((e=e+Math.imul(E,Mt)|0)+(n>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,h=Math.imul(j,mt),n=(n=Math.imul(j,ft))+Math.imul(K,mt)|0,e=Math.imul(K,ft);var Et=(l+(h=h+Math.imul(z,pt)|0)|0)+((8191&(n=(n=n+Math.imul(z,Mt)|0)+Math.imul(O,pt)|0))<<13)|0;l=((e=e+Math.imul(O,Mt)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863;var It=(l+(h=Math.imul(j,pt))|0)+((8191&(n=(n=Math.imul(j,Mt))+Math.imul(K,pt)|0))<<13)|0;return l=((e=Math.imul(K,Mt))+(n>>>13)|0)+(It>>>26)|0,It&=67108863,u[0]=vt,u[1]=gt,u[2]=ct,u[3]=wt,u[4]=yt,u[5]=bt,u[6]=_t,u[7]=kt,u[8]=At,u[9]=St,u[10]=xt,u[11]=qt,u[12]=Zt,u[13]=Bt,u[14]=Rt,u[15]=Lt,u[16]=Nt,u[17]=Et,u[18]=It,0!==l&&(u[19]=l,r.length++),r};function g(t,i,r){r.negative=i.negative^t.negative,r.length=t.length+i.length;for(var h=0,n=0,e=0;e<r.length-1;e++){var o=n;n=0;for(var s=67108863&h,u=Math.min(e,i.length-1),l=Math.max(0,e-t.length+1);l<=u;l++){var a=e-l,m=(0|t.words[a])*(0|i.words[l]),f=67108863&m;s=67108863&(f=f+s|0),n+=(o=(o=o+(m/67108864|0)|0)+(f>>>26)|0)>>>26,o&=67108863}r.words[e]=s,h=o,o=n}return 0!==h?r.words[e]=h:r.length--,r._strip()}function c(t,i,r){return g(t,i,r)}Math.imul||(v=M),e.prototype.mulTo=function(t,i){var r=this.length+t.length;return 10===this.length&&10===t.length?v(this,t,i):r<63?M(this,t,i):r<1024?g(this,t,i):c(this,t,i)},e.prototype.mul=function(t){var i=new e(null);return i.words=new Array(this.length+t.length),this.mulTo(t,i)},e.prototype.mulf=function(t){var i=new e(null);return i.words=new Array(this.length+t.length),c(this,t,i)},e.prototype.imul=function(t){return this.clone().mulTo(t,this)},e.prototype.imuln=function(t){var i=t<0;i&&(t=-t),h("number"==typeof t),h(t<67108864);for(var r=0,n=0;n<this.length;n++){var e=(0|this.words[n])*t,o=(67108863&e)+(67108863&r);r>>=26,r+=e/67108864|0,r+=o>>>26,this.words[n]=67108863&o}return 0!==r&&(this.words[n]=r,this.length++),i?this.ineg():this},e.prototype.muln=function(t){return this.clone().imuln(t)},e.prototype.sqr=function(){return this.mul(this)},e.prototype.isqr=function(){return this.imul(this.clone())},e.prototype.pow=function(t){var i=function(t){for(var i=new Array(t.bitLength()),r=0;r<i.length;r++){var h=r/26|0,n=r%26;i[r]=t.words[h]>>>n&1}return i}(t);if(0===i.length)return new e(1);for(var r=this,h=0;h<i.length&&0===i[h];h++,r=r.sqr());if(++h<i.length)for(var n=r.sqr();h<i.length;h++,n=n.sqr())0!==i[h]&&(r=r.mul(n));return r},e.prototype.iushln=function(t){h("number"==typeof t&&t>=0);var i,r=t%26,n=(t-r)/26,e=67108863>>>26-r<<26-r;if(0!==r){var o=0;for(i=0;i<this.length;i++){var s=this.words[i]&e,u=(0|this.words[i])-s<<r;this.words[i]=u|o,o=s>>>26-r}o&&(this.words[i]=o,this.length++)}if(0!==n){for(i=this.length-1;i>=0;i--)this.words[i+n]=this.words[i];for(i=0;i<n;i++)this.words[i]=0;this.length+=n}return this._strip()},e.prototype.ishln=function(t){return h(0===this.negative),this.iushln(t)},e.prototype.iushrn=function(t,i,r){var n;h("number"==typeof t&&t>=0),n=i?(i-i%26)/26:0;var e=t%26,o=Math.min((t-e)/26,this.length),s=67108863^67108863>>>e<<e,u=r;if(n-=o,n=Math.max(0,n),u){for(var l=0;l<o;l++)u.words[l]=this.words[l];u.length=o}if(0===o);else if(this.length>o)for(this.length-=o,l=0;l<this.length;l++)this.words[l]=this.words[l+o];else this.words[0]=0,this.length=1;var a=0;for(l=this.length-1;l>=0&&(0!==a||l>=n);l--){var m=0|this.words[l];this.words[l]=a<<26-e|m>>>e,a=m&s}return u&&0!==a&&(u.words[u.length++]=a),0===this.length&&(this.words[0]=0,this.length=1),this._strip()},e.prototype.ishrn=function(t,i,r){return h(0===this.negative),this.iushrn(t,i,r)},e.prototype.shln=function(t){return this.clone().ishln(t)},e.prototype.ushln=function(t){return this.clone().iushln(t)},e.prototype.shrn=function(t){return this.clone().ishrn(t)},e.prototype.ushrn=function(t){return this.clone().iushrn(t)},e.prototype.testn=function(t){h("number"==typeof t&&t>=0);var i=t%26,r=(t-i)/26,n=1<<i;return!(this.length<=r||!(this.words[r]&n))},e.prototype.imaskn=function(t){h("number"==typeof t&&t>=0);var i=t%26,r=(t-i)/26;if(h(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==i&&r++,this.length=Math.min(r,this.length),0!==i){var n=67108863^67108863>>>i<<i;this.words[this.length-1]&=n}return this._strip()},e.prototype.maskn=function(t){return this.clone().imaskn(t)},e.prototype.iaddn=function(t){return h("number"==typeof t),h(t<67108864),t<0?this.isubn(-t):0!==this.negative?1===this.length&&(0|this.words[0])<=t?(this.words[0]=t-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(t),this.negative=1,this):this._iaddn(t)},e.prototype._iaddn=function(t){this.words[0]+=t;for(var i=0;i<this.length&&this.words[i]>=67108864;i++)this.words[i]-=67108864,i===this.length-1?this.words[i+1]=1:this.words[i+1]++;return this.length=Math.max(this.length,i+1),this},e.prototype.isubn=function(t){if(h("number"==typeof t),h(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var i=0;i<this.length&&this.words[i]<0;i++)this.words[i]+=67108864,this.words[i+1]-=1;return this._strip()},e.prototype.addn=function(t){return this.clone().iaddn(t)},e.prototype.subn=function(t){return this.clone().isubn(t)},e.prototype.iabs=function(){return this.negative=0,this},e.prototype.abs=function(){return this.clone().iabs()},e.prototype._ishlnsubmul=function(t,i,r){var n,e,o=t.length+r;this._expand(o);var s=0;for(n=0;n<t.length;n++){e=(0|this.words[n+r])+s;var u=(0|t.words[n])*i;s=((e-=67108863&u)>>26)-(u/67108864|0),this.words[n+r]=67108863&e}for(;n<this.length-r;n++)s=(e=(0|this.words[n+r])+s)>>26,this.words[n+r]=67108863&e;if(0===s)return this._strip();for(h(-1===s),s=0,n=0;n<this.length;n++)s=(e=-(0|this.words[n])+s)>>26,this.words[n]=67108863&e;return this.negative=1,this._strip()},e.prototype._wordDiv=function(t,i){var r=(this.length,t.length),h=this.clone(),n=t,o=0|n.words[n.length-1];0!=(r=26-this._countBits(o))&&(n=n.ushln(r),h.iushln(r),o=0|n.words[n.length-1]);var s,u=h.length-n.length;if("mod"!==i){(s=new e(null)).length=u+1,s.words=new Array(s.length);for(var l=0;l<s.length;l++)s.words[l]=0}var a=h.clone()._ishlnsubmul(n,1,u);0===a.negative&&(h=a,s&&(s.words[u]=1));for(var m=u-1;m>=0;m--){var f=67108864*(0|h.words[n.length+m])+(0|h.words[n.length+m-1]);for(f=Math.min(f/o|0,67108863),h._ishlnsubmul(n,f,m);0!==h.negative;)f--,h.negative=0,h._ishlnsubmul(n,1,m),h.isZero()||(h.negative^=1);s&&(s.words[m]=f)}return s&&s._strip(),h._strip(),"div"!==i&&0!==r&&h.iushrn(r),{div:s||null,mod:h}},e.prototype.divmod=function(t,i,r){return h(!t.isZero()),this.isZero()?{div:new e(0),mod:new e(0)}:0!==this.negative&&0===t.negative?(s=this.neg().divmod(t,i),"mod"!==i&&(n=s.div.neg()),"div"!==i&&(o=s.mod.neg(),r&&0!==o.negative&&o.iadd(t)),{div:n,mod:o}):0===this.negative&&0!==t.negative?(s=this.divmod(t.neg(),i),"mod"!==i&&(n=s.div.neg()),{div:n,mod:s.mod}):0!=(this.negative&t.negative)?(s=this.neg().divmod(t.neg(),i),"div"!==i&&(o=s.mod.neg(),r&&0!==o.negative&&o.isub(t)),{div:s.div,mod:o}):t.length>this.length||this.cmp(t)<0?{div:new e(0),mod:this}:1===t.length?"div"===i?{div:this.divn(t.words[0]),mod:null}:"mod"===i?{div:null,mod:new e(this.modrn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new e(this.modrn(t.words[0]))}:this._wordDiv(t,i);var n,o,s},e.prototype.div=function(t){return this.divmod(t,"div",!1).div},e.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},e.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},e.prototype.divRound=function(t){var i=this.divmod(t);if(i.mod.isZero())return i.div;var r=0!==i.div.negative?i.mod.isub(t):i.mod,h=t.ushrn(1),n=t.andln(1),e=r.cmp(h);return e<0||1===n&&0===e?i.div:0!==i.div.negative?i.div.isubn(1):i.div.iaddn(1)},e.prototype.modrn=function(t){var i=t<0;i&&(t=-t),h(t<=67108863);for(var r=(1<<26)%t,n=0,e=this.length-1;e>=0;e--)n=(r*n+(0|this.words[e]))%t;return i?-n:n},e.prototype.modn=function(t){return this.modrn(t)},e.prototype.idivn=function(t){var i=t<0;i&&(t=-t),h(t<=67108863);for(var r=0,n=this.length-1;n>=0;n--){var e=(0|this.words[n])+67108864*r;this.words[n]=e/t|0,r=e%t}return this._strip(),i?this.ineg():this},e.prototype.divn=function(t){return this.clone().idivn(t)},e.prototype.egcd=function(t){h(0===t.negative),h(!t.isZero());var i=this,r=t.clone();i=0!==i.negative?i.umod(t):i.clone();for(var n=new e(1),o=new e(0),s=new e(0),u=new e(1),l=0;i.isEven()&&r.isEven();)i.iushrn(1),r.iushrn(1),++l;for(var a=r.clone(),m=i.clone();!i.isZero();){for(var f=0,d=1;0==(i.words[0]&d)&&f<26;++f,d<<=1);if(f>0)for(i.iushrn(f);f-- >0;)(n.isOdd()||o.isOdd())&&(n.iadd(a),o.isub(m)),n.iushrn(1),o.iushrn(1);for(var p=0,M=1;0==(r.words[0]&M)&&p<26;++p,M<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(s.isOdd()||u.isOdd())&&(s.iadd(a),u.isub(m)),s.iushrn(1),u.iushrn(1);i.cmp(r)>=0?(i.isub(r),n.isub(s),o.isub(u)):(r.isub(i),s.isub(n),u.isub(o))}return{a:s,b:u,gcd:r.iushln(l)}},e.prototype._invmp=function(t){h(0===t.negative),h(!t.isZero());var i=this,r=t.clone();i=0!==i.negative?i.umod(t):i.clone();for(var n,o=new e(1),s=new e(0),u=r.clone();i.cmpn(1)>0&&r.cmpn(1)>0;){for(var l=0,a=1;0==(i.words[0]&a)&&l<26;++l,a<<=1);if(l>0)for(i.iushrn(l);l-- >0;)o.isOdd()&&o.iadd(u),o.iushrn(1);for(var m=0,f=1;0==(r.words[0]&f)&&m<26;++m,f<<=1);if(m>0)for(r.iushrn(m);m-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);i.cmp(r)>=0?(i.isub(r),o.isub(s)):(r.isub(i),s.isub(o))}return(n=0===i.cmpn(1)?o:s).cmpn(0)<0&&n.iadd(t),n},e.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var i=this.clone(),r=t.clone();i.negative=0,r.negative=0;for(var h=0;i.isEven()&&r.isEven();h++)i.iushrn(1),r.iushrn(1);for(;;){for(;i.isEven();)i.iushrn(1);for(;r.isEven();)r.iushrn(1);var n=i.cmp(r);if(n<0){var e=i;i=r,r=e}else if(0===n||0===r.cmpn(1))break;i.isub(r)}return r.iushln(h)},e.prototype.invm=function(t){return this.egcd(t).a.umod(t)},e.prototype.isEven=function(){return 0==(1&this.words[0])},e.prototype.isOdd=function(){return 1==(1&this.words[0])},e.prototype.andln=function(t){return this.words[0]&t},e.prototype.bincn=function(t){h("number"==typeof t);var i=t%26,r=(t-i)/26,n=1<<i;if(this.length<=r)return this._expand(r+1),this.words[r]|=n,this;for(var e=n,o=r;0!==e&&o<this.length;o++){var s=0|this.words[o];e=(s+=e)>>>26,s&=67108863,this.words[o]=s}return 0!==e&&(this.words[o]=e,this.length++),this},e.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},e.prototype.cmpn=function(t){var i,r=t<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this._strip(),this.length>1)i=1;else{r&&(t=-t),h(t<=67108863,"Number is too big");var n=0|this.words[0];i=n===t?0:n<t?-1:1}return 0!==this.negative?0|-i:i},e.prototype.cmp=function(t){if(0!==this.negative&&0===t.negative)return-1;if(0===this.negative&&0!==t.negative)return 1;var i=this.ucmp(t);return 0!==this.negative?0|-i:i},e.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var i=0,r=this.length-1;r>=0;r--){var h=0|this.words[r],n=0|t.words[r];if(h!==n){h<n?i=-1:h>n&&(i=1);break}}return i},e.prototype.gtn=function(t){return 1===this.cmpn(t)},e.prototype.gt=function(t){return 1===this.cmp(t)},e.prototype.gten=function(t){return this.cmpn(t)>=0},e.prototype.gte=function(t){return this.cmp(t)>=0},e.prototype.ltn=function(t){return-1===this.cmpn(t)},e.prototype.lt=function(t){return-1===this.cmp(t)},e.prototype.lten=function(t){return this.cmpn(t)<=0},e.prototype.lte=function(t){return this.cmp(t)<=0},e.prototype.eqn=function(t){return 0===this.cmpn(t)},e.prototype.eq=function(t){return 0===this.cmp(t)},e.red=function(t){return new S(t)},e.prototype.toRed=function(t){return h(!this.red,"Already a number in reduction context"),h(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},e.prototype.fromRed=function(){return h(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},e.prototype._forceRed=function(t){return this.red=t,this},e.prototype.forceRed=function(t){return h(!this.red,"Already a number in reduction context"),this._forceRed(t)},e.prototype.redAdd=function(t){return h(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},e.prototype.redIAdd=function(t){return h(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},e.prototype.redSub=function(t){return h(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},e.prototype.redISub=function(t){return h(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},e.prototype.redShl=function(t){return h(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},e.prototype.redMul=function(t){return h(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},e.prototype.redIMul=function(t){return h(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},e.prototype.redSqr=function(){return h(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},e.prototype.redISqr=function(){return h(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},e.prototype.redSqrt=function(){return h(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},e.prototype.redInvm=function(){return h(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},e.prototype.redNeg=function(){return h(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},e.prototype.redPow=function(t){return h(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var w={k256:null,p224:null,p192:null,p25519:null};function y(t,i){this.name=t,this.p=new e(i,16),this.n=this.p.bitLength(),this.k=new e(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function b(){y.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function _(){y.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function k(){y.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function A(){y.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function S(t){if("string"==typeof t){var i=e._prime(t);this.m=i.p,this.prime=i}else h(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function x(t){S.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new e(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)}y.prototype._tmp=function(){var t=new e(null);return t.words=new Array(Math.ceil(this.n/13)),t},y.prototype.ireduce=function(t){var i,r=t;do{this.split(r,this.tmp),i=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(i>this.n);var h=i<this.n?-1:r.ucmp(this.p);return 0===h?(r.words[0]=0,r.length=1):h>0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},y.prototype.split=function(t,i){t.iushrn(this.n,0,i)},y.prototype.imulK=function(t){return t.imul(this.k)},n(b,y),b.prototype.split=function(t,i){for(var r=4194303,h=Math.min(t.length,9),n=0;n<h;n++)i.words[n]=t.words[n];if(i.length=h,t.length<=9)return t.words[0]=0,void(t.length=1);var e=t.words[9];for(i.words[i.length++]=e&r,n=10;n<t.length;n++){var o=0|t.words[n];t.words[n-10]=(o&r)<<4|e>>>22,e=o}e>>>=22,t.words[n-10]=e,0===e&&t.length>10?t.length-=10:t.length-=9},b.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var i=0,r=0;r<t.length;r++){var h=0|t.words[r];i+=977*h,t.words[r]=67108863&i,i=64*h+(i/67108864|0)}return 0===t.words[t.length-1]&&(t.length--,0===t.words[t.length-1]&&t.length--),t},n(_,y),n(k,y),n(A,y),A.prototype.imulK=function(t){for(var i=0,r=0;r<t.length;r++){var h=19*(0|t.words[r])+i,n=67108863&h;h>>>=26,t.words[r]=n,i=h}return 0!==i&&(t.words[t.length++]=i),t},e._prime=function(t){if(w[t])return w[t];var i;if("k256"===t)i=new b;else if("p224"===t)i=new _;else if("p192"===t)i=new k;else{if("p25519"!==t)throw new Error("Unknown prime "+t);i=new A}return w[t]=i,i},S.prototype._verify1=function(t){h(0===t.negative,"red works only with positives"),h(t.red,"red works only with red numbers")},S.prototype._verify2=function(t,i){h(0==(t.negative|i.negative),"red works only with positives"),h(t.red&&t.red===i.red,"red works only with red numbers")},S.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):(a(t,t.umod(this.m)._forceRed(this)),t)},S.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},S.prototype.add=function(t,i){this._verify2(t,i);var r=t.add(i);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},S.prototype.iadd=function(t,i){this._verify2(t,i);var r=t.iadd(i);return r.cmp(this.m)>=0&&r.isub(this.m),r},S.prototype.sub=function(t,i){this._verify2(t,i);var r=t.sub(i);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},S.prototype.isub=function(t,i){this._verify2(t,i);var r=t.isub(i);return r.cmpn(0)<0&&r.iadd(this.m),r},S.prototype.shl=function(t,i){return this._verify1(t),this.imod(t.ushln(i))},S.prototype.imul=function(t,i){return this._verify2(t,i),this.imod(t.imul(i))},S.prototype.mul=function(t,i){return this._verify2(t,i),this.imod(t.mul(i))},S.prototype.isqr=function(t){return this.imul(t,t.clone())},S.prototype.sqr=function(t){return this.mul(t,t)},S.prototype.sqrt=function(t){if(t.isZero())return t.clone();var i=this.m.andln(3);if(h(i%2==1),3===i){var r=this.m.add(new e(1)).iushrn(2);return this.pow(t,r)}for(var n=this.m.subn(1),o=0;!n.isZero()&&0===n.andln(1);)o++,n.iushrn(1);h(!n.isZero());var s=new e(1).toRed(this),u=s.redNeg(),l=this.m.subn(1).iushrn(1),a=this.m.bitLength();for(a=new e(2*a*a).toRed(this);0!==this.pow(a,l).cmp(u);)a.redIAdd(u);for(var m=this.pow(a,n),f=this.pow(t,n.addn(1).iushrn(1)),d=this.pow(t,n),p=o;0!==d.cmp(s);){for(var M=d,v=0;0!==M.cmp(s);v++)M=M.redSqr();h(v<p);var g=this.pow(m,new e(1).iushln(p-v-1));f=f.redMul(g),m=g.redSqr(),d=d.redMul(m),p=v}return f},S.prototype.invm=function(t){var i=t._invmp(this.m);return 0!==i.negative?(i.negative=0,this.imod(i).redNeg()):this.imod(i)},S.prototype.pow=function(t,i){if(i.isZero())return new e(1).toRed(this);if(0===i.cmpn(1))return t.clone();var r=new Array(16);r[0]=new e(1).toRed(this),r[1]=t;for(var h=2;h<r.length;h++)r[h]=this.mul(r[h-1],t);var n=r[0],o=0,s=0,u=i.bitLength()%26;for(0===u&&(u=26),h=i.length-1;h>=0;h--){for(var l=i.words[h],a=u-1;a>=0;a--){var m=l>>a&1;n!==r[0]&&(n=this.sqr(n)),0!==m||0!==o?(o<<=1,o|=m,(4==++s||0===h&&0===a)&&(n=this.mul(n,r[o]),s=0,o=0)):s=0}u=26}return n},S.prototype.convertTo=function(t){var i=t.umod(this.m);return i===t?i.clone():i},S.prototype.convertFrom=function(t){var i=t.clone();return i.red=null,i},e.mont=function(t){return new x(t)},n(x,S),x.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},x.prototype.convertFrom=function(t){var i=this.imod(t.mul(this.rinv));return i.red=null,i},x.prototype.imul=function(t,i){if(t.isZero()||i.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(i),h=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(h).iushrn(this.shift),e=n;return n.cmp(this.m)>=0?e=n.isub(this.m):n.cmpn(0)<0&&(e=n.iadd(this.m)),e._forceRed(this)},x.prototype.mul=function(t,i){if(t.isZero()||i.isZero())return new e(0)._forceRed(this);var r=t.mul(i),h=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=r.isub(h).iushrn(this.shift),o=n;return n.cmp(this.m)>=0?o=n.isub(this.m):n.cmpn(0)<0&&(o=n.iadd(this.m)),o._forceRed(this)},x.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(r,t);var h=r.exports;export{h as B,r as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as t,b as e}from"./index-
|
|
1
|
+
import{c as t,b as e}from"./index-7decf620.js";var r={exports:{}};!function(e,r){var o="undefined"!=typeof self?self:t,n=function(){function t(){this.fetch=!1,this.DOMException=o.DOMException}return t.prototype=o,new t}();!function(t){!function(e){var r={searchParams:"URLSearchParams"in t,iterable:"Symbol"in t&&"iterator"in Symbol,blob:"FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(t){return!1}}(),formData:"FormData"in t,arrayBuffer:"ArrayBuffer"in t};if(r.arrayBuffer)var o=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],n=ArrayBuffer.isView||function(t){return t&&o.indexOf(Object.prototype.toString.call(t))>-1};function i(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(t))throw new TypeError("Invalid character in header field name");return t.toLowerCase()}function s(t){return"string"!=typeof t&&(t=String(t)),t}function a(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return r.iterable&&(e[Symbol.iterator]=function(){return e}),e}function h(t){this.map={},t instanceof h?t.forEach((function(t,e){this.append(e,t)}),this):Array.isArray(t)?t.forEach((function(t){this.append(t[0],t[1])}),this):t&&Object.getOwnPropertyNames(t).forEach((function(e){this.append(e,t[e])}),this)}function f(t){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}function u(t){return new Promise((function(e,r){t.onload=function(){e(t.result)},t.onerror=function(){r(t.error)}}))}function c(t){var e=new FileReader,r=u(e);return e.readAsArrayBuffer(t),r}function d(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function p(){return this.bodyUsed=!1,this._initBody=function(t){var e;this._bodyInit=t,t?"string"==typeof t?this._bodyText=t:r.blob&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:r.formData&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:r.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():r.arrayBuffer&&r.blob&&((e=t)&&DataView.prototype.isPrototypeOf(e))?(this._bodyArrayBuffer=d(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):r.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(t)||n(t))?this._bodyArrayBuffer=d(t):this._bodyText=t=Object.prototype.toString.call(t):this._bodyText="",this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):r.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},r.blob&&(this.blob=function(){var t=f(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?f(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(c)}),this.text=function(){var t,e,r,o=f(this);if(o)return o;if(this._bodyBlob)return t=this._bodyBlob,e=new FileReader,r=u(e),e.readAsText(t),r;if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var e=new Uint8Array(t),r=new Array(e.length),o=0;o<e.length;o++)r[o]=String.fromCharCode(e[o]);return r.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},r.formData&&(this.formData=function(){return this.text().then(b)}),this.json=function(){return this.text().then(JSON.parse)},this}h.prototype.append=function(t,e){t=i(t),e=s(e);var r=this.map[t];this.map[t]=r?r+", "+e:e},h.prototype.delete=function(t){delete this.map[i(t)]},h.prototype.get=function(t){return t=i(t),this.has(t)?this.map[t]:null},h.prototype.has=function(t){return this.map.hasOwnProperty(i(t))},h.prototype.set=function(t,e){this.map[i(t)]=s(e)},h.prototype.forEach=function(t,e){for(var r in this.map)this.map.hasOwnProperty(r)&&t.call(e,this.map[r],r,this)},h.prototype.keys=function(){var t=[];return this.forEach((function(e,r){t.push(r)})),a(t)},h.prototype.values=function(){var t=[];return this.forEach((function(e){t.push(e)})),a(t)},h.prototype.entries=function(){var t=[];return this.forEach((function(e,r){t.push([r,e])})),a(t)},r.iterable&&(h.prototype[Symbol.iterator]=h.prototype.entries);var y=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function l(t,e){var r,o,n=(e=e||{}).body;if(t instanceof l){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new h(t.headers)),this.method=t.method,this.mode=t.mode,this.signal=t.signal,n||null==t._bodyInit||(n=t._bodyInit,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=e.credentials||this.credentials||"same-origin",!e.headers&&this.headers||(this.headers=new h(e.headers)),this.method=(r=e.method||this.method||"GET",o=r.toUpperCase(),y.indexOf(o)>-1?o:r),this.mode=e.mode||this.mode||null,this.signal=e.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&n)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(n)}function b(t){var e=new FormData;return t.trim().split("&").forEach((function(t){if(t){var r=t.split("="),o=r.shift().replace(/\+/g," "),n=r.join("=").replace(/\+/g," ");e.append(decodeURIComponent(o),decodeURIComponent(n))}})),e}function m(t,e){e||(e={}),this.type="default",this.status=void 0===e.status?200:e.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in e?e.statusText:"OK",this.headers=new h(e.headers),this.url=e.url||"",this._initBody(t)}l.prototype.clone=function(){return new l(this,{body:this._bodyInit})},p.call(l.prototype),p.call(m.prototype),m.prototype.clone=function(){return new m(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new h(this.headers),url:this.url})},m.error=function(){var t=new m(null,{status:0,statusText:""});return t.type="error",t};var w=[301,302,303,307,308];m.redirect=function(t,e){if(-1===w.indexOf(e))throw new RangeError("Invalid status code");return new m(null,{status:e,headers:{location:t}})},e.DOMException=t.DOMException;try{new e.DOMException}catch(t){e.DOMException=function(t,e){this.message=t,this.name=e;var r=Error(t);this.stack=r.stack},e.DOMException.prototype=Object.create(Error.prototype),e.DOMException.prototype.constructor=e.DOMException}function v(t,o){return new Promise((function(n,i){var s=new l(t,o);if(s.signal&&s.signal.aborted)return i(new e.DOMException("Aborted","AbortError"));var a=new XMLHttpRequest;function f(){a.abort()}a.onload=function(){var t,e,r={status:a.status,statusText:a.statusText,headers:(t=a.getAllResponseHeaders()||"",e=new h,t.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach((function(t){var r=t.split(":"),o=r.shift().trim();if(o){var n=r.join(":").trim();e.append(o,n)}})),e)};r.url="responseURL"in a?a.responseURL:r.headers.get("X-Request-URL");var o="response"in a?a.response:a.responseText;n(new m(o,r))},a.onerror=function(){i(new TypeError("Network request failed"))},a.ontimeout=function(){i(new TypeError("Network request failed"))},a.onabort=function(){i(new e.DOMException("Aborted","AbortError"))},a.open(s.method,s.url,!0),"include"===s.credentials?a.withCredentials=!0:"omit"===s.credentials&&(a.withCredentials=!1),"responseType"in a&&r.blob&&(a.responseType="blob"),s.headers.forEach((function(t,e){a.setRequestHeader(e,t)})),s.signal&&(s.signal.addEventListener("abort",f),a.onreadystatechange=function(){4===a.readyState&&s.signal.removeEventListener("abort",f)}),a.send(void 0===s._bodyInit?null:s._bodyInit)}))}v.polyfill=!0,t.fetch||(t.fetch=v,t.Headers=h,t.Request=l,t.Response=m),e.Headers=h,e.Request=l,e.Response=m,e.fetch=v,Object.defineProperty(e,"__esModule",{value:!0})}({})}(n),n.fetch.ponyfill=!0,delete n.fetch.polyfill;var i=n;(r=i.fetch).default=i.fetch,r.fetch=i.fetch,r.Headers=i.Headers,r.Request=i.Request,r.Response=i.Response,e.exports=r}(r,r.exports);var o=e(r.exports);export{r as b,o as c};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{B as e,m as t,s as r,o as a,p as s,q as o,r as n,u as c,w as i,H as d,x as p}from"./index-
|
|
1
|
+
import{B as e,m as t,s as r,o as a,p as s,q as o,r as n,u as c,w as i,H as d,x as p}from"./index-3dfcceec.js";import"./index-7decf620.js";import"@ethersproject/providers";import"zustand";import"events";import"@ethersproject/address";import"@ethersproject/constants";import"@ethersproject/contracts";import"@ethersproject/properties";import"@ethersproject/transactions";import"@ethersproject/bytes";import"@ethersproject/abstract-provider";import"./index-21722c04.js";import"@ethersproject/abstract-signer";import"./id-3aece8c0.js";import"./bn-92d59440.js";import"./__node-resolve_empty-261d59ac.js";import"./index-cd6bd2ce.js";import"./hash-b468659c.js";import"./inherits_browser-51bb8c3c.js";import"@ethersproject/json-wallets";import"./DefaultJsonRpcProvider-0d7925ff.js";import"./browser-ponyfill-d3098539.js";import"buffer";import"./index-5b79ce49.js";class l extends e{constructor({callbackSelector:e,cause:r,data:a,extraData:s,sender:o,urls:n}){super(r.shortMessage||"An error occurred while fetching for an offchain result.",{cause:r,metaMessages:[...r.metaMessages||[],r.metaMessages?.length?"":[],"Offchain Gateway Call:",n&&[" Gateway URL(s):",...n.map((e=>` ${t(e)}`))],` Sender: ${o}`,` Data: ${a}`,` Callback selector: ${e}`,` Extra data: ${s}`].flat()}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"OffchainLookupError"})}}class u extends e{constructor({result:e,url:a}){super("Offchain gateway response is malformed. Response data must be a hex value.",{metaMessages:[`Gateway URL: ${t(a)}`,`Response: ${r(e)}`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"OffchainLookupResponseMalformedError"})}}class m extends e{constructor({sender:e,to:t}){super("Reverted sender address does not match target contract address (`to`).",{metaMessages:[`Contract address: ${t}`,`OffchainLookup sender address: ${e}`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"OffchainLookupSenderMismatchError"})}}const f="0x556f1830",h={name:"OffchainLookup",type:"error",inputs:[{name:"sender",type:"address"},{name:"urls",type:"string[]"},{name:"callData",type:"bytes"},{name:"callbackFunction",type:"bytes4"},{name:"extraData",type:"bytes"}]};async function b(e,{blockNumber:t,blockTag:r,data:d,to:p}){const{args:u}=o({data:d,abi:[h]}),[f,b,y,j,g]=u;try{if(!function(e,t){if(!a(e,{strict:!1}))throw new s({address:e});if(!a(t,{strict:!1}))throw new s({address:t});return e.toLowerCase()===t.toLowerCase()}(p,f))throw new m({sender:f,to:p});const o=await w({data:y,sender:f,urls:b}),{data:d}=await n(e,{blockNumber:t,blockTag:r,data:c([j,i([{type:"bytes"},{type:"bytes"}],[o,g])]),to:p});return d}catch(e){throw new l({callbackSelector:j,cause:e,data:d,extraData:g,sender:f,urls:b})}}async function w({data:e,sender:t,urls:a}){let s=new Error("An unknown error occurred.");for(let o=0;o<a.length;o++){const n=a[o],c=n.includes("{data}")?"GET":"POST",i="POST"===c?{data:e,sender:t}:void 0;try{const a=await fetch(n.replace("{sender}",t).replace("{data}",e),{body:JSON.stringify(i),method:c});let o;if(o=a.headers.get("Content-Type")?.startsWith("application/json")?(await a.json()).data:await a.text(),!a.ok){s=new d({body:i,details:o?.error?r(o.error):a.statusText,headers:a.headers,status:a.status,url:n});continue}if(!p(o)){s=new u({result:o,url:n});continue}return o}catch(e){s=new d({body:i,details:e.message,url:n})}}throw s}export{w as ccipFetch,b as offchainLookup,h as offchainLookupAbiItem,f as offchainLookupSignature};
|
package/dist/cjs/{DefaultJsonRpcProvider-a94708b3.cjs → DefaultJsonRpcProvider-bca8f91d.cjs}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("@ethersproject/providers"),r=require("./index-
|
|
1
|
+
"use strict";var e=require("@ethersproject/providers"),r=require("./index-f63cfc3f.cjs"),t=require("@ethersproject/properties");function s(e){if(e.error){const r=new Error(e.error.message);throw r.code=e.error.code,r.data=e.error.data,r}return e.result}class o extends e.StaticJsonRpcProvider{getNetwork(){return"object"==typeof this.network&&"number"==typeof this.network.chainId?Promise.resolve(this.network):"number"==typeof this.network&&this.network?Promise.resolve({chainId:this.network,name:"unknown"}):super.getNetwork()}send(e,o){var i;const n={method:e,params:o,id:this._nextId++,jsonrpc:"2.0"};this.emit("debug",{action:"request",request:t.deepCopy(n),provider:this});const c=["eth_chainId","eth_blockNumber"].indexOf(e)>=0;if(c&&this._cache[e])return this._cache[e];const h=r.fetchJson(Object.assign(Object.assign({},this.connection),{url:this.rpcUrl||(null===(i=this.connection)||void 0===i?void 0:i.url)}),JSON.stringify(n),s).then((e=>(this.emit("debug",{action:"response",request:n,response:e,provider:this}),e)),(e=>{throw this.emit("debug",{action:"response",error:e,request:n,provider:this}),e}));return c&&(this._cache[e]=h,setTimeout((()=>{this._cache[e]=null}),0)),h}}exports.DefaultJsonRpcProvider=o;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("./index-
|
|
1
|
+
"use strict";var e=require("./index-94459054.cjs"),r=Object.freeze({__proto__:null,default:{}}),t=e.getAugmentedNamespace(r);exports.require$$1=t;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e=require("./index-94459054.cjs"),r=e.getAugmentedNamespace(e._tslib);exports.require$$0=r;
|
package/dist/cjs/{alchemy-provider-5870b6fa-b4296005.cjs → alchemy-provider-5870b6fa-96ba77e7.cjs}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("./index-
|
|
1
|
+
"use strict";var e=require("./index-18b9efa9.cjs"),r=require("./id-64cfc377.cjs"),t=require("@ethersproject/providers"),n=require("./index-f63cfc3f.cjs");require("@ethersproject/abstract-provider"),require("@ethersproject/contracts");const i=new r.Logger("networks/5.7.1");function o(e){const r=function(r,t){null==t&&(t={});const n=[];if(r.InfuraProvider&&"-"!==t.infura)try{n.push(new r.InfuraProvider(e,t.infura))}catch(e){}if(r.EtherscanProvider&&"-"!==t.etherscan)try{n.push(new r.EtherscanProvider(e,t.etherscan))}catch(e){}if(r.AlchemyProvider&&"-"!==t.alchemy)try{n.push(new r.AlchemyProvider(e,t.alchemy))}catch(e){}if(r.PocketProvider&&"-"!==t.pocket){const i=["goerli","ropsten","rinkeby","sepolia"];try{const o=new r.PocketProvider(e,t.pocket);o.network&&-1===i.indexOf(o.network.name)&&n.push(o)}catch(e){}}if(r.CloudflareProvider&&"-"!==t.cloudflare)try{n.push(new r.CloudflareProvider(e))}catch(e){}if(r.AnkrProvider&&"-"!==t.ankr)try{const i=["ropsten"],o=new r.AnkrProvider(e,t.ankr);o.network&&-1===i.indexOf(o.network.name)&&n.push(o)}catch(e){}if(0===n.length)return null;if(r.FallbackProvider){let i=1;return null!=t.quorum?i=t.quorum:"homestead"===e&&(i=2),new r.FallbackProvider(n,i)}return n[0]};return r.renetwork=function(e){return o(e)},r}function s(e,r){const t=function(t,n){return t.JsonRpcProvider?new t.JsonRpcProvider(e,r):null};return t.renetwork=function(r){return s(e,r)},t}const a={chainId:1,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"homestead",_defaultProvider:o("homestead")},c={chainId:3,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"ropsten",_defaultProvider:o("ropsten")},d={chainId:63,name:"classicMordor",_defaultProvider:s("https://www.ethercluster.com/mordor","classicMordor")},h={unspecified:{chainId:0,name:"unspecified"},homestead:a,mainnet:a,morden:{chainId:2,name:"morden"},ropsten:c,testnet:c,rinkeby:{chainId:4,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"rinkeby",_defaultProvider:o("rinkeby")},kovan:{chainId:42,name:"kovan",_defaultProvider:o("kovan")},goerli:{chainId:5,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"goerli",_defaultProvider:o("goerli")},kintsugi:{chainId:1337702,name:"kintsugi"},sepolia:{chainId:11155111,name:"sepolia",_defaultProvider:o("sepolia")},classic:{chainId:61,name:"classic",_defaultProvider:s("https://www.ethercluster.com/etc","classic")},classicMorden:{chainId:62,name:"classicMorden"},classicMordor:d,classicTestnet:d,classicKotti:{chainId:6,name:"classicKotti",_defaultProvider:s("https://www.ethercluster.com/kotti","classicKotti")},xdai:{chainId:100,name:"xdai"},matic:{chainId:137,name:"matic",_defaultProvider:o("matic")},maticmum:{chainId:80001,name:"maticmum"},optimism:{chainId:10,name:"optimism",_defaultProvider:o("optimism")},"optimism-kovan":{chainId:69,name:"optimism-kovan"},"optimism-goerli":{chainId:420,name:"optimism-goerli"},arbitrum:{chainId:42161,name:"arbitrum"},"arbitrum-rinkeby":{chainId:421611,name:"arbitrum-rinkeby"},"arbitrum-goerli":{chainId:421613,name:"arbitrum-goerli"},bnb:{chainId:56,name:"bnb"},bnbt:{chainId:97,name:"bnbt"}};function u(e){if(null==e)return null;if("number"==typeof e){for(const r in h){const t=h[r];if(t.chainId===e)return{name:t.name,chainId:t.chainId,ensAddress:t.ensAddress||null,_defaultProvider:t._defaultProvider||null}}return{chainId:e,name:"unknown"}}if("string"==typeof e){const r=h[e];return null==r?null:{name:r.name,chainId:r.chainId,ensAddress:r.ensAddress,_defaultProvider:r._defaultProvider||null}}const r=h[e.name];if(!r)return"number"!=typeof e.chainId&&i.throwArgumentError("invalid network chainId","network",e),e;0!==e.chainId&&e.chainId!==r.chainId&&i.throwArgumentError("network chainId mismatch","network",e);let t=e._defaultProvider||null;var n;return null==t&&r._defaultProvider&&(t=(n=r._defaultProvider)&&"function"==typeof n.renetwork?r._defaultProvider.renetwork(e):r._defaultProvider),{name:e.name,chainId:r.chainId,ensAddress:e.ensAddress||r.ensAddress||null,_defaultProvider:t}}class l{constructor(e,r=100){this.sendBatchFn=e,this.maxBatchSize=r,this.pendingBatch=[]}enqueueRequest(r){return e.__awaiter$1(this,void 0,void 0,(function*(){const e={request:r,resolve:void 0,reject:void 0},t=new Promise(((r,t)=>{e.resolve=r,e.reject=t}));return this.pendingBatch.push(e),this.pendingBatch.length===this.maxBatchSize?this.sendBatchRequest():this.pendingBatchTimer||(this.pendingBatchTimer=setTimeout((()=>this.sendBatchRequest()),10)),t}))}sendBatchRequest(){return e.__awaiter$1(this,void 0,void 0,(function*(){const e=this.pendingBatch;this.pendingBatch=[],this.pendingBatchTimer&&(clearTimeout(this.pendingBatchTimer),this.pendingBatchTimer=void 0);const r=e.map((e=>e.request));return this.sendBatchFn(r).then((r=>{e.forEach(((e,t)=>{const n=r[t];if(n.error){const r=new Error(n.error.message);r.code=n.error.code,r.data=n.error.data,e.reject(r)}else e.resolve(n.result)}))}),(r=>{e.forEach((e=>{e.reject(r)}))}))}))}}class m extends t.JsonRpcProvider{constructor(r){const t=m.getApiKey(r.apiKey),i=m.getAlchemyNetwork(r.network),o=m.getAlchemyConnectionInfo(i,t,"http");void 0!==r.url&&(o.url=r.url),o.throttleLimit=r.maxRetries;super(o,e.EthersNetwork[i]),this.apiKey=r.apiKey,this.maxRetries=r.maxRetries,this.batchRequests=r.batchRequests;const s=Object.assign(Object.assign({},this.connection),{headers:Object.assign(Object.assign({},this.connection.headers),{"Alchemy-Ethers-Sdk-Method":"batchSend"})});this.batcher=new l((e=>n.fetchJson(s,JSON.stringify(e)))),this.modifyFormatter()}static getApiKey(r){if(null==r)return e.DEFAULT_ALCHEMY_API_KEY;if(r&&"string"!=typeof r)throw new Error(`Invalid apiKey '${r}' provided. apiKey must be a string.`);return r}static getNetwork(r){return"string"==typeof r&&r in e.CustomNetworks?e.CustomNetworks[r]:u(r)}static getAlchemyNetwork(r){if(void 0===r)return e.DEFAULT_NETWORK;if("number"==typeof r)throw new Error(`Invalid network '${r}' provided. Network must be a string.`);if(!Object.values(e.Network).includes(r))throw new Error(`Invalid network '${r}' provided. Network must be one of: ${Object.values(e.Network).join(", ")}.`);return r}static getAlchemyConnectionInfo(r,t,n){const i="http"===n?e.getAlchemyHttpUrl(r,t):e.getAlchemyWsUrl(r,t);return{headers:e.IS_BROWSER?{"Alchemy-Ethers-Sdk-Version":e.VERSION}:{"Alchemy-Ethers-Sdk-Version":e.VERSION,"Accept-Encoding":"gzip"},allowGzip:!0,url:i}}detectNetwork(){const r=Object.create(null,{detectNetwork:{get:()=>super.detectNetwork}});return e.__awaiter$1(this,void 0,void 0,(function*(){let e=this.network;if(null==e&&(e=yield r.detectNetwork.call(this),!e))throw new Error("No network detected");return e}))}_startPending(){e.logWarn("WARNING: Alchemy Provider does not support pending filters")}isCommunityResource(){return this.apiKey===e.DEFAULT_ALCHEMY_API_KEY}send(e,r){return this._send(e,r,"send")}_send(r,t,i,o=!1){const s={method:r,params:t,id:this._nextId++,jsonrpc:"2.0"};if(Object.assign({},this.connection).headers["Alchemy-Ethers-Sdk-Method"]=i,this.batchRequests||o)return this.batcher.enqueueRequest(s);this.emit("debug",{action:"request",request:e.deepCopy(s),provider:this});const a=["eth_chainId","eth_blockNumber"].indexOf(r)>=0;if(a&&this._cache[r])return this._cache[r];const c=n.fetchJson(this.connection,JSON.stringify(s),f).then((e=>(this.emit("debug",{action:"response",request:s,response:e,provider:this}),e)),(e=>{throw this.emit("debug",{action:"response",error:e,request:s,provider:this}),e}));return a&&(this._cache[r]=c,setTimeout((()=>{this._cache[r]=null}),0)),c}modifyFormatter(){this.formatter.formats.receiptLog.removed=e=>{if("boolean"==typeof e)return e}}}function f(e){if(e.error){const r=new Error(e.error.message);throw r.code=e.error.code,r.data=e.error.data,r}return e.result}var p=Object.freeze({__proto__:null,AlchemyProvider:m});exports.AlchemyProvider=m,exports.alchemyProvider5870b6fa=p,exports.getNetwork=u;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("./index-a60557e5.cjs"),t=require("./alchemy-provider-5870b6fa-b4296005.cjs"),s=require("@ethersproject/providers");require("@ethersproject/abstract-provider"),require("@ethersproject/contracts");var n=require("./id-80cf99a8.cjs");require("./index-f56317c4.cjs"),require("zustand"),require("events"),require("@ethersproject/address"),require("@ethersproject/constants"),require("@ethersproject/properties"),require("@ethersproject/transactions"),require("@ethersproject/bytes"),require("./index-a5d1fc7d.cjs"),require("@ethersproject/abstract-signer"),require("./index-4925f240.cjs"),require("./bn-f89c8fd2.cjs"),require("./__node-resolve_empty-26284176.cjs"),require("./hash-7ce6fed5.cjs"),require("./inherits_browser-50deae74.cjs"),require("@ethersproject/json-wallets"),require("./DefaultJsonRpcProvider-a94708b3.cjs"),require("./browser-ponyfill-d62ef4bf.cjs"),require("buffer"),require("./index-e373c760.cjs");var i={};Object.defineProperty(i,"__esModule",{value:!0});var r=function(){function e(t,s,n){if(void 0===n&&(n={}),this.url=t,this.onclose=null,this.onerror=null,this.onmessage=null,this.onopen=null,this.ondown=null,this.onreopen=null,this.CONNECTING=e.CONNECTING,this.OPEN=e.OPEN,this.CLOSING=e.CLOSING,this.CLOSED=e.CLOSED,this.hasBeenOpened=!1,this.isClosed=!1,this.messageBuffer=[],this.nextRetryTime=0,this.reconnectCount=0,this.lastKnownExtensions="",this.lastKnownProtocol="",this.listeners={},null==s||"string"==typeof s||Array.isArray(s)?this.protocols=s:n=s,this.options=c(n),!this.options.wsConstructor){if("undefined"==typeof WebSocket)throw new Error("WebSocket not present in global scope and no wsConstructor option was provided.");this.options.wsConstructor=WebSocket}this.openNewWebSocket()}return Object.defineProperty(e.prototype,"binaryType",{get:function(){return this.binaryTypeInternal||"blob"},set:function(e){this.binaryTypeInternal=e,this.ws&&(this.ws.binaryType=e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"bufferedAmount",{get:function(){var e=this.ws?this.ws.bufferedAmount:0,t=!1;return this.messageBuffer.forEach((function(s){var n=function(e){return"string"==typeof e?2*e.length:e instanceof ArrayBuffer?e.byteLength:e instanceof Blob?e.size:void 0}(s);null!=n?e+=n:t=!0})),t&&this.debugLog("Some buffered data had unknown length. bufferedAmount() return value may be below the correct amount."),e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"extensions",{get:function(){return this.ws?this.ws.extensions:this.lastKnownExtensions},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"protocol",{get:function(){return this.ws?this.ws.protocol:this.lastKnownProtocol},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"readyState",{get:function(){return this.isClosed?e.CLOSED:e.OPEN},enumerable:!0,configurable:!0}),e.prototype.close=function(e,t){this.disposeSocket(e,t),this.shutdown(),this.debugLog("WebSocket permanently closed by client.")},e.prototype.send=function(e){if(this.isClosed)throw new Error("WebSocket is already in CLOSING or CLOSED state.");this.ws&&this.ws.readyState===this.OPEN?this.ws.send(e):this.messageBuffer.push(e)},e.prototype.reconnect=function(){if(this.isClosed)throw new Error("Cannot call reconnect() on socket which is permanently closed.");this.disposeSocket(1e3,"Client requested reconnect."),this.handleClose(void 0)},e.prototype.addEventListener=function(e,t){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].push(t)},e.prototype.dispatchEvent=function(e){return this.dispatchEventOfType(e.type,e)},e.prototype.removeEventListener=function(e,t){this.listeners[e]&&(this.listeners[e]=this.listeners[e].filter((function(e){return e!==t})))},e.prototype.openNewWebSocket=function(){var e=this;if(!this.isClosed){var t=this.options,s=t.connectTimeout,n=t.wsConstructor;this.debugLog("Opening new WebSocket to "+this.url+".");var i=new n(this.url,this.protocols);i.onclose=function(t){return e.handleClose(t)},i.onerror=function(t){return e.handleError(t)},i.onmessage=function(t){return e.handleMessage(t)},i.onopen=function(t){return e.handleOpen(t)},this.connectTimeoutId=setTimeout((function(){e.clearConnectTimeout(),e.disposeSocket(),e.handleClose(void 0)}),s),this.ws=i}},e.prototype.handleOpen=function(e){var t=this;if(this.ws&&!this.isClosed){var s=this.options.allClearResetTime;this.debugLog("WebSocket opened."),null!=this.binaryTypeInternal?this.ws.binaryType=this.binaryTypeInternal:this.binaryTypeInternal=this.ws.binaryType,this.clearConnectTimeout(),this.hasBeenOpened?this.dispatchEventOfType("reopen",e):(this.dispatchEventOfType("open",e),this.hasBeenOpened=!0),this.messageBuffer.forEach((function(e){return t.send(e)})),this.messageBuffer=[],this.allClearTimeoutId=setTimeout((function(){t.clearAllClearTimeout(),t.nextRetryTime=0,t.reconnectCount=0;var e=s/1e3|0;t.debugLog("WebSocket remained open for "+e+" seconds. Resetting retry time and count.")}),s)}},e.prototype.handleMessage=function(e){this.isClosed||this.dispatchEventOfType("message",e)},e.prototype.handleClose=function(e){var t=this;if(!this.isClosed){var s=this.options,n=s.maxReconnectAttempts,i=s.shouldReconnect;if(this.clearConnectTimeout(),this.clearAllClearTimeout(),this.ws&&(this.lastKnownExtensions=this.ws.extensions,this.lastKnownProtocol=this.ws.protocol,this.disposeSocket()),this.dispatchEventOfType("down",e),this.reconnectCount>=n)this.stopReconnecting(e,this.getTooManyFailedReconnectsMessage());else{var r=!e||i(e);"boolean"==typeof r?this.handleWillReconnect(r,e,"Provided shouldReconnect() returned false. Closing permanently."):r.then((function(s){t.isClosed||t.handleWillReconnect(s,e,"Provided shouldReconnect() resolved to false. Closing permanently.")}))}}},e.prototype.handleError=function(e){this.dispatchEventOfType("error",e),this.debugLog("WebSocket encountered an error.")},e.prototype.handleWillReconnect=function(e,t,s){e?this.reestablishConnection():this.stopReconnecting(t,s)},e.prototype.reestablishConnection=function(){var e=this,t=this.options,s=t.minReconnectDelay,n=t.maxReconnectDelay,i=t.reconnectBackoffFactor;this.reconnectCount++;var r=this.nextRetryTime;this.nextRetryTime=Math.max(s,Math.min(this.nextRetryTime*i,n)),setTimeout((function(){return e.openNewWebSocket()}),r);var o=r/1e3|0;this.debugLog("WebSocket was closed. Re-opening in "+o+" seconds.")},e.prototype.stopReconnecting=function(e,t){this.debugLog(t),this.shutdown(),e&&this.dispatchEventOfType("close",e)},e.prototype.shutdown=function(){this.isClosed=!0,this.clearAllTimeouts(),this.messageBuffer=[],this.disposeSocket()},e.prototype.disposeSocket=function(e,t){this.ws&&(this.ws.onerror=l,this.ws.onclose=l,this.ws.onmessage=l,this.ws.onopen=l,this.ws.close(e,t),this.ws=void 0)},e.prototype.clearAllTimeouts=function(){this.clearConnectTimeout(),this.clearAllClearTimeout()},e.prototype.clearConnectTimeout=function(){null!=this.connectTimeoutId&&(clearTimeout(this.connectTimeoutId),this.connectTimeoutId=void 0)},e.prototype.clearAllClearTimeout=function(){null!=this.allClearTimeoutId&&(clearTimeout(this.allClearTimeoutId),this.allClearTimeoutId=void 0)},e.prototype.dispatchEventOfType=function(e,t){var s=this;switch(e){case"close":this.onclose&&this.onclose(t);break;case"error":this.onerror&&this.onerror(t);break;case"message":this.onmessage&&this.onmessage(t);break;case"open":this.onopen&&this.onopen(t);break;case"down":this.ondown&&this.ondown(t);break;case"reopen":this.onreopen&&this.onreopen(t)}return e in this.listeners&&this.listeners[e].slice().forEach((function(e){return s.callListener(e,t)})),!t||!t.defaultPrevented},e.prototype.callListener=function(e,t){"function"==typeof e?e.call(this,t):e.handleEvent.call(this,t)},e.prototype.debugLog=function(e){this.options.debug&&console.log(e)},e.prototype.getTooManyFailedReconnectsMessage=function(){var e,t=this.options.maxReconnectAttempts;return"Failed to reconnect after "+t+" "+(e="attempt",(1===t?e:e+"s")+". Closing permanently.")},e.DEFAULT_OPTIONS={allClearResetTime:5e3,connectTimeout:5e3,debug:!1,minReconnectDelay:1e3,maxReconnectDelay:3e4,maxReconnectAttempts:Number.POSITIVE_INFINITY,reconnectBackoffFactor:1.5,shouldReconnect:function(){return!0},wsConstructor:void 0},e.CONNECTING=0,e.OPEN=1,e.CLOSING=2,e.CLOSED=3,e}(),o=i.default=r;function c(e){var t={};return Object.keys(r.DEFAULT_OPTIONS).forEach((function(s){var n=e[s];t[s]=void 0===n?r.DEFAULT_OPTIONS[s]:n})),t}function l(){}class a{constructor(e){this.provider=e,this.maxBackfillBlocks=120}getNewHeadsBackfill(t,s,n){return e.__awaiter$1(this,void 0,void 0,(function*(){f(t);const i=yield this.getBlockNumber();if(f(t),0===s.length)return this.getHeadEventsInRange(Math.max(n,i-this.maxBackfillBlocks)+1,i+1);const r=e.fromHex(s[s.length-1].number),o=i-this.maxBackfillBlocks+1;if(r<=o)return this.getHeadEventsInRange(o,i+1);const c=yield this.getReorgHeads(t,s);f(t);const l=yield this.getHeadEventsInRange(r+1,i+1);return f(t),[...c,...l]}))}getLogsBackfill(t,s,n,i){return e.__awaiter$1(this,void 0,void 0,(function*(){f(t);const r=yield this.getBlockNumber();if(f(t),0===n.length)return this.getLogsInRange(s,Math.max(i,r-this.maxBackfillBlocks)+1,r+1);const o=e.fromHex(n[n.length-1].blockNumber),c=r-this.maxBackfillBlocks+1;if(o<c)return this.getLogsInRange(s,c,r+1);const l=yield this.getCommonAncestor(t,n);f(t);const a=n.filter((t=>e.fromHex(t.blockNumber)>l.blockNumber)).map((e=>Object.assign(Object.assign({},e),{removed:!0}))),h=l.blockNumber===Number.NEGATIVE_INFINITY?e.fromHex(n[0].blockNumber):l.blockNumber;let u=yield this.getLogsInRange(s,h,r+1);return u=u.filter((t=>t&&(e.fromHex(t.blockNumber)>l.blockNumber||e.fromHex(t.logIndex)>l.logIndex))),f(t),[...a,...u]}))}setMaxBackfillBlock(e){this.maxBackfillBlocks=e}getBlockNumber(){return e.__awaiter$1(this,void 0,void 0,(function*(){const t=yield this.provider.send("eth_blockNumber");return e.fromHex(t)}))}getHeadEventsInRange(t,s){return e.__awaiter$1(this,void 0,void 0,(function*(){if(t>=s)return[];const n=[];for(let i=t;i<s;i++)n.push({method:"eth_getBlockByNumber",params:[e.toHex(i),!1]});return(yield this.provider.sendBatch(n)).map(h)}))}getReorgHeads(t,s){return e.__awaiter$1(this,void 0,void 0,(function*(){const n=[];for(let i=s.length-1;i>=0;i--){const r=s[i],o=yield this.getBlockByNumber(e.fromHex(r.number));if(f(t),r.hash===o.hash)break;n.push(h(o))}return n.reverse()}))}getBlockByNumber(t){return e.__awaiter$1(this,void 0,void 0,(function*(){return this.provider.send("eth_getBlockByNumber",[e.toHex(t),!1])}))}getCommonAncestor(t,s){return e.__awaiter$1(this,void 0,void 0,(function*(){let n=yield this.getBlockByNumber(e.fromHex(s[s.length-1].blockNumber));f(t);for(let t=s.length-1;t>=0;t--){const i=s[t];if(i.blockNumber!==n.number&&(n=yield this.getBlockByNumber(e.fromHex(i.blockNumber))),i.blockHash===n.hash)return{blockNumber:e.fromHex(i.blockNumber),logIndex:e.fromHex(i.logIndex)}}return{blockNumber:Number.NEGATIVE_INFINITY,logIndex:Number.NEGATIVE_INFINITY}}))}getLogsInRange(t,s,n){return e.__awaiter$1(this,void 0,void 0,(function*(){if(s>=n)return[];const i=Object.assign(Object.assign({},t),{fromBlock:e.toHex(s),toBlock:e.toHex(n-1)});return this.provider.send("eth_getLogs",[i])}))}}function h(e){const t=Object.assign({},e);return delete t.totalDifficulty,delete t.transactions,delete t.uncles,t}function u(e,t){const s=new Set,n=[];return e.forEach((e=>{const i=t(e);s.has(i)||(s.add(i),n.push(e))})),n}const d=new Error("Cancelled");function f(e){if(e())throw d}const m=10;class p extends s.WebSocketProvider{constructor(s,n){var i;const r=t.AlchemyProvider.getApiKey(s.apiKey),c=t.AlchemyProvider.getAlchemyNetwork(s.network),l=t.AlchemyProvider.getAlchemyConnectionInfo(c,r,"wss"),h=`alchemy-sdk-${e.VERSION}`;super(new o(null!==(i=s.url)&&void 0!==i?i:l.url,h,{wsConstructor:null!=n?n:"undefined"!=typeof process&&null!=process&&null!=process.versions&&null!=process.versions.node?require("websocket").w3cwebsocket:WebSocket}),e.EthersNetwork[c]),this._events=[],this.virtualSubscriptionsById=new Map,this.virtualIdsByPhysicalId=new Map,this.handleMessage=e=>{const t=JSON.parse(e.data);if(!function(e){return!function(e){return Array.isArray(e)||"2.0"===e.jsonrpc&&void 0!==e.id}(e)}(t))return;const s=t.params.subscription,n=this.virtualIdsByPhysicalId.get(s);if(!n)return;const i=this.virtualSubscriptionsById.get(n);if("eth_subscribe"===i.method)switch(i.params[0]){case"newHeads":{const e=i,r=t,{isBackfilling:o,backfillBuffer:c}=e,{result:l}=r.params;o?function(e,t){N(e,t,_)}(c,l):s!==n?this.emitAndRememberEvent(n,l,_):this.rememberEvent(n,l,_);break}case"logs":{const e=i,r=t,{isBackfilling:o,backfillBuffer:c}=e,{result:l}=r.params;o?function(e,t){N(e,t,w)}(c,l):n!==s?this.emitAndRememberEvent(n,l,w):this.rememberEvent(n,l,w);break}default:if(s!==n){const{result:e}=t.params;this.emitEvent(n,e)}}},this.handleReopen=()=>{this.virtualIdsByPhysicalId.clear();const{cancel:t,isCancelled:s}=function(){let e=!1;return{cancel:()=>e=!0,isCancelled:()=>e}}();this.cancelBackfill=t;for(const t of this.virtualSubscriptionsById.values())(()=>{e.__awaiter$1(this,void 0,void 0,(function*(){try{yield this.resubscribeAndBackfill(s,t)}catch(e){s()||console.error(`Error while backfilling "${t.params[0]}" subscription. Some events may be missing.`,e)}}))})();this.startHeartbeat()},this.stopHeartbeatAndBackfill=()=>{null!=this.heartbeatIntervalId&&(clearInterval(this.heartbeatIntervalId),this.heartbeatIntervalId=void 0),this.cancelBackfill()},this.apiKey=r,this.backfiller=new a(this),this.addSocketListeners(),this.startHeartbeat(),this.cancelBackfill=e.noop}static getNetwork(s){return"string"==typeof s&&s in e.CustomNetworks?e.CustomNetworks[s]:t.getNetwork(s)}on(e,t){return this._addEventListener(e,t,!1)}once(e,t){return this._addEventListener(e,t,!0)}off(t,s){return e.isAlchemyEvent(t)?this._off(t,s):super.off(t,s)}removeAllListeners(t){return void 0!==t&&e.isAlchemyEvent(t)?this._removeAllListeners(t):super.removeAllListeners(t)}listenerCount(t){return void 0!==t&&e.isAlchemyEvent(t)?this._listenerCount(t):super.listenerCount(t)}listeners(t){return void 0!==t&&e.isAlchemyEvent(t)?this._listeners(t):super.listeners(t)}_addEventListener(t,s,n){if(e.isAlchemyEvent(t)){e.verifyAlchemyEventName(t);const i=new e.EthersEvent(e.getAlchemyEventTag(t),s,n);return this._events.push(i),this._startEvent(i),this}return super._addEventListener(t,s,n)}_startEvent(t){[...e.ALCHEMY_EVENT_TYPES,"block","filter"].includes(t.type)?this.customStartEvent(t):super._startEvent(t)}_subscribe(t,s,n,i){return e.__awaiter$1(this,void 0,void 0,(function*(){let e=this._subIds[t];const r=yield this.getBlockNumber();null==e&&(e=Promise.all(s).then((e=>this.send("eth_subscribe",e))),this._subIds[t]=e);const o=yield e,c=yield Promise.all(s);this.virtualSubscriptionsById.set(o,{event:i,method:"eth_subscribe",params:c,startingBlockNumber:r,virtualId:o,physicalId:o,sentEvents:[],isBackfilling:!1,backfillBuffer:[]}),this.virtualIdsByPhysicalId.set(o,o),this._subs[o]={tag:t,processFunc:n}}))}emit(t,...s){if(e.isAlchemyEvent(t)){let n=!1;const i=[],r=e.getAlchemyEventTag(t);return this._events=this._events.filter((e=>e.tag!==r||(setTimeout((()=>{e.listener.apply(this,s)}),0),n=!0,!e.once||(i.push(e),!1)))),i.forEach((e=>{this._stopEvent(e)})),n}return super.emit(t,...s)}sendBatch(t){return e.__awaiter$1(this,void 0,void 0,(function*(){let e=0;const s=t.map((({method:t,params:s})=>({method:t,params:s,jsonrpc:"2.0",id:"alchemy-sdk:"+e++})));return this.sendBatchConcurrently(s)}))}destroy(){return this.removeSocketListeners(),this.stopHeartbeatAndBackfill(),super.destroy()}isCommunityResource(){return this.apiKey===e.DEFAULT_ALCHEMY_API_KEY}_stopEvent(t){let s=t.tag;if(e.ALCHEMY_EVENT_TYPES.includes(t.type)){if(this._events.filter((t=>e.ALCHEMY_EVENT_TYPES.includes(t.type))).length)return}else if("tx"===t.type){if(this._events.filter((e=>"tx"===e.type)).length)return;s="tx"}else if(this.listenerCount(t.event))return;const n=this._subIds[s];n&&(delete this._subIds[s],n.then((e=>{this._subs[e]&&(delete this._subs[e],this.send("eth_unsubscribe",[e]))})))}addSocketListeners(){this._websocket.addEventListener("message",this.handleMessage),this._websocket.addEventListener("reopen",this.handleReopen),this._websocket.addEventListener("down",this.stopHeartbeatAndBackfill)}removeSocketListeners(){this._websocket.removeEventListener("message",this.handleMessage),this._websocket.removeEventListener("reopen",this.handleReopen),this._websocket.removeEventListener("down",this.stopHeartbeatAndBackfill)}resubscribeAndBackfill(t,s){return e.__awaiter$1(this,void 0,void 0,(function*(){const{virtualId:e,method:n,params:i,sentEvents:r,backfillBuffer:o,startingBlockNumber:c}=s;s.isBackfilling=!0,o.length=0;try{const l=yield this.send(n,i);switch(f(t),s.physicalId=l,this.virtualIdsByPhysicalId.set(l,e),i[0]){case"newHeads":{const s=yield g((()=>k(this.backfiller.getNewHeadsBackfill(t,r,c),6e4)),5,(()=>!t()));f(t);(function(e){return u(e,(e=>e.hash))})([...s,...o]).forEach((t=>this.emitNewHeadsEvent(e,t)));break}case"logs":{const s=i[1]||{},n=yield g((()=>k(this.backfiller.getLogsBackfill(t,s,r,c),6e4)),5,(()=>!t()));f(t);(function(e){return u(e,(e=>`${e.blockHash}/${e.logIndex}`))})([...n,...o]).forEach((t=>this.emitLogsEvent(e,t)));break}}}finally{s.isBackfilling=!1,o.length=0}}))}emitNewHeadsEvent(e,t){this.emitAndRememberEvent(e,t,_)}emitLogsEvent(e,t){this.emitAndRememberEvent(e,t,w)}emitAndRememberEvent(e,t,s){this.rememberEvent(e,t,s),this.emitEvent(e,t)}emitEvent(e,t){const s=this.virtualSubscriptionsById.get(e);s&&this.emitGenericEvent(s,t)}rememberEvent(e,t,s){const n=this.virtualSubscriptionsById.get(e);n&&N(n.sentEvents,Object.assign({},t),s)}emitGenericEvent(e,t){this.emitProcessFn(e.event)(t)}startHeartbeat(){null==this.heartbeatIntervalId&&(this.heartbeatIntervalId=setInterval((()=>e.__awaiter$1(this,void 0,void 0,(function*(){try{yield k(this.send("net_version"),1e4)}catch(e){this._websocket.reconnect()}}))),3e4))}sendBatchConcurrently(t){return e.__awaiter$1(this,void 0,void 0,(function*(){return Promise.all(t.map((e=>this.send(e.method,e.params))))}))}customStartEvent(t){if(t.type===e.ALCHEMY_PENDING_TRANSACTIONS_EVENT_TYPE){const{fromAddress:s,toAddress:n,hashesOnly:i}=t;this._subscribe(t.tag,[e.AlchemySubscription.PENDING_TRANSACTIONS,{fromAddress:s,toAddress:n,hashesOnly:i}],this.emitProcessFn(t),t)}else if(t.type===e.ALCHEMY_MINED_TRANSACTIONS_EVENT_TYPE){const{addresses:s,includeRemoved:n,hashesOnly:i}=t;this._subscribe(t.tag,[e.AlchemySubscription.MINED_TRANSACTIONS,{addresses:s,includeRemoved:n,hashesOnly:i}],this.emitProcessFn(t),t)}else"block"===t.type?this._subscribe("block",["newHeads"],this.emitProcessFn(t),t):"filter"===t.type&&this._subscribe(t.tag,["logs",this._getFilter(t.filter)],this.emitProcessFn(t),t)}emitProcessFn(t){switch(t.type){case e.ALCHEMY_PENDING_TRANSACTIONS_EVENT_TYPE:return s=>this.emit({method:e.AlchemySubscription.PENDING_TRANSACTIONS,fromAddress:t.fromAddress,toAddress:t.toAddress,hashesOnly:t.hashesOnly},s);case e.ALCHEMY_MINED_TRANSACTIONS_EVENT_TYPE:return s=>this.emit({method:e.AlchemySubscription.MINED_TRANSACTIONS,addresses:t.addresses,includeRemoved:t.includeRemoved,hashesOnly:t.hashesOnly},s);case"block":return e=>{const t=n.BigNumber.from(e.number).toNumber();this._emitted.block=t,this.emit("block",t)};case"filter":return e=>{null==e.removed&&(e.removed=!1),this.emit(t.filter,this.formatter.filterLog(e))};default:throw new Error("Invalid event type to `emitProcessFn()`")}}_off(t,s){if(null==s)return this.removeAllListeners(t);const n=[];let i=!1;const r=e.getAlchemyEventTag(t);return this._events=this._events.filter((e=>e.tag!==r||e.listener!=s||(!!i||(i=!0,n.push(e),!1)))),n.forEach((e=>{this._stopEvent(e)})),this}_removeAllListeners(t){let s=[];if(null==t)s=this._events,this._events=[];else{const n=e.getAlchemyEventTag(t);this._events=this._events.filter((e=>e.tag!==n||(s.push(e),!1)))}return s.forEach((e=>{this._stopEvent(e)})),this}_listenerCount(t){if(!t)return this._events.length;const s=e.getAlchemyEventTag(t);return this._events.filter((e=>e.tag===s)).length}_listeners(t){if(null==t)return this._events.map((e=>e.listener));const s=e.getAlchemyEventTag(t);return this._events.filter((e=>e.tag===s)).map((e=>e.listener))}}const b=1e3,v=2,y=3e4;function g(t,s,n=(()=>!0)){return e.__awaiter$1(this,void 0,void 0,(function*(){let e=0,i=0;for(;;)try{return yield t()}catch(t){if(i++,i>=s||!n(t))throw t;if(yield E(e),!n(t))throw t;e=0===e?b:Math.min(y,v*e)}}))}function E(e){return new Promise((t=>setTimeout(t,e)))}function k(e,t){return Promise.race([e,new Promise(((e,s)=>setTimeout((()=>s(new Error("Timeout"))),t)))])}function _(t){return e.fromHex(t.number)}function w(t){return e.fromHex(t.blockNumber)}function N(e,t,s){const n=s(t),i=e.findIndex((e=>s(e)>n-m));-1===i?e.length=0:e.splice(0,i),e.push(t)}exports.AlchemyWebSocketProvider=p;
|
|
1
|
+
"use strict";var e=require("./index-18b9efa9.cjs"),t=require("./alchemy-provider-5870b6fa-96ba77e7.cjs"),s=require("@ethersproject/providers");require("@ethersproject/abstract-provider"),require("@ethersproject/contracts");var n=require("./id-64cfc377.cjs");require("./index-94459054.cjs"),require("zustand"),require("events"),require("@ethersproject/address"),require("@ethersproject/constants"),require("@ethersproject/properties"),require("@ethersproject/transactions"),require("@ethersproject/bytes"),require("./index-2d21ff5b.cjs"),require("@ethersproject/abstract-signer"),require("./index-f63cfc3f.cjs"),require("./bn-70ac244c.cjs"),require("./__node-resolve_empty-265d1c49.cjs"),require("./hash-7ce6fed5.cjs"),require("./inherits_browser-50deae74.cjs"),require("@ethersproject/json-wallets"),require("./DefaultJsonRpcProvider-bca8f91d.cjs"),require("./browser-ponyfill-71fb8794.cjs"),require("buffer"),require("./index-e373c760.cjs");var i={};Object.defineProperty(i,"__esModule",{value:!0});var r=function(){function e(t,s,n){if(void 0===n&&(n={}),this.url=t,this.onclose=null,this.onerror=null,this.onmessage=null,this.onopen=null,this.ondown=null,this.onreopen=null,this.CONNECTING=e.CONNECTING,this.OPEN=e.OPEN,this.CLOSING=e.CLOSING,this.CLOSED=e.CLOSED,this.hasBeenOpened=!1,this.isClosed=!1,this.messageBuffer=[],this.nextRetryTime=0,this.reconnectCount=0,this.lastKnownExtensions="",this.lastKnownProtocol="",this.listeners={},null==s||"string"==typeof s||Array.isArray(s)?this.protocols=s:n=s,this.options=c(n),!this.options.wsConstructor){if("undefined"==typeof WebSocket)throw new Error("WebSocket not present in global scope and no wsConstructor option was provided.");this.options.wsConstructor=WebSocket}this.openNewWebSocket()}return Object.defineProperty(e.prototype,"binaryType",{get:function(){return this.binaryTypeInternal||"blob"},set:function(e){this.binaryTypeInternal=e,this.ws&&(this.ws.binaryType=e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"bufferedAmount",{get:function(){var e=this.ws?this.ws.bufferedAmount:0,t=!1;return this.messageBuffer.forEach((function(s){var n=function(e){return"string"==typeof e?2*e.length:e instanceof ArrayBuffer?e.byteLength:e instanceof Blob?e.size:void 0}(s);null!=n?e+=n:t=!0})),t&&this.debugLog("Some buffered data had unknown length. bufferedAmount() return value may be below the correct amount."),e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"extensions",{get:function(){return this.ws?this.ws.extensions:this.lastKnownExtensions},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"protocol",{get:function(){return this.ws?this.ws.protocol:this.lastKnownProtocol},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"readyState",{get:function(){return this.isClosed?e.CLOSED:e.OPEN},enumerable:!0,configurable:!0}),e.prototype.close=function(e,t){this.disposeSocket(e,t),this.shutdown(),this.debugLog("WebSocket permanently closed by client.")},e.prototype.send=function(e){if(this.isClosed)throw new Error("WebSocket is already in CLOSING or CLOSED state.");this.ws&&this.ws.readyState===this.OPEN?this.ws.send(e):this.messageBuffer.push(e)},e.prototype.reconnect=function(){if(this.isClosed)throw new Error("Cannot call reconnect() on socket which is permanently closed.");this.disposeSocket(1e3,"Client requested reconnect."),this.handleClose(void 0)},e.prototype.addEventListener=function(e,t){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].push(t)},e.prototype.dispatchEvent=function(e){return this.dispatchEventOfType(e.type,e)},e.prototype.removeEventListener=function(e,t){this.listeners[e]&&(this.listeners[e]=this.listeners[e].filter((function(e){return e!==t})))},e.prototype.openNewWebSocket=function(){var e=this;if(!this.isClosed){var t=this.options,s=t.connectTimeout,n=t.wsConstructor;this.debugLog("Opening new WebSocket to "+this.url+".");var i=new n(this.url,this.protocols);i.onclose=function(t){return e.handleClose(t)},i.onerror=function(t){return e.handleError(t)},i.onmessage=function(t){return e.handleMessage(t)},i.onopen=function(t){return e.handleOpen(t)},this.connectTimeoutId=setTimeout((function(){e.clearConnectTimeout(),e.disposeSocket(),e.handleClose(void 0)}),s),this.ws=i}},e.prototype.handleOpen=function(e){var t=this;if(this.ws&&!this.isClosed){var s=this.options.allClearResetTime;this.debugLog("WebSocket opened."),null!=this.binaryTypeInternal?this.ws.binaryType=this.binaryTypeInternal:this.binaryTypeInternal=this.ws.binaryType,this.clearConnectTimeout(),this.hasBeenOpened?this.dispatchEventOfType("reopen",e):(this.dispatchEventOfType("open",e),this.hasBeenOpened=!0),this.messageBuffer.forEach((function(e){return t.send(e)})),this.messageBuffer=[],this.allClearTimeoutId=setTimeout((function(){t.clearAllClearTimeout(),t.nextRetryTime=0,t.reconnectCount=0;var e=s/1e3|0;t.debugLog("WebSocket remained open for "+e+" seconds. Resetting retry time and count.")}),s)}},e.prototype.handleMessage=function(e){this.isClosed||this.dispatchEventOfType("message",e)},e.prototype.handleClose=function(e){var t=this;if(!this.isClosed){var s=this.options,n=s.maxReconnectAttempts,i=s.shouldReconnect;if(this.clearConnectTimeout(),this.clearAllClearTimeout(),this.ws&&(this.lastKnownExtensions=this.ws.extensions,this.lastKnownProtocol=this.ws.protocol,this.disposeSocket()),this.dispatchEventOfType("down",e),this.reconnectCount>=n)this.stopReconnecting(e,this.getTooManyFailedReconnectsMessage());else{var r=!e||i(e);"boolean"==typeof r?this.handleWillReconnect(r,e,"Provided shouldReconnect() returned false. Closing permanently."):r.then((function(s){t.isClosed||t.handleWillReconnect(s,e,"Provided shouldReconnect() resolved to false. Closing permanently.")}))}}},e.prototype.handleError=function(e){this.dispatchEventOfType("error",e),this.debugLog("WebSocket encountered an error.")},e.prototype.handleWillReconnect=function(e,t,s){e?this.reestablishConnection():this.stopReconnecting(t,s)},e.prototype.reestablishConnection=function(){var e=this,t=this.options,s=t.minReconnectDelay,n=t.maxReconnectDelay,i=t.reconnectBackoffFactor;this.reconnectCount++;var r=this.nextRetryTime;this.nextRetryTime=Math.max(s,Math.min(this.nextRetryTime*i,n)),setTimeout((function(){return e.openNewWebSocket()}),r);var o=r/1e3|0;this.debugLog("WebSocket was closed. Re-opening in "+o+" seconds.")},e.prototype.stopReconnecting=function(e,t){this.debugLog(t),this.shutdown(),e&&this.dispatchEventOfType("close",e)},e.prototype.shutdown=function(){this.isClosed=!0,this.clearAllTimeouts(),this.messageBuffer=[],this.disposeSocket()},e.prototype.disposeSocket=function(e,t){this.ws&&(this.ws.onerror=l,this.ws.onclose=l,this.ws.onmessage=l,this.ws.onopen=l,this.ws.close(e,t),this.ws=void 0)},e.prototype.clearAllTimeouts=function(){this.clearConnectTimeout(),this.clearAllClearTimeout()},e.prototype.clearConnectTimeout=function(){null!=this.connectTimeoutId&&(clearTimeout(this.connectTimeoutId),this.connectTimeoutId=void 0)},e.prototype.clearAllClearTimeout=function(){null!=this.allClearTimeoutId&&(clearTimeout(this.allClearTimeoutId),this.allClearTimeoutId=void 0)},e.prototype.dispatchEventOfType=function(e,t){var s=this;switch(e){case"close":this.onclose&&this.onclose(t);break;case"error":this.onerror&&this.onerror(t);break;case"message":this.onmessage&&this.onmessage(t);break;case"open":this.onopen&&this.onopen(t);break;case"down":this.ondown&&this.ondown(t);break;case"reopen":this.onreopen&&this.onreopen(t)}return e in this.listeners&&this.listeners[e].slice().forEach((function(e){return s.callListener(e,t)})),!t||!t.defaultPrevented},e.prototype.callListener=function(e,t){"function"==typeof e?e.call(this,t):e.handleEvent.call(this,t)},e.prototype.debugLog=function(e){this.options.debug&&console.log(e)},e.prototype.getTooManyFailedReconnectsMessage=function(){var e,t=this.options.maxReconnectAttempts;return"Failed to reconnect after "+t+" "+(e="attempt",(1===t?e:e+"s")+". Closing permanently.")},e.DEFAULT_OPTIONS={allClearResetTime:5e3,connectTimeout:5e3,debug:!1,minReconnectDelay:1e3,maxReconnectDelay:3e4,maxReconnectAttempts:Number.POSITIVE_INFINITY,reconnectBackoffFactor:1.5,shouldReconnect:function(){return!0},wsConstructor:void 0},e.CONNECTING=0,e.OPEN=1,e.CLOSING=2,e.CLOSED=3,e}(),o=i.default=r;function c(e){var t={};return Object.keys(r.DEFAULT_OPTIONS).forEach((function(s){var n=e[s];t[s]=void 0===n?r.DEFAULT_OPTIONS[s]:n})),t}function l(){}class a{constructor(e){this.provider=e,this.maxBackfillBlocks=120}getNewHeadsBackfill(t,s,n){return e.__awaiter$1(this,void 0,void 0,(function*(){f(t);const i=yield this.getBlockNumber();if(f(t),0===s.length)return this.getHeadEventsInRange(Math.max(n,i-this.maxBackfillBlocks)+1,i+1);const r=e.fromHex(s[s.length-1].number),o=i-this.maxBackfillBlocks+1;if(r<=o)return this.getHeadEventsInRange(o,i+1);const c=yield this.getReorgHeads(t,s);f(t);const l=yield this.getHeadEventsInRange(r+1,i+1);return f(t),[...c,...l]}))}getLogsBackfill(t,s,n,i){return e.__awaiter$1(this,void 0,void 0,(function*(){f(t);const r=yield this.getBlockNumber();if(f(t),0===n.length)return this.getLogsInRange(s,Math.max(i,r-this.maxBackfillBlocks)+1,r+1);const o=e.fromHex(n[n.length-1].blockNumber),c=r-this.maxBackfillBlocks+1;if(o<c)return this.getLogsInRange(s,c,r+1);const l=yield this.getCommonAncestor(t,n);f(t);const a=n.filter((t=>e.fromHex(t.blockNumber)>l.blockNumber)).map((e=>Object.assign(Object.assign({},e),{removed:!0}))),h=l.blockNumber===Number.NEGATIVE_INFINITY?e.fromHex(n[0].blockNumber):l.blockNumber;let u=yield this.getLogsInRange(s,h,r+1);return u=u.filter((t=>t&&(e.fromHex(t.blockNumber)>l.blockNumber||e.fromHex(t.logIndex)>l.logIndex))),f(t),[...a,...u]}))}setMaxBackfillBlock(e){this.maxBackfillBlocks=e}getBlockNumber(){return e.__awaiter$1(this,void 0,void 0,(function*(){const t=yield this.provider.send("eth_blockNumber");return e.fromHex(t)}))}getHeadEventsInRange(t,s){return e.__awaiter$1(this,void 0,void 0,(function*(){if(t>=s)return[];const n=[];for(let i=t;i<s;i++)n.push({method:"eth_getBlockByNumber",params:[e.toHex(i),!1]});return(yield this.provider.sendBatch(n)).map(h)}))}getReorgHeads(t,s){return e.__awaiter$1(this,void 0,void 0,(function*(){const n=[];for(let i=s.length-1;i>=0;i--){const r=s[i],o=yield this.getBlockByNumber(e.fromHex(r.number));if(f(t),r.hash===o.hash)break;n.push(h(o))}return n.reverse()}))}getBlockByNumber(t){return e.__awaiter$1(this,void 0,void 0,(function*(){return this.provider.send("eth_getBlockByNumber",[e.toHex(t),!1])}))}getCommonAncestor(t,s){return e.__awaiter$1(this,void 0,void 0,(function*(){let n=yield this.getBlockByNumber(e.fromHex(s[s.length-1].blockNumber));f(t);for(let t=s.length-1;t>=0;t--){const i=s[t];if(i.blockNumber!==n.number&&(n=yield this.getBlockByNumber(e.fromHex(i.blockNumber))),i.blockHash===n.hash)return{blockNumber:e.fromHex(i.blockNumber),logIndex:e.fromHex(i.logIndex)}}return{blockNumber:Number.NEGATIVE_INFINITY,logIndex:Number.NEGATIVE_INFINITY}}))}getLogsInRange(t,s,n){return e.__awaiter$1(this,void 0,void 0,(function*(){if(s>=n)return[];const i=Object.assign(Object.assign({},t),{fromBlock:e.toHex(s),toBlock:e.toHex(n-1)});return this.provider.send("eth_getLogs",[i])}))}}function h(e){const t=Object.assign({},e);return delete t.totalDifficulty,delete t.transactions,delete t.uncles,t}function u(e,t){const s=new Set,n=[];return e.forEach((e=>{const i=t(e);s.has(i)||(s.add(i),n.push(e))})),n}const d=new Error("Cancelled");function f(e){if(e())throw d}const m=10;class p extends s.WebSocketProvider{constructor(s,n){var i;const r=t.AlchemyProvider.getApiKey(s.apiKey),c=t.AlchemyProvider.getAlchemyNetwork(s.network),l=t.AlchemyProvider.getAlchemyConnectionInfo(c,r,"wss"),h=`alchemy-sdk-${e.VERSION}`;super(new o(null!==(i=s.url)&&void 0!==i?i:l.url,h,{wsConstructor:null!=n?n:"undefined"!=typeof process&&null!=process&&null!=process.versions&&null!=process.versions.node?require("websocket").w3cwebsocket:WebSocket}),e.EthersNetwork[c]),this._events=[],this.virtualSubscriptionsById=new Map,this.virtualIdsByPhysicalId=new Map,this.handleMessage=e=>{const t=JSON.parse(e.data);if(!function(e){return!function(e){return Array.isArray(e)||"2.0"===e.jsonrpc&&void 0!==e.id}(e)}(t))return;const s=t.params.subscription,n=this.virtualIdsByPhysicalId.get(s);if(!n)return;const i=this.virtualSubscriptionsById.get(n);if("eth_subscribe"===i.method)switch(i.params[0]){case"newHeads":{const e=i,r=t,{isBackfilling:o,backfillBuffer:c}=e,{result:l}=r.params;o?function(e,t){N(e,t,_)}(c,l):s!==n?this.emitAndRememberEvent(n,l,_):this.rememberEvent(n,l,_);break}case"logs":{const e=i,r=t,{isBackfilling:o,backfillBuffer:c}=e,{result:l}=r.params;o?function(e,t){N(e,t,w)}(c,l):n!==s?this.emitAndRememberEvent(n,l,w):this.rememberEvent(n,l,w);break}default:if(s!==n){const{result:e}=t.params;this.emitEvent(n,e)}}},this.handleReopen=()=>{this.virtualIdsByPhysicalId.clear();const{cancel:t,isCancelled:s}=function(){let e=!1;return{cancel:()=>e=!0,isCancelled:()=>e}}();this.cancelBackfill=t;for(const t of this.virtualSubscriptionsById.values())(()=>{e.__awaiter$1(this,void 0,void 0,(function*(){try{yield this.resubscribeAndBackfill(s,t)}catch(e){s()||console.error(`Error while backfilling "${t.params[0]}" subscription. Some events may be missing.`,e)}}))})();this.startHeartbeat()},this.stopHeartbeatAndBackfill=()=>{null!=this.heartbeatIntervalId&&(clearInterval(this.heartbeatIntervalId),this.heartbeatIntervalId=void 0),this.cancelBackfill()},this.apiKey=r,this.backfiller=new a(this),this.addSocketListeners(),this.startHeartbeat(),this.cancelBackfill=e.noop}static getNetwork(s){return"string"==typeof s&&s in e.CustomNetworks?e.CustomNetworks[s]:t.getNetwork(s)}on(e,t){return this._addEventListener(e,t,!1)}once(e,t){return this._addEventListener(e,t,!0)}off(t,s){return e.isAlchemyEvent(t)?this._off(t,s):super.off(t,s)}removeAllListeners(t){return void 0!==t&&e.isAlchemyEvent(t)?this._removeAllListeners(t):super.removeAllListeners(t)}listenerCount(t){return void 0!==t&&e.isAlchemyEvent(t)?this._listenerCount(t):super.listenerCount(t)}listeners(t){return void 0!==t&&e.isAlchemyEvent(t)?this._listeners(t):super.listeners(t)}_addEventListener(t,s,n){if(e.isAlchemyEvent(t)){e.verifyAlchemyEventName(t);const i=new e.EthersEvent(e.getAlchemyEventTag(t),s,n);return this._events.push(i),this._startEvent(i),this}return super._addEventListener(t,s,n)}_startEvent(t){[...e.ALCHEMY_EVENT_TYPES,"block","filter"].includes(t.type)?this.customStartEvent(t):super._startEvent(t)}_subscribe(t,s,n,i){return e.__awaiter$1(this,void 0,void 0,(function*(){let e=this._subIds[t];const r=yield this.getBlockNumber();null==e&&(e=Promise.all(s).then((e=>this.send("eth_subscribe",e))),this._subIds[t]=e);const o=yield e,c=yield Promise.all(s);this.virtualSubscriptionsById.set(o,{event:i,method:"eth_subscribe",params:c,startingBlockNumber:r,virtualId:o,physicalId:o,sentEvents:[],isBackfilling:!1,backfillBuffer:[]}),this.virtualIdsByPhysicalId.set(o,o),this._subs[o]={tag:t,processFunc:n}}))}emit(t,...s){if(e.isAlchemyEvent(t)){let n=!1;const i=[],r=e.getAlchemyEventTag(t);return this._events=this._events.filter((e=>e.tag!==r||(setTimeout((()=>{e.listener.apply(this,s)}),0),n=!0,!e.once||(i.push(e),!1)))),i.forEach((e=>{this._stopEvent(e)})),n}return super.emit(t,...s)}sendBatch(t){return e.__awaiter$1(this,void 0,void 0,(function*(){let e=0;const s=t.map((({method:t,params:s})=>({method:t,params:s,jsonrpc:"2.0",id:"alchemy-sdk:"+e++})));return this.sendBatchConcurrently(s)}))}destroy(){return this.removeSocketListeners(),this.stopHeartbeatAndBackfill(),super.destroy()}isCommunityResource(){return this.apiKey===e.DEFAULT_ALCHEMY_API_KEY}_stopEvent(t){let s=t.tag;if(e.ALCHEMY_EVENT_TYPES.includes(t.type)){if(this._events.filter((t=>e.ALCHEMY_EVENT_TYPES.includes(t.type))).length)return}else if("tx"===t.type){if(this._events.filter((e=>"tx"===e.type)).length)return;s="tx"}else if(this.listenerCount(t.event))return;const n=this._subIds[s];n&&(delete this._subIds[s],n.then((e=>{this._subs[e]&&(delete this._subs[e],this.send("eth_unsubscribe",[e]))})))}addSocketListeners(){this._websocket.addEventListener("message",this.handleMessage),this._websocket.addEventListener("reopen",this.handleReopen),this._websocket.addEventListener("down",this.stopHeartbeatAndBackfill)}removeSocketListeners(){this._websocket.removeEventListener("message",this.handleMessage),this._websocket.removeEventListener("reopen",this.handleReopen),this._websocket.removeEventListener("down",this.stopHeartbeatAndBackfill)}resubscribeAndBackfill(t,s){return e.__awaiter$1(this,void 0,void 0,(function*(){const{virtualId:e,method:n,params:i,sentEvents:r,backfillBuffer:o,startingBlockNumber:c}=s;s.isBackfilling=!0,o.length=0;try{const l=yield this.send(n,i);switch(f(t),s.physicalId=l,this.virtualIdsByPhysicalId.set(l,e),i[0]){case"newHeads":{const s=yield g((()=>k(this.backfiller.getNewHeadsBackfill(t,r,c),6e4)),5,(()=>!t()));f(t);(function(e){return u(e,(e=>e.hash))})([...s,...o]).forEach((t=>this.emitNewHeadsEvent(e,t)));break}case"logs":{const s=i[1]||{},n=yield g((()=>k(this.backfiller.getLogsBackfill(t,s,r,c),6e4)),5,(()=>!t()));f(t);(function(e){return u(e,(e=>`${e.blockHash}/${e.logIndex}`))})([...n,...o]).forEach((t=>this.emitLogsEvent(e,t)));break}}}finally{s.isBackfilling=!1,o.length=0}}))}emitNewHeadsEvent(e,t){this.emitAndRememberEvent(e,t,_)}emitLogsEvent(e,t){this.emitAndRememberEvent(e,t,w)}emitAndRememberEvent(e,t,s){this.rememberEvent(e,t,s),this.emitEvent(e,t)}emitEvent(e,t){const s=this.virtualSubscriptionsById.get(e);s&&this.emitGenericEvent(s,t)}rememberEvent(e,t,s){const n=this.virtualSubscriptionsById.get(e);n&&N(n.sentEvents,Object.assign({},t),s)}emitGenericEvent(e,t){this.emitProcessFn(e.event)(t)}startHeartbeat(){null==this.heartbeatIntervalId&&(this.heartbeatIntervalId=setInterval((()=>e.__awaiter$1(this,void 0,void 0,(function*(){try{yield k(this.send("net_version"),1e4)}catch(e){this._websocket.reconnect()}}))),3e4))}sendBatchConcurrently(t){return e.__awaiter$1(this,void 0,void 0,(function*(){return Promise.all(t.map((e=>this.send(e.method,e.params))))}))}customStartEvent(t){if(t.type===e.ALCHEMY_PENDING_TRANSACTIONS_EVENT_TYPE){const{fromAddress:s,toAddress:n,hashesOnly:i}=t;this._subscribe(t.tag,[e.AlchemySubscription.PENDING_TRANSACTIONS,{fromAddress:s,toAddress:n,hashesOnly:i}],this.emitProcessFn(t),t)}else if(t.type===e.ALCHEMY_MINED_TRANSACTIONS_EVENT_TYPE){const{addresses:s,includeRemoved:n,hashesOnly:i}=t;this._subscribe(t.tag,[e.AlchemySubscription.MINED_TRANSACTIONS,{addresses:s,includeRemoved:n,hashesOnly:i}],this.emitProcessFn(t),t)}else"block"===t.type?this._subscribe("block",["newHeads"],this.emitProcessFn(t),t):"filter"===t.type&&this._subscribe(t.tag,["logs",this._getFilter(t.filter)],this.emitProcessFn(t),t)}emitProcessFn(t){switch(t.type){case e.ALCHEMY_PENDING_TRANSACTIONS_EVENT_TYPE:return s=>this.emit({method:e.AlchemySubscription.PENDING_TRANSACTIONS,fromAddress:t.fromAddress,toAddress:t.toAddress,hashesOnly:t.hashesOnly},s);case e.ALCHEMY_MINED_TRANSACTIONS_EVENT_TYPE:return s=>this.emit({method:e.AlchemySubscription.MINED_TRANSACTIONS,addresses:t.addresses,includeRemoved:t.includeRemoved,hashesOnly:t.hashesOnly},s);case"block":return e=>{const t=n.BigNumber.from(e.number).toNumber();this._emitted.block=t,this.emit("block",t)};case"filter":return e=>{null==e.removed&&(e.removed=!1),this.emit(t.filter,this.formatter.filterLog(e))};default:throw new Error("Invalid event type to `emitProcessFn()`")}}_off(t,s){if(null==s)return this.removeAllListeners(t);const n=[];let i=!1;const r=e.getAlchemyEventTag(t);return this._events=this._events.filter((e=>e.tag!==r||e.listener!=s||(!!i||(i=!0,n.push(e),!1)))),n.forEach((e=>{this._stopEvent(e)})),this}_removeAllListeners(t){let s=[];if(null==t)s=this._events,this._events=[];else{const n=e.getAlchemyEventTag(t);this._events=this._events.filter((e=>e.tag!==n||(s.push(e),!1)))}return s.forEach((e=>{this._stopEvent(e)})),this}_listenerCount(t){if(!t)return this._events.length;const s=e.getAlchemyEventTag(t);return this._events.filter((e=>e.tag===s)).length}_listeners(t){if(null==t)return this._events.map((e=>e.listener));const s=e.getAlchemyEventTag(t);return this._events.filter((e=>e.tag===s)).map((e=>e.listener))}}const b=1e3,v=2,y=3e4;function g(t,s,n=(()=>!0)){return e.__awaiter$1(this,void 0,void 0,(function*(){let e=0,i=0;for(;;)try{return yield t()}catch(t){if(i++,i>=s||!n(t))throw t;if(yield E(e),!n(t))throw t;e=0===e?b:Math.min(y,v*e)}}))}function E(e){return new Promise((t=>setTimeout(t,e)))}function k(e,t){return Promise.race([e,new Promise(((e,s)=>setTimeout((()=>s(new Error("Timeout"))),t)))])}function _(t){return e.fromHex(t.number)}function w(t){return e.fromHex(t.blockNumber)}function N(e,t,s){const n=s(t),i=e.findIndex((e=>s(e)>n-m));-1===i?e.length=0:e.splice(0,i),e.push(t)}exports.AlchemyWebSocketProvider=p;
|