"use strict";(self.webpackChunkfrog=self.webpackChunkfrog||[]).push([[1449],{16131:(t,e,s)=>{s.d(e,{Q:()=>V,J:()=>H});var r=s(41442),n=s(30031),a=s(76601),i=s(24391),o=s(13890),l=s(10634),c=s(88081),u=s(36212),h=s(57339),p=s(26976),d=s(27033),f=s(99381),g=s(87303),m=s(14132);function w(t){return t.match(/^ipfs:\/\/ipfs\//i)?t=t.substring(12):t.match(/^ipfs:\/\//i)?t=t.substring(7):(0,h.MR)(!1,"unsupported IPFS format","link",t),`https://gateway.ipfs.io/ipfs/${t}`}class b{name;constructor(t){(0,c.n)(this,{name:t})}connect(t){return this}supportsCoinType(t){return!1}async encodeAddress(t,e){throw new Error("unsupported coin")}async decodeAddress(t,e){throw new Error("unsupported coin")}}const y=new RegExp("^(ipfs)://(.*)$","i"),k=[new RegExp("^(https)://(.*)$","i"),new RegExp("^(data):(.*)$","i"),y,new RegExp("^eip155:[0-9]+/(erc[0-9]+):(.*)$","i")];class v{provider;address;name;#t;#e;constructor(t,e,s){(0,c.n)(this,{provider:t,address:e,name:s}),this.#t=null,this.#e=new i.NZ(e,["function supportsInterface(bytes4) view returns (bool)","function resolve(bytes, bytes) view returns (bytes)","function addr(bytes32) view returns (address)","function addr(bytes32, uint) view returns (bytes)","function text(bytes32, string) view returns (string)","function contenthash(bytes32) view returns (bytes)"],t)}async supportsWildcard(){return null==this.#t&&(this.#t=(async()=>{try{return await this.#e.supportsInterface("0x9061b923")}catch(t){if((0,h.bJ)(t,"CALL_EXCEPTION"))return!1;throw this.#t=null,t}})()),await this.#t}async#s(t,e){e=(e||[]).slice();const s=this.#e.interface;e.unshift((0,o.kM)(this.name));let r=null;await this.supportsWildcard()&&(r=s.getFunction(t),(0,h.vA)(r,"missing fragment","UNKNOWN_ERROR",{info:{funcName:t}}),e=[(0,o.Wh)(this.name,255),s.encodeFunctionData(r,e)],t="resolve(bytes,bytes)"),e.push({enableCcipRead:!0});try{const n=await this.#e[t](...e);return r?s.decodeFunctionResult(r,n)[0]:n}catch(t){if(!(0,h.bJ)(t,"CALL_EXCEPTION"))throw t}return null}async getAddress(t){if(null==t&&(t=60),60===t)try{const t=await this.#s("addr(bytes32)");return null==t||t===a.j?null:t}catch(t){if((0,h.bJ)(t,"CALL_EXCEPTION"))return null;throw t}if(t>=0&&t<2147483648){let e=t+2147483648;const s=await this.#s("addr(bytes32,uint)",[e]);if((0,u.Lo)(s,20))return(0,n.b)(s)}let e=null;for(const s of this.provider.plugins)if(s instanceof b&&s.supportsCoinType(t)){e=s;break}if(null==e)return null;const s=await this.#s("addr(bytes32,uint)",[t]);if(null==s||"0x"===s)return null;const r=await e.decodeAddress(t,s);if(null!=r)return r;(0,h.vA)(!1,"invalid coin data","UNSUPPORTED_OPERATION",{operation:`getAddress(${t})`,info:{coinType:t,data:s}})}async getText(t){const e=await this.#s("text(bytes32,string)",[t]);return null==e||"0x"===e?null:e}async getContentHash(){const t=await this.#s("contenthash(bytes32)");if(null==t||"0x"===t)return null;const e=t.match(/^0x(e3010170|e5010172)(([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f]*))$/);if(e){const t="e3010170"===e[1]?"ipfs":"ipns",s=parseInt(e[4],16);if(e[5].length===2*s)return`${t}://${(0,m.R)("0x"+e[2])}`}const s=t.match(/^0xe40101fa011b20([0-9a-f]*)$/);if(s&&64===s[1].length)return`bzz://${s[1]}`;(0,h.vA)(!1,"invalid or unsupported content hash data","UNSUPPORTED_OPERATION",{operation:"getContentHash()",info:{data:t}})}async getAvatar(){return(await this._getAvatar()).url}async _getAvatar(){const t=[{type:"name",value:this.name}];try{const e=await this.getText("avatar");if(null==e)return t.push({type:"!avatar",value:""}),{url:null,linkage:t};t.push({type:"avatar",value:e});for(let s=0;s{if(e&&null==s)return null;if(!Array.isArray(s))throw new Error("not an array");return s.map((e=>t(e)))}}function x(t,e){return s=>{const r={};for(const n in t){let a=n;if(e&&n in e&&!(a in s))for(const t of e[n])if(t in s){a=t;break}try{const e=t[n](s[a]);void 0!==e&&(r[n]=e)}catch(t){const e=t instanceof Error?t.message:"not-an-error";(0,h.vA)(!1,`invalid value for value.${n} (${e})`,"BAD_DATA",{value:s})}}return r}}function O(t){return(0,h.MR)((0,u.Lo)(t,!0),"invalid data","value",t),t}function F(t){return(0,h.MR)((0,u.Lo)(t,32),"invalid hash","value",t),t}const _=x({address:n.b,blockHash:F,blockNumber:d.WZ,data:O,index:d.WZ,removed:R((function(t){switch(t){case!0:case"true":return!0;case!1:case"false":return!1}(0,h.MR)(!1,`invalid boolean; ${JSON.stringify(t)}`,"value",t)}),!1),topics:C(F),transactionHash:F,transactionIndex:d.WZ},{index:["logIndex"]});const E=x({hash:R(F),parentHash:F,parentBeaconBlockRoot:R(F,null),number:d.WZ,timestamp:d.WZ,nonce:R(O),difficulty:d.Ab,gasLimit:d.Ab,gasUsed:d.Ab,stateRoot:R(F,null),receiptsRoot:R(F,null),blobGasUsed:R(d.Ab,null),excessBlobGas:R(d.Ab,null),miner:R(n.b),prevRandao:R(F,null),extraData:O,baseFeePerGas:R(d.Ab)},{prevRandao:["mixHash"]});const I=x({transactionIndex:d.WZ,blockNumber:d.WZ,transactionHash:F,address:n.b,topics:C(F),data:O,index:d.WZ,blockHash:F},{index:["logIndex"]});const L=x({to:R(n.b,null),from:R(n.b,null),contractAddress:R(n.b,null),index:d.WZ,root:R(u.c$),gasUsed:d.Ab,blobGasUsed:R(d.Ab,null),logsBloom:R(O),blockHash:F,hash:F,logs:C((function(t){return I(t)})),blockNumber:d.WZ,cumulativeGasUsed:d.Ab,effectiveGasPrice:R(d.Ab),blobGasPrice:R(d.Ab,null),status:R(d.WZ),type:R(d.WZ,0)},{effectiveGasPrice:["gasPrice"],hash:["transactionHash"],index:["transactionIndex"]});function G(t){t.to&&(0,d.Ab)(t.to)===N&&(t.to="0x0000000000000000000000000000000000000000");const e=x({hash:F,index:R(d.WZ,void 0),type:t=>"0x"===t||null==t?0:(0,d.WZ)(t),accessList:R(T.$,null),blobVersionedHashes:R(C(F,!0),null),blockHash:R(F,null),blockNumber:R(d.WZ,null),transactionIndex:R(d.WZ,null),from:n.b,gasPrice:R(d.Ab),maxPriorityFeePerGas:R(d.Ab),maxFeePerGas:R(d.Ab),maxFeePerBlobGas:R(d.Ab,null),gasLimit:d.Ab,to:R(n.b,null),value:d.Ab,nonce:d.WZ,data:O,creates:R(n.b,null),chainId:R(d.Ab,null)},{data:["input"],gasLimit:["gas"],index:["transactionIndex"]})(t);if(null==e.to&&null==e.creates&&(e.creates=(0,A.t)(e)),1!==t.type&&2!==t.type||null!=t.accessList||(e.accessList=[]),t.signature?e.signature=P.t.from(t.signature):e.signature=P.t.from(t),null==e.chainId){const t=e.signature.legacyChainId;null!=t&&(e.chainId=t)}return e.blockHash&&(0,d.Ab)(e.blockHash)===N&&(e.blockHash=null),e}var S=s(64170),B=s(43948),U=s(41441);const Z=BigInt(2);function D(t){return t&&"function"==typeof t.then}function W(t,e){return t+":"+JSON.stringify(e,((t,e)=>{if(null==e)return"null";if("bigint"==typeof e)return`bigint:${e.toString()}`;if("string"==typeof e)return e.toLowerCase();if("object"==typeof e&&!Array.isArray(e)){const t=Object.keys(e);return t.sort(),t.reduce(((t,s)=>(t[s]=e[s],t)),{})}return e}))}class H{name;constructor(t){(0,c.n)(this,{name:t})}start(){}stop(){}pause(t){}resume(){}}function M(t){return(t=Array.from(new Set(t).values())).sort(),t}async function $(t,e){if(null==t)throw new Error("invalid event");if(Array.isArray(t)&&(t={topics:t}),"string"==typeof t)switch(t){case"block":case"debug":case"error":case"finalized":case"network":case"pending":case"safe":return{type:t,tag:t}}if((0,u.Lo)(t,32)){const e=t.toLowerCase();return{type:"transaction",tag:W("tx",{hash:e}),hash:e}}if(t.orphan){const e=t;return{type:"orphan",tag:W("orphan",e),filter:(s=e,JSON.parse(JSON.stringify(s)))}}var s;if(t.address||t.topics){const s=t,n={topics:(s.topics||[]).map((t=>null==t?null:Array.isArray(t)?M(t.map((t=>t.toLowerCase()))):t.toLowerCase()))};if(s.address){const t=[],a=[],i=s=>{(0,u.Lo)(s)?t.push(s):a.push((async()=>{t.push(await(0,r.tG)(s,e))})())};Array.isArray(s.address)?s.address.forEach(i):i(s.address),a.length&&await Promise.all(a),n.address=M(t.map((t=>t.toLowerCase())))}return{filter:n,tag:W("event",n),type:"event"}}(0,h.MR)(!1,"unknown ProviderEvent","event",t)}function J(){return(new Date).getTime()}const j={cacheTimeout:250,pollingInterval:4e3};class V{#n;#a;#i;#o;#l;#c;#u;#h;#p;#d;#f;#g;constructor(t,e){if(this.#g=Object.assign({},j,e||{}),"any"===t)this.#c=!0,this.#l=null;else if(t){const e=S.l.from(t);this.#c=!1,this.#l=Promise.resolve(e),setTimeout((()=>{this.emit("network",e,null)}),0)}else this.#c=!1,this.#l=null;this.#h=-1,this.#u=new Map,this.#n=new Map,this.#a=new Map,this.#i=null,this.#o=!1,this.#p=1,this.#d=new Map,this.#f=!1}get pollingInterval(){return this.#g.pollingInterval}get provider(){return this}get plugins(){return Array.from(this.#a.values())}attachPlugin(t){if(this.#a.get(t.name))throw new Error(`cannot replace existing plugin: ${t.name} `);return this.#a.set(t.name,t.connect(this)),this}getPlugin(t){return this.#a.get(t)||null}get disableCcipRead(){return this.#f}set disableCcipRead(t){this.#f=!!t}async#m(t){const e=this.#g.cacheTimeout;if(e<0)return await this._perform(t);const s=W(t.method,t);let r=this.#u.get(s);return r||(r=this._perform(t),this.#u.set(s,r),setTimeout((()=>{this.#u.get(s)===r&&this.#u.delete(s)}),e)),await r}async ccipReadFetch(t,e,s){if(this.disableCcipRead||0===s.length||null==t.to)return null;const r=t.to.toLowerCase(),n=e.toLowerCase(),a=[];for(let e=0;e=500,`response not found during CCIP fetch: ${u}`,"OFFCHAIN_FAULT",{reason:"404_MISSING_RESOURCE",transaction:t,info:{url:i,errorMessage:u}}),a.push(u)}(0,h.vA)(!1,`error encountered during CCIP fetch: ${a.map((t=>JSON.stringify(t))).join(", ")}`,"OFFCHAIN_FAULT",{reason:"500_SERVER_ERROR",transaction:t,info:{urls:s,errorMessages:a}})}_wrapBlock(t,e){return new B.eB(function(t){const e=E(t);return e.transactions=t.transactions.map((t=>"string"==typeof t?t:G(t))),e}(t),this)}_wrapLog(t,e){return new B.tG(function(t){return _(t)}(t),this)}_wrapTransactionReceipt(t,e){return new B.z5(function(t){return L(t)}(t),this)}_wrapTransactionResponse(t,e){return new B.uI(G(t),this)}_detectNetwork(){(0,h.vA)(!1,"sub-classes must implement this","UNSUPPORTED_OPERATION",{operation:"_detectNetwork"})}async _perform(t){(0,h.vA)(!1,`unsupported method: ${t.method}`,"UNSUPPORTED_OPERATION",{operation:t.method,info:t})}async getBlockNumber(){const t=(0,d.WZ)(await this.#m({method:"getBlockNumber"}),"%response");return this.#h>=0&&(this.#h=t),t}_getAddress(t){return(0,r.tG)(t,this)}_getBlockTag(t){if(null==t)return"latest";switch(t){case"earliest":return"0x0";case"finalized":case"latest":case"pending":case"safe":return t}return(0,u.Lo)(t)?(0,u.Lo)(t,32)?t:(0,d.nD)(t):("bigint"==typeof t&&(t=(0,d.WZ)(t,"blockTag")),"number"==typeof t?t>=0?(0,d.nD)(t):this.#h>=0?(0,d.nD)(this.#h+t):this.getBlockNumber().then((e=>(0,d.nD)(e+t))):void(0,h.MR)(!1,"invalid blockTag","blockTag",t))}_getFilter(t){const e=(t.topics||[]).map((t=>null==t?null:Array.isArray(t)?M(t.map((t=>t.toLowerCase()))):t.toLowerCase())),s="blockHash"in t?t.blockHash:void 0,r=(t,r,n)=>{let a;switch(t.length){case 0:break;case 1:a=t[0];break;default:t.sort(),a=t}if(s&&(null!=r||null!=n))throw new Error("invalid filter");const i={};return a&&(i.address=a),e.length&&(i.topics=e),r&&(i.fromBlock=r),n&&(i.toBlock=n),s&&(i.blockHash=s),i};let n,a,i=[];if(t.address)if(Array.isArray(t.address))for(const e of t.address)i.push(this._getAddress(e));else i.push(this._getAddress(t.address));return"fromBlock"in t&&(n=this._getBlockTag(t.fromBlock)),"toBlock"in t&&(a=this._getBlockTag(t.toBlock)),i.filter((t=>"string"!=typeof t)).length||null!=n&&"string"!=typeof n||null!=a&&"string"!=typeof a?Promise.all([Promise.all(i),n,a]).then((t=>r(t[0],t[1],t[2]))):r(i,n,a)}_getTransactionRequest(t){const e=(0,B.VS)(t),s=[];if(["to","from"].forEach((t=>{if(null==e[t])return;const n=(0,r.tG)(e[t],this);D(n)?s.push(async function(){e[t]=await n}()):e[t]=n})),null!=e.blockTag){const t=this._getBlockTag(e.blockTag);D(t)?s.push(async function(){e.blockTag=await t}()):e.blockTag=t}return s.length?async function(){return await Promise.all(s),e}():e}async getNetwork(){if(null==this.#l){const t=(async()=>{try{const t=await this._detectNetwork();return this.emit("network",t,null),t}catch(e){throw this.#l===t&&(this.#l=null),e}})();return this.#l=t,(await t).clone()}const t=this.#l,[e,s]=await Promise.all([t,this._detectNetwork()]);return e.chainId!==s.chainId&&(this.#c?(this.emit("network",s,e),this.#l===t&&(this.#l=Promise.resolve(s))):(0,h.vA)(!1,`network changed: ${e.chainId} => ${s.chainId} `,"NETWORK_ERROR",{event:"changed"})),e.clone()}async getFeeData(){const t=await this.getNetwork(),e=async()=>{const{_block:e,gasPrice:s,priorityFee:r}=await(0,c.k)({_block:this.#w("latest",!1),gasPrice:(async()=>{try{const t=await this.#m({method:"getGasPrice"});return(0,d.Ab)(t,"%response")}catch(t){}return null})(),priorityFee:(async()=>{try{const t=await this.#m({method:"getPriorityFee"});return(0,d.Ab)(t,"%response")}catch(t){}return null})()});let n=null,a=null;const i=this._wrapBlock(e,t);return i&&i.baseFeePerGas&&(a=null!=r?r:BigInt("1000000000"),n=i.baseFeePerGas*Z+a),new B.J9(s,n,a)},s=t.getPlugin("org.ethers.plugins.network.FetchUrlFeeDataPlugin");if(s){const t=new p.ui(s.url),r=await s.processFunc(e,this,t);return new B.J9(r.gasPrice,r.maxFeePerGas,r.maxPriorityFeePerGas)}return await e()}async estimateGas(t){let e=this._getTransactionRequest(t);return D(e)&&(e=await e),(0,d.Ab)(await this.#m({method:"estimateGas",transaction:e}),"%response")}async#b(t,e,s){(0,h.vA)(s<10,"CCIP read exceeded maximum redirections","OFFCHAIN_FAULT",{reason:"TOO_MANY_REDIRECTS",transaction:Object.assign({},t,{blockTag:e,enableCcipRead:!0})});const n=(0,B.VS)(t);try{return(0,u.c$)(await this._perform({method:"call",transaction:n,blockTag:e}))}catch(t){if(!this.disableCcipRead&&(0,h.E)(t)&&t.data&&s>=0&&"latest"===e&&null!=n.to&&"0x556f1830"===(0,u.ZG)(t.data,0,4)){const a=t.data,i=await(0,r.tG)(n.to,this);let o;try{o=function(t){const e={sender:"",urls:[],calldata:"",selector:"",extraData:"",errorArgs:[]};(0,h.vA)((0,u.pO)(t)>=160,"insufficient OffchainLookup data","OFFCHAIN_FAULT",{reason:"insufficient OffchainLookup data"});const s=(0,u.ZG)(t,0,32);(0,h.vA)((0,u.ZG)(s,0,12)===(0,u.ZG)(tt,0,12),"corrupt OffchainLookup sender","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup sender"}),e.sender=(0,u.ZG)(s,12);try{const s=[],r=(0,d.WZ)((0,u.ZG)(t,32,64)),n=(0,d.WZ)((0,u.ZG)(t,r,r+32)),a=(0,u.ZG)(t,r+32);for(let t=0;te[t])),e}((0,u.ZG)(t.data,4))}catch(t){(0,h.vA)(!1,t.message,"OFFCHAIN_FAULT",{reason:"BAD_DATA",transaction:n,info:{data:a}})}(0,h.vA)(o.sender.toLowerCase()===i.toLowerCase(),"CCIP Read sender mismatch","CALL_EXCEPTION",{action:"call",data:a,reason:"OffchainLookup",transaction:n,invocation:null,revert:{signature:"OffchainLookup(address,string[],bytes,bytes4,bytes)",name:"OffchainLookup",args:o.errorArgs}});const l=await this.ccipReadFetch(n,o.calldata,o.urls);(0,h.vA)(null!=l,"CCIP Read failed to fetch data","OFFCHAIN_FAULT",{reason:"FETCH_FAILED",transaction:n,info:{data:t.data,errorArgs:o.errorArgs}});const c={to:i,data:(0,u.xW)([o.selector,Q([l,o.extraData])])};this.emit("debug",{action:"sendCcipReadCall",transaction:c});try{const t=await this.#b(c,e,s+1);return this.emit("debug",{action:"receiveCcipReadCallResult",transaction:Object.assign({},c),result:t}),t}catch(t){throw this.emit("debug",{action:"receiveCcipReadCallError",transaction:Object.assign({},c),error:t}),t}}throw t}}async#y(t){const{value:e}=await(0,c.k)({network:this.getNetwork(),value:t});return e}async call(t){const{tx:e,blockTag:s}=await(0,c.k)({tx:this._getTransactionRequest(t),blockTag:this._getBlockTag(t.blockTag)});return await this.#y(this.#b(e,s,t.enableCcipRead?0:-1))}async#k(t,e,s){let r=this._getAddress(e),n=this._getBlockTag(s);return"string"==typeof r&&"string"==typeof n||([r,n]=await Promise.all([r,n])),await this.#y(this.#m(Object.assign(t,{address:r,blockTag:n})))}async getBalance(t,e){return(0,d.Ab)(await this.#k({method:"getBalance"},t,e),"%response")}async getTransactionCount(t,e){return(0,d.WZ)(await this.#k({method:"getTransactionCount"},t,e),"%response")}async getCode(t,e){return(0,u.c$)(await this.#k({method:"getCode"},t,e))}async getStorage(t,e,s){const r=(0,d.Ab)(e,"position");return(0,u.c$)(await this.#k({method:"getStorage",position:r},t,s))}async broadcastTransaction(t){const{blockNumber:e,hash:s,network:r}=await(0,c.k)({blockNumber:this.getBlockNumber(),hash:this._perform({method:"broadcastTransaction",signedTransaction:t}),network:this.getNetwork()}),n=l.Z.from(t);if(n.hash!==s)throw new Error("@TODO: the returned hash did not match");return this._wrapTransactionResponse(n,r).replaceableTransaction(e)}async#w(t,e){if((0,u.Lo)(t,32))return await this.#m({method:"getBlock",blockHash:t,includeTransactions:e});let s=this._getBlockTag(t);return"string"!=typeof s&&(s=await s),await this.#m({method:"getBlock",blockTag:s,includeTransactions:e})}async getBlock(t,e){const{network:s,params:r}=await(0,c.k)({network:this.getNetwork(),params:this.#w(t,!!e)});return null==r?null:this._wrapBlock(r,s)}async getTransaction(t){const{network:e,params:s}=await(0,c.k)({network:this.getNetwork(),params:this.#m({method:"getTransaction",hash:t})});return null==s?null:this._wrapTransactionResponse(s,e)}async getTransactionReceipt(t){const{network:e,params:s}=await(0,c.k)({network:this.getNetwork(),params:this.#m({method:"getTransactionReceipt",hash:t})});if(null==s)return null;if(null==s.gasPrice&&null==s.effectiveGasPrice){const e=await this.#m({method:"getTransaction",hash:t});if(null==e)throw new Error("report this; could not find tx or effectiveGasPrice");s.effectiveGasPrice=e.gasPrice}return this._wrapTransactionReceipt(s,e)}async getTransactionResult(t){const{result:e}=await(0,c.k)({network:this.getNetwork(),result:this.#m({method:"getTransactionResult",hash:t})});return null==e?null:(0,u.c$)(e)}async getLogs(t){let e=this._getFilter(t);D(e)&&(e=await e);const{network:s,params:r}=await(0,c.k)({network:this.getNetwork(),params:this.#m({method:"getLogs",filter:e})});return r.map((t=>this._wrapLog(t,s)))}_getProvider(t){(0,h.vA)(!1,"provider cannot connect to target network","UNSUPPORTED_OPERATION",{operation:"_getProvider()"})}async getResolver(t){return await v.fromName(this,t)}async getAvatar(t){const e=await this.getResolver(t);return e?await e.getAvatar():null}async resolveName(t){const e=await this.getResolver(t);return e?await e.getAddress():null}async lookupAddress(t){t=(0,n.b)(t);const e=(0,o.kM)(t.substring(2).toLowerCase()+".addr.reverse");try{const s=await v.getEnsAddress(this),r=new i.NZ(s,["function resolver(bytes32) view returns (address)"],this),n=await r.resolver(e);if(null==n||n===a.j)return null;const o=new i.NZ(n,["function name(bytes32) view returns (string)"],this),l=await o.name(e);return await this.resolveName(l)!==t?null:l}catch(t){if((0,h.bJ)(t,"BAD_DATA")&&"0x"===t.value)return null;if((0,h.bJ)(t,"CALL_EXCEPTION"))return null;throw t}return null}async waitForTransaction(t,e,s){const r=null!=e?e:1;return 0===r?this.getTransactionReceipt(t):new Promise((async(e,n)=>{let a=null;const i=async s=>{try{const n=await this.getTransactionReceipt(t);if(null!=n&&s-n.blockNumber+1>=r)return e(n),void(a&&(clearTimeout(a),a=null))}catch(t){}this.once("block",i)};null!=s&&(a=setTimeout((()=>{null!=a&&(a=null,this.off("block",i),n((0,h.xz)("timeout","TIMEOUT",{reason:"timeout"})))}),s)),i(await this.getBlockNumber())}))}async waitForBlock(t){(0,h.vA)(!1,"not implemented yet","NOT_IMPLEMENTED",{operation:"waitForBlock"})}_clearTimeout(t){const e=this.#d.get(t);e&&(e.timer&&clearTimeout(e.timer),this.#d.delete(t))}_setTimeout(t,e){null==e&&(e=0);const s=this.#p++,r=()=>{this.#d.delete(s),t()};if(this.paused)this.#d.set(s,{timer:null,func:r,time:e});else{const t=setTimeout(r,e);this.#d.set(s,{timer:t,func:r,time:J()})}return s}_forEachSubscriber(t){for(const e of this.#n.values())t(e.subscriber)}_getSubscriber(t){switch(t.type){case"debug":case"error":case"network":return new H(t.type);case"block":{const t=new U.bs(this);return t.pollingInterval=this.pollingInterval,t}case"safe":case"finalized":return new U.l8(this,t.type);case"event":return new U.MY(this,t.filter);case"transaction":return new U.AC(this,t.hash);case"orphan":return new U.wF(this,t.filter)}throw new Error(`unsupported event: ${t.type}`)}_recoverSubscriber(t,e){for(const s of this.#n.values())if(s.subscriber===t){s.started&&s.subscriber.stop(),s.subscriber=e,s.started&&e.start(),null!=this.#i&&e.pause(this.#i);break}}async#v(t,e){let s=await $(t,this);return"event"===s.type&&e&&e.length>0&&!0===e[0].removed&&(s=await $({orphan:"drop-log",log:e[0]},this)),this.#n.get(s.tag)||null}async#A(t){const e=await $(t,this),s=e.tag;let r=this.#n.get(s);if(!r){r={subscriber:this._getSubscriber(e),tag:s,addressableMap:new WeakMap,nameMap:new Map,started:!1,listeners:[]},this.#n.set(s,r)}return r}async on(t,e){const s=await this.#A(t);return s.listeners.push({listener:e,once:!1}),s.started||(s.subscriber.start(),s.started=!0,null!=this.#i&&s.subscriber.pause(this.#i)),this}async once(t,e){const s=await this.#A(t);return s.listeners.push({listener:e,once:!0}),s.started||(s.subscriber.start(),s.started=!0,null!=this.#i&&s.subscriber.pause(this.#i)),this}async emit(t,...e){const s=await this.#v(t,e);if(!s||0===s.listeners.length)return!1;const r=s.listeners.length;return s.listeners=s.listeners.filter((({listener:s,once:r})=>{const n=new f.z(this,r?null:s,t);try{s.call(this,...e,n)}catch(t){}return!r})),0===s.listeners.length&&(s.started&&s.subscriber.stop(),this.#n.delete(s.tag)),r>0}async listenerCount(t){if(t){const e=await this.#v(t);return e?e.listeners.length:0}let e=0;for(const{listeners:t}of this.#n.values())e+=t.length;return e}async listeners(t){if(t){const e=await this.#v(t);return e?e.listeners.map((({listener:t})=>t)):[]}let e=[];for(const{listeners:t}of this.#n.values())e=e.concat(t.map((({listener:t})=>t)));return e}async off(t,e){const s=await this.#v(t);if(!s)return this;if(e){const t=s.listeners.map((({listener:t})=>t)).indexOf(e);t>=0&&s.listeners.splice(t,1)}return e&&0!==s.listeners.length||(s.started&&s.subscriber.stop(),this.#n.delete(s.tag)),this}async removeAllListeners(t){if(t){const{tag:e,started:s,subscriber:r}=await this.#A(t);s&&r.stop(),this.#n.delete(e)}else for(const[t,{started:e,subscriber:s}]of this.#n)e&&s.stop(),this.#n.delete(t);return this}async addListener(t,e){return await this.on(t,e)}async removeListener(t,e){return this.off(t,e)}get destroyed(){return this.#o}destroy(){this.removeAllListeners();for(const t of this.#d.keys())this._clearTimeout(t);this.#o=!0}get paused(){return null!=this.#i}set paused(t){!!t!==this.paused&&(this.paused?this.resume():this.pause(!1))}pause(t){if(this.#h=-1,null!=this.#i){if(this.#i==!!t)return;(0,h.vA)(!1,"cannot change pause type; resume first","UNSUPPORTED_OPERATION",{operation:"pause"})}this._forEachSubscriber((e=>e.pause(t))),this.#i=!!t;for(const t of this.#d.values())t.timer&&clearTimeout(t.timer),t.time=J()-t.time}resume(){if(null!=this.#i){this._forEachSubscriber((t=>t.resume())),this.#i=null;for(const t of this.#d.values()){let e=t.time;e<0&&(e=0),t.time=J(),setTimeout(t.func,e)}}}}function q(t,e){try{const s=z(t,e);if(s)return(0,g._v)(s)}catch(t){}return null}function z(t,e){if("0x"===t)return null;try{const s=(0,d.WZ)((0,u.ZG)(t,e,e+32)),r=(0,d.WZ)((0,u.ZG)(t,s,s+32));return(0,u.ZG)(t,s+32,s+32+r)}catch(t){}return null}function X(t){const e=(0,d.c4)(t);if(e.length>32)throw new Error("internal; should not happen");const s=new Uint8Array(32);return s.set(e,32-e.length),s}function K(t){if(t.length%32==0)return t;const e=new Uint8Array(32*Math.ceil(t.length/32));return e.set(t),e}const Y=new Uint8Array([]);function Q(t){const e=[];let s=0;for(let r=0;r{s.d(e,{Z:()=>h});var r=s(41442),n=s(10634),a=s(57339),i=s(88081),o=s(27033),l=s(43948);function c(t,e){if(t.provider)return t.provider;(0,a.vA)(!1,"missing provider","UNSUPPORTED_OPERATION",{operation:e})}async function u(t,e){let s=(0,l.VS)(e);if(null!=s.to&&(s.to=(0,r.tG)(s.to,t)),null!=s.from){const e=s.from;s.from=Promise.all([t.getAddress(),(0,r.tG)(e,t)]).then((([t,e])=>((0,a.MR)(t.toLowerCase()===e.toLowerCase(),"transaction from mismatch","tx.from",e),t)))}else s.from=t.getAddress();return await(0,i.k)(s)}class h{provider;constructor(t){(0,i.n)(this,{provider:t||null})}async getNonce(t){return c(this,"getTransactionCount").getTransactionCount(await this.getAddress(),t)}async populateCall(t){return await u(this,t)}async populateTransaction(t){const e=c(this,"populateTransaction"),s=await u(this,t);null==s.nonce&&(s.nonce=await this.getNonce("pending")),null==s.gasLimit&&(s.gasLimit=await this.estimateGas(s));const r=await this.provider.getNetwork();if(null!=s.chainId){const e=(0,o.Ab)(s.chainId);(0,a.MR)(e===r.chainId,"transaction chainId mismatch","tx.chainId",t.chainId)}else s.chainId=r.chainId;const n=null!=s.maxFeePerGas||null!=s.maxPriorityFeePerGas;if(null==s.gasPrice||2!==s.type&&!n?0!==s.type&&1!==s.type||!n||(0,a.MR)(!1,"pre-eip-1559 transaction do not support maxFeePerGas/maxPriorityFeePerGas","tx",t):(0,a.MR)(!1,"eip-1559 transaction do not support gasPrice","tx",t),2!==s.type&&null!=s.type||null==s.maxFeePerGas||null==s.maxPriorityFeePerGas)if(0===s.type||1===s.type){const t=await e.getFeeData();(0,a.vA)(null!=t.gasPrice,"network does not support gasPrice","UNSUPPORTED_OPERATION",{operation:"getGasPrice"}),null==s.gasPrice&&(s.gasPrice=t.gasPrice)}else{const t=await e.getFeeData();if(null==s.type)if(null!=t.maxFeePerGas&&null!=t.maxPriorityFeePerGas)if(s.type=2,null!=s.gasPrice){const t=s.gasPrice;delete s.gasPrice,s.maxFeePerGas=t,s.maxPriorityFeePerGas=t}else null==s.maxFeePerGas&&(s.maxFeePerGas=t.maxFeePerGas),null==s.maxPriorityFeePerGas&&(s.maxPriorityFeePerGas=t.maxPriorityFeePerGas);else null!=t.gasPrice?((0,a.vA)(!n,"network does not support EIP-1559","UNSUPPORTED_OPERATION",{operation:"populateTransaction"}),null==s.gasPrice&&(s.gasPrice=t.gasPrice),s.type=0):(0,a.vA)(!1,"failed to get consistent fee data","UNSUPPORTED_OPERATION",{operation:"signer.getFeeData"});else 2!==s.type&&3!==s.type||(null==s.maxFeePerGas&&(s.maxFeePerGas=t.maxFeePerGas),null==s.maxPriorityFeePerGas&&(s.maxPriorityFeePerGas=t.maxPriorityFeePerGas))}else s.type=2;return await(0,i.k)(s)}async estimateGas(t){return c(this,"estimateGas").estimateGas(await this.populateCall(t))}async call(t){return c(this,"call").call(await this.populateCall(t))}async resolveName(t){const e=c(this,"resolveName");return await e.resolveName(t)}async sendTransaction(t){const e=c(this,"sendTransaction"),s=await this.populateTransaction(t);delete s.from;const r=n.Z.from(s);return await e.broadcastTransaction(await this.signTransaction(r))}}},86684:(t,e,s)=>{s.d(e,{Z:()=>n});const r=new Set;function n(t){r.has(t)||r.add(t)}}}]);