1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[347],{4146:function(f,c,a){a.d(c,{CH:function(){return A}});var g=a(1184),h=a(8198),i=a(1556),j=a(8088),k=a(9485),l=a(2593),m=a(6441),n=a(6881),o=a(3875),d=a(1581),p=function(b,c,a,d){return new(a||(a=Promise))(function(f,g){function h(a){try{e(d.next(a))}catch(b){g(b)}}function i(a){try{e(d.throw(a))}catch(b){g(b)}}function e(b){var c;b.done?f(b.value):((c=b.value)instanceof a?c:new a(function(a){a(c)})).then(h,i)}e((d=d.apply(b,c||[])).next())})};const q=new d.Logger("contracts/5.7.0");function r(a,b){return p(this,void 0,void 0,function*(){const c=yield b;"string"!=typeof c&&q.throwArgumentError("invalid address or ENS name","name",c);try{return(0,k.getAddress)(c)}catch(f){}a||q.throwError("a provider or signer is needed to resolve ENS names",d.Logger.errors.UNSUPPORTED_OPERATION,{operation:"resolveName"});const e=yield a.resolveName(c);return null==e&&q.throwArgumentError("resolver or addr is not configured for ENS name","name",c),e})}function s(a,b,c){return p(this,void 0,void 0,function*(){return Array.isArray(c)?yield Promise.all(c.map((c,d)=>s(a,Array.isArray(b)?b[d]:b[c.name],c))):"address"===c.type?yield r(a,b):"tuple"===c.type?yield s(a,b,c.components):"array"===c.baseType?Array.isArray(b)?yield Promise.all(b.map(b=>s(a,b,c.arrayChildren))):Promise.reject(q.makeError("invalid value for array",d.Logger.errors.INVALID_ARGUMENT,{argument:"value",value:b})):b})}function t(a,b,c){return p(this,void 0,void 0,function*(){let e={};c.length===b.inputs.length+1&&"object"==typeof c[c.length-1]&&(e=(0,n.shallowCopy)(c.pop())),q.checkArgumentCount(c.length,b.inputs.length,"passed to contract"),a.signer?e.from?e.from=(0,n.resolveProperties)({override:r(a.signer,e.from),signer:a.signer.getAddress()}).then(a=>p(this,void 0,void 0,function*(){return(0,k.getAddress)(a.signer)!==a.override&&q.throwError("Contract with a Signer cannot override from",d.Logger.errors.UNSUPPORTED_OPERATION,{operation:"overrides.from"}),a.override})):e.from=a.signer.getAddress():e.from&&(e.from=r(a.provider,e.from));const h=yield(0,n.resolveProperties)({args:s(a.signer||a.provider,c,b.inputs),address:a.resolvedAddress,overrides:(0,n.resolveProperties)(e)||{}}),u=a.interface.encodeFunctionData(b,h.args),g={data:u,to:h.address},f=h.overrides;if(null!=f.nonce&&(g.nonce=l.O$.from(f.nonce).toNumber()),null!=f.gasLimit&&(g.gasLimit=l.O$.from(f.gasLimit)),null!=f.gasPrice&&(g.gasPrice=l.O$.from(f.gasPrice)),null!=f.maxFeePerGas&&(g.maxFeePerGas=l.O$.from(f.maxFeePerGas)),null!=f.maxPriorityFeePerGas&&(g.maxPriorityFeePerGas=l.O$.from(f.maxPriorityFeePerGas)),null!=f.from&&(g.from=f.from),null!=f.type&&(g.type=f.type),null!=f.accessList&&(g.accessList=(0,o.accessListify)(f.accessList)),null==g.gasLimit&&null!=b.gas){let i=21e3;const v=(0,m.arrayify)(u);for(let j=0;j<v.length;j++)i+=4,v[j]&&(i+=64);
1g.gasLimit=l.O$.from(b.gas).add(i)}if(f.value){const w=l.O$.from(f.value);w.isZero()||b.payable||q.throwError("non-payable method cannot override value",d.Logger.errors.UNSUPPORTED_OPERATION,{operation:"overrides.value",value:e.value}),g.value=w}f.customData&&(g.customData=(0,n.shallowCopy)(f.customData)),f.ccipReadEnabled&&(g.ccipReadEnabled=!!f.ccipReadEnabled),delete e.nonce,delete e.gasLimit,delete e.gasPrice,delete e.from,delete e.value,delete e.type,delete e.accessList,delete e.maxFeePerGas,delete e.maxPriorityFeePerGas,delete e.customData,delete e.ccipReadEnabled;const t=Object.keys(e).filter(a=>null!=e[a]);return t.length&&q.throwError(`cannot override ${t.map(a=>JSON.stringify(a)).join(",")}`,d.Logger.errors.UNSUPPORTED_OPERATION,{operation:"overrides",overrides:t}),g})}function u(a,b,c){const e=a.signer||a.provider;return function(...f){return p(this,void 0,void 0,function*(){let i;if(f.length===b.inputs.length+1&&"object"==typeof f[f.length-1]){const h=(0,n.shallowCopy)(f.pop());null!=h.blockTag&&(i=yield h.blockTag),delete h.blockTag,f.push(h)}null!=a.deployTransaction&&(yield a._deployed(i));const k=yield t(a,b,f),l=yield e.call(k,i);try{let j=a.interface.decodeFunctionResult(b,l);return c&&1===b.outputs.length&&(j=j[0]),j}catch(g){throw g.code===d.Logger.errors.CALL_EXCEPTION&&(g.address=a.address,g.args=f,g.transaction=k),g}})}}function v(b,a,c){var e,f;return a.constant?u(b,a,c):(e=b,f=a,function(...a){return p(this,void 0,void 0,function*(){e.signer||q.throwError("sending a transaction requires a signer",d.Logger.errors.UNSUPPORTED_OPERATION,{operation:"sendTransaction"}),null!=e.deployTransaction&&(yield e._deployed());const c=yield t(e,f,a),b=yield e.signer.sendTransaction(c);return function(b,a){const c=a.wait.bind(a);a.wait=a=>c(a).then(a=>(a.events=a.logs.map(e=>{let c=(0,n.deepCopy)(e),d=null;try{d=b.interface.parseLog(e)}catch(f){}return d&&(c.args=d.args,c.decode=(a,c)=>b.interface.decodeEventLog(d.eventFragment,a,c),c.event=d.name,c.eventSignature=d.signature),c.removeListener=()=>b.provider,c.getBlock=()=>b.provider.getBlock(a.blockHash),c.getTransaction=()=>b.provider.getTransaction(a.transactionHash),c.getTransactionReceipt=()=>Promise.resolve(a),c}),a))}(e,b),b})})}function w(a){return a.address&&(null==a.topics||0===a.topics.length)?"*":(a.address||"*")+"@"+(a.topics?a.topics.map(a=>Array.isArray(a)?a.join("|"):a).join(":"):"")}class b{constructor(a,b){(0,n.defineReadOnly)(this,"tag",a),(0,n.defineReadOnly)(this,"filter",b),this._listeners=[]}addListener(a,b){this._listeners.push({listener:a,once:b})}removeListener(a){let b=!1;this._listeners=this._listeners.filter(c=>!!b||c.listener!==a||(b=!0,!1))}removeAllListeners(){this._listeners=[]}listeners(){return this._listeners.map(a=>a.listener)}listenerCount(){return this._listeners.length}run(b){const a=this.listenerCount();return this._listeners=this._listeners.filter(a=>{const c=b.slice();return setTimeout(()=>{a.listener.apply(this,c)},0),!a.once}),a}prepareEvent(a){}getEmit(a){return[a]}}class x extends b{constructor(){super("error",null)}}class y extends b{constructor(c,d,e,a){const b={address:c};let f=d.getEventTopic(e);a?(f!==a[0]&&q.throwArgumentError("topic mismatch","topics",a),b.topics=a.slice()):b.topics=[f],super(w(b),b),(0,n.defineReadOnly)(this,"address",c),(0,n.defineReadOnly)(this,"interface",d),(0,n.defineReadOnly)(this,"fragment",e)}prepareEvent(a){super.prepareEvent(a),a.event=this.fragment.name,a.eventSignature=this.fragment.format(),a.decode=(a,b)=>this.interface.decodeEventLog(this.fragment,a,b);try{a.args=this.interface.decodeEventLog(this.fragment,a.data,a.topics)}catch(b){a.args=null,a.decodeError=b}}getEmit(a){const b=(0,g.BR)(a.args);if(b.length)throw b[0].error;const c=(a.args||[]).slice();return c.push(a),c}}class z extends b{constructor(a,b){super("*",{address:a}),(0,n.defineReadOnly)(this,"address",a),(0,n.defineReadOnly)(this,"interface",b)}prepareEvent(a){super.prepareEvent(a);try{const b=this.interface.parseLog(a);a.event=b.name,a.eventSignature=b.signature,a.decode=(a,c)=>this.interface.decodeEventLog(b.eventFragment,a,c),a.args=b.args}catch(c){}}}class e{constructor(b,c,a){(0,n.defineReadOnly)(this,"interface",(0,n.getStatic)(new.target,"getInterface")(c)),null==a?((0,n.defineReadOnly)(this,"provider",null),(0,n.defineReadOnly)(this,"signer",null)):j.E.isSigner(a)?((0,n.defineReadOnly)(this,"provider",a.provider||null),(0,n.defineReadOnly)(this,"signer",a)):i.zt.isProvider(a)?((0,n.defineReadOnly)(this,"provider",a),(0,n.defineReadOnly)(this,"signer",null)):q.throwArgumentError("invalid signer or provider","signerOrProvider",a),(0,n.defineReadOnly)(this,"callStatic",{}),(0,n.defineReadOnly)(this,"estimateGas",{}),(0,n.defineReadOnly)(this,"functions",{}),(0,n.defineReadOnly)(this,"populateTransaction",{}),(0,n.defineReadOnly)(this,"filters",{});{const e={};
1Object.keys(this.interface.events).forEach(a=>{const b=this.interface.events[a];(0,n.defineReadOnly)(this.filters,a,(...a)=>({address:this.address,topics:this.interface.encodeFilterTopics(b,a)})),e[b.name]||(e[b.name]=[]),e[b.name].push(a)}),Object.keys(e).forEach(a=>{const b=e[a];1===b.length?(0,n.defineReadOnly)(this.filters,a,this.filters[b[0]]):q.warn(`Duplicate definition of ${a} (${b.join(", ")})`)})}if((0,n.defineReadOnly)(this,"_runningEvents",{}),(0,n.defineReadOnly)(this,"_wrappedEmits",{}),null==b&&q.throwArgumentError("invalid contract address or ENS name","addressOrName",b),(0,n.defineReadOnly)(this,"address",b),this.provider)(0,n.defineReadOnly)(this,"resolvedAddress",r(this.provider,b));else try{(0,n.defineReadOnly)(this,"resolvedAddress",Promise.resolve((0,k.getAddress)(b)))}catch(g){q.throwError("provider is required to use ENS name as contract address",d.Logger.errors.UNSUPPORTED_OPERATION,{operation:"new Contract"})}this.resolvedAddress.catch(a=>{});const f={},h={};Object.keys(this.interface.functions).forEach(a=>{const b=this.interface.functions[a];if(h[a]){q.warn(`Duplicate ABI entry for ${JSON.stringify(a)}`);return}h[a]=!0;{const c=b.name;f[`%${c}`]||(f[`%${c}`]=[]),f[`%${c}`].push(a)}if(null==this[a]&&(0,n.defineReadOnly)(this,a,v(this,b,!0)),null==this.functions[a]&&(0,n.defineReadOnly)(this.functions,a,v(this,b,!1)),null==this.callStatic[a]&&(0,n.defineReadOnly)(this.callStatic,a,u(this,b,!0)),null==this.populateTransaction[a]){var e,g;(0,n.defineReadOnly)(this.populateTransaction,a,(e=this,g=b,function(...a){return t(e,g,a)}))}null==this.estimateGas[a]&&(0,n.defineReadOnly)(this.estimateGas,a,function(a,b){const c=a.signer||a.provider;return function(...e){return p(this,void 0,void 0,function*(){c||q.throwError("estimate require a provider or signer",d.Logger.errors.UNSUPPORTED_OPERATION,{operation:"estimateGas"});const f=yield t(a,b,e);return yield c.estimateGas(f)})}}(this,b))}),Object.keys(f).forEach(a=>{const c=f[a];if(c.length>1)return;a=a.substring(1);const b=c[0];try{null==this[a]&&(0,n.defineReadOnly)(this,a,this[b])}catch(d){}null==this.functions[a]&&(0,n.defineReadOnly)(this.functions,a,this.functions[b]),null==this.callStatic[a]&&(0,n.defineReadOnly)(this.callStatic,a,this.callStatic[b]),null==this.populateTransaction[a]&&(0,n.defineReadOnly)(this.populateTransaction,a,this.populateTransaction[b]),null==this.estimateGas[a]&&(0,n.defineReadOnly)(this.estimateGas,a,this.estimateGas[b])})}static getContractAddress(a){return(0,k.getContractAddress)(a)}static getInterface(a){return h.vU.isInterface(a)?a:new h.vU(a)}deployed(){return this._deployed()}_deployed(a){return this._deployedPromise||(this.deployTransaction?this._deployedPromise=this.deployTransaction.wait().then(()=>this):this._deployedPromise=this.provider.getCode(this.address,a).then(a=>("0x"===a&&q.throwError("contract not deployed",d.Logger.errors.UNSUPPORTED_OPERATION,{contractAddress:this.address,operation:"getDeployed"}),this))),this._deployedPromise}fallback(a){this.signer||q.throwError("sending a transactions require a signer",d.Logger.errors.UNSUPPORTED_OPERATION,{operation:"sendTransaction(fallback)"});const b=(0,n.shallowCopy)(a||{});return["from","to"].forEach(function(a){null!=b[a]&&q.throwError("cannot override "+a,d.Logger.errors.UNSUPPORTED_OPERATION,{operation:a})}),b.to=this.resolvedAddress,this.deployed().then(()=>this.signer.sendTransaction(b))}connect(a){"string"==typeof a&&(a=new j.b(a,this.provider));const b=new this.constructor(this.address,this.interface,a);return this.deployTransaction&&(0,n.defineReadOnly)(b,"deployTransaction",this.deployTransaction),b}attach(a){return new this.constructor(a,this.interface,this.signer||this.provider)}static isIndexed(a){return h.Hk.isIndexed(a)}_normalizeRunningEvent(a){return this._runningEvents[a.tag]?this._runningEvents[a.tag]:a}_getRunningEvent(a){if("string"==typeof a){if("error"===a)return this._normalizeRunningEvent(new x);if("event"===a)return this._normalizeRunningEvent(new b("event",null));if("*"===a)return this._normalizeRunningEvent(new z(this.address,this.interface));const e=this.interface.getEvent(a);return this._normalizeRunningEvent(new y(this.address,this.interface,e))}if(a.topics&&a.topics.length>0){try{const c=a.topics[0];if("string"!=typeof c)throw new Error("invalid topic");const f=this.interface.getEvent(c);return this._normalizeRunningEvent(new y(this.address,this.interface,f,a.topics))}catch(g){}const d={address:this.address,topics:a.topics};return this._normalizeRunningEvent(new b(w(d),d))}return this._normalizeRunningEvent(new z(this.address,this.interface))}_checkRunningEvents(a){if(0===a.listenerCount()){delete this._runningEvents[a.tag];const b=this._wrappedEmits[a.tag];b&&a.filter&&(this.provider.off(a.filter,b),delete this._wrappedEmits[a.tag])}}_wrapEvent(b,c,d){const a=(0,n.deepCopy)(c);return a.removeListener=()=>{d&&(b.removeListener(d),this._checkRunningEvents(b))},a.getBlock=()=>this.provider.getBlock(c.blockHash),a.getTransaction=()=>this.provider.getTransaction(c.transactionHash),a.getTransactionReceipt=()=>this.provider.getTransactionReceipt(c.transactionHash),b.prepareEvent(a),a}_addEventListener(a,c,e){if(this.provider||q.throwError("events require a provider or a signer with a provider",d.Logger.errors.UNSUPPORTED_OPERATION,{operation:"once"}),a.addListener(c,e),this._runningEvents[a.tag]=a,!this._wrappedEmits[a.tag]){const b=d=>{let b=this._wrapEvent(a,d,c);if(null==b.decodeError)try{const e=a.getEmit(b);
1this.emit(a.filter,...e)}catch(f){b.decodeError=f.error}null!=a.filter&&this.emit("event",b),null!=b.decodeError&&this.emit("error",b.decodeError,b)};this._wrappedEmits[a.tag]=b,null!=a.filter&&this.provider.on(a.filter,b)}}queryFilter(d,a,b){const e=this._getRunningEvent(d),c=(0,n.shallowCopy)(e.filter);return"string"==typeof a&&(0,m.isHexString)(a,32)?(null!=b&&q.throwArgumentError("cannot specify toBlock with blockhash","toBlock",b),c.blockHash=a):(c.fromBlock=null!=a?a:0,c.toBlock=null!=b?b:"latest"),this.provider.getLogs(c).then(a=>a.map(a=>this._wrapEvent(e,a,null)))}on(a,b){return this._addEventListener(this._getRunningEvent(a),b,!1),this}once(a,b){return this._addEventListener(this._getRunningEvent(a),b,!0),this}emit(b,...c){if(!this.provider)return!1;const a=this._getRunningEvent(b),d=a.run(c)>0;return this._checkRunningEvents(a),d}listenerCount(a){return this.provider?null==a?Object.keys(this._runningEvents).reduce((a,b)=>a+this._runningEvents[b].listenerCount(),0):this._getRunningEvent(a).listenerCount():0}listeners(a){if(!this.provider)return[];if(null==a){const b=[];for(let c in this._runningEvents)this._runningEvents[c].listeners().forEach(a=>{b.push(a)});return b}return this._getRunningEvent(a).listeners()}removeAllListeners(a){if(!this.provider)return this;if(null==a){for(const d in this._runningEvents){const b=this._runningEvents[d];b.removeAllListeners(),this._checkRunningEvents(b)}return this}const c=this._getRunningEvent(a);return c.removeAllListeners(),this._checkRunningEvents(c),this}off(b,c){if(!this.provider)return this;const a=this._getRunningEvent(b);return a.removeListener(c),this._checkRunningEvents(a),this}removeListener(a,b){return this.off(a,b)}}class A extends e{}},6621:function(q,i,a){a.d(i,{Q:function(){return ar}});var r=a(6881),c=a(1581);const d="providers/5.7.1";var j=a(8088),s=a(2593),t=a(6441),u=a(7827),v=a(9251),w=a(3875),x=a(7707),k=a(1556),y=a(9567),z=a(7727),A=a(7218),B=a(7586);const C=new c.Logger("networks/5.7.1");function b(c){const a=function(b,a){null==a&&(a={});const d=[];if(b.InfuraProvider&&"-"!==a.infura)try{d.push(new b.InfuraProvider(c,a.infura))}catch(j){}if(b.EtherscanProvider&&"-"!==a.etherscan)try{d.push(new b.EtherscanProvider(c,a.etherscan))}catch(k){}if(b.AlchemyProvider&&"-"!==a.alchemy)try{d.push(new b.AlchemyProvider(c,a.alchemy))}catch(l){}if(b.PocketProvider&&"-"!==a.pocket){const h=["goerli","ropsten","rinkeby","sepolia"];try{const e=new b.PocketProvider(c,a.pocket);e.network&& -1===h.indexOf(e.network.name)&&d.push(e)}catch(m){}}if(b.CloudflareProvider&&"-"!==a.cloudflare)try{d.push(new b.CloudflareProvider(c))}catch(n){}if(b.AnkrProvider&&"-"!==a.ankr)try{const i=["ropsten"],f=new b.AnkrProvider(c,a.ankr);f.network&& -1===i.indexOf(f.network.name)&&d.push(f)}catch(o){}if(0===d.length)return null;if(b.FallbackProvider){let g=1;return null!=a.quorum?g=a.quorum:"homestead"===c&&(g=2),new b.FallbackProvider(d,g)}return d[0]};return a.renetwork=function(a){return b(a)},a}function e(b,c){const a=function(a,d){return a.JsonRpcProvider?new a.JsonRpcProvider(b,c):null};return a.renetwork=function(a){return e(b,a)},a}const f={chainId:1,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"homestead",_defaultProvider:b("homestead")},g={chainId:3,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"ropsten",_defaultProvider:b("ropsten")},h={chainId:63,name:"classicMordor",_defaultProvider:e("https://www.ethercluster.com/mordor","classicMordor")},D={unspecified:{chainId:0,name:"unspecified"},homestead:f,mainnet:f,morden:{chainId:2,name:"morden"},ropsten:g,testnet:g,rinkeby:{chainId:4,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"rinkeby",_defaultProvider:b("rinkeby")},kovan:{chainId:42,name:"kovan",_defaultProvider:b("kovan")},goerli:{chainId:5,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"goerli",_defaultProvider:b("goerli")},kintsugi:{chainId:1337702,name:"kintsugi"},sepolia:{chainId:11155111,name:"sepolia",_defaultProvider:b("sepolia")},classic:{chainId:61,name:"classic",_defaultProvider:e("https://www.ethercluster.com/etc","classic")},classicMorden:{chainId:62,name:"classicMorden"},classicMordor:h,classicTestnet:h,classicKotti:{chainId:6,name:"classicKotti",_defaultProvider:e("https://www.ethercluster.com/kotti","classicKotti")},xdai:{chainId:100,name:"xdai"},matic:{chainId:137,name:"matic",_defaultProvider:b("matic")},maticmum:{chainId:80001,name:"maticmum"},optimism:{chainId:10,name:"optimism",_defaultProvider:b("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"}};var E=a(2006),l=a(2882),F=a.n(l),G=a(9485);const H=new c.Logger(d);class I{constructor(){this.formats=this.getDefaultFormats()}getDefaultFormats(){const d={},e=this.address.bind(this),b=this.bigNumber.bind(this),g=this.blockTag.bind(this),f=this.data.bind(this),c=this.hash.bind(this),h=this.hex.bind(this),a=this.number.bind(this),i=this.type.bind(this);
1return d.transaction={hash:c,type:i,accessList:I.allowNull(this.accessList.bind(this),null),blockHash:I.allowNull(c,null),blockNumber:I.allowNull(a,null),transactionIndex:I.allowNull(a,null),confirmations:I.allowNull(a,null),from:e,gasPrice:I.allowNull(b),maxPriorityFeePerGas:I.allowNull(b),maxFeePerGas:I.allowNull(b),gasLimit:b,to:I.allowNull(e,null),value:b,nonce:a,data:f,r:I.allowNull(this.uint256),s:I.allowNull(this.uint256),v:I.allowNull(a),creates:I.allowNull(e,null),raw:I.allowNull(f)},d.transactionRequest={from:I.allowNull(e),nonce:I.allowNull(a),gasLimit:I.allowNull(b),gasPrice:I.allowNull(b),maxPriorityFeePerGas:I.allowNull(b),maxFeePerGas:I.allowNull(b),to:I.allowNull(e),value:I.allowNull(b),data:I.allowNull(a=>this.data(a,!0)),type:I.allowNull(a),accessList:I.allowNull(this.accessList.bind(this),null)},d.receiptLog={transactionIndex:a,blockNumber:a,transactionHash:c,address:e,topics:I.arrayOf(c),data:f,logIndex:a,blockHash:c},d.receipt={to:I.allowNull(this.address,null),from:I.allowNull(this.address,null),contractAddress:I.allowNull(e,null),transactionIndex:a,root:I.allowNull(h),gasUsed:b,logsBloom:I.allowNull(f),blockHash:c,transactionHash:c,logs:I.arrayOf(this.receiptLog.bind(this)),blockNumber:a,confirmations:I.allowNull(a,null),cumulativeGasUsed:b,effectiveGasPrice:I.allowNull(b),status:I.allowNull(a),type:i},d.block={hash:I.allowNull(c),parentHash:c,number:a,timestamp:a,nonce:I.allowNull(h),difficulty:this.difficulty.bind(this),gasLimit:b,gasUsed:b,miner:I.allowNull(e),extraData:f,transactions:I.allowNull(I.arrayOf(c)),baseFeePerGas:I.allowNull(b)},d.blockWithTransactions=(0,r.shallowCopy)(d.block),d.blockWithTransactions.transactions=I.allowNull(I.arrayOf(this.transactionResponse.bind(this))),d.filter={fromBlock:I.allowNull(g,void 0),toBlock:I.allowNull(g,void 0),blockHash:I.allowNull(c,void 0),address:I.allowNull(e,void 0),topics:I.allowNull(this.topics.bind(this),void 0)},d.filterLog={blockNumber:I.allowNull(a),blockHash:I.allowNull(c),transactionIndex:a,removed:I.allowNull(this.boolean.bind(this)),address:e,data:I.allowFalsish(f,"0x"),topics:I.arrayOf(c),transactionHash:c,logIndex:a},d}accessList(a){return(0,w.accessListify)(a||[])}number(a){return"0x"===a?0:s.O$.from(a).toNumber()}type(a){return"0x"===a||null==a?0:s.O$.from(a).toNumber()}bigNumber(a){return s.O$.from(a)}boolean(a){if("boolean"==typeof a)return a;if("string"==typeof a){if("true"===(a=a.toLowerCase()))return!0;if("false"===a)return!1}throw new Error("invalid boolean - "+a)}hex(a,b){return"string"==typeof a&&(b||"0x"===a.substring(0,2)||(a="0x"+a),(0,t.isHexString)(a))?a.toLowerCase():H.throwArgumentError("invalid hash","value",a)}data(a,c){const b=this.hex(a,c);if(b.length%2!=0)throw new Error("invalid data; odd-length - "+a);return b}address(a){return(0,G.getAddress)(a)}callAddress(a){if(!(0,t.isHexString)(a,32))return null;const b=(0,G.getAddress)((0,t.hexDataSlice)(a,12));return"0x0000000000000000000000000000000000000000"===b?null:b}contractAddress(a){return(0,G.getContractAddress)(a)}blockTag(a){if(null==a)return"latest";if("earliest"===a)return"0x0";switch(a){case"earliest":return"0x0";case"latest":case"pending":case"safe":case"finalized":return a}if("number"==typeof a||(0,t.isHexString)(a))return(0,t.hexValue)(a);throw new Error("invalid blockTag")}hash(a,c){const b=this.hex(a,c);return 32!==(0,t.hexDataLength)(b)?H.throwArgumentError("invalid hash","value",a):b}difficulty(a){if(null==a)return null;const b=s.O$.from(a);try{return b.toNumber()}catch(c){}return null}uint256(a){if(!(0,t.isHexString)(a))throw new Error("invalid uint256");return(0,t.hexZeroPad)(a,32)}_block(a,d){null!=a.author&&null==a.miner&&(a.miner=a.author);const b=null!=a._difficulty?a._difficulty:a.difficulty,c=I.check(d,a);return c._difficulty=null==b?null:s.O$.from(b),c}block(a){return this._block(a,this.formats.block)}blockWithTransactions(a){return this._block(a,this.formats.blockWithTransactions)}transactionRequest(a){return I.check(this.formats.transactionRequest,a)}transactionResponse(a){null!=a.gas&&null==a.gasLimit&&(a.gasLimit=a.gas),a.to&&s.O$.from(a.to).isZero()&&(a.to="0x0000000000000000000000000000000000000000"),null!=a.input&&null==a.data&&(a.data=a.input),null==a.to&&null==a.creates&&(a.creates=this.contractAddress(a)),(1===a.type||2===a.type)&&null==a.accessList&&(a.accessList=[]);const c=I.check(this.formats.transaction,a);if(null!=a.chainId){let d=a.chainId;(0,t.isHexString)(d)&&(d=s.O$.from(d).toNumber()),c.chainId=d}else{let b=a.networkId;null==b&&null==c.v&&(b=a.chainId),(0,t.isHexString)(b)&&(b=s.O$.from(b).toNumber()),"number"!=typeof b&&null!=c.v&&((b=(c.v-35)/2)<0&&(b=0),b=parseInt(b)),"number"!=typeof b&&(b=0),c.chainId=b}return c.blockHash&&"x"===c.blockHash.replace(/0/g,"")&&(c.blockHash=null),c}transaction(a){return(0,w.parse)(a)}receiptLog(a){return I.check(this.formats.receiptLog,a)}receipt(c){const a=I.check(this.formats.receipt,c);if(null!=a.root)if(a.root.length<=4){const b=s.O$.from(a.root).toNumber();0===b||1===b?(null!=a.status&&a.status!==b&&H.throwArgumentError("alt-root-status/status mismatch","value",{root:a.root,status:a.status}),a.status=b,delete a.root):H.throwArgumentError("invalid alt-root-status","value.root",a.root)}else 66!==a.root.length&&H.throwArgumentError("invalid root hash","value.root",a.root);return null!=a.status&&(a.byzantium=!0),a}topics(a){return Array.isArray(a)?a.map(a=>this.topics(a)):null!=a?this.hash(a,!0):null}filter(a){return I.check(this.formats.filter,a)}filterLog(a){return I.check(this.formats.filterLog,a)}static check(c,d){const e={};for(const a in c)try{const f=c[a](d[a]);void 0!==f&&(e[a]=f)}catch(b){throw b.checkKey=a,b.checkValue=d[a],b}return e}static allowNull(a,b){return function(c){return null==c?b:a(c)}}static allowFalsish(a,b){return function(c){return c?a(c):b}}static arrayOf(a){return function(b){if(!Array.isArray(b))throw new Error("not an array");const c=[];return b.forEach(function(b){c.push(a(b))}),c}}}var J=function(b,c,a,d){return new(a||(a=Promise))(function(f,g){function h(a){try{e(d.next(a))}catch(b){g(b)}}function i(a){try{e(d.throw(a))}catch(b){g(b)}}function e(b){var c;b.done?f(b.value):((c=b.value)instanceof a?c:new a(function(a){a(c)})).then(h,i)}e((d=d.apply(b,c||[])).next())})};const K=new c.Logger(d);function L(a){return null==a?"null":(32!==(0,t.hexDataLength)(a)&&K.throwArgumentError("invalid topic","topic",a),a.toLowerCase())}function M(a){for(a=a.slice();a.length>0&&null==a[a.length-1];)a.pop();return a.map(a=>{if(!Array.isArray(a))return L(a);{const c={};a.forEach(a=>{c[L(a)]=!0});const b=Object.keys(c);return b.sort(),b.join("|")}}).join("&")}function N(a){if("string"==typeof a){if(a=a.toLowerCase(),32===(0,t.hexDataLength)(a))return"tx:"+a;if(-1===a.indexOf(":"))return a}else if(Array.isArray(a))return"filter:*:"+M(a);else if(k.Sg.isForkEvent(a))throw K.warn("not implemented"),new Error("not implemented");else if(a&&"object"==typeof a)return"filter:"+(a.address||"*")+":"+M(a.topics||[]);throw new Error("invalid event - "+a)}function O(){return new Date().getTime()}function P(a){return new Promise(b=>{setTimeout(b,a)})}const Q=["block","network","pending","poll"];class R{constructor(a,b,c){(0,r.defineReadOnly)(this,"tag",a),(0,r.defineReadOnly)(this,"listener",b),(0,r.defineReadOnly)(this,"once",c),this._lastBlockNumber=-2,this._inflight=!1}get event(){switch(this.type){case"tx":return this.hash;case"filter":return this.filter}return this.tag}get type(){return this.tag.split(":")[0]}get hash(){const a=this.tag.split(":");return"tx"!==a[0]?null:a[1]}get filter(){var d;const a=this.tag.split(":");if("filter"!==a[0])return null;const b=a[1],e=""===(d=a[2])?[]:d.split(/&/g).map(b=>{if(""===b)return[];const a=b.split("|").map(a=>"null"===a?null:a);return 1===a.length?a[0]:a}),c={};return e.length>0&&(c.topics=e),b&&"*"!==b&&(c.address=b),c}pollable(){return this.tag.indexOf(":")>=0||Q.indexOf(this.tag)>=0}}const S={"0":{symbol:"btc",p2pkh:0,p2sh:5,prefix:"bc"}
1,"2":{symbol:"ltc",p2pkh:48,p2sh:50,prefix:"ltc"},"3":{symbol:"doge",p2pkh:30,p2sh:22},"60":{symbol:"eth",ilk:"eth"},"61":{symbol:"etc",ilk:"eth"},"700":{symbol:"xdai",ilk:"eth"}};function T(a){return(0,t.hexZeroPad)(s.O$.from(a).toHexString(),32)}function U(a){return z.Base58.encode((0,t.concat)([a,(0,t.hexDataSlice)((0,E.JQ)((0,E.JQ)(a)),0,4)]))}const m=new RegExp("^(ipfs)://(.*)$","i"),V=[new RegExp("^(https)://(.*)$","i"),new RegExp("^(data):(.*)$","i"),m,new RegExp("^eip155:[0-9]+/(erc[0-9]+):(.*)$","i"),];function W(a,b){try{return(0,v.ZN)(X(a,b))}catch(c){}return null}function X(a,c){if("0x"===a)return null;const b=s.O$.from((0,t.hexDataSlice)(a,c,c+32)).toNumber(),d=s.O$.from((0,t.hexDataSlice)(a,b,b+32)).toNumber();return(0,t.hexDataSlice)(a,b+32,b+32+d)}function Y(a){return a.match(/^ipfs:\/\/ipfs\//i)?a=a.substring(12):a.match(/^ipfs:\/\//i)?a=a.substring(7):K.throwArgumentError("unsupported IPFS format","link",a),`https://gateway.ipfs.io/ipfs/${a}`}function Z(c){const a=(0,t.arrayify)(c);if(a.length>32)throw new Error("internal; should not happen");const b=new Uint8Array(32);return b.set(a,32-a.length),b}function $(a){if(a.length%32==0)return a;const b=new Uint8Array(32*Math.ceil(a.length/32));return b.set(a),b}function _(c){const a=[];let d=0;for(let f=0;f<c.length;f++)a.push(null),d+=32;for(let b=0;b<c.length;b++){const e=(0,t.arrayify)(c[b]);a[b]=Z(d),a.push(Z(e.length)),a.push($(e)),d+=32+32*Math.ceil(e.length/32)}return(0,t.hexConcat)(a)}class aa{constructor(a,b,c,d){(0,r.defineReadOnly)(this,"provider",a),(0,r.defineReadOnly)(this,"name",c),(0,r.defineReadOnly)(this,"address",a.formatter.address(b)),(0,r.defineReadOnly)(this,"_resolvedAddress",d)}supportsWildcard(){return this._supportsEip2544||(this._supportsEip2544=this.provider.call({to:this.address,data:"0x01ffc9a79061b92300000000000000000000000000000000000000000000000000000000"}).then(a=>s.O$.from(a).eq(1)).catch(a=>{if(a.code===c.Logger.errors.CALL_EXCEPTION)return!1;throw this._supportsEip2544=null,a})),this._supportsEip2544}_fetch(a,b){return J(this,void 0,void 0,function*(){const e={to:this.address,ccipReadEnabled:!0,data:(0,t.hexConcat)([a,(0,B.VM)(this.name),b||"0x"])};let f=!1;(yield this.supportsWildcard())&&(f=!0,e.data=(0,t.hexConcat)(["0x9061b923",_([(0,B.Kn)(this.name),e.data])]));try{let d=yield this.provider.call(e);return(0,t.arrayify)(d).length%32==4&&K.throwError("resolver threw error",c.Logger.errors.CALL_EXCEPTION,{transaction:e,data:d}),f&&(d=X(d,0)),d}catch(g){if(g.code===c.Logger.errors.CALL_EXCEPTION)return null;throw g}})}_fetchBytes(a,b){return J(this,void 0,void 0,function*(){const c=yield this._fetch(a,b);return null!=c?X(c,0):null})}_getAddress(i,e){const a=S[String(i)];if(null==a&&K.throwError(`unsupported coin type: ${i}`,c.Logger.errors.UNSUPPORTED_OPERATION,{operation:`getAddress(${i})`}),"eth"===a.ilk)return this.provider.formatter.address(e);const f=(0,t.arrayify)(e);if(null!=a.p2pkh){const g=e.match(/^0x76a9([0-9a-f][0-9a-f])([0-9a-f]*)88ac$/);if(g){const j=parseInt(g[1],16);if(g[2].length===2*j&&j>=1&&j<=75)return U((0,t.concat)([[a.p2pkh],"0x"+g[2]]))}}if(null!=a.p2sh){const h=e.match(/^0xa9([0-9a-f][0-9a-f])([0-9a-f]*)87$/);if(h){const k=parseInt(h[1],16);if(h[2].length===2*k&&k>=1&&k<=75)return U((0,t.concat)([[a.p2sh],"0x"+h[2]]))}}if(null!=a.prefix){const b=f[1];let d=f[0];if(0===d?20!==b&&32!==b&&(d=-1):d=-1,d>=0&&f.length===2+b&&b>=1&&b<=75){const l=F().toWords(f.slice(2));return l.unshift(d),F().encode(a.prefix,l)}}return null}getAddress(a){return J(this,void 0,void 0,function*(){if(null==a&&(a=60),60===a)try{const d=yield this._fetch("0x3b3b57de");if("0x"===d||d===A.R)return null;return this.provider.formatter.callAddress(d)}catch(e){if(e.code===c.Logger.errors.CALL_EXCEPTION)return null;throw e}const b=yield this._fetchBytes("0xf1cb7e06",T(a));if(null==b||"0x"===b)return null;const f=this._getAddress(a,b);return null==f&&K.throwError("invalid or unsupported coin data",c.Logger.errors.UNSUPPORTED_OPERATION,{operation:`getAddress(${a})`,coinType:a,data:b}),f})}getAvatar(){return J(this,void 0,void 0,function*(){const a=[{type:"name",content:this.name}];try{const c=yield this.getText("avatar");if(null==c)return null;for(let h=0;h<V.length;h++){const i=c.match(V[h]);if(null==i)continue;const e=i[1].toLowerCase();switch(e){case"https":return a.push({type:"url",content:c}),{linkage:a,url:c};case"data":return a.push({type:"data",content:c}),{linkage:a,url:c};case"ipfs":return a.push({type:"ipfs",content:c}),{linkage:a,url:Y(c)};case"erc721":case"erc1155":{const p="erc721"===e?"0xc87b56dd":"0x0e89341c";a.push({type:e,content:c});const k=this._resolvedAddress||(yield this.getAddress()),f=(i[2]||"").split("/");if(2!==f.length)return null;const l=yield this.provider.formatter.address(f[0]),g=(0,t.hexZeroPad)(s.O$.from(f[1]).toHexString(),32);if("erc721"===e){const n=this.provider.formatter.callAddress((yield this.provider.call({to:l,data:(0,t.hexConcat)(["0x6352211e",g])})));if(k!==n)return null;a.push({type:"owner",content:n})}else if("erc1155"===e){const o=s.O$.from((yield this.provider.call({to:l,data:(0,t.hexConcat)(["0x00fdd58e",(0,t.hexZeroPad)(k,32),g])})));if(o.isZero())return null;a.push({type:"balance",content:o.toString()})}const q={to:this.provider.formatter.address(f[0]),data:(0,t.hexConcat)([p,g])};let b=W((yield this.provider.call(q)),0);if(null==b)return null;a.push({type:"metadata-url-base",content:b}),"erc1155"===e&&(b=b.replace("{id}",g.substring(2)),a.push({type:"metadata-url-expanded",content:b})),b.match(/^ipfs:/i)&&(b=Y(b)),a.push({type:"metadata-url",content:b});const j=yield(0,x.fetchJson)(b);if(!j)return null;a.push({type:"metadata",content:JSON.stringify(j)});let d=j.image;if("string"!=typeof d)return null;if(d.match(/^(https:\/\/|data:)/i));else{const r=d.match(m);if(null==r)return null;a.push({type:"url-ipfs",content:d}),d=Y(d)}return a.push({type:"url",content:d}),{linkage:a,url:d}}}}}catch(u){}return null})}getContentHash(){return J(this,void 0,void 0,function*(){const a=yield this._fetchBytes("0xbc1c58d1");if(null==a||"0x"===a)return null;const b=a.match(/^0xe3010170(([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f]*))$/);if(b){const g=parseInt(b[3],16);if(b[4].length===2*g)return"ipfs://"+z.Base58.encode("0x"+b[1])}const d=a.match(/^0xe5010172(([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f]*))$/);if(d){const h=parseInt(d[3],16);if(d[4].length===2*h)return"ipns://"+z.Base58.encode("0x"+d[1])}const e=a.match(/^0xe40101fa011b20([0-9a-f]*)$/);if(e&&64===e[1].length)return"bzz://"+e[1];const f=a.match(/^0x90b2c605([0-9a-f]*)$/);if(f&&68===f[1].length){const j={"=":"","+":"-","/":"_"},i=(0,y.c)("0x"+f[1]).replace(/[=+\/]/g,a=>j[a]);return"sia://"+i}return K.throwError("invalid or unsupported content hash data",c.Logger.errors.UNSUPPORTED_OPERATION,{operation:"getContentHash()",data:a})})}getText(a){return J(this,void 0,void 0,function*(){let b=(0,v.Y0)(a);(b=(0,t.concat)([T(64),T(b.length),b])).length%32!=0&&(b=(0,t.concat)([b,(0,t.hexZeroPad)("0x",32-a.length%32)]));const c=yield this._fetchBytes("0x59d1d43c",(0,t.hexlify)(b));return null==c||"0x"===c?null:(0,v.ZN)(c)})}}let ab=null,ac=1;class n extends k.zt{constructor(a){if(super(),this._events=[],this._emitted={block:-2},this.disableCcipRead=!1,this.formatter=new.target.getFormatter(),(0,r.defineReadOnly)(this,"anyNetwork","any"===a),this.anyNetwork&&(a=this.detectNetwork()),a instanceof Promise)this._networkPromise=a,a.cat
1ch(a=>{}),this._ready().catch(a=>{});else{const b=(0,r.getStatic)(new.target,"getNetwork")(a);b?((0,r.defineReadOnly)(this,"_network",b),this.emit("network",b,null)):K.throwArgumentError("invalid network","network",a)}this._maxInternalBlockNumber=-1024,this._lastBlockNumber=-2,this._maxFilterBlockRange=10,this._pollingInterval=4e3,this._fastQueryDate=0}_ready(){return J(this,void 0,void 0,function*(){if(null==this._network){let a=null;if(this._networkPromise)try{a=yield this._networkPromise}catch(b){}null==a&&(a=yield this.detectNetwork()),a||K.throwError("no network detected",c.Logger.errors.UNKNOWN_ERROR,{}),null==this._network&&(this.anyNetwork?this._network=a:(0,r.defineReadOnly)(this,"_network",a),this.emit("network",a,null))}return this._network})}get ready(){return(0,x.poll)(()=>this._ready().then(a=>a,a=>{if(a.code!==c.Logger.errors.NETWORK_ERROR||"noNetwork"!==a.event)throw a}))}static getFormatter(){return null==ab&&(ab=new I),ab}static getNetwork(a){return function(a){if(null==a)return null;if("number"==typeof a){for(const g in D){const c=D[g];if(c.chainId===a)return{name:c.name,chainId:c.chainId,ensAddress:c.ensAddress||null,_defaultProvider:c._defaultProvider||null}}return{chainId:a,name:"unknown"}}if("string"==typeof a){const d=D[a];return null==d?null:{name:d.name,chainId:d.chainId,ensAddress:d.ensAddress,_defaultProvider:d._defaultProvider||null}}const b=D[a.name];if(!b)return"number"!=typeof a.chainId&&C.throwArgumentError("invalid network chainId","network",a),a;0!==a.chainId&&a.chainId!==b.chainId&&C.throwArgumentError("network chainId mismatch","network",a);let e=a._defaultProvider||null;if(null==e&&b._defaultProvider){var f;e=(f=b._defaultProvider)&&"function"==typeof f.renetwork?b._defaultProvider.renetwork(a):b._defaultProvider}return{name:a.name,chainId:b.chainId,ensAddress:a.ensAddress||b.ensAddress||null,_defaultProvider:e}}(null==a?"homestead":a)}ccipReadFetch(a,b,d){return J(this,void 0,void 0,function*(){if(this.disableCcipRead||0===d.length)return null;const j=a.to.toLowerCase(),k=b.toLowerCase(),f=[];for(let g=0;g<d.length;g++){const h=d[g],l=h.replace("{sender}",j).replace("{data}",k),m=h.indexOf("{data}")>=0?null:JSON.stringify({data:k,sender:j}),e=yield(0,x.fetchJson)({url:l,errorPassThrough:!0},m,(a,b)=>(a.status=b.statusCode,a));if(e.data)return e.data;const i=e.message||"unknown error";if(e.status>=400&&e.status<500)return K.throwError(`response not found during CCIP fetch: ${i}`,c.Logger.errors.SERVER_ERROR,{url:h,errorMessage:i});f.push(i)}return K.throwError(`error encountered during CCIP fetch: ${f.map(a=>JSON.stringify(a)).join(", ")}`,c.Logger.errors.SERVER_ERROR,{urls:d,errorMessages:f})})}_getInternalBlockNumber(a){return J(this,void 0,void 0,function*(){if(yield this._ready(),a>0)for(;this._internalBlockNumber;){const c=this._internalBlockNumber;try{const d=yield c;if(O()-d.respTime<=a)return d.blockNumber;break}catch(e){if(this._internalBlockNumber===c)break}}const f=O(),b=(0,r.resolveProperties)({blockNumber:this.perform("getBlockNumber",{}),networkError:this.getNetwork().then(a=>null,a=>a)}).then(({blockNumber:a,networkError:c})=>{if(c)throw this._internalBlockNumber===b&&(this._internalBlockNumber=null),c;const d=O();return a=s.O$.from(a).toNumber(),a<this._maxInternalBlockNumber&&(a=this._maxInternalBlockNumber),this._maxInternalBlockNumber=a,this._setFastBlockNumber(a),{blockNumber:a,reqTime:f,respTime:d}});return this._internalBlockNumber=b,b.catch(a=>{this._internalBlockNumber===b&&(this._internalBlockNumber=null)}),(yield b).blockNumber})}poll(){return J(this,void 0,void 0,function*(){const d=ac++,e=[];let a=null;try{a=yield this._getInternalBlockNumber(100+this.pollingInterval/2)}catch(f){this.emit("error",f);return}if(this._setFastBlockNumber(a),this.emit("poll",d,a),a===this._lastBlockNumber){this.emit("didPoll",d);return}if(-2===this._emitted.block&&(this._emitted.block=a-1),Math.abs(this._emitted.block-a)>1e3)K.warn(`network block skew detected; skipping block events (emitted=${this._emitted.block} blockNumber${a})`),this.emit("error",K.makeError("network block skew detected",c.Logger.errors.NETWORK_E
1RROR,{blockNumber:a,event:"blockSkew",previousBlockNumber:this._emitted.block})),this.emit("block",a);else for(let b=this._emitted.block+1;b<=a;b++)this.emit("block",b);this._emitted.block!==a&&(this._emitted.block=a,Object.keys(this._emitted).forEach(b=>{if("block"===b)return;const c=this._emitted[b];"pending"!==c&&a-c>12&&delete this._emitted[b]})),-2===this._lastBlockNumber&&(this._lastBlockNumber=a-1),this._events.forEach(b=>{switch(b.type){case"tx":{const f=b.hash;let g=this.getTransactionReceipt(f).then(a=>(a&&null!=a.blockNumber&&(this._emitted["t:"+f]=a.blockNumber,this.emit(f,a)),null)).catch(a=>{this.emit("error",a)});e.push(g);break}case"filter":if(!b._inflight){b._inflight=!0,-2===b._lastBlockNumber&&(b._lastBlockNumber=a-1);const c=b.filter;c.fromBlock=b._lastBlockNumber+1,c.toBlock=a;const d=c.toBlock-this._maxFilterBlockRange;d>c.fromBlock&&(c.fromBlock=d),c.fromBlock<0&&(c.fromBlock=0);const h=this.getLogs(c).then(a=>{b._inflight=!1,0!==a.length&&a.forEach(a=>{a.blockNumber>b._lastBlockNumber&&(b._lastBlockNumber=a.blockNumber),this._emitted["b:"+a.blockHash]=a.blockNumber,this._emitted["t:"+a.transactionHash]=a.blockNumber,this.emit(c,a)})}).catch(a=>{this.emit("error",a),b._inflight=!1});e.push(h)}break}}),this._lastBlockNumber=a,Promise.all(e).then(()=>{this.emit("didPoll",d)}).catch(a=>{this.emit("error",a)})})}resetEventsBlock(a){this._lastBlockNumber=a-1,this.polling&&this.poll()}get network(){return this._network}detectNetwork(){return J(this,void 0,void 0,function*(){return K.throwError("provider does not support network detection",c.Logger.errors.UNSUPPORTED_OPERATION,{operation:"provider.detectNetwork"})})}getNetwork(){return J(this,void 0,void 0,function*(){const a=yield this._ready(),b=yield this.detectNetwork();if(a.chainId!==b.chainId){if(this.anyNetwork)return this._network=b,this._lastBlockNumber=-2,this._fastBlockNumber=null,this._fastBlockNumberPromise=null,this._fastQueryDate=0,this._emitted.block=-2,this._maxInternalBlockNumber=-1024,this._internalBlockNumber=null,this.emit("network",b,a),yield P(0),this._network;const d=K.makeError("underlying network changed",c.Logger.errors.NETWORK_ERROR,{event:"changed",network:a,detectedNetwork:b});throw this.emit("error",d),d}return a})}get blockNumber(){return this._getInternalBlockNumber(100+this.pollingInterval/2).then(a=>{this._setFastBlockNumber(a)},a=>{}),null!=this._fastBlockNumber?this._fastBlockNumber:-1}get polling(){return null!=this._poller}set polling(a){a&&!this._poller?(this._poller=setInterval(()=>{this.poll()},this.pollingInterval),this._bootstrapPoll||(this._bootstrapPoll=setTimeout(()=>{this.poll(),this._bootstrapPoll=setTimeout(()=>{this._poller||this.poll(),this._bootstrapPoll=null},this.pollingInterval)},0))):!a&&this._poller&&(clearInterval(this._poller),this._poller=null)}get pollingInterval(){return this._pollingInterval}set pollingInterval(a){if("number"!=typeof a||a<=0||parseInt(String(a))!=a)throw new Error("invalid polling interval");this._pollingInterval=a,this._poller&&(clearInterval(this._poller),this._poller=setInterval(()=>{this.poll()},this._pollingInterval))}_getFastBlockNumber(){const a=O();return a-this._fastQueryDate>2*this._pollingInterval&&(this._fastQueryDate=a,this._fastBlockNumberPromise=this.getBlockNumber().then(a=>((null==this._fastBlockNumber||a>this._fastBlockNumber)&&(this._fastBlockNumber=a),this._fastBlockNumber))),this._fastBlockNumberPromise}_setFastBlockNumber(a){(null==this._fastBlockNumber||!(a<this._fastBlockNumber))&&(this._fastQueryDate=O(),(null==this._fastBlockNumber||a>this._fastBlockNumber)&&(this._fastBlockNumber=a,this._fastBlockNumberPromise=Promise.resolve(a)))}waitForTransaction(a,b,c){return J(this,void 0,void 0,function*(){return this._waitForTransaction(a,null==b?1:b,c||0,null)})}_waitForTransaction(a,b,d,e){return J(this,void 0,void 0,function*(){const f=yield this.getTransactionReceipt(a);return(f?f.confirmations:0)>=b?f:new Promise((k,l)=>{const f=[];let h=!1;const m=function(){return!!h||(h=!0,f.forEach(a=>{a()}),!1)},i=a=>{!(a.confirmations<b)&&(m()||k(a))};if(this.on(a,i),f.push(()=>{this.removeListener(a,i)}),e){let n=e.startBlock,o=null;const j=d=>J(this,void 0,void 0,function*(){h||(yield P(1e3),this.getTransactionCount(e.from).then(f=>
1J(this,void 0,void 0,function*(){if(!h){if(f<=e.nonce)n=d;else{{const p=yield this.getTransaction(a);if(p&&null!=p.blockNumber)return}for(null==o&&(o=n-3)<e.startBlock&&(o=e.startBlock);o<=d;){if(h)return;const q=yield this.getBlockWithTransactions(o);for(let k=0;k<q.transactions.length;k++){const g=q.transactions[k];if(g.hash===a)return;if(g.from===e.from&&g.nonce===e.nonce){if(h)return;const r=yield this.waitForTransaction(g.hash,b);if(m())return;let i="replaced";g.data===e.data&&g.to===e.to&&g.value.eq(e.value)?i="repriced":"0x"===g.data&&g.from===g.to&&g.value.isZero()&&(i="cancelled"),l(K.makeError("transaction was replaced",c.Logger.errors.TRANSACTION_REPLACED,{cancelled:"replaced"===i||"cancelled"===i,reason:i,replacement:this._wrapTransaction(g),hash:a,receipt:r}));return}}o++}}h||this.once("block",j)}}),a=>{h||this.once("block",j)}))});if(h)return;this.once("block",j),f.push(()=>{this.removeListener("block",j)})}if("number"==typeof d&&d>0){const g=setTimeout(()=>{m()||l(K.makeError("timeout exceeded",c.Logger.errors.TIMEOUT,{timeout:d}))},d);g.unref&&g.unref(),f.push(()=>{clearTimeout(g)})}})})}getBlockNumber(){return J(this,void 0,void 0,function*(){return this._getInternalBlockNumber(0)})}getGasPrice(){return J(this,void 0,void 0,function*(){yield this.getNetwork();const a=yield this.perform("getGasPrice",{});try{return s.O$.from(a)}catch(b){return K.throwError("bad result from backend",c.Logger.errors.SERVER_ERROR,{method:"getGasPrice",result:a,error:b})}})}getBalance(a,b){return J(this,void 0,void 0,function*(){yield this.getNetwork();const d=yield(0,r.resolveProperties)({address:this._getAddress(a),blockTag:this._getBlockTag(b)}),e=yield this.perform("getBalance",d);try{return s.O$.from(e)}catch(f){return K.throwError("bad result from backend",c.Logger.errors.SERVER_ERROR,{method:"getBalance",params:d,result:e,error:f})}})}getTransactionCount(a,b){return J(this,void 0,void 0,function*(){yield this.getNetwork();const d=yield(0,r.resolveProperties)({address:this._getAddress(a),blockTag:this._getBlockTag(b)}),e=yield this.perform("getTransactionCount",d);try{return s.O$.from(e).toNumber()}catch(f){return K.throwError("bad result from backend",c.Logger.errors.SERVER_ERROR,{method:"getTransactionCount",params:d,result:e,error:f})}})}getCode(a,b){return J(this,void 0,void 0,function*(){yield this.getNetwork();const d=yield(0,r.resolveProperties)({address:this._getAddress(a),blockTag:this._getBlockTag(b)}),e=yield this.perform("getCode",d);try{return(0,t.hexlify)(e)}catch(f){return K.throwError("bad result from backend",c.Logger.errors.SERVER_ERROR,{method:"getCode",params:d,result:e,error:f})}})}getStorageAt(a,b,d){return J(this,void 0,void 0,function*(){yield this.getNetwork();const e=yield(0,r.resolveProperties)({address:this._getAddress(a),blockTag:this._getBlockTag(d),position:Promise.resolve(b).then(a=>(0,t.hexValue)(a))}),f=yield this.perform("getStorageAt",e);try{return(0,t.hexlify)(f)}catch(g){return K.throwError("bad result from backend",c.Logger.errors.SERVER_ERROR,{method:"getStorageAt",params:e,result:f,error:g})}})}_wrapTransaction(b,a,e){if(null!=a&&32!==(0,t.hexDataLength)(a))throw new Error("invalid response - sendTransaction");const d=b;return null!=a&&b.hash!==a&&K.throwError("Transaction hash mismatch from Provider.sendTransaction.",c.Logger.errors.UNKNOWN_ERROR,{expectedHash:b.hash,returnedHash:a}),d.wait=(a,d)=>J(this,void 0,void 0,function*(){null==a&&(a=1),null==d&&(d=0);let g;0!==a&&null!=e&&(g={data:b.data,from:b.from,nonce:b.nonce,to:b.to,value:b.value,startBlock:e});const f=yield this._waitForTransaction(b.hash,a,d,g);return null==f&&0===a?null:(this._emitted["t:"+b.hash]=f.blockNumber,0===f.status&&K.throwError("transaction failed",c.Logger.errors.CALL_EXCEPTION,{transactionHash:b.hash,transaction:b,receipt:f}),f)}),d}sendTransaction(a){return J(this,void 0,void 0,function*(){yield this.getNetwork();const d=yield Promise.resolve(a).then(a=>(0,t.hexlify)(a)),b=this.formatter.transaction(a);null==b.confirmations&&(b.confirmations=0);const e=yield this._getInternalBlockNumber(100+2*this.pollingInterval);try{const f=yield this.perform("sendTransaction",{signedTransaction:d});return this._wrapTransaction(b,f,e)}catch(c){throw c.transaction=b,c.transactionHash=b.hash,c}})}_getTransactionRequest(a){return J(this,void 0,void 0,function*(){const b=yield a,c={};return["from","to"].forEach(a=>{null!=b[a]&&(c[a]=Promise.resolve(b[a]).then(a=>a?this._getAddress(a):null))}),["gasLimit","gasPrice","maxFeePerGas","maxPriorityFeePerGas","value"].forEach(a=>{null!=b[a]&&(c[a]=Promise.resolve(b[a]).then(a=>a?s.O$.from(a):null))}),["type"].forEach(a=>{null!=b[a]&&(c[a]=Promise.resolve(b[a]).then(a=>null!=a?a:null))}),b.accessList&&(c.accessList=this.formatter.accessList(b.accessList)),["data"].forEach(a=>{null!=b[a]&&(c[a]=Promise.resolve(b[a]).then(a=>a?(0,t.hexlify)(a):null))}),this.formatter.transactionRequest((yield(0,r.resolveProperties)(c)))})}_getFilter(a){return J(this,void 0,void 0,function*(){a=yield a;const b={};return null!=a.address&&(b.address=this._getAddress(a.address)),["blockHash","topics"].forEach(c=>{null!=a[c]&&(b[c]=a[c])}),["fromBlock","toBlock"].forEach(c=>{null!=a[c]&&(b[c]=this._getBlockTag(a[c]))}),this.formatter.filter((yield(0,r.resolveProperties)(b)))})}_call(a,b,d){return J(this,void 0,void 0,function*(){d>=10&&K.throwError("CCIP read exceeded maximum redirections",c.Logger.errors.SERVER_ERROR,{redirects:d,transaction:a});const g=a.to,e=yield this.perform("call",{transaction:a,blockTag:b});if(d>=0&&"latest"===b&&null!=g&&"0x556f1830"===e.substring(0,10)&&(0,t.hexDataLength)(e)%32==4)try{const f=(0,t.hexDataSlice)(e,4),n=(0,t.hexDataSlice)(f,0,32);s.O$.from(n).eq(g)||K.throwError("CCIP Read sender did not match",c.Logger.errors.CALL_EXCEPTION,{name:"OffchainLookup",signature:"OffchainLookup(address,string[],bytes,bytes4,bytes)",transaction:a,data:e});const j=[],h=s.O$.from((0,t.hexDataSlice)(f,32,64)).toNumber(),o=s.O$.from((0,t.hexDataSlice)(f,h,h+32)).toNumber(),p=(0,t.hexDataSlice)(f,h+32);for(let i=0;i<o;i++){const k=W(p,32*i);null==k&&K.throwError("CCIP Read contained corrupt URL string",c.Logger.errors.CALL_EXCEPTION,{name:"OffchainLookup",signature:"OffchainLookup(address,string[],bytes,bytes4,bytes)",transaction:a,data:e}),j.push(k)}const q=X(f,64);s.O$.from((0,t.hexDataSlice)(f,100,128)).isZero()||K.throwError("CCIP Read callback selector included junk",c.Logger.errors.CALL_EXCEPTION,{name:"OffchainLookup",signature:"OffchainLookup(address,string[],bytes,bytes4,bytes)",transaction:a,data:e});const r=(0,t.hexDataSlice)(f,96,100),u=X(f,128),l=yield this.ccipReadFetch(a,q,j);null==l&&K.throwError("CCIP Read disabled or provided no URLs",c.Logger.errors.CALL_EXCEPTION,{name:"OffchainLookup",signature:"OffchainLookup(address,string[],bytes,bytes4,bytes)",transaction:a,data:e});const v={to:g,data:(0,t.hexConcat)([r,_([l,u])])};return this._call(v,b,d+1)}catch(m){if(m.code===c.Logger.errors.SERVER_ERROR)throw m}try{return(0,t.hexlify)(e)}catch(w){return K.throwError("bad result from backend",c.Logger.errors.SERVER_ERROR,{method:"call",params:{transaction:a,blockTag:b},result:e,error:w})}})}call(a,b){return J(this,void 0,void 0,function*(){yield this.getNetwork();const c=yield(0,r.resolveProperties)({transaction:this._getTransactionRequest(a),blockTag:this._getBlockTag(b),ccipReadEnabled:Promise.resolve(a.ccipReadEnabled)});return this._call(c.transaction,c.blockTag,c.ccipReadEnabled?0:-1)})}estimateGas(a){return J(this,void 0,void 0,function*(){yield this.getNetwork();const b=yield(0,r.resolveProperties)({transaction:this._getTransactionRequest(a)}),d=yield this.perform("estimateGas",b);try{return s.O$.from(d)}catch(e){return K.throwError("bad result from backend",c.Logger.errors.SERVER_ERROR,{method:"estimateGas",params:b,result:d,error:e})}})}_getAddress(a){return J(this,void 0,void 0,function*(){"string"!=typeof(a=yield a)&&K.throwArgumentError("invalid address or ENS name","name",a);const b=yield this.resolveName(a);return null==b&&K.throwError("ENS name not configured",c.Logger.errors.UNSUPPORTED_OPERATION,{operation:`resolveName(${JSON.stringify(a)})`}),b})}_getBlock(a,b){return J(this,void 0,void 0,function*(){yield this.getNetwork(),a=yield a;let d=-128;const c={includeTransactions:!!b};if((0,t.isHexString)(a,32))c.blockHash=a;else try{c.blockTag=yield this._getBlockTag(a),(0,t.isHexString)(c.blockTag)&&(d=parseInt(c.blockTag.substring(2),16))}catch(e){K.throwArgumentError("invalid block hash or block tag","blockHashOrBlockTag",a)}return(0,x.poll)(()=>J(this,void 0,void 0,function*(){const a=yield this.perform("getBlock",c);if(null==a)return null!=c.blockHash&&null==this._emitted["b:"+c.blockHash]?null:null!=c.blockTag&&d>this._emitted.block?null:void 0;if(b){let f=null;for(let g=0;g<a.transactions.length;g++){const e=a.transactions[g];if(null==e.blockNumber)e.confirmations=0;else if(null==e.confirmations){null==f&&(f=yield this._getInternalBlockNumber(100+2*this.pollingInterval));let h=f-e.blockNumber+1;h<=0&&(h=1),e.confirmations=h}}const i=this.formatter.blockWithTransactions(a);return i.transactions=i.transactions.map(a=>this._wrapTransaction(a)),i}return this.formatter.block(a)}),{oncePoll:this})})}getBlock(a){return this._getBlock(a,!1)}getBlockWithTransactions(a){return this._getBlock(a,!0)}getTransaction(a){return J(this,void 0,void 0,function*(){yield this.getNetwork(),a=yield a;const b={transactionHash:this.formatter.hash(a,!0)};return(0,x.poll)(()=>J(this,void 0,void 0,function*(){const e=yield this.perform("getTransaction",b);if(null==e)return null==this._emitted["t:"+a]?null:void 0;const c=this.formatter.transactionResponse(e);if(null==c.blockNumber)c.confirmations=0;else if(null==c.confirmations){const f=yield this._getInternalBlockNumber(100+2*this.pollingInterval);let d=f-c.blockNumber+1;d<=0&&(d=1),c.confirmations=d}return this._wrapTransaction(c)}),{oncePoll:this})})}getTransactionReceipt(a){return J(this,void 0,void 0,function*(){yield this.getNetwork(),a=yield a;const b={transactionHash:this.formatter.hash(a,!0)};return(0,x.poll)(()=>J(this,void 0,void 0,function*(){const d=yield this.perform("getTransactionReceipt",b);if(null==d)return null==this._emitted["t:"+a]?null:void 0;if(null==d.blockHash)return;const c=this.formatter.receipt(d);if(null==c.blockNumber)c.confirmations=0;else if(null==c.confirmations){const f=yield this._getInternalBlockNumber(100+2*this.pollingInterval);let e=f-c.blockNumber+1;e<=0&&(e=1),c.confirmations=e}return c}),{oncePoll:this})})}getLogs(a){return J(this,void 0,void 0,function*(){yield this.getNetwork();const c=yield(0,r.resolveProperties)({filter:this._getFilter(a)}),b=yield this.perform("getLogs",c);return b.forEach(a=>{null==a.removed&&(a.removed=!1)}),I.arrayOf(this.formatter.filterLog.bind(this.formatter))(b)})}getEtherPrice(){return J(this,void 0,void 0,function*(){return yield this.getNetwork(),this.perform("getEtherPrice",{})})}_getBlockTag(a){return J(this,void 0,void 0,function*(){if("number"==typeof(a=yield a)&&a<0){a%1&&K.throwArgumentError("invalid BlockTag","blockTag",a);let b=yield this._getInternalBlockNumber(100+2*this.pollingInterval);
1return(b+=a)<0&&(b=0),this.formatter.blockTag(b)}return this.formatter.blockTag(a)})}getResolver(a){return J(this,void 0,void 0,function*(){let b=a;for(;;){if(""===b||"."===b)return null;if("eth"!==a&&"eth"===b)return null;const c=yield this._getResolver(b,"getResolver");if(null!=c){const d=new aa(this,c,a);if(b!==a&&!(yield d.supportsWildcard()))return null;return d}b=b.split(".").slice(1).join(".")}})}_getResolver(a,b){return J(this,void 0,void 0,function*(){null==b&&(b="ENS");const d=yield this.getNetwork();d.ensAddress||K.throwError("network does not support ENS",c.Logger.errors.UNSUPPORTED_OPERATION,{operation:b,network:d.name});try{const e=yield this.call({to:d.ensAddress,data:"0x0178b8bf"+(0,B.VM)(a).substring(2)});return this.formatter.callAddress(e)}catch(f){}return null})}resolveName(a){return J(this,void 0,void 0,function*(){a=yield a;try{return Promise.resolve(this.formatter.address(a))}catch(c){if((0,t.isHexString)(a))throw c}"string"!=typeof a&&K.throwArgumentError("invalid ENS name","name",a);const b=yield this.getResolver(a);return b?yield b.getAddress():null})}lookupAddress(a){return J(this,void 0,void 0,function*(){a=yield a,a=this.formatter.address(a);const b=a.substring(2).toLowerCase()+".addr.reverse",c=yield this._getResolver(b,"lookupAddress");if(null==c)return null;const d=W((yield this.call({to:c,data:"0x691f3431"+(0,B.VM)(b).substring(2)})),0),e=yield this.resolveName(d);return e!=a?null:d})}getAvatar(a){return J(this,void 0,void 0,function*(){let b=null;if((0,t.isHexString)(a)){const j=this.formatter.address(a),d=j.substring(2).toLowerCase()+".addr.reverse",e=yield this._getResolver(d,"getAvatar");if(!e)return null;b=new aa(this,e,d);try{const f=yield b.getAvatar();if(f)return f.url}catch(g){if(g.code!==c.Logger.errors.CALL_EXCEPTION)throw g}try{const k=W((yield this.call({to:e,data:"0x691f3431"+(0,B.VM)(d).substring(2)})),0);b=yield this.getResolver(k)}catch(h){if(h.code!==c.Logger.errors.CALL_EXCEPTION)throw h;return null}}else if(!(b=yield this.getResolver(a)))return null;const i=yield b.getAvatar();return null==i?null:i.url})}perform(a,b){return K.throwError(a+" not implemented",c.Logger.errors.NOT_IMPLEMENTED,{operation:a})}_startEvent(a){this.polling=this._events.filter(a=>a.pollable()).length>0}_stopEvent(a){this.polling=this._events.filter(a=>a.pollable()).length>0}_addEventListener(b,c,d){const a=new R(N(b),c,d);return this._events.push(a),this._startEvent(a),this}on(a,b){return this._addEventListener(a,b,!1)}once(a,b){return this._addEventListener(a,b,!0)}emit(a,...d){let b=!1,c=[],e=N(a);return this._events=this._events.filter(a=>a.tag!==e||(setTimeout(()=>{a.listener.apply(this,d)},0),b=!0,!a.once||(c.push(a),!1))),c.forEach(a=>{this._stopEvent(a)}),b}listenerCount(a){if(!a)return this._events.length;let b=N(a);return this._events.filter(a=>a.tag===b).length}listeners(a){if(null==a)return this._events.map(a=>a.listener);let b=N(a);return this._events.filter(a=>a.tag===b).map(a=>a.listener)}off(a,b){if(null==b)return this.removeAllListeners(a);const c=[];let d=!1,e=N(a);return this._events=this._events.filter(a=>a.tag!==e||a.listener!=b|| !!d||(d=!0,c.push(a),!1)),c.forEach(a=>{this._stopEvent(a)}),this}removeAllListeners(a){let b=[];if(null==a)b=this._events,this._events=[];else{const c=N(a);this._events=this._events.filter(a=>a.tag!==c||(b.push(a),!1))}return b.forEach(a=>{this._stopEvent(a)}),this}}var ad=function(b,c,a,d){return new(a||(a=Promise))(function(f,g){function h(a){try{e(d.next(a))}catch(b){g(b)}}function i(a){try{e(d.throw(a))}catch(b){g(b)}}function e(b){var c;b.done?f(b.value):((c=b.value)instanceof a?c:new a(function(a){a(c)})).then(h,i)}e((d=d.apply(b,c||[])).next())})};const ae=new c.Logger(d),af=["call","estimateGas"];function ag(a,b){if(null==a)return null;if("string"==typeof a.message&&a.message.match("reverted")){const c=(0,t.isHexString)(a.data)?a.data:null;if(!b||c)return{message:a.message,data:c}}if("object"==typeof a){for(const e in a){const d=ag(a[e],b);if(d)return d}return null}if("string"==typeof a)try{return ag(JSON.parse(a),b)}catch(f){}return null}function ah(b,a,g){const e=g.transaction||g.signedTransaction;if("call"===b){const h=ag(a,!0);if(h)return h.data;ae.throwError("missing revert data in call exception; Transaction reverted without a reason string",c.Logger.errors.CALL_EXCEPTION,{data:"0x",transaction:e,error:a})}if("estimateGas"===b){let f=ag(a.body,!1);null==f&&(f=ag(a,!1)),f&&ae.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",c.Logger.errors.UNPREDICTABLE_GAS_LIMIT,{reason:f.message,method:b,transaction:e,error:a})}let d=a.message;throw a.code===c.Logger.errors.SERVER_ERROR&&a.error&&"string"==typeof a.error.message?d=a.error.message:"string"==typeof a.body?d=a.body:"string"==typeof a.responseText&&(d=a.responseText),(d=(d||"").toLowerCase()).match(/insufficient funds|base fee exceeds gas limit/i)&&ae.throwError("insufficient funds for intrinsic transaction cost",c.Logger.errors.INSUFFICIENT_FUNDS,{error:a,method:b,transaction:e}),d.match(/nonce (is )?too low/i)&&ae.throwError("nonce has already been used",c.Logger.errors.NONCE_EXPIRED,{error:a,method:b,transaction:e}),d.match(/replacement transaction underpriced|transaction gas price.*too low/i)&&ae.throwError("replacement fee too low",c.Logger.errors.REPLACEMENT_UNDERPRICED,{error:a,method:b,transaction:e}),d.match(/only replay-protected/i)&&ae.throwError("legacy pre-eip-155 transactions not supported",c.Logger.errors.UNSUPPORTED_OPERATION,{error:a,method:b,transaction:e}),af.indexOf(b)>=0&&d.match(/gas required exceeds allowance|always failing transaction|execution reverted/)&&ae.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",c.Logger.errors.UNPREDICTABLE_GAS_LIMIT,{error:a,method:b,transaction:e}),a}function ai(a){return new Promise(function(b){setTimeout(b,a)})}function aj(a){if(a.error){const b=new Error(a.error.message);throw b.code=a.error.code,b.data=a.error.data,b}return a.result}function ak(a){return a?a.toLowerCase():a}const al={};class o extends j.E{constructor(b,c,a){if(super(),b!==al)throw new Error("do not call the JsonRpcSigner constructor directly; use provider.getSigner");(0,r.defineReadOnly)(this,"provider",c),null==a&&(a=0),"string"==typeof a?((0,r.defineReadOnly)(this,"_address",this.provider.formatter.address(a)),(0,r.defineReadOnly)(this,"_index",null)):"number"==typeof a?((0,r.defineReadOnly)(this,"_index",a),(0,r.defineReadOnly)(this,"_address",null)):ae.throwArgumentError("invalid address or index","addressOrIndex",a)}connect(a){return ae.throwError("cannot alter JSON-RPC Signer connection",c.Logger.errors.UNSUPPORTED_OPERATION,{operation:"connect"})}connectUnchecked(){return new am(al,this.provider,this._address||this._index)}getAddress(){return this._address?Promise.resolve(this._address):this.provider.send("eth_accounts",[]).then(a=>(a.length<=this._index&&ae.throwError("unknown account #"+this._index,c.Logger.errors.UNSUPPORTED_OPERATION,{operation:"getAddress"}),this.provider.formatter.address(a[this._index])))}sendUncheckedTransaction(a){a=(0,r.shallowCopy)(a);const b=this.getAddress().then(a=>(a&&(a=a.toLowerCase()),a));if(null==a.gasLimit){const d=(0,r.shallowCopy)(a);d.from=b,a.gasLimit=this.provider.estimateGas(d)}return null!=a.to&&(a.to=Promise.resolve(a.to).then(a=>ad(this,void 0,void 0,function*(){if(null==a)return null;const b=yield this.provider.resolveName(a);return null==b&&ae.throwArgumentError("provided ENS name resolves to null","tx.to",a),b}))),(0,r.resolveProperties)({tx:(0,r.resolveProperties)(a),sender:b}).then(({tx:b,sender:d})=>{null!=b.from?b.from.toLowerCase()!==d&&ae.throwArgumentError("from address mismatch","transaction",a):b.from=d;const e=this.provider.constructor.hexlifyTransaction(b,{from:!0});return this.provider.send("eth_sendTransaction",[e]).then(a=>a,a=>("string"==typeof a.message&&a.message.match(/user denied/i)&&ae.throwError("user rejected transaction",c.Logger.errors.ACTION_REJECTED,{action:"sendTransaction",transaction:b}),ah("sendTransaction",a,e)))})}signTransaction(a){return ae.throwError("signing transactions is unsupported",c.Logger.errors.UNSUPPORTED_OPERATION,{operation:"signTransaction"})}sendTransaction(a){return ad(this,void 0,void 0,function*(){const d=yield this.provider._getInternalBlockNumber(100+2*this.provider.pollingInterval),c=yield this.sendUncheckedTransaction(a);try{return yield(0,x.poll)(()=>ad(this,void 0,void 0,function*(){const a=yield this.provider.getTransaction(c);if(null!==a)return this.provider._wrapTransaction(a,c,d)}),{oncePoll:this.provider})}catch(b){throw b.transactionHash=c,b}})}signMessage(a){return ad(this,void 0,void 0,function*(){const e="string"==typeof a?(0,v.Y0)(a):a,d=yield this.getAddress();try{return yield this.provider.send("personal_sign",[(0,t.hexlify)(e),d.toLowerCase()])}catch(b){throw"string"==typeof b.message&&b.message.match(/user denied/i)&&ae.throwError("user rejected signing",c.Logger.errors.ACTION_REJECTED,{action:"signMessage",from:d,messageData:a}),b}})}_legacySignMessage(a){return ad(this,void 0,void 0,function*(){const e="string"==typeof a?(0,v.Y0)(a):a,d=yield this.getAddress();try{return yield this.provider.send("eth_sign",[d.toLowerCase(),(0,t.hexlify)(e)])}catch(b){throw"string"==typeof b.message&&b.message.match(/user denied/i)&&ae.throwError("user rejected signing",c.Logger.errors.ACTION_REJECTED,{action:"_legacySignMessage",from:d,messageData:a}),b}})}_signTypedData(a,b,d){return ad(this,void 0,void 0,function*(){const e=yield u.E.resolveNames(a,b,d,a=>this.provider.resolveName(a)),g=yield this.getAddress();try{return yield this.provider.send("eth_signTypedData_v4",[g.toLowerCase(),JSON.stringify(u.E.getPayload(e.domain,b,e.value))])}catch(f){throw"string"==typeof f.message&&f.message.match(/user denied/i)&&ae.throwError("user rejected signing",c.Logger.errors.ACTION_REJECTED,{action:"_signTypedData",from:g,messageData:{domain:e.domain,types:b,value:e.value}}),f}})}unlock(a){return ad(this,void 0,void 0,function*(){const b=this.provider,c=yield this.getAddress();return b.send("personal_unlockAccount",[c.toLowerCase(),a,null])})}}class am extends o{sendTransaction(a){return this.sendUncheckedTransaction(a).then(a=>({hash:a,nonce:null,gasLimit:null,gasPrice:null,data:null,value:null,chainId:null,confirmations:0,from:null,wait:b=>this.provider.waitForTransaction(a,b)}))}}const an={chainId:!0,data:!0,gasLimit:!0,gasPrice:!0,nonce:!0,to:!0,value:!0,type:!0,accessList:!0,maxFeePerGas:!0,maxPriorityFeePerGas:!0};class p extends n{constructor(a,c){let b=c;
1null==b&&(b=new Promise((a,b)=>{setTimeout(()=>{this.detectNetwork().then(b=>{a(b)},a=>{b(a)})},0)})),super(b),a||(a=(0,r.getStatic)(this.constructor,"defaultUrl")()),"string"==typeof a?(0,r.defineReadOnly)(this,"connection",Object.freeze({url:a})):(0,r.defineReadOnly)(this,"connection",Object.freeze((0,r.shallowCopy)(a))),this._nextId=42}get _cache(){return null==this._eventLoopCache&&(this._eventLoopCache={}),this._eventLoopCache}static defaultUrl(){return"http://localhost:8545"}detectNetwork(){return this._cache.detectNetwork||(this._cache.detectNetwork=this._uncachedDetectNetwork(),setTimeout(()=>{this._cache.detectNetwork=null},0)),this._cache.detectNetwork}_uncachedDetectNetwork(){return ad(this,void 0,void 0,function*(){yield ai(0);let a=null;try{a=yield this.send("eth_chainId",[])}catch(e){try{a=yield this.send("net_version",[])}catch(f){}}if(null!=a){const b=(0,r.getStatic)(this.constructor,"getNetwork");try{return b(s.O$.from(a).toNumber())}catch(d){return ae.throwError("could not detect network",c.Logger.errors.NETWORK_ERROR,{chainId:a,event:"invalidNetwork",serverError:d})}}return ae.throwError("could not detect network",c.Logger.errors.NETWORK_ERROR,{event:"noNetwork"})})}getSigner(a){return new o(al,this,a)}getUncheckedSigner(a){return this.getSigner(a).connectUnchecked()}listAccounts(){return this.send("eth_accounts",[]).then(a=>a.map(a=>this.formatter.address(a)))}send(a,e){const b={method:a,params:e,id:this._nextId++,jsonrpc:"2.0"};this.emit("debug",{action:"request",request:(0,r.deepCopy)(b),provider:this});const c=["eth_chainId","eth_blockNumber"].indexOf(a)>=0;if(c&&this._cache[a])return this._cache[a];const d=(0,x.fetchJson)(this.connection,JSON.stringify(b),aj).then(a=>(this.emit("debug",{action:"response",request:b,response:a,provider:this}),a),a=>{throw this.emit("debug",{action:"response",error:a,request:b,provider:this}),a});return c&&(this._cache[a]=d,setTimeout(()=>{this._cache[a]=null},0)),d}prepareRequest(b,a){switch(b){case"getBlockNumber":return["eth_blockNumber",[]];case"getGasPrice":return["eth_gasPrice",[]];case"getBalance":return["eth_getBalance",[ak(a.address),a.blockTag]];case"getTransactionCount":return["eth_getTransactionCount",[ak(a.address),a.blockTag]];case"getCode":return["eth_getCode",[ak(a.address),a.blockTag]];case"getStorageAt":return["eth_getStorageAt",[ak(a.address),(0,t.hexZeroPad)(a.position,32),a.blockTag]];case"sendTransaction":return["eth_sendRawTransaction",[a.signedTransaction]];case"getBlock":if(a.blockTag)return["eth_getBlockByNumber",[a.blockTag,!!a.includeTransactions]];if(a.blockHash)return["eth_getBlockByHash",[a.blockHash,!!a.includeTransactions]];return null;case"getTransaction":return["eth_getTransactionByHash",[a.transactionHash]];case"getTransactionReceipt":return["eth_getTransactionReceipt",[a.transactionHash]];case"call":{const c=(0,r.getStatic)(this.constructor,"hexlifyTransaction");return["eth_call",[c(a.transaction,{from:!0}),a.blockTag]]}case"estimateGas":{const d=(0,r.getStatic)(this.constructor,"hexlifyTransaction");return["eth_estimateGas",[d(a.transaction,{from:!0})]]}case"getLogs":return a.filter&&null!=a.filter.address&&(a.filter.address=ak(a.filter.address)),["eth_getLogs",[a.filter]];default:break}return null}perform(a,b){return ad(this,void 0,void 0,function*(){if("call"===a||"estimateGas"===a){const d=b.transaction;if(d&&null!=d.type&&s.O$.from(d.type).isZero()&&null==d.maxFeePerGas&&null==d.maxPriorityFeePerGas){const f=yield this.getFeeData();null==f.maxFeePerGas&&null==f.maxPriorityFeePerGas&&((b=(0,r.shallowCopy)(b)).transaction=(0,r.shallowCopy)(d),delete b.transaction.type)}}const e=this.prepareRequest(a,b);null==e&&ae.throwError(a+" not implemented",c.Logger.errors.NOT_IMPLEMENTED,{operation:a});try{return yield this.send(e[0],e[1])}catch(g){return ah(a,g,b)}})}_startEvent(a){"pending"===a.tag&&this._startPending(),super._startEvent(a)}_startPending(){if(null!=this._pendingFilter)return;const b=this,a=this.send("eth_newPendingTransactionFilter",[]);this._pendingFilter=a,a.then(function(c){function d(){b.send("eth_getFilterChanges",[c]).then(function(c){if(b._pendingFilter!=a)return null;
1let d=Promise.resolve();return c.forEach(function(a){b._emitted["t:"+a.toLowerCase()]="pending",d=d.then(function(){return b.getTransaction(a).then(function(a){return b.emit("pending",a),null})})}),d.then(function(){return ai(1e3)})}).then(function(){if(b._pendingFilter!=a){b.send("eth_uninstallFilter",[c]);return}return setTimeout(function(){d()},0),null}).catch(a=>{})}return d(),c}).catch(a=>{})}_stopEvent(a){"pending"===a.tag&&0===this.listenerCount("pending")&&(this._pendingFilter=null),super._stopEvent(a)}static hexlifyTransaction(a,b){const c=(0,r.shallowCopy)(an);if(b)for(const d in b)b[d]&&(c[d]=!0);(0,r.checkProperties)(a,c);const e={};return["chainId","gasLimit","gasPrice","type","maxFeePerGas","maxPriorityFeePerGas","nonce","value"].forEach(function(b){if(null==a[b])return;const c=(0,t.hexValue)(s.O$.from(a[b]));"gasLimit"===b&&(b="gas"),e[b]=c}),["from","to","data"].forEach(function(b){null!=a[b]&&(e[b]=(0,t.hexlify)(a[b]))}),a.accessList&&(e.accessList=(0,w.accessListify)(a.accessList)),e}}const ao=new c.Logger(d);let ap=1;function aq(a,b){const c="Web3LegacyFetcher";return function(a,d){const e={method:a,params:d,id:ap++,jsonrpc:"2.0"};return new Promise((a,d)=>{this.emit("debug",{action:"request",fetcher:c,request:(0,r.deepCopy)(e),provider:this}),b(e,(f,b)=>{if(f)return this.emit("debug",{action:"response",fetcher:c,error:f,request:e,provider:this}),d(f);if(this.emit("debug",{action:"response",fetcher:c,request:e,response:b,provider:this}),b.error){const g=new Error(b.error.message);return g.code=b.error.code,g.data=b.error.data,d(g)}a(b.result)})})}}class ar extends p{constructor(a,e){null==a&&ao.throwArgumentError("missing provider","provider",a);let b=null,c=null,d=null;if("function"==typeof a)b="unknown:",c=a;else{if((b=a.host||a.path||"")||!a.isMetaMask||(b="metamask"),d=a,a.request){var f;""===b&&(b="eip-1193:"),c=(f=a,function(c,a){null==a&&(a=[]);const b={method:c,params:a};return this.emit("debug",{action:"request",fetcher:"Eip1193Fetcher",request:(0,r.deepCopy)(b),provider:this}),f.request(b).then(a=>(this.emit("debug",{action:"response",fetcher:"Eip1193Fetcher",request:b,response:a,provider:this}),a),a=>{throw this.emit("debug",{action:"response",fetcher:"Eip1193Fetcher",request:b,error:a,provider:this}),a})})}else a.sendAsync?c=aq(a,a.sendAsync.bind(a)):a.send?c=aq(a,a.send.bind(a)):ao.throwArgumentError("unsupported provider","provider",a);b||(b="unknown:")}super(b,e),(0,r.defineReadOnly)(this,"jsonRpcFetchFunc",c),(0,r.defineReadOnly)(this,"provider",d)}send(a,b){return this.jsonRpcFetchFunc(a,b)}}},2882:function(e){for(var c="qpzry9x8gf2tvdw0s3jn54khce6mua7l",d={},a=0;a<c.length;a++){var b=c.charAt(a);if(void 0!==d[b])throw new TypeError(b+" is ambiguous");d[b]=a}function f(b){var a=b>>25;return(33554431&b)<<5^996825010& -(a>>0&1)^642813549& -(a>>1&1)^513874426& -(a>>2&1)^1027748829& -(a>>3&1)^705979059& -(a>>4&1)}function g(c){for(var a=1,b=0;b<c.length;++b){var d=c.charCodeAt(b);if(d<33||d>126)return"Invalid prefix ("+c+")";a=f(a)^d>>5}for(b=0,a=f(a);b<c.length;++b){var e=c.charCodeAt(b);a=f(a)^31&e}return a}function h(a,i){if(i=i||90,a.length<8)return a+" too short";if(a.length>i)return"Exceeds length limit";var k=a.toLowerCase(),o=a.toUpperCase();if(a!==k&&a!==o)return"Mixed-case string "+a;var c=(a=k).lastIndexOf("1");if(-1===c)return"No separator character for "+a;if(0===c)return"Missing prefix for "+a;var l=a.slice(0,c),e=a.slice(c+1);if(e.length<6)return"Data too short";var b=g(l);if("string"==typeof b)return b;for(var m=[],h=0;h<e.length;++h){var n=e.charAt(h),j=d[n];if(void 0===j)return"Unknown character "+n;b=f(b)^j,h+6>=e.length||m.push(j)}return 1!==b?"Invalid checksum for "+a:{prefix:l,words:m}}function i(h,d,b,i){for(var c=0,a=0,e=(1<<b)-1,f=[],g=0;g<h.length;++g)for(c=c<<d|h[g],a+=d;a>=b;)a-=b,f.push(c>>a&e);if(i)a>0&&f.push(c<<b-a&e);else{if(a>=d)return"Excess padding";if(c<<b-a&e)return"Non-zero padding"}return f}e.exports={decodeUnsafe:function(){var a=h.apply(null,arguments);if("object"==typeof a)return a},decode:function(b){var a=h.apply(null,arguments);if("object"==typeof a)return a;throw new Error(a)},encode:function(d,e,h){if(h=h||90,d.length+7+e.length>h)throw new TypeError("Exceeds length limit");var b=g(d=d.toLowerCase());if("string"==typeof b)throw new Error(b);for(var i=d+"1",a=0;a<e.length;++a){var j=e[a];if(j>>5!=0)throw new Error("Non 5-bit word");b=f(b)^j,i+=c.charAt(j)}for(a=0;a<6;++a)b=f(b);for(b^=1,a=0;a<6;++a){var k=b>>(5-a)*5&31;i+=c.charAt(k)}return i},toWordsUnsafe:function(b){var a=i(b,8,5,!0);if(Array.isArray(a))return a},toWords:function(b){var a=i(b,8,5,!0);if(Array.isArray(a))return a;throw new Error(a)},fromWordsUnsafe:function(b){var a=i(b,5,8,!1);if(Array.isArray(a))return a},fromWords:function(b){var a=i(b,5,8,!1);if(Array.isArray(a))return a;throw new Error(a)}}}}])
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.