ethers.js/packages/ethers/dist/ethers.umd.min.js

7 lines
320 KiB
JavaScript
Raw Permalink Normal View History

2022-04-20 17:36:06 -04:00
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).ethers={})}(this,(function(t){"use strict";async function e(t){const e=Object.keys(t);return(await Promise.all(e.map((e=>Promise.resolve(t[e]))))).reduce(((t,r,n)=>(t[e[n]]=r,t)),{})}function r(t,e){const r=e.split("|").map((t=>t.trim()));for(let n=0;n<r.length;n++)switch(e){case"any":return;case"boolean":case"number":case"string":if(typeof t===e)return}throw new Error("invalid value for type")}function n(t,e,n,s){for(let i in e){let o=e[i];const a=s?s[i]:void 0;if(void 0!==a)o=a;else{const t=n?n[i]:null;t&&r(o,t)}Object.defineProperty(t,i,{enumerable:!0,value:o,writable:!1})}}var s,i=window&&window.__classPrivateFieldSet||function(t,e,r,n,s){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?s.call(t,r):s?s.value=r:e.set(t,r),r},o=window&&window.__classPrivateFieldGet||function(t,e,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(t):n?n.value:e.get(t)};class a{constructor(t,e,r){s.set(this,void 0),i(this,s,e,"f"),n(this,{emitter:t,filter:r})}async removeListener(){null!=o(this,s,"f")&&await this.emitter.off(this.filter,o(this,s,"f"))}}function c(t,e){return t[e]}function l(t,e,r){if(Object.isFrozen(t))throw new Error("frozen object is immuatable; cannot set "+e);t[e]=r}function u(t,e){return t&&t.code===e}function h(t){return u(t,"CALL_EXCEPTION")}s=new WeakMap;var f,d,p,g,w=window&&window.__classPrivateFieldGet||function(t,e,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(t):n?n.value:e.get(t)};!function(t){t.DEBUG="DEBUG",t.INFO="INFO",t.WARNING="WARNING",t.ERROR="ERROR",t.OFF="OFF"}(g||(g={}));const m={debug:1,default:2,info:2,warning:3,error:4,off:5};let y=m.default,b=null;const v=["NFD","NFC","NFKD","NFKC"].reduce(((t,e)=>{try{if("test"!=="test".normalize(e))throw new Error("bad");if("NFD"===e){const t=String.fromCharCode(233).normalize("NFD");if(t!==String.fromCharCode(101,769))throw new Error("broken")}t.push(e)}catch(t){}return t}),[]);function E(t,e,r){Object.defineProperty(t,e,{enumerable:!0,writable:!1,value:r})}const A=9007199254740991,k={};k.INVALID_ARGUMENT=TypeError,k.NUMERIC_FAULT=RangeError,k.BUFFER_OVERRUN=RangeError;class T{constructor(t){f.add(this),E(this,"version",t||"_")}makeError(t,e,r){{const s=[];if(r)for(const t in r){const e=r[t];try{s.push(t+"="+JSON.stringify(e))}catch(n){s.push(t+"=[could not serialize object]")}}s.push(`code=${e}`),s.push(`version=${this.version}`),s.length&&(t+=" ("+s.join(", ")+")")}const n=new(k[e]||Error)(t);if(E(n,"code",e),r)for(const t in r)E(n,t,r[t]);return n}throwError(t,e,r){throw this.makeError(t,e,r)}throwArgumentError(t,e,r){return this.throwError(t,"INVALID_ARGUMENT",{argument:e,value:r})}assert(t,e,r,n){t||this.throwError(e,r||"UNKNOWN_ERROR",n)}assertArgument(t,e,r,n){return this.assert(t,e,"INVALID_ARGUMENT",{argument:r,value:n})}assertIntegerArgument(t,e,r,n){let s=null;"number"!=typeof e?s="expected a number":Number.isInteger(e)?(null!=r&&e<r||null!=n&&e>n)&&(s="value is out of range"):s="invalid integer",s&&this.throwArgumentError(s,t,e)}assertSafeUint53(t,e){this.assertArgument("number"==typeof t,"invalid number","value",t),null==e&&(e="value not safe");const r="assertSafeInteger";this.assert(t>=0&&t<9007199254740991,e,"NUMERIC_FAULT",{operation:r,fault:"out-of-safe-range",value:t}),this.assert(t%
2022-04-11 17:09:17 -04:00
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
2022-04-20 17:36:06 -04:00
const He=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4)),Ve=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),Ke=(t,e)=>t<<32-e|t>>>e;if(!(68===new Uint8Array(new Uint32Array([287454020]).buffer)[0]))throw new Error("Non little-endian hardware is not supported");Array.from({length:256},((t,e)=>e.toString(16).padStart(2,"0")));const Je=(()=>{const t="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);try{if(t){const{setImmediate:e}=t("timers");return()=>new Promise((t=>e(t)))}}catch(t){}return()=>new Promise((t=>setTimeout(t,0)))})();async function qe(t,e,r){let n=Date.now();for(let s=0;s<t;s++){r(s);const t=Date.now()-n;t>=0&&t<e||(await Je(),n+=t)}}function Xe(t){if("string"==typeof t&&(t=function(t){if("string"!=typeof t)throw new TypeError("utf8ToBytes expected string, got "+typeof t);return(new TextEncoder).encode(t)}(t)),!(t instanceof Uint8Array))throw new TypeError(`Expected input type is Uint8Array (got ${typeof t})`);return t}function Ye(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function Ze(t){if("function"!=typeof t||"function"!=typeof t.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");Ye(t.outputLen),Ye(t.blockLen)}class Qe{clone(){return this._cloneInto()}}function tr(t,e){if(void 0!==e&&("object"!=typeof e||(r=e,"[object Object]"!==Object.prototype.toString.call(r)||r.constructor!==Object)))throw new TypeError("Options should be object or undefined");var r;return Object.assign(t,e)}function er(t){const e=e=>t().update(Xe(e)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}class rr extends Qe{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,Ze(t);const r=Xe(e);if(this.iHash=t.create(),!(this.iHash instanceof Qe))throw new TypeError("Expected instance of class which extends utils.Hash");const n=this.blockLen=this.iHash.blockLen;this.outputLen=this.iHash.outputLen;const s=new Uint8Array(n);s.set(r.length>this.iHash.blockLen?t.create().update(r).digest():r);for(let t=0;t<s.length;t++)s[t]^=54;this.iHash.update(s),this.oHash=t.create();for(let t=0;t<s.length;t++)s[t]^=106;this.oHash.update(s),s.fill(0)}update(t){if(this.destroyed)throw new Error("instance is destroyed");return this.iHash.update(t),this}digestInto(t){if(this.destroyed)throw new Error("instance is destroyed");if(!(t instanceof Uint8Array)||t.length!==this.outputLen)throw new Error("HMAC: Invalid output buffer");if(this.finished)throw new Error("digest() was already called");this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));const{oHash:e,iHash:r,finished:n,destroyed:s,blockLen:i,outputLen:o}=this;return(t=t).finished=n,t.destroyed=s,t.blockLen=i,t.outputLen=o,t.oHash=e._cloneInto(t.oHash),t.iHash=r._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const nr=(t,e,r)=>new rr(t,e).update(r).digest();function sr(t,e,r,n){const{c:s,dkLen:i,DK:o,PRF:a,PRFSalt:c}=function(t,e,r,n){Ze(t);const s=tr({dkLen:32,asyncTick:10},n),{c:i,dkLen:o,asyncTick:a}=s;if(Ye(i),Ye(o),Ye(a),i<1)throw new Error("PBKDF2: iterations (c) should be >= 1");const c=Xe(e),l=Xe(r),u=new Uint8Array(o),h=nr.create(t,c),f=h._cloneInto().update(l);return{c:i,dkLen:o,asyncTick:a,DK:u,PRF:h,PRFSalt:f}}(t,e,r,n);let l;const u=new Uint8Array(4),h=Ve(u),f=new Uint8Array(a.outputLen);for(let t=1,e=0;e<i;t++,e+=a.outputLen){const r=o.subarray(e,e+a.outputLen);h.setInt32(0,t,!1),(l=c._cloneInto(l)).update(u).digestInto(f),r.set(f.subarray(0,r.length));for(let t=1;t<s;t++){a._cloneInto(l).update(f).digestInto(f);for(let t=0;t<r.length;t++)r[t]^=f[t]}}return function(t,e,r,n,s){return t.destroy(),e.destroy(),n&&n.destroy(),s.fill(0),r}(a,c,o,l,f)}nr.create=(t,e)=>new rr(t,e);class ir extends Qe{constructor(t,e,r,n){super(),this.blockLen=t,this.outputLen=e,this.padOffset=r,this.isLE
/*! noble-secp256k1 - MIT License (c) 2019 Paul Miller (paulmillr.com) */const Ia=BigInt(0),Sa=BigInt(1),Ra=BigInt(2),Ba=BigInt(3),Ca=BigInt(8),_a=Ra**BigInt(256),Fa={a:Ia,b:BigInt(7),P:_a-Ra**BigInt(32)-BigInt(977),n:_a-BigInt("432420386565659656852420866394968145599"),h:Sa,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee")};function Ua(t){const{a:e,b:r}=Fa,n=ec(t*t),s=ec(n*t);return ec(s+e*t+r)}const La=Fa.a===Ia;class Da{constructor(t,e,r){this.x=t,this.y=e,this.z=r}static fromAffine(t){if(!(t instanceof ja))throw new TypeError("JacobianPoint#fromAffine: expected Point");return new Da(t.x,t.y,Sa)}static toAffineBatch(t){const e=function(t,e=Fa.P){const r=new Array(t.length),n=nc(t.reduce(((t,n,s)=>n===Ia?t:(r[s]=t,ec(t*n,e))),Sa),e);return t.reduceRight(((t,n,s)=>n===Ia?t:(r[s]=ec(t*r[s],e),ec(t*n,e))),n),r}(t.map((t=>t.z)));return t.map(((t,r)=>t.toAffine(e[r])))}static normalizeZ(t){return Da.toAffineBatch(t).map(Da.fromAffine)}equals(t){if(!(t instanceof Da))throw new TypeError("JacobianPoint expected");const{x:e,y:r,z:n}=this,{x:s,y:i,z:o}=t,a=ec(n**Ra),c=ec(o**Ra),l=ec(e*c),u=ec(s*a),h=ec(ec(r*o)*c),f=ec(ec(i*n)*a);return l===u&&h===f}negate(){return new Da(this.x,ec(-this.y),this.z)}double(){const{x:t,y:e,z:r}=this,n=ec(t**Ra),s=ec(e**Ra),i=ec(s**Ra),o=ec(Ra*(ec((t+s)**Ra)-n-i)),a=ec(Ba*n),c=ec(a**Ra),l=ec(c-Ra*o),u=ec(a*(o-l)-Ca*i),h=ec(Ra*e*r);return new Da(l,u,h)}add(t){if(!(t instanceof Da))throw new TypeError("JacobianPoint expected");const{x:e,y:r,z:n}=this,{x:s,y:i,z:o}=t;if(s===Ia||i===Ia)return this;if(e===Ia||r===Ia)return t;const a=ec(n**Ra),c=ec(o**Ra),l=ec(e*c),u=ec(s*a),h=ec(ec(r*o)*c),f=ec(ec(i*n)*a),d=ec(u-l),p=ec(f-h);if(d===Ia)return p===Ia?this.double():Da.ZERO;const g=ec(d**Ra),w=ec(d*g),m=ec(l*g),y=ec(p**Ra-w-Ra*m),b=ec(p*(m-y)-h*w),v=ec(n*o*d);return new Da(y,b,v)}subtract(t){return this.add(t.negate())}multiplyUnsafe(t){let e=tc(t);const r=Da.ZERO;if(e===Ia)return r;if(e===Sa)return this;if(!La){let t=r,n=this;for(;e>Ia;)e&Sa&&(t=t.add(n)),n=n.double(),e>>=Sa;return t}let{k1neg:n,k1:s,k2neg:i,k2:o}=oc(e),a=r,c=r,l=this;for(;s>Ia||o>Ia;)s&Sa&&(a=a.add(l)),o&Sa&&(c=c.add(l)),l=l.double(),s>>=Sa,o>>=Sa;return n&&(a=a.negate()),i&&(c=c.negate()),c=new Da(ec(c.x*Fa.beta),c.y,c.z),a.add(c)}precomputeWindow(t){const e=La?128/t+1:256/t+1,r=[];let n=this,s=n;for(let i=0;i<e;i++){s=n,r.push(s);for(let e=1;e<2**(t-1);e++)s=s.add(n),r.push(s);n=s.double()}return r}wNAF(t,e){!e&&this.equals(Da.BASE)&&(e=ja.BASE);const r=e&&e._WINDOW_SIZE||1;if(256%r)throw new Error("Point#wNAF: Invalid precomputation window, must be power of 2");let n=e&&Ma.get(e);n||(n=this.precomputeWindow(r),e&&1!==r&&(n=Da.normalizeZ(n),Ma.set(e,n)));let s=Da.ZERO,i=Da.ZERO;const o=1+(La?128/r:256/r),a=2**(r-1),c=BigInt(2**r-1),l=2**r,u=BigInt(r);for(let e=0;e<o;e++){const r=e*a;let o=Number(t&c);if(t>>=u,o>a&&(o-=l,t+=Sa),0===o){let t=n[r];e%2&&(t=t.negate()),i=i.add(t)}else{let t=n[r+Math.abs(o)-1];o<0&&(t=t.negate()),s=s.add(t)}}return{p:s,f:i}}multiply(t,e){let r,n,s=tc(t);if(La){const{k1neg:t,k1:i,k2neg:o,k2:a}=oc(s);let{p:c,f:l}=this.wNAF(i,e),{p:u,f:h}=this.wNAF(a,e);t&&(c=c.negate()),o&&(u=u.negate()),u=new Da(ec(u.x*Fa.beta),u.y,u.z),r=c.add(u),n=l.add(h)}else{const{p:t,f:i}=this.wNAF(s,e);r=t,n=i}return Da.normalizeZ([r,n])[0]}toAffine(t=nc(this.z)){const{x:e,y:r,z:n}=this,s=t,i=ec(s*s),o=ec(i*s),a=ec(e*i),c=ec(r*o);if(ec(n*s)!==Sa)throw new Error("invZ was invalid");return new ja(a,c)}}Da.BASE=new Da(Fa.Gx,Fa.Gy,Sa),Da.ZERO=new Da(Ia,Sa,Ia);const Ma=new WeakMap;class ja{constructor(t,e){this.x=t,this.y=e}_setWindowSize(t){this._WINDOW_SIZE=t,Ma.delete(this)}static fromCompressedHex(t){const e=32===t.length,r=Za(e?t:t.subarray(1));if(!lc(r))throw new Error("Point is not on curve");let n=function(t){const{P:e}=Fa,r=BigInt(6),n=BigInt(11),s=BigInt(22),i=BigInt(23),o=BigInt(44),a=BigInt(88),c=t*t*t%e,l=c*c*t%e,u=rc
/*! MIT License. Copyright 2015-2022 Richard Moore <me@ricmoo.com>. See LICENSE.txt. */Sd=new WeakMap;var Vd,Kd,Jd,qd=window&&window.__classPrivateFieldSet||function(t,e,r,n,s){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!s)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!s:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?s.call(t,r):s?s.value=r:e.set(t,r),r},Xd=window&&window.__classPrivateFieldGet||function(t,e,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(t):n?n.value:e.get(t)};const Yd={16:10,24:12,32:14},Zd=[1,2,4,8,16,32,64,128,27,54,108,216,171,77,154,47,94,188,99,198,151,53,106,212,179,125,250,239,197,145],Qd=[99,124,119,123,242,107,111,197,48,1,103,43,254,215,171,118,202,130,201,125,250,89,71,240,173,212,162,175,156,164,114,192,183,253,147,38,54,63,247,204,52,165,229,241,113,216,49,21,4,199,35,195,24,150,5,154,7,18,128,226,235,39,178,117,9,131,44,26,27,110,90,160,82,59,214,179,41,227,47,132,83,209,0,237,32,252,177,91,106,203,190,57,74,76,88,207,208,239,170,251,67,77,51,133,69,249,2,127,80,60,159,168,81,163,64,143,146,157,56,245,188,182,218,33,16,255,243,210,205,12,19,236,95,151,68,23,196,167,126,61,100,93,25,115,96,129,79,220,34,42,144,136,70,238,184,20,222,94,11,219,224,50,58,10,73,6,36,92,194,211,172,98,145,149,228,121,231,200,55,109,141,213,78,169,108,86,244,234,101,122,174,8,186,120,37,46,28,166,180,198,232,221,116,31,75,189,139,138,112,62,181,102,72,3,246,14,97,53,87,185,134,193,29,158,225,248,152,17,105,217,142,148,155,30,135,233,206,85,40,223,140,161,137,13,191,230,66,104,65,153,45,15,176,84,187,22],tp=[82,9,106,213,48,54,165,56,191,64,163,158,129,243,215,251,124,227,57,130,155,47,255,135,52,142,67,68,196,222,233,203,84,123,148,50,166,194,35,61,238,76,149,11,66,250,195,78,8,46,161,102,40,217,36,178,118,91,162,73,109,139,209,37,114,248,246,100,134,104,152,22,212,164,92,204,93,101,182,146,108,112,72,80,253,237,185,218,94,21,70,87,167,141,157,132,144,216,171,0,140,188,211,10,247,228,88,5,184,179,69,6,208,44,30,143,202,63,15,2,193,175,189,3,1,19,138,107,58,145,17,65,79,103,220,234,151,242,207,206,240,180,230,115,150,172,116,34,231,173,53,133,226,249,55,232,28,117,223,110,71,241,26,113,29,41,197,137,111,183,98,14,170,24,190,27,252,86,62,75,198,210,121,32,154,219,192,254,120,205,90,244,31,221,168,51,136,7,199,49,177,18,16,89,39,128,236,95,96,81,127,169,25,181,74,13,45,229,122,159,147,201,156,239,160,224,59,77,174,42,245,176,200,235,187,60,131,83,153,97,23,43,4,126,186,119,214,38,225,105,20,99,85,33,12,125],ep=[3328402341,4168907908,4000806809,4135287693,4294111757,3597364157,3731845041,2445657428,1613770832,33620227,3462883241,1445669757,3892248089,3050821474,1303096294,3967186586,2412431941,528646813,2311702848,4202528135,4026202645,2992200171,2387036105,4226871307,1101901292,3017069671,1604494077,1169141738,597466303,1403299063,3832705686,2613100635,1974974402,3791519004,1033081774,1277568618,1815492186,2118074177,4126668546,2211236943,1748251740,1369810420,3521504564,4193382664,3799085459,2883115123,1647391059,706024767,134480908,2512897874,1176707941,2646852446,806885416,932615841,168101135,798661301,235341577,605164086,461406363,3756188221,3454790438,1311188841,2142417613,3933566367,302582043,495158174,1479289972,874125870,907746093,3698224818,3025820398,1537253627,2756858614,1983593293,3084310113,2108928974,1378429307,3722699582,1580150641,327451799,2790478837,3117535592,0,3253595436,1075847264,3825007647,2041688520,3059440621,3563743934,2378943302,1740553945,1916352843,2487896798,2555137236,2958579944,2244988746,3151024235,3320835882,1336584933,3992714006,2252555205,2588757463,1714631509,293963156,2319795663,3925473552,67240454,4269768577,2689618160,2017213508,631218106,1269344483,2723238387,1571005438,2151694528,93294474,1066570413,56397766
2022-04-11 17:09:17 -04:00
//# sourceMappingURL=ethers.umd.min.js.map