@layerzerolabs/verify-contract 1.1.10 → 1.1.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -469,7 +469,7 @@ ${JSON.stringify(r)}`),await x1(async()=>{let i=await lL(this.props.apiUrl,r);if
469
469
 
470
470
  ${JSON.stringify(i)}`),gx(i.result))throw new Error("API Rate limit has been exceeded");return i},3,async(i,n)=>{this.emit("retry",i,n),await $u(2e3);})}async __poll(r){for(;;){this.emit("poll",r);let i=await hL(this.props.apiUrl,r);if(this.logger.verbose(`Received raw polling response from ${this.props.apiUrl}:
471
471
 
472
- ${JSON.stringify(i)}`),i.status===1)return {alreadyVerified:!1};if(_x(i.result))return {alreadyVerified:!0};if(uL(i.result)){await $u(1e4);continue}if(gx(i.result)){await $u(1e4);continue}throw new Error(`Verification failed with result "${i.result}", status ${i.status} (${i.message})`)}}},yx=(t,e)=>new qd(t,e),uL=t=>!!(t!=null&&t.match(/Pending/gi)),_x=t=>!!(t!=null&&t.match(/already verified/gi)),gx=t=>!!(t!=null&&t.match(/rate/)),lL=async(t,e)=>{try{let r=await Bd(t,{method:"POST",form:e,headers:{"Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"}}).json();return xx.parse(r)}catch(r){throw new Error(`Failed to submit verification request: ${r}`)}},hL=async(t,e)=>{let r=new URL(t);r.searchParams.set("module","contract"),r.searchParams.set("action","checkverifystatus"),r.searchParams.set("guid",e);try{let i=await Bd(r).json();return xx.parse(i)}catch(i){throw new Error(`Failed to check verification status: ${i}`)}},cL=({apiKey:t,address:e,contractName:r,constructorArguments:i,compilerVersion:n,optimizerRuns:o=0,sourceCode:s,evmVersion:a,licenseType:u})=>{let l={action:"verifysourcecode",module:"contract",codeformat:"solidity-standard-json-input",contractaddress:e,contractname:r,compilerversion:`v${n}`,optimizationUsed:o>0?"1":"0",sourceCode:s};return t!=null&&(l.apikey=t),o!=null&&(l.runs=String(o)),i!=null&&(l.constructorArguements=i),a!=null&&(l.evmversion=a),u!=null&&(l.licenseType=String(u)),l},xx=Pe.object({status:Pe.coerce.number().nullish(),message:Pe.string().nullish(),result:Pe.string().nullish()});var Ma=$t(Io());Pe.object({enabled:Pe.boolean().optional(),runs:Pe.number().optional()});Pe.record(Pe.string(),Pe.object({content:Pe.string()}));var fL=Pe.array(Pe.record(Pe.string(),Pe.any())),dL=Pe.object({language:Pe.string(),compiler:Pe.object({version:Pe.string()}),settings:Pe.object({compilationTarget:Pe.record(Pe.string(),Pe.string()),evmVersion:Pe.string(),optimizer:Pe.object({enabled:Pe.boolean().optional(),runs:Pe.number().optional()})}),sources:Pe.record(Pe.string(),Pe.object({content:Pe.string()}))}),Hd=Pe.object({address:Pe.string(),abi:fL,args:Pe.array(Pe.any()),solcInputHash:Pe.string(),metadata:Pe.string().transform((t,e)=>{try{return JSON.parse(t)}catch(r){return e.addIssue({code:"custom",message:"Invalid JSON"}),Pe.NEVER}}).pipe(dL),bytecode:Pe.string(),deployedBytecode:Pe.string()});var jd=t=>{let{compilationTarget:e,...r}=t.settings,i=Object.entries(t.sources).reduce((n,[o,s])=>({...n,[o]:{content:s.content}}),{});return {language:t.language,settings:r,sources:i}};var Ix=$t(Ex());var bx="logger/5.7.0";var Tx=!1,Cx=!1,gl={debug:1,default:2,info:2,warning:3,error:4,off:5},Ax=gl.default,Vd=null;function pL(){try{let t=[];if(["NFD","NFC","NFKD","NFKC"].forEach(e=>{try{if("test".normalize(e)!=="test")throw new Error("bad normalize")}catch(r){t.push(e);}}),t.length)throw new Error("missing "+t.join(", "));if("\xE9".normalize("NFD")!=="e\u0301")throw new Error("broken implementation")}catch(t){return t.message}return null}var wx=pL(),$d;(function(t){t.DEBUG="DEBUG",t.INFO="INFO",t.WARNING="WARNING",t.ERROR="ERROR",t.OFF="OFF";})($d||($d={}));var qr;(function(t){t.UNKNOWN_ERROR="UNKNOWN_ERROR",t.NOT_IMPLEMENTED="NOT_IMPLEMENTED",t.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",t.NETWORK_ERROR="NETWORK_ERROR",t.SERVER_ERROR="SERVER_ERROR",t.TIMEOUT="TIMEOUT",t.BUFFER_OVERRUN="BUFFER_OVERRUN",t.NUMERIC_FAULT="NUMERIC_FAULT",t.MISSING_NEW="MISSING_NEW",t.INVALID_ARGUMENT="INVALID_ARGUMENT",t.MISSING_ARGUMENT="MISSING_ARGUMENT",t.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",t.CALL_EXCEPTION="CALL_EXCEPTION",t.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",t.NONCE_EXPIRED="NONCE_EXPIRED",t.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",t.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",t.TRANSACTION_REPLACED="TRANSACTION_REPLACED",t.ACTION_REJECTED="ACTION_REJECTED";})(qr||(qr={}));var Dx="0123456789abcdef",Ie=class t{constructor(e){Object.defineProperty(this,"version",{enumerable:!0,value:e,writable:!1});}_log(e,r){let i=e.toLowerCase();gl[i]==null&&this.throwArgumentError("invalid log level name","logLevel",e),!(Ax>gl[i])&&console.log.apply(console,r);}debug(...e){this._log(t.levels.DEBUG,e);}info(...e){this._log(t.levels.INFO,e);}warn(...e){this._log(t.levels.WARNING,e);}makeError(e,r,i){if(Cx)return this.makeError("censored error",r,{});r||(r=t.errors.UNKNOWN_ERROR),i||(i={});let n=[];Object.keys(i).forEach(u=>{let l=i[u];try{if(l instanceof Uint8Array){let h="";for(let c=0;c<l.length;c++)h+=Dx[l[c]>>4],h+=Dx[l[c]&15];n.push(u+"=Uint8Array(0x"+h+")");}else n.push(u+"="+JSON.stringify(l));}catch(h){n.push(u+"="+JSON.stringify(i[u].toString()));}}),n.push(`code=${r}`),n.push(`version=${this.version}`);let o=e,s="";switch(r){case qr.NUMERIC_FAULT:{s="NUMERIC_FAULT";let u=e;switch(u){case"overflow":case"underflow":case"division-by-zero":s+="-"+u;break;case"negative-power":case"negative-width":s+="-unsupported";break;case"unbound-bitwise-result":s+="-unbound-result";break}break}case qr.CALL_EXCEPTION:case qr.INSUFFICIENT_FUNDS:case qr.MISSING_NEW:case qr.NONCE_EXPIRED:case qr.REPLACEMENT_UNDERPRICED:case qr.TRANSACTION_REPLACED:case qr.UNPREDICTABLE_GAS_LIMIT:s=r;break}s&&(e+=" [ See: https://links.ethers.org/v5-errors-"+s+" ]"),n.length&&(e+=" ("+n.join(", ")+")");let a=new Error(e);return a.reason=o,a.code=r,Object.keys(i).forEach(function(u){a[u]=i[u];}),a}throwError(e,r,i){throw this.makeError(e,r,i)}throwArgumentError(e,r,i){return this.throwError(e,t.errors.INVALID_ARGUMENT,{argument:r,value:i})}assert(e,r,i,n){e||this.throwError(r,i,n);}assertArgument(e,r,i,n){e||this.throwArgumentError(r,i,n);}checkNormalize(e){wx&&this.throwError("platform missing String.prototype.normalize",t.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:wx});}checkSafeUint53(e,r){typeof e=="number"&&(r==null&&(r="value not safe"),(e<0||e>=9007199254740991)&&this.throwError(r,t.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:e}),e%1&&this.throwError(r,t.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:e}));}checkArgumentCount(e,r,i){i?i=": "+i:i="",e<r&&this.throwError("missing argument"+i,t.errors.MISSING_ARGUMENT,{count:e,expectedCount:r}),e>r&&this.throwError("too many arguments"+i,t.errors.UNEXPECTED_ARGUMENT,{count:e,expectedCount:r});}checkNew(e,r){(e===Object||e==null)&&this.throwError("missing new",t.errors.MISSING_NEW,{name:r.name});}checkAbstract(e,r){e===r?this.throwError("cannot instantiate abstract class "+JSON.stringify(r.name)+" directly; use a sub-class",t.errors.UNSUPPORTED_OPERATION,{name:e.name,operation:"new"}):(e===Object||e==null)&&this.throwError("missing new",t.errors.MISSING_NEW,{name:r.name});}static globalLogger(){return Vd||(Vd=new t(bx)),Vd}static setCensorship(e,r){if(!e&&r&&this.globalLogger().throwError("cannot permanently disable censorship",t.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),Tx){if(!e)return;this.globalLogger().throwError("error censorship permanent",t.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"});}Cx=!!e,Tx=!!r;}static setLogLevel(e){let r=gl[e.toLowerCase()];if(r==null){t.globalLogger().warn("invalid log level - "+e);return}Ax=r;}static from(e){return new t(e)}};Ie.errors=qr;Ie.levels=$d;var Sx="bytes/5.7.0";var yi=new Ie(Sx);function Nx(t){return !!t.toHexString}function aa(t){return t.slice||(t.slice=function(){let e=Array.prototype.slice.call(arguments);return aa(new Uint8Array(Array.prototype.slice.apply(t,e)))}),t}function Rx(t){return typeof t=="number"&&t==t&&t%1===0}function yl(t){if(t==null)return !1;if(t.constructor===Uint8Array)return !0;if(typeof t=="string"||!Rx(t.length)||t.length<0)return !1;for(let e=0;e<t.length;e++){let r=t[e];if(!Rx(r)||r<0||r>=256)return !1}return !0}function Lt(t,e){if(e||(e={}),typeof t=="number"){yi.checkSafeUint53(t,"invalid arrayify value");let r=[];for(;t;)r.unshift(t&255),t=parseInt(String(t/256));return r.length===0&&r.push(0),aa(new Uint8Array(r))}if(e.allowMissingPrefix&&typeof t=="string"&&t.substring(0,2)!=="0x"&&(t="0x"+t),Nx(t)&&(t=t.toHexString()),hr(t)){let r=t.substring(2);r.length%2&&(e.hexPad==="left"?r="0"+r:e.hexPad==="right"?r+="0":yi.throwArgumentError("hex data is odd-length","value",t));let i=[];for(let n=0;n<r.length;n+=2)i.push(parseInt(r.substring(n,n+2),16));return aa(new Uint8Array(i))}return yl(t)?aa(new Uint8Array(t)):yi.throwArgumentError("invalid arrayify value","value",t)}function xi(t){let e=t.map(n=>Lt(n)),r=e.reduce((n,o)=>n+o.length,0),i=new Uint8Array(r);return e.reduce((n,o)=>(i.set(o,n),n+o.length),0),aa(i)}function hr(t,e){return !(typeof t!="string"||!t.match(/^0x[0-9A-Fa-f]*$/)||e&&t.length!==2+2*e)}var zd="0123456789abcdef";function Dt(t,e){if(e||(e={}),typeof t=="number"){yi.checkSafeUint53(t,"invalid hexlify value");let r="";for(;t;)r=zd[t&15]+r,t=Math.floor(t/16);return r.length?(r.length%2&&(r="0"+r),"0x"+r):"0x00"}if(typeof t=="bigint")return t=t.toString(16),t.length%2?"0x0"+t:"0x"+t;if(e.allowMissingPrefix&&typeof t=="string"&&t.substring(0,2)!=="0x"&&(t="0x"+t),Nx(t))return t.toHexString();if(hr(t))return t.length%2&&(e.hexPad==="left"?t="0x0"+t.substring(2):e.hexPad==="right"?t+="0":yi.throwArgumentError("hex data is odd-length","value",t)),t.toLowerCase();if(yl(t)){let r="0x";for(let i=0;i<t.length;i++){let n=t[i];r+=zd[(n&240)>>4]+zd[n&15];}return r}return yi.throwArgumentError("invalid hexlify value","value",t)}function Kd(t,e,r){return typeof t!="string"?t=Dt(t):(!hr(t)||t.length%2)&&yi.throwArgumentError("invalid hexData","value",t),e=2+2*e,r!=null?"0x"+t.substring(e,2+2*r):"0x"+t.substring(e)}function Ox(t){let e="0x";return t.forEach(r=>{e+=Dt(r).substring(2);}),e}function xl(t,e){for(typeof t!="string"?t=Dt(t):hr(t)||yi.throwArgumentError("invalid hex string","value",t),t.length>2*e+2&&yi.throwArgumentError("value out of range","value",arguments[1]);t.length<2*e+2;)t="0x0"+t.substring(2);return t}var Fx="bignumber/5.7.0";var vl=Ix.default.BN,vi=new Ie(Fx),Gd={},Lx=9007199254740991;var Px=!1,St=class t{constructor(e,r){e!==Gd&&vi.throwError("cannot call constructor directly; use BigNumber.from",Ie.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=r,this._isBigNumber=!0,Object.freeze(this);}fromTwos(e){return cr(Ke(this).fromTwos(e))}toTwos(e){return cr(Ke(this).toTwos(e))}abs(){return this._hex[0]==="-"?t.from(this._hex.substring(1)):this}add(e){return cr(Ke(this).add(Ke(e)))}sub(e){return cr(Ke(this).sub(Ke(e)))}div(e){return t.from(e).isZero()&&Lr("division-by-zero","div"),cr(Ke(this).div(Ke(e)))}mul(e){return cr(Ke(this).mul(Ke(e)))}mod(e){let r=Ke(e);return r.isNeg()&&Lr("division-by-zero","mod"),cr(Ke(this).umod(r))}pow(e){let r=Ke(e);return r.isNeg()&&Lr("negative-power","pow"),cr(Ke(this).pow(r))}and(e){let r=Ke(e);return (this.isNegative()||r.isNeg())&&Lr("unbound-bitwise-result","and"),cr(Ke(this).and(r))}or(e){let r=Ke(e);return (this.isNegative()||r.isNeg())&&Lr("unbound-bitwise-result","or"),cr(Ke(this).or(r))}xor(e){let r=Ke(e);return (this.isNegative()||r.isNeg())&&Lr("unbound-bitwise-result","xor"),cr(Ke(this).xor(r))}mask(e){return (this.isNegative()||e<0)&&Lr("negative-width","mask"),cr(Ke(this).maskn(e))}shl(e){return (this.isNegative()||e<0)&&Lr("negative-width","shl"),cr(Ke(this).shln(e))}shr(e){return (this.isNegative()||e<0)&&Lr("negative-width","shr"),cr(Ke(this).shrn(e))}eq(e){return Ke(this).eq(Ke(e))}lt(e){return Ke(this).lt(Ke(e))}lte(e){return Ke(this).lte(Ke(e))}gt(e){return Ke(this).gt(Ke(e))}gte(e){return Ke(this).gte(Ke(e))}isNegative(){return this._hex[0]==="-"}isZero(){return Ke(this).isZero()}toNumber(){try{return Ke(this).toNumber()}catch(e){Lr("overflow","toNumber",this.toString());}return null}toBigInt(){try{return BigInt(this.toString())}catch(e){}return vi.throwError("this platform does not support BigInt",Ie.errors.UNSUPPORTED_OPERATION,{value:this.toString()})}toString(){return arguments.length>0&&(arguments[0]===10?Px||(Px=!0,vi.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")):arguments[0]===16?vi.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()",Ie.errors.UNEXPECTED_ARGUMENT,{}):vi.throwError("BigNumber.toString does not accept parameters",Ie.errors.UNEXPECTED_ARGUMENT,{})),Ke(this).toString(10)}toHexString(){return this._hex}toJSON(e){return {type:"BigNumber",hex:this.toHexString()}}static from(e){if(e instanceof t)return e;if(typeof e=="string")return e.match(/^-?0x[0-9a-f]+$/i)?new t(Gd,ua(e)):e.match(/^-?[0-9]+$/)?new t(Gd,ua(new vl(e))):vi.throwArgumentError("invalid BigNumber string","value",e);if(typeof e=="number")return e%1&&Lr("underflow","BigNumber.from",e),(e>=Lx||e<=-Lx)&&Lr("overflow","BigNumber.from",e),t.from(String(e));let r=e;if(typeof r=="bigint")return t.from(r.toString());if(yl(r))return t.from(Dt(r));if(r)if(r.toHexString){let i=r.toHexString();if(typeof i=="string")return t.from(i)}else {let i=r._hex;if(i==null&&r.type==="BigNumber"&&(i=r.hex),typeof i=="string"&&(hr(i)||i[0]==="-"&&hr(i.substring(1))))return t.from(i)}return vi.throwArgumentError("invalid BigNumber value","value",e)}static isBigNumber(e){return !!(e&&e._isBigNumber)}};function ua(t){if(typeof t!="string")return ua(t.toString(16));if(t[0]==="-")return t=t.substring(1),t[0]==="-"&&vi.throwArgumentError("invalid hex","value",t),t=ua(t),t==="0x00"?t:"-"+t;if(t.substring(0,2)!=="0x"&&(t="0x"+t),t==="0x")return "0x00";for(t.length%2&&(t="0x0"+t.substring(2));t.length>4&&t.substring(0,4)==="0x00";)t="0x"+t.substring(4);return t}function cr(t){return St.from(ua(t))}function Ke(t){let e=St.from(t).toHexString();return e[0]==="-"?new vl("-"+e.substring(3),16):new vl(e.substring(2),16)}function Lr(t,e,r){let i={fault:t,operation:e};return r!=null&&(i.value=r),vi.throwError(t,Ie.errors.NUMERIC_FAULT,i)}function Wd(t){return new vl(t,36).toString(16)}var kx="properties/5.7.0";var Mx=new Ie(kx);function kt(t,e,r){Object.defineProperty(t,e,{enumerable:!0,value:r,writable:!1});}function la(t,e){for(let r=0;r<32;r++){if(t[e])return t[e];if(!t.prototype||typeof t.prototype!="object")break;t=Object.getPrototypeOf(t.prototype).constructor;}return null}var _L={bigint:!0,boolean:!0,function:!0,number:!0,string:!0};function Bx(t){if(t==null||_L[typeof t])return !0;if(Array.isArray(t)||typeof t=="object"){if(!Object.isFrozen(t))return !1;let e=Object.keys(t);for(let r=0;r<e.length;r++){let i=null;try{i=t[e[r]];}catch(n){continue}if(!Bx(i))return !1}return !0}return Mx.throwArgumentError(`Cannot deepCopy ${typeof t}`,"object",t)}function gL(t){if(Bx(t))return t;if(Array.isArray(t))return Object.freeze(t.map(e=>Yd(e)));if(typeof t=="object"){let e={};for(let r in t){let i=t[r];i!==void 0&&kt(e,r,Yd(i));}return e}return Mx.throwArgumentError(`Cannot deepCopy ${typeof t}`,"object",t)}function Yd(t){return gL(t)}var Yn=class{constructor(e){for(let r in e)this[r]=Yd(e[r]);}};var Zr="abi/5.7.0";var Ge=new Ie(Zr),Zn={},qx={calldata:!0,memory:!0,storage:!0},yL={calldata:!0,memory:!0};function El(t,e){if(t==="bytes"||t==="string"){if(qx[e])return !0}else if(t==="address"){if(e==="payable")return !0}else if((t.indexOf("[")>=0||t==="tuple")&&yL[e])return !0;return (qx[e]||e==="payable")&&Ge.throwArgumentError("invalid modifier","name",e),!1}function xL(t,e){let r=t;function i(a){Ge.throwArgumentError(`unexpected character at position ${a}`,"param",t);}t=t.replace(/\s/g," ");function n(a){let u={type:"",name:"",parent:a,state:{allowType:!0}};return e&&(u.indexed=!1),u}let o={type:"",name:"",state:{allowType:!0}},s=o;for(let a=0;a<t.length;a++){let u=t[a];switch(u){case"(":s.state.allowType&&s.type===""?s.type="tuple":s.state.allowParams||i(a),s.state.allowType=!1,s.type=Ys(s.type),s.components=[n(s)],s=s.components[0];break;case")":delete s.state,s.name==="indexed"&&(e||i(a),s.indexed=!0,s.name=""),El(s.type,s.name)&&(s.name=""),s.type=Ys(s.type);let l=s;s=s.parent,s||i(a),delete l.parent,s.state.allowParams=!1,s.state.allowName=!0,s.state.allowArray=!0;break;case",":delete s.state,s.name==="indexed"&&(e||i(a),s.indexed=!0,s.name=""),El(s.type,s.name)&&(s.name=""),s.type=Ys(s.type);let h=n(s.parent);s.parent.components.push(h),delete s.parent,s=h;break;case" ":s.state.allowType&&s.type!==""&&(s.type=Ys(s.type),delete s.state.allowType,s.state.allowName=!0,s.state.allowParams=!0),s.state.allowName&&s.name!==""&&(s.name==="indexed"?(e||i(a),s.indexed&&i(a),s.indexed=!0,s.name=""):El(s.type,s.name)?s.name="":s.state.allowName=!1);break;case"[":s.state.allowArray||i(a),s.type+=u,s.state.allowArray=!1,s.state.allowName=!1,s.state.readArray=!0;break;case"]":s.state.readArray||i(a),s.type+=u,s.state.readArray=!1,s.state.allowArray=!0,s.state.allowName=!0;break;default:s.state.allowType?(s.type+=u,s.state.allowParams=!0,s.state.allowArray=!0):s.state.allowName?(s.name+=u,delete s.state.allowArray):s.state.readArray?s.type+=u:i(a);}}return s.parent&&Ge.throwArgumentError("unexpected eof","param",t),delete o.state,s.name==="indexed"?(e||i(r.length-7),s.indexed&&i(r.length-7),s.indexed=!0,s.name=""):El(s.type,s.name)&&(s.name=""),o.type=Ys(o.type),o}function bl(t,e){for(let r in e)kt(t,r,e[r]);}var Ye=Object.freeze({sighash:"sighash",minimal:"minimal",full:"full",json:"json"}),vL=new RegExp(/^(.*)\[([0-9]*)\]$/),fr=class t{constructor(e,r){e!==Zn&&Ge.throwError("use fromString",Ie.errors.UNSUPPORTED_OPERATION,{operation:"new ParamType()"}),bl(this,r);let i=this.type.match(vL);i?bl(this,{arrayLength:parseInt(i[2]||"-1"),arrayChildren:t.fromObject({type:i[1],components:this.components}),baseType:"array"}):bl(this,{arrayLength:null,arrayChildren:null,baseType:this.components!=null?"tuple":this.type}),this._isParamType=!0,Object.freeze(this);}format(e){if(e||(e=Ye.sighash),Ye[e]||Ge.throwArgumentError("invalid format type","format",e),e===Ye.json){let i={type:this.baseType==="tuple"?"tuple":this.type,name:this.name||void 0};return typeof this.indexed=="boolean"&&(i.indexed=this.indexed),this.components&&(i.components=this.components.map(n=>JSON.parse(n.format(e)))),JSON.stringify(i)}let r="";return this.baseType==="array"?(r+=this.arrayChildren.format(e),r+="["+(this.arrayLength<0?"":String(this.arrayLength))+"]"):this.baseType==="tuple"?(e!==Ye.sighash&&(r+=this.type),r+="("+this.components.map(i=>i.format(e)).join(e===Ye.full?", ":",")+")"):r+=this.type,e!==Ye.sighash&&(this.indexed===!0&&(r+=" indexed"),e===Ye.full&&this.name&&(r+=" "+this.name)),r}static from(e,r){return typeof e=="string"?t.fromString(e,r):t.fromObject(e)}static fromObject(e){return t.isParamType(e)?e:new t(Zn,{name:e.name||null,type:Ys(e.type),indexed:e.indexed==null?null:!!e.indexed,components:e.components?e.components.map(t.fromObject):null})}static fromString(e,r){function i(n){return t.fromObject({name:n.name,type:n.type,indexed:n.indexed,components:n.components})}return i(xL(e,!!r))}static isParamType(e){return !!(e!=null&&e._isParamType)}};function ha(t,e){return bL(t).map(r=>fr.fromString(r,e))}var Xn=class t{constructor(e,r){e!==Zn&&Ge.throwError("use a static from method",Ie.errors.UNSUPPORTED_OPERATION,{operation:"new Fragment()"}),bl(this,r),this._isFragment=!0,Object.freeze(this);}static from(e){return t.isFragment(e)?e:typeof e=="string"?t.fromString(e):t.fromObject(e)}static fromObject(e){if(t.isFragment(e))return e;switch(e.type){case"function":return Qn.fromObject(e);case"event":return Zs.fromObject(e);case"constructor":return Jn.fromObject(e);case"error":return Tl.fromObject(e);case"fallback":case"receive":return null}return Ge.throwArgumentError("invalid fragment object","value",e)}static fromString(e){return e=e.replace(/\s/g," "),e=e.replace(/\(/g," (").replace(/\)/g,") ").replace(/\s+/g," "),e=e.trim(),e.split(" ")[0]==="event"?Zs.fromString(e.substring(5).trim()):e.split(" ")[0]==="function"?Qn.fromString(e.substring(8).trim()):e.split("(")[0].trim()==="constructor"?Jn.fromString(e.trim()):e.split(" ")[0]==="error"?Tl.fromString(e.substring(5).trim()):Ge.throwArgumentError("unsupported fragment","value",e)}static isFragment(e){return !!(e&&e._isFragment)}},Zs=class t extends Xn{format(e){if(e||(e=Ye.sighash),Ye[e]||Ge.throwArgumentError("invalid format type","format",e),e===Ye.json)return JSON.stringify({type:"event",anonymous:this.anonymous,name:this.name,inputs:this.inputs.map(i=>JSON.parse(i.format(e)))});let r="";return e!==Ye.sighash&&(r+="event "),r+=this.name+"("+this.inputs.map(i=>i.format(e)).join(e===Ye.full?", ":",")+") ",e!==Ye.sighash&&this.anonymous&&(r+="anonymous "),r.trim()}static from(e){return typeof e=="string"?t.fromString(e):t.fromObject(e)}static fromObject(e){if(t.isEventFragment(e))return e;e.type!=="event"&&Ge.throwArgumentError("invalid event object","value",e);let r={name:ca(e.name),anonymous:e.anonymous,inputs:e.inputs?e.inputs.map(fr.fromObject):[],type:"event"};return new t(Zn,r)}static fromString(e){let r=e.match(fa);r||Ge.throwArgumentError("invalid event string","value",e);let i=!1;return r[3].split(" ").forEach(n=>{switch(n.trim()){case"anonymous":i=!0;break;case"":break;default:Ge.warn("unknown modifier: "+n);}}),t.fromObject({name:r[1].trim(),anonymous:i,inputs:ha(r[2],!0),type:"event"})}static isEventFragment(e){return e&&e._isFragment&&e.type==="event"}};function jx(t,e){e.gas=null;let r=t.split("@");return r.length!==1?(r.length>2&&Ge.throwArgumentError("invalid human-readable ABI signature","value",t),r[1].match(/^[0-9]+$/)||Ge.throwArgumentError("invalid human-readable ABI signature gas","value",t),e.gas=St.from(r[1]),r[0]):t}function Ux(t,e){e.constant=!1,e.payable=!1,e.stateMutability="nonpayable",t.split(" ").forEach(r=>{switch(r.trim()){case"constant":e.constant=!0;break;case"payable":e.payable=!0,e.stateMutability="payable";break;case"nonpayable":e.payable=!1,e.stateMutability="nonpayable";break;case"pure":e.constant=!0,e.stateMutability="pure";break;case"view":e.constant=!0,e.stateMutability="view";break;case"external":case"public":case"":break;default:console.log("unknown modifier: "+r);}});}function Vx(t){let e={constant:!1,payable:!0,stateMutability:"payable"};return t.stateMutability!=null?(e.stateMutability=t.stateMutability,e.constant=e.stateMutability==="view"||e.stateMutability==="pure",t.constant!=null&&!!t.constant!==e.constant&&Ge.throwArgumentError("cannot have constant function with mutability "+e.stateMutability,"value",t),e.payable=e.stateMutability==="payable",t.payable!=null&&!!t.payable!==e.payable&&Ge.throwArgumentError("cannot have payable function with mutability "+e.stateMutability,"value",t)):t.payable!=null?(e.payable=!!t.payable,t.constant==null&&!e.payable&&t.type!=="constructor"&&Ge.throwArgumentError("unable to determine stateMutability","value",t),e.constant=!!t.constant,e.constant?e.stateMutability="view":e.stateMutability=e.payable?"payable":"nonpayable",e.payable&&e.constant&&Ge.throwArgumentError("cannot have constant payable function","value",t)):t.constant!=null?(e.constant=!!t.constant,e.payable=!e.constant,e.stateMutability=e.constant?"view":"payable"):t.type!=="constructor"&&Ge.throwArgumentError("unable to determine stateMutability","value",t),e}var Jn=class t extends Xn{format(e){if(e||(e=Ye.sighash),Ye[e]||Ge.throwArgumentError("invalid format type","format",e),e===Ye.json)return JSON.stringify({type:"constructor",stateMutability:this.stateMutability!=="nonpayable"?this.stateMutability:void 0,payable:this.payable,gas:this.gas?this.gas.toNumber():void 0,inputs:this.inputs.map(i=>JSON.parse(i.format(e)))});e===Ye.sighash&&Ge.throwError("cannot format a constructor for sighash",Ie.errors.UNSUPPORTED_OPERATION,{operation:"format(sighash)"});let r="constructor("+this.inputs.map(i=>i.format(e)).join(e===Ye.full?", ":",")+") ";return this.stateMutability&&this.stateMutability!=="nonpayable"&&(r+=this.stateMutability+" "),r.trim()}static from(e){return typeof e=="string"?t.fromString(e):t.fromObject(e)}static fromObject(e){if(t.isConstructorFragment(e))return e;e.type!=="constructor"&&Ge.throwArgumentError("invalid constructor object","value",e);let r=Vx(e);r.constant&&Ge.throwArgumentError("constructor cannot be constant","value",e);let i={name:null,type:e.type,inputs:e.inputs?e.inputs.map(fr.fromObject):[],payable:r.payable,stateMutability:r.stateMutability,gas:e.gas?St.from(e.gas):null};return new t(Zn,i)}static fromString(e){let r={type:"constructor"};e=jx(e,r);let i=e.match(fa);return (!i||i[1].trim()!=="constructor")&&Ge.throwArgumentError("invalid constructor string","value",e),r.inputs=ha(i[2].trim(),!1),Ux(i[3].trim(),r),t.fromObject(r)}static isConstructorFragment(e){return e&&e._isFragment&&e.type==="constructor"}},Qn=class t extends Jn{format(e){if(e||(e=Ye.sighash),Ye[e]||Ge.throwArgumentError("invalid format type","format",e),e===Ye.json)return JSON.stringify({type:"function",name:this.name,constant:this.constant,stateMutability:this.stateMutability!=="nonpayable"?this.stateMutability:void 0,payable:this.payable,gas:this.gas?this.gas.toNumber():void 0,inputs:this.inputs.map(i=>JSON.parse(i.format(e))),outputs:this.outputs.map(i=>JSON.parse(i.format(e)))});let r="";return e!==Ye.sighash&&(r+="function "),r+=this.name+"("+this.inputs.map(i=>i.format(e)).join(e===Ye.full?", ":",")+") ",e!==Ye.sighash&&(this.stateMutability?this.stateMutability!=="nonpayable"&&(r+=this.stateMutability+" "):this.constant&&(r+="view "),this.outputs&&this.outputs.length&&(r+="returns ("+this.outputs.map(i=>i.format(e)).join(", ")+") "),this.gas!=null&&(r+="@"+this.gas.toString()+" ")),r.trim()}static from(e){return typeof e=="string"?t.fromString(e):t.fromObject(e)}static fromObject(e){if(t.isFunctionFragment(e))return e;e.type!=="function"&&Ge.throwArgumentError("invalid function object","value",e);let r=Vx(e),i={type:e.type,name:ca(e.name),constant:r.constant,inputs:e.inputs?e.inputs.map(fr.fromObject):[],outputs:e.outputs?e.outputs.map(fr.fromObject):[],payable:r.payable,stateMutability:r.stateMutability,gas:e.gas?St.from(e.gas):null};return new t(Zn,i)}static fromString(e){let r={type:"function"};e=jx(e,r);let i=e.split(" returns ");i.length>2&&Ge.throwArgumentError("invalid function string","value",e);let n=i[0].match(fa);if(n||Ge.throwArgumentError("invalid function signature","value",e),r.name=n[1].trim(),r.name&&ca(r.name),r.inputs=ha(n[2],!1),Ux(n[3].trim(),r),i.length>1){let o=i[1].match(fa);(o[1].trim()!=""||o[3].trim()!="")&&Ge.throwArgumentError("unexpected tokens","value",e),r.outputs=ha(o[2],!1);}else r.outputs=[];return t.fromObject(r)}static isFunctionFragment(e){return e&&e._isFragment&&e.type==="function"}};function Hx(t){let e=t.format();return (e==="Error(string)"||e==="Panic(uint256)")&&Ge.throwArgumentError(`cannot specify user defined ${e} error`,"fragment",t),t}var Tl=class t extends Xn{format(e){if(e||(e=Ye.sighash),Ye[e]||Ge.throwArgumentError("invalid format type","format",e),e===Ye.json)return JSON.stringify({type:"error",name:this.name,inputs:this.inputs.map(i=>JSON.parse(i.format(e)))});let r="";return e!==Ye.sighash&&(r+="error "),r+=this.name+"("+this.inputs.map(i=>i.format(e)).join(e===Ye.full?", ":",")+") ",r.trim()}static from(e){return typeof e=="string"?t.fromString(e):t.fromObject(e)}static fromObject(e){if(t.isErrorFragment(e))return e;e.type!=="error"&&Ge.throwArgumentError("invalid error object","value",e);let r={type:e.type,name:ca(e.name),inputs:e.inputs?e.inputs.map(fr.fromObject):[]};return Hx(new t(Zn,r))}static fromString(e){let r={type:"error"},i=e.match(fa);return i||Ge.throwArgumentError("invalid error signature","value",e),r.name=i[1].trim(),r.name&&ca(r.name),r.inputs=ha(i[2],!1),Hx(t.fromObject(r))}static isErrorFragment(e){return e&&e._isFragment&&e.type==="error"}};function Ys(t){return t.match(/^uint($|[^1-9])/)?t="uint256"+t.substring(4):t.match(/^int($|[^1-9])/)&&(t="int256"+t.substring(3)),t}var EL=new RegExp("^[a-zA-Z$_][a-zA-Z0-9$_]*$");function ca(t){return (!t||!t.match(EL))&&Ge.throwArgumentError(`invalid identifier "${t}"`,"value",t),t}var fa=new RegExp("^([^)(]*)\\((.*)\\)([^)(]*)$");function bL(t){t=t.trim();let e=[],r="",i=0;for(let n=0;n<t.length;n++){let o=t[n];o===","&&i===0?(e.push(r),r=""):(r+=o,o==="("?i++:o===")"&&(i--,i===-1&&Ge.throwArgumentError("unbalanced parenthesis","value",t)));}return r&&e.push(r),e}var Zd=new Ie(Zr);var qt=class{constructor(e,r,i,n){this.name=e,this.type=r,this.localName=i,this.dynamic=n;}_throwError(e,r){Zd.throwArgumentError(e,this.localName,r);}},es=class{constructor(e){kt(this,"wordSize",e||32),this._data=[],this._dataLength=0,this._padding=new Uint8Array(e);}get data(){return Ox(this._data)}get length(){return this._dataLength}_writeData(e){return this._data.push(e),this._dataLength+=e.length,e.length}appendWriter(e){return this._writeData(xi(e._data))}writeBytes(e){let r=Lt(e),i=r.length%this.wordSize;return i&&(r=xi([r,this._padding.slice(i)])),this._writeData(r)}_getValue(e){let r=Lt(St.from(e));return r.length>this.wordSize&&Zd.throwError("value out-of-bounds",Ie.errors.BUFFER_OVERRUN,{length:this.wordSize,offset:r.length}),r.length%this.wordSize&&(r=xi([this._padding.slice(r.length%this.wordSize),r])),r}writeValue(e){return this._writeData(this._getValue(e))}writeUpdatableValue(){let e=this._data.length;return this._data.push(this._padding),this._dataLength+=this.wordSize,r=>{this._data[e]=this._getValue(r);}}},Cl=class t{constructor(e,r,i,n){kt(this,"_data",Lt(e)),kt(this,"wordSize",r||32),kt(this,"_coerceFunc",i),kt(this,"allowLoose",n),this._offset=0;}get data(){return Dt(this._data)}get consumed(){return this._offset}static coerce(e,r){let i=e.match("^u?int([0-9]+)$");return i&&parseInt(i[1])<=48&&(r=r.toNumber()),r}coerce(e,r){return this._coerceFunc?this._coerceFunc(e,r):t.coerce(e,r)}_peekBytes(e,r,i){let n=Math.ceil(r/this.wordSize)*this.wordSize;return this._offset+n>this._data.length&&(this.allowLoose&&i&&this._offset+r<=this._data.length?n=r:Zd.throwError("data out-of-bounds",Ie.errors.BUFFER_OVERRUN,{length:this._data.length,offset:this._offset+n})),this._data.slice(this._offset,this._offset+n)}subReader(e){return new t(this._data.slice(this._offset+e),this.wordSize,this._coerceFunc,this.allowLoose)}readBytes(e,r){let i=this._peekBytes(0,e,!!r);return this._offset+=i.length,i.slice(0,e)}readValue(){return St.from(this.readBytes(this.wordSize))}};var zx=$t($x());function ts(t){return "0x"+zx.default.keccak_256(Lt(t))}var Kx="address/5.7.0";var da=new Ie(Kx);function Gx(t){hr(t,20)||da.throwArgumentError("invalid address","address",t),t=t.toLowerCase();let e=t.substring(2).split(""),r=new Uint8Array(40);for(let n=0;n<40;n++)r[n]=e[n].charCodeAt(0);let i=Lt(ts(r));for(let n=0;n<40;n+=2)i[n>>1]>>4>=8&&(e[n]=e[n].toUpperCase()),(i[n>>1]&15)>=8&&(e[n+1]=e[n+1].toUpperCase());return "0x"+e.join("")}var TL=9007199254740991;function CL(t){return Math.log10?Math.log10(t):Math.log(t)/Math.LN10}var Xd={};for(let t=0;t<10;t++)Xd[String(t)]=String(t);for(let t=0;t<26;t++)Xd[String.fromCharCode(65+t)]=String(10+t);var Wx=Math.floor(CL(TL));function AL(t){t=t.toUpperCase(),t=t.substring(4)+t.substring(0,2)+"00";let e=t.split("").map(i=>Xd[i]).join("");for(;e.length>=Wx;){let i=e.substring(0,Wx);e=parseInt(i,10)%97+e.substring(i.length);}let r=String(98-parseInt(e,10)%97);for(;r.length<2;)r="0"+r;return r}function pa(t){let e=null;if(typeof t!="string"&&da.throwArgumentError("invalid address","address",t),t.match(/^(0x)?[0-9a-fA-F]{40}$/))t.substring(0,2)!=="0x"&&(t="0x"+t),e=Gx(t),t.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&e!==t&&da.throwArgumentError("bad address checksum","address",t);else if(t.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(t.substring(2,4)!==AL(t)&&da.throwArgumentError("bad icap checksum","address",t),e=Wd(t.substring(4));e.length<40;)e="0"+e;e=Gx("0x"+e);}else da.throwArgumentError("invalid address","address",t);return e}var wl=class extends qt{constructor(e){super("address","address",e,!1);}defaultValue(){return "0x0000000000000000000000000000000000000000"}encode(e,r){try{r=pa(r);}catch(i){this._throwError(i.message,r);}return e.writeValue(r)}decode(e){return pa(xl(e.readValue().toHexString(),20))}};var Dl=class extends qt{constructor(e){super(e.name,e.type,void 0,e.dynamic),this.coder=e;}defaultValue(){return this.coder.defaultValue()}encode(e,r){return this.coder.encode(e,r)}decode(e){return this.coder.decode(e)}};var Xs=new Ie(Zr);function Jd(t,e,r){let i=null;if(Array.isArray(r))i=r;else if(r&&typeof r=="object"){let u={};i=e.map(l=>{let h=l.localName;return h||Xs.throwError("cannot encode object for signature with missing names",Ie.errors.INVALID_ARGUMENT,{argument:"values",coder:l,value:r}),u[h]&&Xs.throwError("cannot encode object for signature with duplicate names",Ie.errors.INVALID_ARGUMENT,{argument:"values",coder:l,value:r}),u[h]=!0,r[h]});}else Xs.throwArgumentError("invalid tuple value","tuple",r);e.length!==i.length&&Xs.throwArgumentError("types/value length mismatch","tuple",r);let n=new es(t.wordSize),o=new es(t.wordSize),s=[];e.forEach((u,l)=>{let h=i[l];if(u.dynamic){let c=o.length;u.encode(o,h);let p=n.writeUpdatableValue();s.push(f=>{p(f+c);});}else u.encode(n,h);}),s.forEach(u=>{u(n.length);});let a=t.appendWriter(n);return a+=t.appendWriter(o),a}function Qd(t,e){let r=[],i=t.subReader(0);e.forEach(o=>{let s=null;if(o.dynamic){let a=t.readValue(),u=i.subReader(a.toNumber());try{s=o.decode(u);}catch(l){if(l.code===Ie.errors.BUFFER_OVERRUN)throw l;s=l,s.baseType=o.name,s.name=o.localName,s.type=o.type;}}else try{s=o.decode(t);}catch(a){if(a.code===Ie.errors.BUFFER_OVERRUN)throw a;s=a,s.baseType=o.name,s.name=o.localName,s.type=o.type;}s!=null&&r.push(s);});let n=e.reduce((o,s)=>{let a=s.localName;return a&&(o[a]||(o[a]=0),o[a]++),o},{});e.forEach((o,s)=>{let a=o.localName;if(!a||n[a]!==1||(a==="length"&&(a="_length"),r[a]!=null))return;let u=r[s];u instanceof Error?Object.defineProperty(r,a,{enumerable:!0,get:()=>{throw u}}):r[a]=u;});for(let o=0;o<r.length;o++){let s=r[o];s instanceof Error&&Object.defineProperty(r,o,{enumerable:!0,get:()=>{throw s}});}return Object.freeze(r)}var Sl=class extends qt{constructor(e,r,i){let n=e.type+"["+(r>=0?r:"")+"]",o=r===-1||e.dynamic;super("array",n,i,o),this.coder=e,this.length=r;}defaultValue(){let e=this.coder.defaultValue(),r=[];for(let i=0;i<this.length;i++)r.push(e);return r}encode(e,r){Array.isArray(r)||this._throwError("expected array value",r);let i=this.length;i===-1&&(i=r.length,e.writeValue(r.length)),Xs.checkArgumentCount(r.length,i,"coder array"+(this.localName?" "+this.localName:""));let n=[];for(let o=0;o<r.length;o++)n.push(this.coder);return Jd(e,n,r)}decode(e){let r=this.length;r===-1&&(r=e.readValue().toNumber(),r*32>e._data.length&&Xs.throwError("insufficient data length",Ie.errors.BUFFER_OVERRUN,{length:e._data.length,count:r}));let i=[];for(let n=0;n<r;n++)i.push(new Dl(this.coder));return e.coerce(this.name,Qd(e,i))}};var Rl=class extends qt{constructor(e){super("bool","bool",e,!1);}defaultValue(){return !1}encode(e,r){return e.writeValue(r?1:0)}decode(e){return e.coerce(this.type,!e.readValue().isZero())}};var ma=class extends qt{constructor(e,r){super(e,e,r,!0);}defaultValue(){return "0x"}encode(e,r){r=Lt(r);let i=e.writeValue(r.length);return i+=e.writeBytes(r),i}decode(e){return e.readBytes(e.readValue().toNumber(),!0)}},Nl=class extends ma{constructor(e){super("bytes",e);}decode(e){return e.coerce(this.name,Dt(super.decode(e)))}};var Ol=class extends qt{constructor(e,r){let i="bytes"+String(e);super(i,i,r,!1),this.size=e;}defaultValue(){return "0x0000000000000000000000000000000000000000000000000000000000000000".substring(0,2+this.size*2)}encode(e,r){let i=Lt(r);return i.length!==this.size&&this._throwError("incorrect data length",r),e.writeBytes(i)}decode(e){return e.coerce(this.name,Dt(e.readBytes(this.size)))}};var Fl=class extends qt{constructor(e){super("null","",e,!1);}defaultValue(){return null}encode(e,r){return r!=null&&this._throwError("not null",r),e.writeBytes([])}decode(e){return e.readBytes(0),e.coerce(this.name,null)}};var e0=St.from(-1),t0=St.from(0),r0=St.from(1);var i0=St.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");var Ll=class extends qt{constructor(e,r,i){let n=(r?"int":"uint")+e*8;super(n,n,i,!1),this.size=e,this.signed=r;}defaultValue(){return 0}encode(e,r){let i=St.from(r),n=i0.mask(e.wordSize*8);if(this.signed){let o=n.mask(this.size*8-1);(i.gt(o)||i.lt(o.add(r0).mul(e0)))&&this._throwError("value out-of-bounds",r);}else (i.lt(t0)||i.gt(n.mask(this.size*8)))&&this._throwError("value out-of-bounds",r);return i=i.toTwos(this.size*8).mask(this.size*8),this.signed&&(i=i.fromTwos(this.size*8).toTwos(8*e.wordSize)),e.writeValue(i)}decode(e){let r=e.readValue().mask(this.size*8);return this.signed&&(r=r.fromTwos(this.size*8)),e.coerce(this.name,r)}};var Yx="strings/5.7.0";var Zx=new Ie(Yx),_a;(function(t){t.current="",t.NFC="NFC",t.NFD="NFD",t.NFKC="NFKC",t.NFKD="NFKD";})(_a||(_a={}));var dr;(function(t){t.UNEXPECTED_CONTINUE="unexpected continuation byte",t.BAD_PREFIX="bad codepoint prefix",t.OVERRUN="string overrun",t.MISSING_CONTINUE="missing continuation byte",t.OUT_OF_RANGE="out of UTF-8 range",t.UTF16_SURROGATE="UTF-16 surrogate",t.OVERLONG="overlong representation";})(dr||(dr={}));function wL(t,e,r,i,n){return Zx.throwArgumentError(`invalid codepoint at offset ${e}; ${t}`,"bytes",r)}function Xx(t,e,r,i,n){if(t===dr.BAD_PREFIX||t===dr.UNEXPECTED_CONTINUE){let o=0;for(let s=e+1;s<r.length&&r[s]>>6===2;s++)o++;return o}return t===dr.OVERRUN?r.length-e-1:0}function DL(t,e,r,i,n){return t===dr.OVERLONG?(i.push(n),0):(i.push(65533),Xx(t,e,r))}var Jx=Object.freeze({error:wL,ignore:Xx,replace:DL});function SL(t,e){e==null&&(e=Jx.error),t=Lt(t);let r=[],i=0;for(;i<t.length;){let n=t[i++];if(!(n>>7)){r.push(n);continue}let o=null,s=null;if((n&224)===192)o=1,s=127;else if((n&240)===224)o=2,s=2047;else if((n&248)===240)o=3,s=65535;else {(n&192)===128?i+=e(dr.UNEXPECTED_CONTINUE,i-1,t,r):i+=e(dr.BAD_PREFIX,i-1,t,r);continue}if(i-1+o>=t.length){i+=e(dr.OVERRUN,i-1,t,r);continue}let a=n&(1<<8-o-1)-1;for(let u=0;u<o;u++){let l=t[i];if((l&192)!=128){i+=e(dr.MISSING_CONTINUE,i,t,r),a=null;break}a=a<<6|l&63,i++;}if(a!==null){if(a>1114111){i+=e(dr.OUT_OF_RANGE,i-1-o,t,r,a);continue}if(a>=55296&&a<=57343){i+=e(dr.UTF16_SURROGATE,i-1-o,t,r,a);continue}if(a<=s){i+=e(dr.OVERLONG,i-1-o,t,r,a);continue}r.push(a);}}return r}function ga(t,e=_a.current){e!=_a.current&&(Zx.checkNormalize(),t=t.normalize(e));let r=[];for(let i=0;i<t.length;i++){let n=t.charCodeAt(i);if(n<128)r.push(n);else if(n<2048)r.push(n>>6|192),r.push(n&63|128);else if((n&64512)==55296){i++;let o=t.charCodeAt(i);if(i>=t.length||(o&64512)!==56320)throw new Error("invalid utf-8 string");let s=65536+((n&1023)<<10)+(o&1023);r.push(s>>18|240),r.push(s>>12&63|128),r.push(s>>6&63|128),r.push(s&63|128);}else r.push(n>>12|224),r.push(n>>6&63|128),r.push(n&63|128);}return Lt(r)}function RL(t){return t.map(e=>e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10&1023)+55296,(e&1023)+56320))).join("")}function n0(t,e){return RL(SL(t,e))}var Pl=class extends ma{constructor(e){super("string",e);}defaultValue(){return ""}encode(e,r){return super.encode(e,ga(r))}decode(e){return n0(super.decode(e))}};var rs=class extends qt{constructor(e,r){let i=!1,n=[];e.forEach(s=>{s.dynamic&&(i=!0),n.push(s.type);});let o="tuple("+n.join(",")+")";super("tuple",o,r,i),this.coders=e;}defaultValue(){let e=[];this.coders.forEach(i=>{e.push(i.defaultValue());});let r=this.coders.reduce((i,n)=>{let o=n.localName;return o&&(i[o]||(i[o]=0),i[o]++),i},{});return this.coders.forEach((i,n)=>{let o=i.localName;!o||r[o]!==1||(o==="length"&&(o="_length"),e[o]==null&&(e[o]=e[n]));}),Object.freeze(e)}encode(e,r){return Jd(e,this.coders,r)}decode(e){return e.coerce(this.name,Qd(e,this.coders))}};var Il=new Ie(Zr),NL=new RegExp(/^bytes([0-9]*)$/),OL=new RegExp(/^(u?int)([0-9]*)$/),s0=class{constructor(e){kt(this,"coerceFunc",e||null);}_getCoder(e){switch(e.baseType){case"address":return new wl(e.name);case"bool":return new Rl(e.name);case"string":return new Pl(e.name);case"bytes":return new Nl(e.name);case"array":return new Sl(this._getCoder(e.arrayChildren),e.arrayLength,e.name);case"tuple":return new rs((e.components||[]).map(i=>this._getCoder(i)),e.name);case"":return new Fl(e.name)}let r=e.type.match(OL);if(r){let i=parseInt(r[2]||"256");return (i===0||i>256||i%8!==0)&&Il.throwArgumentError("invalid "+r[1]+" bit length","param",e),new Ll(i/8,r[1]==="int",e.name)}if(r=e.type.match(NL),r){let i=parseInt(r[1]);return (i===0||i>32)&&Il.throwArgumentError("invalid bytes length","param",e),new Ol(i,e.name)}return Il.throwArgumentError("invalid type","type",e.type)}_getWordSize(){return 32}_getReader(e,r){return new Cl(e,this._getWordSize(),this.coerceFunc,r)}_getWriter(){return new es(this._getWordSize())}getDefaultValue(e){let r=e.map(n=>this._getCoder(fr.from(n)));return new rs(r,"_").defaultValue()}encode(e,r){e.length!==r.length&&Il.throwError("types/values length mismatch",Ie.errors.INVALID_ARGUMENT,{count:{types:e.length,values:r.length},value:{types:e,values:r}});let i=e.map(s=>this._getCoder(fr.from(s))),n=new rs(i,"_"),o=this._getWriter();return n.encode(o,r),o.data}decode(e,r,i){let n=e.map(s=>this._getCoder(fr.from(s)));return new rs(n,"_").decode(this._getReader(Lt(r),i))}},Qx=new s0;function Js(t){return ts(ga(t))}var Rt=new Ie(Zr);var kl=class extends Yn{},Ml=class extends Yn{},o0=class extends Yn{},ya=class extends Yn{static isIndexed(e){return !!(e&&e._isIndexed)}},FL={"0x08c379a0":{signature:"Error(string)",name:"Error",inputs:["string"],reason:!0},"0x4e487b71":{signature:"Panic(uint256)",name:"Panic",inputs:["uint256"]}};function ev(t,e){let r=new Error(`deferred error during ABI decoding triggered accessing ${t}`);return r.error=e,r}var xa=class{constructor(e){let r=[];typeof e=="string"?r=JSON.parse(e):r=e,kt(this,"fragments",r.map(i=>Xn.from(i)).filter(i=>i!=null)),kt(this,"_abiCoder",la(new.target,"getAbiCoder")()),kt(this,"functions",{}),kt(this,"errors",{}),kt(this,"events",{}),kt(this,"structs",{}),this.fragments.forEach(i=>{let n=null;switch(i.type){case"constructor":if(this.deploy){Rt.warn("duplicate definition - constructor");return}kt(this,"deploy",i);return;case"function":n=this.functions;break;case"event":n=this.events;break;case"error":n=this.errors;break;default:return}let o=i.format();if(n[o]){Rt.warn("duplicate definition - "+o);return}n[o]=i;}),this.deploy||kt(this,"deploy",Jn.from({payable:!1,type:"constructor"})),kt(this,"_isInterface",!0);}format(e){e||(e=Ye.full),e===Ye.sighash&&Rt.throwArgumentError("interface does not support formatting sighash","format",e);let r=this.fragments.map(i=>i.format(e));return e===Ye.json?JSON.stringify(r.map(i=>JSON.parse(i))):r}static getAbiCoder(){return Qx}static getAddress(e){return pa(e)}static getSighash(e){return Kd(Js(e.format()),0,4)}static getEventTopic(e){return Js(e.format())}getFunction(e){if(hr(e)){for(let i in this.functions)if(e===this.getSighash(i))return this.functions[i];Rt.throwArgumentError("no matching function","sighash",e);}if(e.indexOf("(")===-1){let i=e.trim(),n=Object.keys(this.functions).filter(o=>o.split("(")[0]===i);return n.length===0?Rt.throwArgumentError("no matching function","name",i):n.length>1&&Rt.throwArgumentError("multiple matching functions","name",i),this.functions[n[0]]}let r=this.functions[Qn.fromString(e).format()];return r||Rt.throwArgumentError("no matching function","signature",e),r}getEvent(e){if(hr(e)){let i=e.toLowerCase();for(let n in this.events)if(i===this.getEventTopic(n))return this.events[n];Rt.throwArgumentError("no matching event","topichash",i);}if(e.indexOf("(")===-1){let i=e.trim(),n=Object.keys(this.events).filter(o=>o.split("(")[0]===i);return n.length===0?Rt.throwArgumentError("no matching event","name",i):n.length>1&&Rt.throwArgumentError("multiple matching events","name",i),this.events[n[0]]}let r=this.events[Zs.fromString(e).format()];return r||Rt.throwArgumentError("no matching event","signature",e),r}getError(e){if(hr(e)){let i=la(this.constructor,"getSighash");for(let n in this.errors){let o=this.errors[n];if(e===i(o))return this.errors[n]}Rt.throwArgumentError("no matching error","sighash",e);}if(e.indexOf("(")===-1){let i=e.trim(),n=Object.keys(this.errors).filter(o=>o.split("(")[0]===i);return n.length===0?Rt.throwArgumentError("no matching error","name",i):n.length>1&&Rt.throwArgumentError("multiple matching errors","name",i),this.errors[n[0]]}let r=this.errors[Qn.fromString(e).format()];return r||Rt.throwArgumentError("no matching error","signature",e),r}getSighash(e){if(typeof e=="string")try{e=this.getFunction(e);}catch(r){try{e=this.getError(e);}catch(i){throw r}}return la(this.constructor,"getSighash")(e)}getEventTopic(e){return typeof e=="string"&&(e=this.getEvent(e)),la(this.constructor,"getEventTopic")(e)}_decodeParams(e,r){return this._abiCoder.decode(e,r)}_encodeParams(e,r){return this._abiCoder.encode(e,r)}encodeDeploy(e){return this._encodeParams(this.deploy.inputs,e||[])}decodeErrorResult(e,r){typeof e=="string"&&(e=this.getError(e));let i=Lt(r);return Dt(i.slice(0,4))!==this.getSighash(e)&&Rt.throwArgumentError(`data signature does not match error ${e.name}.`,"data",Dt(i)),this._decodeParams(e.inputs,i.slice(4))}encodeErrorResult(e,r){return typeof e=="string"&&(e=this.getError(e)),Dt(xi([this.getSighash(e),this._encodeParams(e.inputs,r||[])]))}decodeFunctionData(e,r){typeof e=="string"&&(e=this.getFunction(e));let i=Lt(r);return Dt(i.slice(0,4))!==this.getSighash(e)&&Rt.throwArgumentError(`data signature does not match function ${e.name}.`,"data",Dt(i)),this._decodeParams(e.inputs,i.slice(4))}encodeFunctionData(e,r){return typeof e=="string"&&(e=this.getFunction(e)),Dt(xi([this.getSighash(e),this._encodeParams(e.inputs,r||[])]))}decodeFunctionResult(e,r){typeof e=="string"&&(e=this.getFunction(e));let i=Lt(r),n=null,o="",s=null,a=null,u=null;switch(i.length%this._abiCoder._getWordSize()){case 0:try{return this._abiCoder.decode(e.outputs,i)}catch(l){}break;case 4:{let l=Dt(i.slice(0,4)),h=FL[l];if(h)s=this._abiCoder.decode(h.inputs,i.slice(4)),a=h.name,u=h.signature,h.reason&&(n=s[0]),a==="Error"?o=`; VM Exception while processing transaction: reverted with reason string ${JSON.stringify(s[0])}`:a==="Panic"&&(o=`; VM Exception while processing transaction: reverted with panic code ${s[0]}`);else try{let c=this.getError(l);s=this._abiCoder.decode(c.inputs,i.slice(4)),a=c.name,u=c.format();}catch(c){}break}}return Rt.throwError("call revert exception"+o,Ie.errors.CALL_EXCEPTION,{method:e.format(),data:Dt(r),errorArgs:s,errorName:a,errorSignature:u,reason:n})}encodeFunctionResult(e,r){return typeof e=="string"&&(e=this.getFunction(e)),Dt(this._abiCoder.encode(e.outputs,r||[]))}encodeFilterTopics(e,r){typeof e=="string"&&(e=this.getEvent(e)),r.length>e.inputs.length&&Rt.throwError("too many arguments for "+e.format(),Ie.errors.UNEXPECTED_ARGUMENT,{argument:"values",value:r});let i=[];e.anonymous||i.push(this.getEventTopic(e));let n=(o,s)=>o.type==="string"?Js(s):o.type==="bytes"?ts(Dt(s)):(o.type==="bool"&&typeof s=="boolean"&&(s=s?"0x01":"0x00"),o.type.match(/^u?int/)&&(s=St.from(s).toHexString()),o.type==="address"&&this._abiCoder.encode(["address"],[s]),xl(Dt(s),32));for(r.forEach((o,s)=>{let a=e.inputs[s];if(!a.indexed){o!=null&&Rt.throwArgumentError("cannot filter non-indexed parameters; must be null","contract."+a.name,o);return}o==null?i.push(null):a.baseType==="array"||a.baseType==="tuple"?Rt.throwArgumentError("filtering with tuples or arrays not supported","contract."+a.name,o):Array.isArray(o)?i.push(o.map(u=>n(a,u))):i.push(n(a,o));});i.length&&i[i.length-1]===null;)i.pop();return i}encodeEventLog(e,r){typeof e=="string"&&(e=this.getEvent(e));let i=[],n=[],o=[];return e.anonymous||i.push(this.getEventTopic(e)),r.length!==e.inputs.length&&Rt.throwArgumentError("event arguments/values mismatch","values",r),e.inputs.forEach((s,a)=>{let u=r[a];if(s.indexed)if(s.type==="string")i.push(Js(u));else if(s.type==="bytes")i.push(ts(u));else {if(s.baseType==="tuple"||s.baseType==="array")throw new Error("not implemented");i.push(this._abiCoder.encode([s.type],[u]));}else n.push(s),o.push(u);}),{data:this._abiCoder.encode(n,o),topics:i}}decodeEventLog(e,r,i){if(typeof e=="string"&&(e=this.getEvent(e)),i!=null&&!e.anonymous){let p=this.getEventTopic(e);(!hr(i[0],32)||i[0].toLowerCase()!==p)&&Rt.throwError("fragment/topic mismatch",Ie.errors.INVALID_ARGUMENT,{argument:"topics[0]",expected:p,value:i[0]}),i=i.slice(1);}let n=[],o=[],s=[];e.inputs.forEach((p,f)=>{p.indexed?p.type==="string"||p.type==="bytes"||p.baseType==="tuple"||p.baseType==="array"?(n.push(fr.fromObject({type:"bytes32",name:p.name})),s.push(!0)):(n.push(p),s.push(!1)):(o.push(p),s.push(!1));});let a=i!=null?this._abiCoder.decode(n,xi(i)):null,u=this._abiCoder.decode(o,r,!0),l=[],h=0,c=0;e.inputs.forEach((p,f)=>{if(p.indexed)if(a==null)l[f]=new ya({_isIndexed:!0,hash:null});else if(s[f])l[f]=new ya({_isIndexed:!0,hash:a[c++]});else try{l[f]=a[c++];}catch(m){l[f]=m;}else try{l[f]=u[h++];}catch(m){l[f]=m;}if(p.name&&l[p.name]==null){let m=l[f];m instanceof Error?Object.defineProperty(l,p.name,{enumerable:!0,get:()=>{throw ev(`property ${JSON.stringify(p.name)}`,m)}}):l[p.name]=m;}});for(let p=0;p<l.length;p++){let f=l[p];f instanceof Error&&Object.defineProperty(l,p,{enumerable:!0,get:()=>{throw ev(`index ${p}`,f)}});}return Object.freeze(l)}parseTransaction(e){let r=this.getFunction(e.data.substring(0,10).toLowerCase());return r?new Ml({args:this._abiCoder.decode(r.inputs,"0x"+e.data.substring(10)),functionFragment:r,name:r.name,signature:r.format(),sighash:this.getSighash(r),value:St.from(e.value||"0")}):null}parseLog(e){let r=this.getEvent(e.topics[0]);return !r||r.anonymous?null:new kl({eventFragment:r,name:r.name,signature:r.format(),topic:this.getEventTopic(r),args:this.decodeEventLog(r,e.data,e.topics)})}parseError(e){let r=Dt(e),i=this.getError(r.substring(0,10).toLowerCase());return i?new o0({args:this._abiCoder.decode(i.inputs,"0x"+r.substring(10)),errorFragment:i,name:i.name,signature:i.format(),sighash:this.getSighash(i)}):null}static isInterface(e){return !!(e&&e._isInterface)}};var mh=$t(HE()),op=(t,e)=>e==null||e.length===0?void 0:new xa(t).encodeDeploy(e).slice(2),UE=t=>{try{let e=mh.parse(t),r;return mh.visit(e,{FunctionDefinition:n=>{n.isConstructor&&(r=n);}}),jE__default.default(r!=null,"Could not find constructor definition"),[{type:"constructor",inputs:r.parameters.map(({typeName:n},o)=>(jE__default.default(n!=null,`Missing a type definition for constructor parameter at position ${o}`),{type:VE(n)}))}]}catch(e){throw new Error(`Could not get an ABI from contract source: ${e}`)}},VE=t=>{switch(t.type){case"ElementaryTypeName":return t.name;case"ArrayTypeName":return `${VE(t.baseTypeName)}[]`;default:throw new Error(`Only primitive and array types are currently supported when constructing ABI from contract source, got ${t.type}`)}};var ap=t=>{var e;return {deployments:(e=t==null?void 0:t.deployments)!=null?e:J8__default.default.resolve(process.cwd(),"deployments")}},$E=t=>{if(t==null)return ()=>!0;switch(typeof t){case"boolean":return ()=>t;case"string":return e=>e===t;case"function":return t;case"object":if(Array.isArray(t)){let e=new Set(t);return r=>e.has(r)}if(t instanceof RegExp)return e=>t.test(e);throw new TypeError(`Invalid verify configuration: expected string, string[], boolean, function or a RegExp, got ${t}`);default:throw new TypeError(`Invalid verify configuration: expected string, string[], boolean, function or a RegExp, got ${t}`)}};var KE=t=>{try{return fs.lstatSync(t).isDirectory()}catch(e){return !1}},GE=t=>{try{return fs.lstatSync(t).isFile()}catch(e){return !1}};var ZE=async(t,e)=>{let r=Ff(e,t.networks),i=ap(t.paths),n=Nf(e),o=JE(e),s=QE(n),a=t.contracts.flatMap(l=>{var te;let{address:h,network:c,contractName:p,deployment:f}=l;e.info(`Collectiong information for contract ${p} on network ${c}`);let m=r[c];if(m==null)return e.info(`No network configured for contract ${p} on network ${c}`),[];let _=`${J8.basename(f,".json")}.json`,x=J8.resolve(i.deployments,c,_);if(!GE(x))return e.error(Gt.error`Deployment file ${x} does not exist or is not a file`),[];let v=me(x),g=Hd.safeParse(v);if(!g.success)return e.error(Gt.error`No network configured for contract ${p} on network ${c}`),[];let b=g.data,E=J8.basename(p,".sol"),w=b.metadata.sources[p];if(w==null)return e.error(Gt.error`Missing source for contract ${p} for network ${c} in ${_}`),[];let D=Pf(w.content),N=UE(w.content),F=op(N,l.constructorArguments),V=jd(b.metadata),X={apiUrl:m.apiUrl,apiKey:m.apiKey,address:h,contractName:`${p}:${E}`,constructorArguments:F,licenseType:D,compilerVersion:b.metadata.compiler.version,sourceCode:JSON.stringify(V),evmVersion:b.metadata.settings.evmVersion,optimizerRuns:(te=b.metadata.settings.optimizer)==null?void 0:te.runs};return n({Contract:p,Network:c,Address:X.address,License:X.licenseType,Arguments:l.constructorArguments?JSON.stringify(l.constructorArguments):void 0,Sources:Object.keys(b.metadata.sources),"Scan URL":X.apiUrl,"Scan API Key":X.apiKey?Rf(X.apiKey):void 0}),[{networkName:c,networkConfig:m,submitProps:X}]});if(a.length===0)return e.warn("No contracts match the verification criteria, exiting"),[];if(t.dryRun)return e.debug("Dry run enabled, exiting"),[];let u=await Promise.all(o(a));return u.forEach(s),u},XE=async(t,e)=>{let r=$E(t.filter),i=Ff(e,t.networks),n=ap(t.paths),o=Nf(e),s=JE(e),a=QE(o);if(!KE(n.deployments))throw new Error(`Path ${n.deployments} is not a directory`);let u=new Set(fs.readdirSync(n.deployments)),l=Object.entries(i);e.debug("Verifying deployments for following networks:"),l.forEach(([p,f])=>{e.debug(` - ${p} (API URL ${f.apiUrl})`);});let h=l.flatMap(([p,f])=>{if(e.info(`Collecting deployments for ${p}...`),!u.has(p))return e.warn(`Could not find deployment for network ${p} in ${n.deployments}`),[];let m=J8.resolve(n.deployments,p);return fs.readdirSync(m).filter(x=>x.endsWith(".json")).flatMap(x=>{e.info(`Inspecting deployment file ${x} on network ${p}`);let v=J8.resolve(m,x),g=me(v),b=Hd.safeParse(g);if(!b.success)throw new Error(`Error parsing deployment file ${x} on network ${p}: ${b.error}`);let E=b.data,w=E.metadata.settings.compilationTarget;return Object.entries(w).flatMap(([D,N])=>{var y;if(!r(N,D,p))return e.debug(`Not verifying ${N} in ${x} on network ${p}`),[];let V=E.metadata.sources[D];if(V==null)return e.error(Gt.error`Could not find source for ${N} (${D})`),[];let X=Pf(V.content),te=op(E.abi,E.args),ae=jd(E.metadata),k={apiUrl:f.apiUrl,apiKey:f.apiKey,address:E.address,contractName:`${D}:${N}`,constructorArguments:te,licenseType:X,compilerVersion:E.metadata.compiler.version,sourceCode:JSON.stringify(ae),evmVersion:E.metadata.settings.evmVersion,optimizerRuns:(y=E.metadata.settings.optimizer)==null?void 0:y.runs};return o({Contract:N,Network:p,Address:E.address,License:k.licenseType,Arguments:JSON.stringify(E.args),Sources:Object.keys(E.metadata.sources),"Scan URL":k.apiUrl,"Scan API Key":k.apiKey?Rf(k.apiKey):void 0}),{submitProps:k,networkName:p,networkConfig:f}})})});if(h.length===0)return e.warn("No contracts match the verification criteria, exiting"),[];if(t.dryRun)return e.debug("Dry run enabled, exiting"),[];let c=await Promise.all(s(h));return c.forEach(a),c},JE=t=>e=>e.map(async(r,i)=>{let{submitProps:n}=r,o=Gt.palette[i%Gt.palette.length],s=`[${i+1}/${e.length}]`,a=Ma.default.bold(n.contractName),u=Ma.default.bold(r.networkName);t.info(o`Verifying contract ${a} for network ${u} ${s}`);try{let l=yx(n,t);l.on("poll",c=>{t.info(o`Polling for verification status of ${a} for network ${u} (GUID ${c}) ${s}`);}),l.on("retry",(c,p)=>{t.verbose(`Received an error: ${c}`),t.info(o`Retrying failed verification attempt of ${a} for network ${u} (attempt ${p+1}) ${s}`);});let h=await l.verify();return {artifact:r,result:h}}catch(l){return t.error(Gt.error`Problem verifying contract ${a} for network ${u} ${s}: ${l} `),{artifact:r,error:l}}}),QE=t=>({artifact:e,response:r,error:i})=>{let n=Ma.default.bold(e.submitProps.contractName),o=Ma.default.bold(e.networkName),s=e.networkConfig.browserUrl?Og(e.networkConfig.browserUrl,e.submitProps.address):void 0;t({Contract:n,Network:o,Result:i==null,"Was verified":r==null?void 0:r.alreadyVerified,"Contract URL":s,Error:i?Gt.error(i):void 0});};var As=$t(o3(),1);$t(aw(),1);var Ro=$t(Io(),1);$t(MR(),1);var BR=(t=>(t.error="error",t.warn="warn",t.info="info",t.http="http",t.verbose="verbose",t.debug="debug",t.silly="silly",t))(BR||{});Pe.nativeEnum(BR);var cU="info";var cg=(t=cU,e=As.format.cli())=>(0, As.createLogger)({level:t,format:e,transports:[new As.transports.Console]});(0, As.format)((t,{label:e})=>({...t,message:`${e?`[${e}] `:""}${t.message}`}));({TRUE:Ro.default.rgb(0,153,0),FALSE:Ro.default.rgb(255,0,0),NOT_APPLICABLE:Ro.default.rgb(255,128,0),DEFAULT_KEY:Ro.default.rgb(255,255,255),DEFAULT_VALUE:Ro.default.rgb(167,125,255)});var qR="1.1.10";var HR=new Nn("-l,--log-level <level>","Log level").choices(["error","warn","info","http","verbose","debug","silly"]).default("info"),jR=new Nn("-d,--deployments <path>","Path to the deployments folder"),UR=new Nn("--dry-run","Do not verify anything, just output the verifications that would be performed"),VR=new Nn("-n,--network <network name>","Network to verify").makeOptionMandatory(),$R=new Nn("-u,--api-url <url>","Scan API URL (fully qualified, with protocol and path)"),zR=new Nn("-k,--api-key <key>","Scan API Key"),dU=new Ru("non-target").description("Verifies a contract that does not have its own deployment file, i.e. has not been a target of a deployment").addOption(HR).addOption(UR).addOption(jR).addOption(VR).addOption($R).addOption(zR).requiredOption("--address <address>","Contract address to verify").requiredOption("--name <contract name>","Fully qualified contract name to verify, e.g. contracts/MyToken.sol").requiredOption("--deployment <deployment file name>","Deployment file name, e.g. MyOtherToken.json").option("--arguments <constructor arguments>",'JSON encoded array of constructor arguments, e.g. [1234, "0x0"]',t=>{try{let e=JSON.parse(t);if(!Array.isArray(e))throw new Error(`Constructor arguments must be an array, got ${e}`);return e}catch(e){throw new Sg(`Malformed constructor arguments specified: ${e}`)}}).action(async t=>{let e=cg(t.logLevel),r={dryRun:t.dryRun,paths:{deployments:t.deployments},networks:{[t.network]:{apiUrl:t.apiUrl,apiKey:t.apiKey}},contracts:[{network:t.network,address:t.address,contractName:t.name,deployment:t.deployment,constructorArguments:t.arguments}]};try{await ZE(r,e);}catch(i){e.error(Gt.error`The verification script exited with an error: ${i}`),process.exit(1);}}),pU=new Ru("target").description("Verifies contracts that have been a part of a deployment, i.e. have their own deployment files").addOption(HR).addOption(UR).addOption(jR).addOption(VR).addOption($R).addOption(zR).option("-c,--contracts <contract names>","Comma-separated list of case-sensitive contract names to verify",t=>t!=null&&t.trim()?t.split(",").map(e=>e.trim()):void 0).action(async t=>{let e=cg(t.logLevel),r={dryRun:t.dryRun,paths:{deployments:t.deployments},networks:{[t.network]:{apiUrl:t.apiUrl,apiKey:t.apiKey}},filter:t.contracts};try{await XE(r,e);}catch(i){e.error(Gt.error`The verification script exited with an error: ${i}`),process.exit(1);}});new Ru("@layerzerolabs/verify-contract").version(qR).description("Verify a set of contracts based on hardhat-deploy outputs").addCommand(dU).addCommand(pU,{isDefault:!0}).parseAsync();
472
+ ${JSON.stringify(i)}`),i.status===1)return {alreadyVerified:!1};if(_x(i.result))return {alreadyVerified:!0};if(uL(i.result)){await $u(1e4);continue}if(gx(i.result)){await $u(1e4);continue}throw new Error(`Verification failed with result "${i.result}", status ${i.status} (${i.message})`)}}},yx=(t,e)=>new qd(t,e),uL=t=>!!(t!=null&&t.match(/Pending/gi)),_x=t=>!!(t!=null&&t.match(/already verified/gi)),gx=t=>!!(t!=null&&t.match(/rate/)),lL=async(t,e)=>{try{let r=await Bd(t,{method:"POST",form:e,headers:{"Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"}}).json();return xx.parse(r)}catch(r){throw new Error(`Failed to submit verification request: ${r}`)}},hL=async(t,e)=>{let r=new URL(t);r.searchParams.set("module","contract"),r.searchParams.set("action","checkverifystatus"),r.searchParams.set("guid",e);try{let i=await Bd(r).json();return xx.parse(i)}catch(i){throw new Error(`Failed to check verification status: ${i}`)}},cL=({apiKey:t,address:e,contractName:r,constructorArguments:i,compilerVersion:n,optimizerRuns:o=0,sourceCode:s,evmVersion:a,licenseType:u})=>{let l={action:"verifysourcecode",module:"contract",codeformat:"solidity-standard-json-input",contractaddress:e,contractname:r,compilerversion:`v${n}`,optimizationUsed:o>0?"1":"0",sourceCode:s};return t!=null&&(l.apikey=t),o!=null&&(l.runs=String(o)),i!=null&&(l.constructorArguements=i),a!=null&&(l.evmversion=a),u!=null&&(l.licenseType=String(u)),l},xx=Pe.object({status:Pe.coerce.number().nullish(),message:Pe.string().nullish(),result:Pe.string().nullish()});var Ma=$t(Io());Pe.object({enabled:Pe.boolean().optional(),runs:Pe.number().optional()});Pe.record(Pe.string(),Pe.object({content:Pe.string()}));var fL=Pe.array(Pe.record(Pe.string(),Pe.any())),dL=Pe.object({language:Pe.string(),compiler:Pe.object({version:Pe.string()}),settings:Pe.object({compilationTarget:Pe.record(Pe.string(),Pe.string()),evmVersion:Pe.string(),optimizer:Pe.object({enabled:Pe.boolean().optional(),runs:Pe.number().optional()})}),sources:Pe.record(Pe.string(),Pe.object({content:Pe.string()}))}),Hd=Pe.object({address:Pe.string(),abi:fL,args:Pe.array(Pe.any()),solcInputHash:Pe.string(),metadata:Pe.string().transform((t,e)=>{try{return JSON.parse(t)}catch(r){return e.addIssue({code:"custom",message:"Invalid JSON"}),Pe.NEVER}}).pipe(dL),bytecode:Pe.string(),deployedBytecode:Pe.string()});var jd=t=>{let{compilationTarget:e,...r}=t.settings,i=Object.entries(t.sources).reduce((n,[o,s])=>({...n,[o]:{content:s.content}}),{});return {language:t.language,settings:r,sources:i}};var Ix=$t(Ex());var bx="logger/5.7.0";var Tx=!1,Cx=!1,gl={debug:1,default:2,info:2,warning:3,error:4,off:5},Ax=gl.default,Vd=null;function pL(){try{let t=[];if(["NFD","NFC","NFKD","NFKC"].forEach(e=>{try{if("test".normalize(e)!=="test")throw new Error("bad normalize")}catch(r){t.push(e);}}),t.length)throw new Error("missing "+t.join(", "));if("\xE9".normalize("NFD")!=="e\u0301")throw new Error("broken implementation")}catch(t){return t.message}return null}var wx=pL(),$d;(function(t){t.DEBUG="DEBUG",t.INFO="INFO",t.WARNING="WARNING",t.ERROR="ERROR",t.OFF="OFF";})($d||($d={}));var qr;(function(t){t.UNKNOWN_ERROR="UNKNOWN_ERROR",t.NOT_IMPLEMENTED="NOT_IMPLEMENTED",t.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",t.NETWORK_ERROR="NETWORK_ERROR",t.SERVER_ERROR="SERVER_ERROR",t.TIMEOUT="TIMEOUT",t.BUFFER_OVERRUN="BUFFER_OVERRUN",t.NUMERIC_FAULT="NUMERIC_FAULT",t.MISSING_NEW="MISSING_NEW",t.INVALID_ARGUMENT="INVALID_ARGUMENT",t.MISSING_ARGUMENT="MISSING_ARGUMENT",t.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",t.CALL_EXCEPTION="CALL_EXCEPTION",t.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",t.NONCE_EXPIRED="NONCE_EXPIRED",t.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",t.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",t.TRANSACTION_REPLACED="TRANSACTION_REPLACED",t.ACTION_REJECTED="ACTION_REJECTED";})(qr||(qr={}));var Dx="0123456789abcdef",Ie=class t{constructor(e){Object.defineProperty(this,"version",{enumerable:!0,value:e,writable:!1});}_log(e,r){let i=e.toLowerCase();gl[i]==null&&this.throwArgumentError("invalid log level name","logLevel",e),!(Ax>gl[i])&&console.log.apply(console,r);}debug(...e){this._log(t.levels.DEBUG,e);}info(...e){this._log(t.levels.INFO,e);}warn(...e){this._log(t.levels.WARNING,e);}makeError(e,r,i){if(Cx)return this.makeError("censored error",r,{});r||(r=t.errors.UNKNOWN_ERROR),i||(i={});let n=[];Object.keys(i).forEach(u=>{let l=i[u];try{if(l instanceof Uint8Array){let h="";for(let c=0;c<l.length;c++)h+=Dx[l[c]>>4],h+=Dx[l[c]&15];n.push(u+"=Uint8Array(0x"+h+")");}else n.push(u+"="+JSON.stringify(l));}catch(h){n.push(u+"="+JSON.stringify(i[u].toString()));}}),n.push(`code=${r}`),n.push(`version=${this.version}`);let o=e,s="";switch(r){case qr.NUMERIC_FAULT:{s="NUMERIC_FAULT";let u=e;switch(u){case"overflow":case"underflow":case"division-by-zero":s+="-"+u;break;case"negative-power":case"negative-width":s+="-unsupported";break;case"unbound-bitwise-result":s+="-unbound-result";break}break}case qr.CALL_EXCEPTION:case qr.INSUFFICIENT_FUNDS:case qr.MISSING_NEW:case qr.NONCE_EXPIRED:case qr.REPLACEMENT_UNDERPRICED:case qr.TRANSACTION_REPLACED:case qr.UNPREDICTABLE_GAS_LIMIT:s=r;break}s&&(e+=" [ See: https://links.ethers.org/v5-errors-"+s+" ]"),n.length&&(e+=" ("+n.join(", ")+")");let a=new Error(e);return a.reason=o,a.code=r,Object.keys(i).forEach(function(u){a[u]=i[u];}),a}throwError(e,r,i){throw this.makeError(e,r,i)}throwArgumentError(e,r,i){return this.throwError(e,t.errors.INVALID_ARGUMENT,{argument:r,value:i})}assert(e,r,i,n){e||this.throwError(r,i,n);}assertArgument(e,r,i,n){e||this.throwArgumentError(r,i,n);}checkNormalize(e){wx&&this.throwError("platform missing String.prototype.normalize",t.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:wx});}checkSafeUint53(e,r){typeof e=="number"&&(r==null&&(r="value not safe"),(e<0||e>=9007199254740991)&&this.throwError(r,t.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:e}),e%1&&this.throwError(r,t.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:e}));}checkArgumentCount(e,r,i){i?i=": "+i:i="",e<r&&this.throwError("missing argument"+i,t.errors.MISSING_ARGUMENT,{count:e,expectedCount:r}),e>r&&this.throwError("too many arguments"+i,t.errors.UNEXPECTED_ARGUMENT,{count:e,expectedCount:r});}checkNew(e,r){(e===Object||e==null)&&this.throwError("missing new",t.errors.MISSING_NEW,{name:r.name});}checkAbstract(e,r){e===r?this.throwError("cannot instantiate abstract class "+JSON.stringify(r.name)+" directly; use a sub-class",t.errors.UNSUPPORTED_OPERATION,{name:e.name,operation:"new"}):(e===Object||e==null)&&this.throwError("missing new",t.errors.MISSING_NEW,{name:r.name});}static globalLogger(){return Vd||(Vd=new t(bx)),Vd}static setCensorship(e,r){if(!e&&r&&this.globalLogger().throwError("cannot permanently disable censorship",t.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),Tx){if(!e)return;this.globalLogger().throwError("error censorship permanent",t.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"});}Cx=!!e,Tx=!!r;}static setLogLevel(e){let r=gl[e.toLowerCase()];if(r==null){t.globalLogger().warn("invalid log level - "+e);return}Ax=r;}static from(e){return new t(e)}};Ie.errors=qr;Ie.levels=$d;var Sx="bytes/5.7.0";var yi=new Ie(Sx);function Nx(t){return !!t.toHexString}function aa(t){return t.slice||(t.slice=function(){let e=Array.prototype.slice.call(arguments);return aa(new Uint8Array(Array.prototype.slice.apply(t,e)))}),t}function Rx(t){return typeof t=="number"&&t==t&&t%1===0}function yl(t){if(t==null)return !1;if(t.constructor===Uint8Array)return !0;if(typeof t=="string"||!Rx(t.length)||t.length<0)return !1;for(let e=0;e<t.length;e++){let r=t[e];if(!Rx(r)||r<0||r>=256)return !1}return !0}function Lt(t,e){if(e||(e={}),typeof t=="number"){yi.checkSafeUint53(t,"invalid arrayify value");let r=[];for(;t;)r.unshift(t&255),t=parseInt(String(t/256));return r.length===0&&r.push(0),aa(new Uint8Array(r))}if(e.allowMissingPrefix&&typeof t=="string"&&t.substring(0,2)!=="0x"&&(t="0x"+t),Nx(t)&&(t=t.toHexString()),hr(t)){let r=t.substring(2);r.length%2&&(e.hexPad==="left"?r="0"+r:e.hexPad==="right"?r+="0":yi.throwArgumentError("hex data is odd-length","value",t));let i=[];for(let n=0;n<r.length;n+=2)i.push(parseInt(r.substring(n,n+2),16));return aa(new Uint8Array(i))}return yl(t)?aa(new Uint8Array(t)):yi.throwArgumentError("invalid arrayify value","value",t)}function xi(t){let e=t.map(n=>Lt(n)),r=e.reduce((n,o)=>n+o.length,0),i=new Uint8Array(r);return e.reduce((n,o)=>(i.set(o,n),n+o.length),0),aa(i)}function hr(t,e){return !(typeof t!="string"||!t.match(/^0x[0-9A-Fa-f]*$/)||e&&t.length!==2+2*e)}var zd="0123456789abcdef";function Dt(t,e){if(e||(e={}),typeof t=="number"){yi.checkSafeUint53(t,"invalid hexlify value");let r="";for(;t;)r=zd[t&15]+r,t=Math.floor(t/16);return r.length?(r.length%2&&(r="0"+r),"0x"+r):"0x00"}if(typeof t=="bigint")return t=t.toString(16),t.length%2?"0x0"+t:"0x"+t;if(e.allowMissingPrefix&&typeof t=="string"&&t.substring(0,2)!=="0x"&&(t="0x"+t),Nx(t))return t.toHexString();if(hr(t))return t.length%2&&(e.hexPad==="left"?t="0x0"+t.substring(2):e.hexPad==="right"?t+="0":yi.throwArgumentError("hex data is odd-length","value",t)),t.toLowerCase();if(yl(t)){let r="0x";for(let i=0;i<t.length;i++){let n=t[i];r+=zd[(n&240)>>4]+zd[n&15];}return r}return yi.throwArgumentError("invalid hexlify value","value",t)}function Kd(t,e,r){return typeof t!="string"?t=Dt(t):(!hr(t)||t.length%2)&&yi.throwArgumentError("invalid hexData","value",t),e=2+2*e,r!=null?"0x"+t.substring(e,2+2*r):"0x"+t.substring(e)}function Ox(t){let e="0x";return t.forEach(r=>{e+=Dt(r).substring(2);}),e}function xl(t,e){for(typeof t!="string"?t=Dt(t):hr(t)||yi.throwArgumentError("invalid hex string","value",t),t.length>2*e+2&&yi.throwArgumentError("value out of range","value",arguments[1]);t.length<2*e+2;)t="0x0"+t.substring(2);return t}var Fx="bignumber/5.7.0";var vl=Ix.default.BN,vi=new Ie(Fx),Gd={},Lx=9007199254740991;var Px=!1,St=class t{constructor(e,r){e!==Gd&&vi.throwError("cannot call constructor directly; use BigNumber.from",Ie.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=r,this._isBigNumber=!0,Object.freeze(this);}fromTwos(e){return cr(Ke(this).fromTwos(e))}toTwos(e){return cr(Ke(this).toTwos(e))}abs(){return this._hex[0]==="-"?t.from(this._hex.substring(1)):this}add(e){return cr(Ke(this).add(Ke(e)))}sub(e){return cr(Ke(this).sub(Ke(e)))}div(e){return t.from(e).isZero()&&Lr("division-by-zero","div"),cr(Ke(this).div(Ke(e)))}mul(e){return cr(Ke(this).mul(Ke(e)))}mod(e){let r=Ke(e);return r.isNeg()&&Lr("division-by-zero","mod"),cr(Ke(this).umod(r))}pow(e){let r=Ke(e);return r.isNeg()&&Lr("negative-power","pow"),cr(Ke(this).pow(r))}and(e){let r=Ke(e);return (this.isNegative()||r.isNeg())&&Lr("unbound-bitwise-result","and"),cr(Ke(this).and(r))}or(e){let r=Ke(e);return (this.isNegative()||r.isNeg())&&Lr("unbound-bitwise-result","or"),cr(Ke(this).or(r))}xor(e){let r=Ke(e);return (this.isNegative()||r.isNeg())&&Lr("unbound-bitwise-result","xor"),cr(Ke(this).xor(r))}mask(e){return (this.isNegative()||e<0)&&Lr("negative-width","mask"),cr(Ke(this).maskn(e))}shl(e){return (this.isNegative()||e<0)&&Lr("negative-width","shl"),cr(Ke(this).shln(e))}shr(e){return (this.isNegative()||e<0)&&Lr("negative-width","shr"),cr(Ke(this).shrn(e))}eq(e){return Ke(this).eq(Ke(e))}lt(e){return Ke(this).lt(Ke(e))}lte(e){return Ke(this).lte(Ke(e))}gt(e){return Ke(this).gt(Ke(e))}gte(e){return Ke(this).gte(Ke(e))}isNegative(){return this._hex[0]==="-"}isZero(){return Ke(this).isZero()}toNumber(){try{return Ke(this).toNumber()}catch(e){Lr("overflow","toNumber",this.toString());}return null}toBigInt(){try{return BigInt(this.toString())}catch(e){}return vi.throwError("this platform does not support BigInt",Ie.errors.UNSUPPORTED_OPERATION,{value:this.toString()})}toString(){return arguments.length>0&&(arguments[0]===10?Px||(Px=!0,vi.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")):arguments[0]===16?vi.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()",Ie.errors.UNEXPECTED_ARGUMENT,{}):vi.throwError("BigNumber.toString does not accept parameters",Ie.errors.UNEXPECTED_ARGUMENT,{})),Ke(this).toString(10)}toHexString(){return this._hex}toJSON(e){return {type:"BigNumber",hex:this.toHexString()}}static from(e){if(e instanceof t)return e;if(typeof e=="string")return e.match(/^-?0x[0-9a-f]+$/i)?new t(Gd,ua(e)):e.match(/^-?[0-9]+$/)?new t(Gd,ua(new vl(e))):vi.throwArgumentError("invalid BigNumber string","value",e);if(typeof e=="number")return e%1&&Lr("underflow","BigNumber.from",e),(e>=Lx||e<=-Lx)&&Lr("overflow","BigNumber.from",e),t.from(String(e));let r=e;if(typeof r=="bigint")return t.from(r.toString());if(yl(r))return t.from(Dt(r));if(r)if(r.toHexString){let i=r.toHexString();if(typeof i=="string")return t.from(i)}else {let i=r._hex;if(i==null&&r.type==="BigNumber"&&(i=r.hex),typeof i=="string"&&(hr(i)||i[0]==="-"&&hr(i.substring(1))))return t.from(i)}return vi.throwArgumentError("invalid BigNumber value","value",e)}static isBigNumber(e){return !!(e&&e._isBigNumber)}};function ua(t){if(typeof t!="string")return ua(t.toString(16));if(t[0]==="-")return t=t.substring(1),t[0]==="-"&&vi.throwArgumentError("invalid hex","value",t),t=ua(t),t==="0x00"?t:"-"+t;if(t.substring(0,2)!=="0x"&&(t="0x"+t),t==="0x")return "0x00";for(t.length%2&&(t="0x0"+t.substring(2));t.length>4&&t.substring(0,4)==="0x00";)t="0x"+t.substring(4);return t}function cr(t){return St.from(ua(t))}function Ke(t){let e=St.from(t).toHexString();return e[0]==="-"?new vl("-"+e.substring(3),16):new vl(e.substring(2),16)}function Lr(t,e,r){let i={fault:t,operation:e};return r!=null&&(i.value=r),vi.throwError(t,Ie.errors.NUMERIC_FAULT,i)}function Wd(t){return new vl(t,36).toString(16)}var kx="properties/5.7.0";var Mx=new Ie(kx);function kt(t,e,r){Object.defineProperty(t,e,{enumerable:!0,value:r,writable:!1});}function la(t,e){for(let r=0;r<32;r++){if(t[e])return t[e];if(!t.prototype||typeof t.prototype!="object")break;t=Object.getPrototypeOf(t.prototype).constructor;}return null}var _L={bigint:!0,boolean:!0,function:!0,number:!0,string:!0};function Bx(t){if(t==null||_L[typeof t])return !0;if(Array.isArray(t)||typeof t=="object"){if(!Object.isFrozen(t))return !1;let e=Object.keys(t);for(let r=0;r<e.length;r++){let i=null;try{i=t[e[r]];}catch(n){continue}if(!Bx(i))return !1}return !0}return Mx.throwArgumentError(`Cannot deepCopy ${typeof t}`,"object",t)}function gL(t){if(Bx(t))return t;if(Array.isArray(t))return Object.freeze(t.map(e=>Yd(e)));if(typeof t=="object"){let e={};for(let r in t){let i=t[r];i!==void 0&&kt(e,r,Yd(i));}return e}return Mx.throwArgumentError(`Cannot deepCopy ${typeof t}`,"object",t)}function Yd(t){return gL(t)}var Yn=class{constructor(e){for(let r in e)this[r]=Yd(e[r]);}};var Zr="abi/5.7.0";var Ge=new Ie(Zr),Zn={},qx={calldata:!0,memory:!0,storage:!0},yL={calldata:!0,memory:!0};function El(t,e){if(t==="bytes"||t==="string"){if(qx[e])return !0}else if(t==="address"){if(e==="payable")return !0}else if((t.indexOf("[")>=0||t==="tuple")&&yL[e])return !0;return (qx[e]||e==="payable")&&Ge.throwArgumentError("invalid modifier","name",e),!1}function xL(t,e){let r=t;function i(a){Ge.throwArgumentError(`unexpected character at position ${a}`,"param",t);}t=t.replace(/\s/g," ");function n(a){let u={type:"",name:"",parent:a,state:{allowType:!0}};return e&&(u.indexed=!1),u}let o={type:"",name:"",state:{allowType:!0}},s=o;for(let a=0;a<t.length;a++){let u=t[a];switch(u){case"(":s.state.allowType&&s.type===""?s.type="tuple":s.state.allowParams||i(a),s.state.allowType=!1,s.type=Ys(s.type),s.components=[n(s)],s=s.components[0];break;case")":delete s.state,s.name==="indexed"&&(e||i(a),s.indexed=!0,s.name=""),El(s.type,s.name)&&(s.name=""),s.type=Ys(s.type);let l=s;s=s.parent,s||i(a),delete l.parent,s.state.allowParams=!1,s.state.allowName=!0,s.state.allowArray=!0;break;case",":delete s.state,s.name==="indexed"&&(e||i(a),s.indexed=!0,s.name=""),El(s.type,s.name)&&(s.name=""),s.type=Ys(s.type);let h=n(s.parent);s.parent.components.push(h),delete s.parent,s=h;break;case" ":s.state.allowType&&s.type!==""&&(s.type=Ys(s.type),delete s.state.allowType,s.state.allowName=!0,s.state.allowParams=!0),s.state.allowName&&s.name!==""&&(s.name==="indexed"?(e||i(a),s.indexed&&i(a),s.indexed=!0,s.name=""):El(s.type,s.name)?s.name="":s.state.allowName=!1);break;case"[":s.state.allowArray||i(a),s.type+=u,s.state.allowArray=!1,s.state.allowName=!1,s.state.readArray=!0;break;case"]":s.state.readArray||i(a),s.type+=u,s.state.readArray=!1,s.state.allowArray=!0,s.state.allowName=!0;break;default:s.state.allowType?(s.type+=u,s.state.allowParams=!0,s.state.allowArray=!0):s.state.allowName?(s.name+=u,delete s.state.allowArray):s.state.readArray?s.type+=u:i(a);}}return s.parent&&Ge.throwArgumentError("unexpected eof","param",t),delete o.state,s.name==="indexed"?(e||i(r.length-7),s.indexed&&i(r.length-7),s.indexed=!0,s.name=""):El(s.type,s.name)&&(s.name=""),o.type=Ys(o.type),o}function bl(t,e){for(let r in e)kt(t,r,e[r]);}var Ye=Object.freeze({sighash:"sighash",minimal:"minimal",full:"full",json:"json"}),vL=new RegExp(/^(.*)\[([0-9]*)\]$/),fr=class t{constructor(e,r){e!==Zn&&Ge.throwError("use fromString",Ie.errors.UNSUPPORTED_OPERATION,{operation:"new ParamType()"}),bl(this,r);let i=this.type.match(vL);i?bl(this,{arrayLength:parseInt(i[2]||"-1"),arrayChildren:t.fromObject({type:i[1],components:this.components}),baseType:"array"}):bl(this,{arrayLength:null,arrayChildren:null,baseType:this.components!=null?"tuple":this.type}),this._isParamType=!0,Object.freeze(this);}format(e){if(e||(e=Ye.sighash),Ye[e]||Ge.throwArgumentError("invalid format type","format",e),e===Ye.json){let i={type:this.baseType==="tuple"?"tuple":this.type,name:this.name||void 0};return typeof this.indexed=="boolean"&&(i.indexed=this.indexed),this.components&&(i.components=this.components.map(n=>JSON.parse(n.format(e)))),JSON.stringify(i)}let r="";return this.baseType==="array"?(r+=this.arrayChildren.format(e),r+="["+(this.arrayLength<0?"":String(this.arrayLength))+"]"):this.baseType==="tuple"?(e!==Ye.sighash&&(r+=this.type),r+="("+this.components.map(i=>i.format(e)).join(e===Ye.full?", ":",")+")"):r+=this.type,e!==Ye.sighash&&(this.indexed===!0&&(r+=" indexed"),e===Ye.full&&this.name&&(r+=" "+this.name)),r}static from(e,r){return typeof e=="string"?t.fromString(e,r):t.fromObject(e)}static fromObject(e){return t.isParamType(e)?e:new t(Zn,{name:e.name||null,type:Ys(e.type),indexed:e.indexed==null?null:!!e.indexed,components:e.components?e.components.map(t.fromObject):null})}static fromString(e,r){function i(n){return t.fromObject({name:n.name,type:n.type,indexed:n.indexed,components:n.components})}return i(xL(e,!!r))}static isParamType(e){return !!(e!=null&&e._isParamType)}};function ha(t,e){return bL(t).map(r=>fr.fromString(r,e))}var Xn=class t{constructor(e,r){e!==Zn&&Ge.throwError("use a static from method",Ie.errors.UNSUPPORTED_OPERATION,{operation:"new Fragment()"}),bl(this,r),this._isFragment=!0,Object.freeze(this);}static from(e){return t.isFragment(e)?e:typeof e=="string"?t.fromString(e):t.fromObject(e)}static fromObject(e){if(t.isFragment(e))return e;switch(e.type){case"function":return Qn.fromObject(e);case"event":return Zs.fromObject(e);case"constructor":return Jn.fromObject(e);case"error":return Tl.fromObject(e);case"fallback":case"receive":return null}return Ge.throwArgumentError("invalid fragment object","value",e)}static fromString(e){return e=e.replace(/\s/g," "),e=e.replace(/\(/g," (").replace(/\)/g,") ").replace(/\s+/g," "),e=e.trim(),e.split(" ")[0]==="event"?Zs.fromString(e.substring(5).trim()):e.split(" ")[0]==="function"?Qn.fromString(e.substring(8).trim()):e.split("(")[0].trim()==="constructor"?Jn.fromString(e.trim()):e.split(" ")[0]==="error"?Tl.fromString(e.substring(5).trim()):Ge.throwArgumentError("unsupported fragment","value",e)}static isFragment(e){return !!(e&&e._isFragment)}},Zs=class t extends Xn{format(e){if(e||(e=Ye.sighash),Ye[e]||Ge.throwArgumentError("invalid format type","format",e),e===Ye.json)return JSON.stringify({type:"event",anonymous:this.anonymous,name:this.name,inputs:this.inputs.map(i=>JSON.parse(i.format(e)))});let r="";return e!==Ye.sighash&&(r+="event "),r+=this.name+"("+this.inputs.map(i=>i.format(e)).join(e===Ye.full?", ":",")+") ",e!==Ye.sighash&&this.anonymous&&(r+="anonymous "),r.trim()}static from(e){return typeof e=="string"?t.fromString(e):t.fromObject(e)}static fromObject(e){if(t.isEventFragment(e))return e;e.type!=="event"&&Ge.throwArgumentError("invalid event object","value",e);let r={name:ca(e.name),anonymous:e.anonymous,inputs:e.inputs?e.inputs.map(fr.fromObject):[],type:"event"};return new t(Zn,r)}static fromString(e){let r=e.match(fa);r||Ge.throwArgumentError("invalid event string","value",e);let i=!1;return r[3].split(" ").forEach(n=>{switch(n.trim()){case"anonymous":i=!0;break;case"":break;default:Ge.warn("unknown modifier: "+n);}}),t.fromObject({name:r[1].trim(),anonymous:i,inputs:ha(r[2],!0),type:"event"})}static isEventFragment(e){return e&&e._isFragment&&e.type==="event"}};function jx(t,e){e.gas=null;let r=t.split("@");return r.length!==1?(r.length>2&&Ge.throwArgumentError("invalid human-readable ABI signature","value",t),r[1].match(/^[0-9]+$/)||Ge.throwArgumentError("invalid human-readable ABI signature gas","value",t),e.gas=St.from(r[1]),r[0]):t}function Ux(t,e){e.constant=!1,e.payable=!1,e.stateMutability="nonpayable",t.split(" ").forEach(r=>{switch(r.trim()){case"constant":e.constant=!0;break;case"payable":e.payable=!0,e.stateMutability="payable";break;case"nonpayable":e.payable=!1,e.stateMutability="nonpayable";break;case"pure":e.constant=!0,e.stateMutability="pure";break;case"view":e.constant=!0,e.stateMutability="view";break;case"external":case"public":case"":break;default:console.log("unknown modifier: "+r);}});}function Vx(t){let e={constant:!1,payable:!0,stateMutability:"payable"};return t.stateMutability!=null?(e.stateMutability=t.stateMutability,e.constant=e.stateMutability==="view"||e.stateMutability==="pure",t.constant!=null&&!!t.constant!==e.constant&&Ge.throwArgumentError("cannot have constant function with mutability "+e.stateMutability,"value",t),e.payable=e.stateMutability==="payable",t.payable!=null&&!!t.payable!==e.payable&&Ge.throwArgumentError("cannot have payable function with mutability "+e.stateMutability,"value",t)):t.payable!=null?(e.payable=!!t.payable,t.constant==null&&!e.payable&&t.type!=="constructor"&&Ge.throwArgumentError("unable to determine stateMutability","value",t),e.constant=!!t.constant,e.constant?e.stateMutability="view":e.stateMutability=e.payable?"payable":"nonpayable",e.payable&&e.constant&&Ge.throwArgumentError("cannot have constant payable function","value",t)):t.constant!=null?(e.constant=!!t.constant,e.payable=!e.constant,e.stateMutability=e.constant?"view":"payable"):t.type!=="constructor"&&Ge.throwArgumentError("unable to determine stateMutability","value",t),e}var Jn=class t extends Xn{format(e){if(e||(e=Ye.sighash),Ye[e]||Ge.throwArgumentError("invalid format type","format",e),e===Ye.json)return JSON.stringify({type:"constructor",stateMutability:this.stateMutability!=="nonpayable"?this.stateMutability:void 0,payable:this.payable,gas:this.gas?this.gas.toNumber():void 0,inputs:this.inputs.map(i=>JSON.parse(i.format(e)))});e===Ye.sighash&&Ge.throwError("cannot format a constructor for sighash",Ie.errors.UNSUPPORTED_OPERATION,{operation:"format(sighash)"});let r="constructor("+this.inputs.map(i=>i.format(e)).join(e===Ye.full?", ":",")+") ";return this.stateMutability&&this.stateMutability!=="nonpayable"&&(r+=this.stateMutability+" "),r.trim()}static from(e){return typeof e=="string"?t.fromString(e):t.fromObject(e)}static fromObject(e){if(t.isConstructorFragment(e))return e;e.type!=="constructor"&&Ge.throwArgumentError("invalid constructor object","value",e);let r=Vx(e);r.constant&&Ge.throwArgumentError("constructor cannot be constant","value",e);let i={name:null,type:e.type,inputs:e.inputs?e.inputs.map(fr.fromObject):[],payable:r.payable,stateMutability:r.stateMutability,gas:e.gas?St.from(e.gas):null};return new t(Zn,i)}static fromString(e){let r={type:"constructor"};e=jx(e,r);let i=e.match(fa);return (!i||i[1].trim()!=="constructor")&&Ge.throwArgumentError("invalid constructor string","value",e),r.inputs=ha(i[2].trim(),!1),Ux(i[3].trim(),r),t.fromObject(r)}static isConstructorFragment(e){return e&&e._isFragment&&e.type==="constructor"}},Qn=class t extends Jn{format(e){if(e||(e=Ye.sighash),Ye[e]||Ge.throwArgumentError("invalid format type","format",e),e===Ye.json)return JSON.stringify({type:"function",name:this.name,constant:this.constant,stateMutability:this.stateMutability!=="nonpayable"?this.stateMutability:void 0,payable:this.payable,gas:this.gas?this.gas.toNumber():void 0,inputs:this.inputs.map(i=>JSON.parse(i.format(e))),outputs:this.outputs.map(i=>JSON.parse(i.format(e)))});let r="";return e!==Ye.sighash&&(r+="function "),r+=this.name+"("+this.inputs.map(i=>i.format(e)).join(e===Ye.full?", ":",")+") ",e!==Ye.sighash&&(this.stateMutability?this.stateMutability!=="nonpayable"&&(r+=this.stateMutability+" "):this.constant&&(r+="view "),this.outputs&&this.outputs.length&&(r+="returns ("+this.outputs.map(i=>i.format(e)).join(", ")+") "),this.gas!=null&&(r+="@"+this.gas.toString()+" ")),r.trim()}static from(e){return typeof e=="string"?t.fromString(e):t.fromObject(e)}static fromObject(e){if(t.isFunctionFragment(e))return e;e.type!=="function"&&Ge.throwArgumentError("invalid function object","value",e);let r=Vx(e),i={type:e.type,name:ca(e.name),constant:r.constant,inputs:e.inputs?e.inputs.map(fr.fromObject):[],outputs:e.outputs?e.outputs.map(fr.fromObject):[],payable:r.payable,stateMutability:r.stateMutability,gas:e.gas?St.from(e.gas):null};return new t(Zn,i)}static fromString(e){let r={type:"function"};e=jx(e,r);let i=e.split(" returns ");i.length>2&&Ge.throwArgumentError("invalid function string","value",e);let n=i[0].match(fa);if(n||Ge.throwArgumentError("invalid function signature","value",e),r.name=n[1].trim(),r.name&&ca(r.name),r.inputs=ha(n[2],!1),Ux(n[3].trim(),r),i.length>1){let o=i[1].match(fa);(o[1].trim()!=""||o[3].trim()!="")&&Ge.throwArgumentError("unexpected tokens","value",e),r.outputs=ha(o[2],!1);}else r.outputs=[];return t.fromObject(r)}static isFunctionFragment(e){return e&&e._isFragment&&e.type==="function"}};function Hx(t){let e=t.format();return (e==="Error(string)"||e==="Panic(uint256)")&&Ge.throwArgumentError(`cannot specify user defined ${e} error`,"fragment",t),t}var Tl=class t extends Xn{format(e){if(e||(e=Ye.sighash),Ye[e]||Ge.throwArgumentError("invalid format type","format",e),e===Ye.json)return JSON.stringify({type:"error",name:this.name,inputs:this.inputs.map(i=>JSON.parse(i.format(e)))});let r="";return e!==Ye.sighash&&(r+="error "),r+=this.name+"("+this.inputs.map(i=>i.format(e)).join(e===Ye.full?", ":",")+") ",r.trim()}static from(e){return typeof e=="string"?t.fromString(e):t.fromObject(e)}static fromObject(e){if(t.isErrorFragment(e))return e;e.type!=="error"&&Ge.throwArgumentError("invalid error object","value",e);let r={type:e.type,name:ca(e.name),inputs:e.inputs?e.inputs.map(fr.fromObject):[]};return Hx(new t(Zn,r))}static fromString(e){let r={type:"error"},i=e.match(fa);return i||Ge.throwArgumentError("invalid error signature","value",e),r.name=i[1].trim(),r.name&&ca(r.name),r.inputs=ha(i[2],!1),Hx(t.fromObject(r))}static isErrorFragment(e){return e&&e._isFragment&&e.type==="error"}};function Ys(t){return t.match(/^uint($|[^1-9])/)?t="uint256"+t.substring(4):t.match(/^int($|[^1-9])/)&&(t="int256"+t.substring(3)),t}var EL=new RegExp("^[a-zA-Z$_][a-zA-Z0-9$_]*$");function ca(t){return (!t||!t.match(EL))&&Ge.throwArgumentError(`invalid identifier "${t}"`,"value",t),t}var fa=new RegExp("^([^)(]*)\\((.*)\\)([^)(]*)$");function bL(t){t=t.trim();let e=[],r="",i=0;for(let n=0;n<t.length;n++){let o=t[n];o===","&&i===0?(e.push(r),r=""):(r+=o,o==="("?i++:o===")"&&(i--,i===-1&&Ge.throwArgumentError("unbalanced parenthesis","value",t)));}return r&&e.push(r),e}var Zd=new Ie(Zr);var qt=class{constructor(e,r,i,n){this.name=e,this.type=r,this.localName=i,this.dynamic=n;}_throwError(e,r){Zd.throwArgumentError(e,this.localName,r);}},es=class{constructor(e){kt(this,"wordSize",e||32),this._data=[],this._dataLength=0,this._padding=new Uint8Array(e);}get data(){return Ox(this._data)}get length(){return this._dataLength}_writeData(e){return this._data.push(e),this._dataLength+=e.length,e.length}appendWriter(e){return this._writeData(xi(e._data))}writeBytes(e){let r=Lt(e),i=r.length%this.wordSize;return i&&(r=xi([r,this._padding.slice(i)])),this._writeData(r)}_getValue(e){let r=Lt(St.from(e));return r.length>this.wordSize&&Zd.throwError("value out-of-bounds",Ie.errors.BUFFER_OVERRUN,{length:this.wordSize,offset:r.length}),r.length%this.wordSize&&(r=xi([this._padding.slice(r.length%this.wordSize),r])),r}writeValue(e){return this._writeData(this._getValue(e))}writeUpdatableValue(){let e=this._data.length;return this._data.push(this._padding),this._dataLength+=this.wordSize,r=>{this._data[e]=this._getValue(r);}}},Cl=class t{constructor(e,r,i,n){kt(this,"_data",Lt(e)),kt(this,"wordSize",r||32),kt(this,"_coerceFunc",i),kt(this,"allowLoose",n),this._offset=0;}get data(){return Dt(this._data)}get consumed(){return this._offset}static coerce(e,r){let i=e.match("^u?int([0-9]+)$");return i&&parseInt(i[1])<=48&&(r=r.toNumber()),r}coerce(e,r){return this._coerceFunc?this._coerceFunc(e,r):t.coerce(e,r)}_peekBytes(e,r,i){let n=Math.ceil(r/this.wordSize)*this.wordSize;return this._offset+n>this._data.length&&(this.allowLoose&&i&&this._offset+r<=this._data.length?n=r:Zd.throwError("data out-of-bounds",Ie.errors.BUFFER_OVERRUN,{length:this._data.length,offset:this._offset+n})),this._data.slice(this._offset,this._offset+n)}subReader(e){return new t(this._data.slice(this._offset+e),this.wordSize,this._coerceFunc,this.allowLoose)}readBytes(e,r){let i=this._peekBytes(0,e,!!r);return this._offset+=i.length,i.slice(0,e)}readValue(){return St.from(this.readBytes(this.wordSize))}};var zx=$t($x());function ts(t){return "0x"+zx.default.keccak_256(Lt(t))}var Kx="address/5.7.0";var da=new Ie(Kx);function Gx(t){hr(t,20)||da.throwArgumentError("invalid address","address",t),t=t.toLowerCase();let e=t.substring(2).split(""),r=new Uint8Array(40);for(let n=0;n<40;n++)r[n]=e[n].charCodeAt(0);let i=Lt(ts(r));for(let n=0;n<40;n+=2)i[n>>1]>>4>=8&&(e[n]=e[n].toUpperCase()),(i[n>>1]&15)>=8&&(e[n+1]=e[n+1].toUpperCase());return "0x"+e.join("")}var TL=9007199254740991;function CL(t){return Math.log10?Math.log10(t):Math.log(t)/Math.LN10}var Xd={};for(let t=0;t<10;t++)Xd[String(t)]=String(t);for(let t=0;t<26;t++)Xd[String.fromCharCode(65+t)]=String(10+t);var Wx=Math.floor(CL(TL));function AL(t){t=t.toUpperCase(),t=t.substring(4)+t.substring(0,2)+"00";let e=t.split("").map(i=>Xd[i]).join("");for(;e.length>=Wx;){let i=e.substring(0,Wx);e=parseInt(i,10)%97+e.substring(i.length);}let r=String(98-parseInt(e,10)%97);for(;r.length<2;)r="0"+r;return r}function pa(t){let e=null;if(typeof t!="string"&&da.throwArgumentError("invalid address","address",t),t.match(/^(0x)?[0-9a-fA-F]{40}$/))t.substring(0,2)!=="0x"&&(t="0x"+t),e=Gx(t),t.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&e!==t&&da.throwArgumentError("bad address checksum","address",t);else if(t.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(t.substring(2,4)!==AL(t)&&da.throwArgumentError("bad icap checksum","address",t),e=Wd(t.substring(4));e.length<40;)e="0"+e;e=Gx("0x"+e);}else da.throwArgumentError("invalid address","address",t);return e}var wl=class extends qt{constructor(e){super("address","address",e,!1);}defaultValue(){return "0x0000000000000000000000000000000000000000"}encode(e,r){try{r=pa(r);}catch(i){this._throwError(i.message,r);}return e.writeValue(r)}decode(e){return pa(xl(e.readValue().toHexString(),20))}};var Dl=class extends qt{constructor(e){super(e.name,e.type,void 0,e.dynamic),this.coder=e;}defaultValue(){return this.coder.defaultValue()}encode(e,r){return this.coder.encode(e,r)}decode(e){return this.coder.decode(e)}};var Xs=new Ie(Zr);function Jd(t,e,r){let i=null;if(Array.isArray(r))i=r;else if(r&&typeof r=="object"){let u={};i=e.map(l=>{let h=l.localName;return h||Xs.throwError("cannot encode object for signature with missing names",Ie.errors.INVALID_ARGUMENT,{argument:"values",coder:l,value:r}),u[h]&&Xs.throwError("cannot encode object for signature with duplicate names",Ie.errors.INVALID_ARGUMENT,{argument:"values",coder:l,value:r}),u[h]=!0,r[h]});}else Xs.throwArgumentError("invalid tuple value","tuple",r);e.length!==i.length&&Xs.throwArgumentError("types/value length mismatch","tuple",r);let n=new es(t.wordSize),o=new es(t.wordSize),s=[];e.forEach((u,l)=>{let h=i[l];if(u.dynamic){let c=o.length;u.encode(o,h);let p=n.writeUpdatableValue();s.push(f=>{p(f+c);});}else u.encode(n,h);}),s.forEach(u=>{u(n.length);});let a=t.appendWriter(n);return a+=t.appendWriter(o),a}function Qd(t,e){let r=[],i=t.subReader(0);e.forEach(o=>{let s=null;if(o.dynamic){let a=t.readValue(),u=i.subReader(a.toNumber());try{s=o.decode(u);}catch(l){if(l.code===Ie.errors.BUFFER_OVERRUN)throw l;s=l,s.baseType=o.name,s.name=o.localName,s.type=o.type;}}else try{s=o.decode(t);}catch(a){if(a.code===Ie.errors.BUFFER_OVERRUN)throw a;s=a,s.baseType=o.name,s.name=o.localName,s.type=o.type;}s!=null&&r.push(s);});let n=e.reduce((o,s)=>{let a=s.localName;return a&&(o[a]||(o[a]=0),o[a]++),o},{});e.forEach((o,s)=>{let a=o.localName;if(!a||n[a]!==1||(a==="length"&&(a="_length"),r[a]!=null))return;let u=r[s];u instanceof Error?Object.defineProperty(r,a,{enumerable:!0,get:()=>{throw u}}):r[a]=u;});for(let o=0;o<r.length;o++){let s=r[o];s instanceof Error&&Object.defineProperty(r,o,{enumerable:!0,get:()=>{throw s}});}return Object.freeze(r)}var Sl=class extends qt{constructor(e,r,i){let n=e.type+"["+(r>=0?r:"")+"]",o=r===-1||e.dynamic;super("array",n,i,o),this.coder=e,this.length=r;}defaultValue(){let e=this.coder.defaultValue(),r=[];for(let i=0;i<this.length;i++)r.push(e);return r}encode(e,r){Array.isArray(r)||this._throwError("expected array value",r);let i=this.length;i===-1&&(i=r.length,e.writeValue(r.length)),Xs.checkArgumentCount(r.length,i,"coder array"+(this.localName?" "+this.localName:""));let n=[];for(let o=0;o<r.length;o++)n.push(this.coder);return Jd(e,n,r)}decode(e){let r=this.length;r===-1&&(r=e.readValue().toNumber(),r*32>e._data.length&&Xs.throwError("insufficient data length",Ie.errors.BUFFER_OVERRUN,{length:e._data.length,count:r}));let i=[];for(let n=0;n<r;n++)i.push(new Dl(this.coder));return e.coerce(this.name,Qd(e,i))}};var Rl=class extends qt{constructor(e){super("bool","bool",e,!1);}defaultValue(){return !1}encode(e,r){return e.writeValue(r?1:0)}decode(e){return e.coerce(this.type,!e.readValue().isZero())}};var ma=class extends qt{constructor(e,r){super(e,e,r,!0);}defaultValue(){return "0x"}encode(e,r){r=Lt(r);let i=e.writeValue(r.length);return i+=e.writeBytes(r),i}decode(e){return e.readBytes(e.readValue().toNumber(),!0)}},Nl=class extends ma{constructor(e){super("bytes",e);}decode(e){return e.coerce(this.name,Dt(super.decode(e)))}};var Ol=class extends qt{constructor(e,r){let i="bytes"+String(e);super(i,i,r,!1),this.size=e;}defaultValue(){return "0x0000000000000000000000000000000000000000000000000000000000000000".substring(0,2+this.size*2)}encode(e,r){let i=Lt(r);return i.length!==this.size&&this._throwError("incorrect data length",r),e.writeBytes(i)}decode(e){return e.coerce(this.name,Dt(e.readBytes(this.size)))}};var Fl=class extends qt{constructor(e){super("null","",e,!1);}defaultValue(){return null}encode(e,r){return r!=null&&this._throwError("not null",r),e.writeBytes([])}decode(e){return e.readBytes(0),e.coerce(this.name,null)}};var e0=St.from(-1),t0=St.from(0),r0=St.from(1);var i0=St.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");var Ll=class extends qt{constructor(e,r,i){let n=(r?"int":"uint")+e*8;super(n,n,i,!1),this.size=e,this.signed=r;}defaultValue(){return 0}encode(e,r){let i=St.from(r),n=i0.mask(e.wordSize*8);if(this.signed){let o=n.mask(this.size*8-1);(i.gt(o)||i.lt(o.add(r0).mul(e0)))&&this._throwError("value out-of-bounds",r);}else (i.lt(t0)||i.gt(n.mask(this.size*8)))&&this._throwError("value out-of-bounds",r);return i=i.toTwos(this.size*8).mask(this.size*8),this.signed&&(i=i.fromTwos(this.size*8).toTwos(8*e.wordSize)),e.writeValue(i)}decode(e){let r=e.readValue().mask(this.size*8);return this.signed&&(r=r.fromTwos(this.size*8)),e.coerce(this.name,r)}};var Yx="strings/5.7.0";var Zx=new Ie(Yx),_a;(function(t){t.current="",t.NFC="NFC",t.NFD="NFD",t.NFKC="NFKC",t.NFKD="NFKD";})(_a||(_a={}));var dr;(function(t){t.UNEXPECTED_CONTINUE="unexpected continuation byte",t.BAD_PREFIX="bad codepoint prefix",t.OVERRUN="string overrun",t.MISSING_CONTINUE="missing continuation byte",t.OUT_OF_RANGE="out of UTF-8 range",t.UTF16_SURROGATE="UTF-16 surrogate",t.OVERLONG="overlong representation";})(dr||(dr={}));function wL(t,e,r,i,n){return Zx.throwArgumentError(`invalid codepoint at offset ${e}; ${t}`,"bytes",r)}function Xx(t,e,r,i,n){if(t===dr.BAD_PREFIX||t===dr.UNEXPECTED_CONTINUE){let o=0;for(let s=e+1;s<r.length&&r[s]>>6===2;s++)o++;return o}return t===dr.OVERRUN?r.length-e-1:0}function DL(t,e,r,i,n){return t===dr.OVERLONG?(i.push(n),0):(i.push(65533),Xx(t,e,r))}var Jx=Object.freeze({error:wL,ignore:Xx,replace:DL});function SL(t,e){e==null&&(e=Jx.error),t=Lt(t);let r=[],i=0;for(;i<t.length;){let n=t[i++];if(!(n>>7)){r.push(n);continue}let o=null,s=null;if((n&224)===192)o=1,s=127;else if((n&240)===224)o=2,s=2047;else if((n&248)===240)o=3,s=65535;else {(n&192)===128?i+=e(dr.UNEXPECTED_CONTINUE,i-1,t,r):i+=e(dr.BAD_PREFIX,i-1,t,r);continue}if(i-1+o>=t.length){i+=e(dr.OVERRUN,i-1,t,r);continue}let a=n&(1<<8-o-1)-1;for(let u=0;u<o;u++){let l=t[i];if((l&192)!=128){i+=e(dr.MISSING_CONTINUE,i,t,r),a=null;break}a=a<<6|l&63,i++;}if(a!==null){if(a>1114111){i+=e(dr.OUT_OF_RANGE,i-1-o,t,r,a);continue}if(a>=55296&&a<=57343){i+=e(dr.UTF16_SURROGATE,i-1-o,t,r,a);continue}if(a<=s){i+=e(dr.OVERLONG,i-1-o,t,r,a);continue}r.push(a);}}return r}function ga(t,e=_a.current){e!=_a.current&&(Zx.checkNormalize(),t=t.normalize(e));let r=[];for(let i=0;i<t.length;i++){let n=t.charCodeAt(i);if(n<128)r.push(n);else if(n<2048)r.push(n>>6|192),r.push(n&63|128);else if((n&64512)==55296){i++;let o=t.charCodeAt(i);if(i>=t.length||(o&64512)!==56320)throw new Error("invalid utf-8 string");let s=65536+((n&1023)<<10)+(o&1023);r.push(s>>18|240),r.push(s>>12&63|128),r.push(s>>6&63|128),r.push(s&63|128);}else r.push(n>>12|224),r.push(n>>6&63|128),r.push(n&63|128);}return Lt(r)}function RL(t){return t.map(e=>e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10&1023)+55296,(e&1023)+56320))).join("")}function n0(t,e){return RL(SL(t,e))}var Pl=class extends ma{constructor(e){super("string",e);}defaultValue(){return ""}encode(e,r){return super.encode(e,ga(r))}decode(e){return n0(super.decode(e))}};var rs=class extends qt{constructor(e,r){let i=!1,n=[];e.forEach(s=>{s.dynamic&&(i=!0),n.push(s.type);});let o="tuple("+n.join(",")+")";super("tuple",o,r,i),this.coders=e;}defaultValue(){let e=[];this.coders.forEach(i=>{e.push(i.defaultValue());});let r=this.coders.reduce((i,n)=>{let o=n.localName;return o&&(i[o]||(i[o]=0),i[o]++),i},{});return this.coders.forEach((i,n)=>{let o=i.localName;!o||r[o]!==1||(o==="length"&&(o="_length"),e[o]==null&&(e[o]=e[n]));}),Object.freeze(e)}encode(e,r){return Jd(e,this.coders,r)}decode(e){return e.coerce(this.name,Qd(e,this.coders))}};var Il=new Ie(Zr),NL=new RegExp(/^bytes([0-9]*)$/),OL=new RegExp(/^(u?int)([0-9]*)$/),s0=class{constructor(e){kt(this,"coerceFunc",e||null);}_getCoder(e){switch(e.baseType){case"address":return new wl(e.name);case"bool":return new Rl(e.name);case"string":return new Pl(e.name);case"bytes":return new Nl(e.name);case"array":return new Sl(this._getCoder(e.arrayChildren),e.arrayLength,e.name);case"tuple":return new rs((e.components||[]).map(i=>this._getCoder(i)),e.name);case"":return new Fl(e.name)}let r=e.type.match(OL);if(r){let i=parseInt(r[2]||"256");return (i===0||i>256||i%8!==0)&&Il.throwArgumentError("invalid "+r[1]+" bit length","param",e),new Ll(i/8,r[1]==="int",e.name)}if(r=e.type.match(NL),r){let i=parseInt(r[1]);return (i===0||i>32)&&Il.throwArgumentError("invalid bytes length","param",e),new Ol(i,e.name)}return Il.throwArgumentError("invalid type","type",e.type)}_getWordSize(){return 32}_getReader(e,r){return new Cl(e,this._getWordSize(),this.coerceFunc,r)}_getWriter(){return new es(this._getWordSize())}getDefaultValue(e){let r=e.map(n=>this._getCoder(fr.from(n)));return new rs(r,"_").defaultValue()}encode(e,r){e.length!==r.length&&Il.throwError("types/values length mismatch",Ie.errors.INVALID_ARGUMENT,{count:{types:e.length,values:r.length},value:{types:e,values:r}});let i=e.map(s=>this._getCoder(fr.from(s))),n=new rs(i,"_"),o=this._getWriter();return n.encode(o,r),o.data}decode(e,r,i){let n=e.map(s=>this._getCoder(fr.from(s)));return new rs(n,"_").decode(this._getReader(Lt(r),i))}},Qx=new s0;function Js(t){return ts(ga(t))}var Rt=new Ie(Zr);var kl=class extends Yn{},Ml=class extends Yn{},o0=class extends Yn{},ya=class extends Yn{static isIndexed(e){return !!(e&&e._isIndexed)}},FL={"0x08c379a0":{signature:"Error(string)",name:"Error",inputs:["string"],reason:!0},"0x4e487b71":{signature:"Panic(uint256)",name:"Panic",inputs:["uint256"]}};function ev(t,e){let r=new Error(`deferred error during ABI decoding triggered accessing ${t}`);return r.error=e,r}var xa=class{constructor(e){let r=[];typeof e=="string"?r=JSON.parse(e):r=e,kt(this,"fragments",r.map(i=>Xn.from(i)).filter(i=>i!=null)),kt(this,"_abiCoder",la(new.target,"getAbiCoder")()),kt(this,"functions",{}),kt(this,"errors",{}),kt(this,"events",{}),kt(this,"structs",{}),this.fragments.forEach(i=>{let n=null;switch(i.type){case"constructor":if(this.deploy){Rt.warn("duplicate definition - constructor");return}kt(this,"deploy",i);return;case"function":n=this.functions;break;case"event":n=this.events;break;case"error":n=this.errors;break;default:return}let o=i.format();if(n[o]){Rt.warn("duplicate definition - "+o);return}n[o]=i;}),this.deploy||kt(this,"deploy",Jn.from({payable:!1,type:"constructor"})),kt(this,"_isInterface",!0);}format(e){e||(e=Ye.full),e===Ye.sighash&&Rt.throwArgumentError("interface does not support formatting sighash","format",e);let r=this.fragments.map(i=>i.format(e));return e===Ye.json?JSON.stringify(r.map(i=>JSON.parse(i))):r}static getAbiCoder(){return Qx}static getAddress(e){return pa(e)}static getSighash(e){return Kd(Js(e.format()),0,4)}static getEventTopic(e){return Js(e.format())}getFunction(e){if(hr(e)){for(let i in this.functions)if(e===this.getSighash(i))return this.functions[i];Rt.throwArgumentError("no matching function","sighash",e);}if(e.indexOf("(")===-1){let i=e.trim(),n=Object.keys(this.functions).filter(o=>o.split("(")[0]===i);return n.length===0?Rt.throwArgumentError("no matching function","name",i):n.length>1&&Rt.throwArgumentError("multiple matching functions","name",i),this.functions[n[0]]}let r=this.functions[Qn.fromString(e).format()];return r||Rt.throwArgumentError("no matching function","signature",e),r}getEvent(e){if(hr(e)){let i=e.toLowerCase();for(let n in this.events)if(i===this.getEventTopic(n))return this.events[n];Rt.throwArgumentError("no matching event","topichash",i);}if(e.indexOf("(")===-1){let i=e.trim(),n=Object.keys(this.events).filter(o=>o.split("(")[0]===i);return n.length===0?Rt.throwArgumentError("no matching event","name",i):n.length>1&&Rt.throwArgumentError("multiple matching events","name",i),this.events[n[0]]}let r=this.events[Zs.fromString(e).format()];return r||Rt.throwArgumentError("no matching event","signature",e),r}getError(e){if(hr(e)){let i=la(this.constructor,"getSighash");for(let n in this.errors){let o=this.errors[n];if(e===i(o))return this.errors[n]}Rt.throwArgumentError("no matching error","sighash",e);}if(e.indexOf("(")===-1){let i=e.trim(),n=Object.keys(this.errors).filter(o=>o.split("(")[0]===i);return n.length===0?Rt.throwArgumentError("no matching error","name",i):n.length>1&&Rt.throwArgumentError("multiple matching errors","name",i),this.errors[n[0]]}let r=this.errors[Qn.fromString(e).format()];return r||Rt.throwArgumentError("no matching error","signature",e),r}getSighash(e){if(typeof e=="string")try{e=this.getFunction(e);}catch(r){try{e=this.getError(e);}catch(i){throw r}}return la(this.constructor,"getSighash")(e)}getEventTopic(e){return typeof e=="string"&&(e=this.getEvent(e)),la(this.constructor,"getEventTopic")(e)}_decodeParams(e,r){return this._abiCoder.decode(e,r)}_encodeParams(e,r){return this._abiCoder.encode(e,r)}encodeDeploy(e){return this._encodeParams(this.deploy.inputs,e||[])}decodeErrorResult(e,r){typeof e=="string"&&(e=this.getError(e));let i=Lt(r);return Dt(i.slice(0,4))!==this.getSighash(e)&&Rt.throwArgumentError(`data signature does not match error ${e.name}.`,"data",Dt(i)),this._decodeParams(e.inputs,i.slice(4))}encodeErrorResult(e,r){return typeof e=="string"&&(e=this.getError(e)),Dt(xi([this.getSighash(e),this._encodeParams(e.inputs,r||[])]))}decodeFunctionData(e,r){typeof e=="string"&&(e=this.getFunction(e));let i=Lt(r);return Dt(i.slice(0,4))!==this.getSighash(e)&&Rt.throwArgumentError(`data signature does not match function ${e.name}.`,"data",Dt(i)),this._decodeParams(e.inputs,i.slice(4))}encodeFunctionData(e,r){return typeof e=="string"&&(e=this.getFunction(e)),Dt(xi([this.getSighash(e),this._encodeParams(e.inputs,r||[])]))}decodeFunctionResult(e,r){typeof e=="string"&&(e=this.getFunction(e));let i=Lt(r),n=null,o="",s=null,a=null,u=null;switch(i.length%this._abiCoder._getWordSize()){case 0:try{return this._abiCoder.decode(e.outputs,i)}catch(l){}break;case 4:{let l=Dt(i.slice(0,4)),h=FL[l];if(h)s=this._abiCoder.decode(h.inputs,i.slice(4)),a=h.name,u=h.signature,h.reason&&(n=s[0]),a==="Error"?o=`; VM Exception while processing transaction: reverted with reason string ${JSON.stringify(s[0])}`:a==="Panic"&&(o=`; VM Exception while processing transaction: reverted with panic code ${s[0]}`);else try{let c=this.getError(l);s=this._abiCoder.decode(c.inputs,i.slice(4)),a=c.name,u=c.format();}catch(c){}break}}return Rt.throwError("call revert exception"+o,Ie.errors.CALL_EXCEPTION,{method:e.format(),data:Dt(r),errorArgs:s,errorName:a,errorSignature:u,reason:n})}encodeFunctionResult(e,r){return typeof e=="string"&&(e=this.getFunction(e)),Dt(this._abiCoder.encode(e.outputs,r||[]))}encodeFilterTopics(e,r){typeof e=="string"&&(e=this.getEvent(e)),r.length>e.inputs.length&&Rt.throwError("too many arguments for "+e.format(),Ie.errors.UNEXPECTED_ARGUMENT,{argument:"values",value:r});let i=[];e.anonymous||i.push(this.getEventTopic(e));let n=(o,s)=>o.type==="string"?Js(s):o.type==="bytes"?ts(Dt(s)):(o.type==="bool"&&typeof s=="boolean"&&(s=s?"0x01":"0x00"),o.type.match(/^u?int/)&&(s=St.from(s).toHexString()),o.type==="address"&&this._abiCoder.encode(["address"],[s]),xl(Dt(s),32));for(r.forEach((o,s)=>{let a=e.inputs[s];if(!a.indexed){o!=null&&Rt.throwArgumentError("cannot filter non-indexed parameters; must be null","contract."+a.name,o);return}o==null?i.push(null):a.baseType==="array"||a.baseType==="tuple"?Rt.throwArgumentError("filtering with tuples or arrays not supported","contract."+a.name,o):Array.isArray(o)?i.push(o.map(u=>n(a,u))):i.push(n(a,o));});i.length&&i[i.length-1]===null;)i.pop();return i}encodeEventLog(e,r){typeof e=="string"&&(e=this.getEvent(e));let i=[],n=[],o=[];return e.anonymous||i.push(this.getEventTopic(e)),r.length!==e.inputs.length&&Rt.throwArgumentError("event arguments/values mismatch","values",r),e.inputs.forEach((s,a)=>{let u=r[a];if(s.indexed)if(s.type==="string")i.push(Js(u));else if(s.type==="bytes")i.push(ts(u));else {if(s.baseType==="tuple"||s.baseType==="array")throw new Error("not implemented");i.push(this._abiCoder.encode([s.type],[u]));}else n.push(s),o.push(u);}),{data:this._abiCoder.encode(n,o),topics:i}}decodeEventLog(e,r,i){if(typeof e=="string"&&(e=this.getEvent(e)),i!=null&&!e.anonymous){let p=this.getEventTopic(e);(!hr(i[0],32)||i[0].toLowerCase()!==p)&&Rt.throwError("fragment/topic mismatch",Ie.errors.INVALID_ARGUMENT,{argument:"topics[0]",expected:p,value:i[0]}),i=i.slice(1);}let n=[],o=[],s=[];e.inputs.forEach((p,f)=>{p.indexed?p.type==="string"||p.type==="bytes"||p.baseType==="tuple"||p.baseType==="array"?(n.push(fr.fromObject({type:"bytes32",name:p.name})),s.push(!0)):(n.push(p),s.push(!1)):(o.push(p),s.push(!1));});let a=i!=null?this._abiCoder.decode(n,xi(i)):null,u=this._abiCoder.decode(o,r,!0),l=[],h=0,c=0;e.inputs.forEach((p,f)=>{if(p.indexed)if(a==null)l[f]=new ya({_isIndexed:!0,hash:null});else if(s[f])l[f]=new ya({_isIndexed:!0,hash:a[c++]});else try{l[f]=a[c++];}catch(m){l[f]=m;}else try{l[f]=u[h++];}catch(m){l[f]=m;}if(p.name&&l[p.name]==null){let m=l[f];m instanceof Error?Object.defineProperty(l,p.name,{enumerable:!0,get:()=>{throw ev(`property ${JSON.stringify(p.name)}`,m)}}):l[p.name]=m;}});for(let p=0;p<l.length;p++){let f=l[p];f instanceof Error&&Object.defineProperty(l,p,{enumerable:!0,get:()=>{throw ev(`index ${p}`,f)}});}return Object.freeze(l)}parseTransaction(e){let r=this.getFunction(e.data.substring(0,10).toLowerCase());return r?new Ml({args:this._abiCoder.decode(r.inputs,"0x"+e.data.substring(10)),functionFragment:r,name:r.name,signature:r.format(),sighash:this.getSighash(r),value:St.from(e.value||"0")}):null}parseLog(e){let r=this.getEvent(e.topics[0]);return !r||r.anonymous?null:new kl({eventFragment:r,name:r.name,signature:r.format(),topic:this.getEventTopic(r),args:this.decodeEventLog(r,e.data,e.topics)})}parseError(e){let r=Dt(e),i=this.getError(r.substring(0,10).toLowerCase());return i?new o0({args:this._abiCoder.decode(i.inputs,"0x"+r.substring(10)),errorFragment:i,name:i.name,signature:i.format(),sighash:this.getSighash(i)}):null}static isInterface(e){return !!(e&&e._isInterface)}};var mh=$t(HE()),op=(t,e)=>e==null||e.length===0?void 0:new xa(t).encodeDeploy(e).slice(2),UE=t=>{try{let e=mh.parse(t),r;return mh.visit(e,{FunctionDefinition:n=>{n.isConstructor&&(r=n);}}),jE__default.default(r!=null,"Could not find constructor definition"),[{type:"constructor",inputs:r.parameters.map(({typeName:n},o)=>(jE__default.default(n!=null,`Missing a type definition for constructor parameter at position ${o}`),{type:VE(n)}))}]}catch(e){throw new Error(`Could not get an ABI from contract source: ${e}`)}},VE=t=>{switch(t.type){case"ElementaryTypeName":return t.name;case"ArrayTypeName":return `${VE(t.baseTypeName)}[]`;default:throw new Error(`Only primitive and array types are currently supported when constructing ABI from contract source, got ${t.type}`)}};var ap=t=>{var e;return {deployments:(e=t==null?void 0:t.deployments)!=null?e:J8__default.default.resolve(process.cwd(),"deployments")}},$E=t=>{if(t==null)return ()=>!0;switch(typeof t){case"boolean":return ()=>t;case"string":return e=>e===t;case"function":return t;case"object":if(Array.isArray(t)){let e=new Set(t);return r=>e.has(r)}if(t instanceof RegExp)return e=>t.test(e);throw new TypeError(`Invalid verify configuration: expected string, string[], boolean, function or a RegExp, got ${t}`);default:throw new TypeError(`Invalid verify configuration: expected string, string[], boolean, function or a RegExp, got ${t}`)}};var KE=t=>{try{return fs.lstatSync(t).isDirectory()}catch(e){return !1}},GE=t=>{try{return fs.lstatSync(t).isFile()}catch(e){return !1}};var ZE=async(t,e)=>{let r=Ff(e,t.networks),i=ap(t.paths),n=Nf(e),o=JE(e),s=QE(n),a=t.contracts.flatMap(l=>{var te;let{address:h,network:c,contractName:p,deployment:f}=l;e.info(`Collectiong information for contract ${p} on network ${c}`);let m=r[c];if(m==null)return e.info(`No network configured for contract ${p} on network ${c}`),[];let _=`${J8.basename(f,".json")}.json`,x=J8.resolve(i.deployments,c,_);if(!GE(x))return e.error(Gt.error`Deployment file ${x} does not exist or is not a file`),[];let v=me(x),g=Hd.safeParse(v);if(!g.success)return e.error(Gt.error`No network configured for contract ${p} on network ${c}`),[];let b=g.data,E=J8.basename(p,".sol"),w=b.metadata.sources[p];if(w==null)return e.error(Gt.error`Missing source for contract ${p} for network ${c} in ${_}`),[];let D=Pf(w.content),N=UE(w.content),F=op(N,l.constructorArguments),V=jd(b.metadata),X={apiUrl:m.apiUrl,apiKey:m.apiKey,address:h,contractName:`${p}:${E}`,constructorArguments:F,licenseType:D,compilerVersion:b.metadata.compiler.version,sourceCode:JSON.stringify(V),evmVersion:b.metadata.settings.evmVersion,optimizerRuns:(te=b.metadata.settings.optimizer)==null?void 0:te.runs};return n({Contract:p,Network:c,Address:X.address,License:X.licenseType,Arguments:l.constructorArguments?JSON.stringify(l.constructorArguments):void 0,Sources:Object.keys(b.metadata.sources),"Scan URL":X.apiUrl,"Scan API Key":X.apiKey?Rf(X.apiKey):void 0}),[{networkName:c,networkConfig:m,submitProps:X}]});if(a.length===0)return e.warn("No contracts match the verification criteria, exiting"),[];if(t.dryRun)return e.debug("Dry run enabled, exiting"),[];let u=await Promise.all(o(a));return u.forEach(s),u},XE=async(t,e)=>{let r=$E(t.filter),i=Ff(e,t.networks),n=ap(t.paths),o=Nf(e),s=JE(e),a=QE(o);if(!KE(n.deployments))throw new Error(`Path ${n.deployments} is not a directory`);let u=new Set(fs.readdirSync(n.deployments)),l=Object.entries(i);e.debug("Verifying deployments for following networks:"),l.forEach(([p,f])=>{e.debug(` - ${p} (API URL ${f.apiUrl})`);});let h=l.flatMap(([p,f])=>{if(e.info(`Collecting deployments for ${p}...`),!u.has(p))return e.warn(`Could not find deployment for network ${p} in ${n.deployments}`),[];let m=J8.resolve(n.deployments,p);return fs.readdirSync(m).filter(x=>x.endsWith(".json")).flatMap(x=>{e.info(`Inspecting deployment file ${x} on network ${p}`);let v=J8.resolve(m,x),g=me(v),b=Hd.safeParse(g);if(!b.success)throw new Error(`Error parsing deployment file ${x} on network ${p}: ${b.error}`);let E=b.data,w=E.metadata.settings.compilationTarget;return Object.entries(w).flatMap(([D,N])=>{var y;if(!r(N,D,p))return e.debug(`Not verifying ${N} in ${x} on network ${p}`),[];let V=E.metadata.sources[D];if(V==null)return e.error(Gt.error`Could not find source for ${N} (${D})`),[];let X=Pf(V.content),te=op(E.abi,E.args),ae=jd(E.metadata),k={apiUrl:f.apiUrl,apiKey:f.apiKey,address:E.address,contractName:`${D}:${N}`,constructorArguments:te,licenseType:X,compilerVersion:E.metadata.compiler.version,sourceCode:JSON.stringify(ae),evmVersion:E.metadata.settings.evmVersion,optimizerRuns:(y=E.metadata.settings.optimizer)==null?void 0:y.runs};return o({Contract:N,Network:p,Address:E.address,License:k.licenseType,Arguments:JSON.stringify(E.args),Sources:Object.keys(E.metadata.sources),"Scan URL":k.apiUrl,"Scan API Key":k.apiKey?Rf(k.apiKey):void 0}),{submitProps:k,networkName:p,networkConfig:f}})})});if(h.length===0)return e.warn("No contracts match the verification criteria, exiting"),[];if(t.dryRun)return e.debug("Dry run enabled, exiting"),[];let c=await Promise.all(s(h));return c.forEach(a),c},JE=t=>e=>e.map(async(r,i)=>{let{submitProps:n}=r,o=Gt.palette[i%Gt.palette.length],s=`[${i+1}/${e.length}]`,a=Ma.default.bold(n.contractName),u=Ma.default.bold(r.networkName);t.info(o`Verifying contract ${a} for network ${u} ${s}`);try{let l=yx(n,t);l.on("poll",c=>{t.info(o`Polling for verification status of ${a} for network ${u} (GUID ${c}) ${s}`);}),l.on("retry",(c,p)=>{t.verbose(`Received an error: ${c}`),t.info(o`Retrying failed verification attempt of ${a} for network ${u} (attempt ${p+1}) ${s}`);});let h=await l.verify();return {artifact:r,result:h}}catch(l){return t.error(Gt.error`Problem verifying contract ${a} for network ${u} ${s}: ${l} `),{artifact:r,error:l}}}),QE=t=>({artifact:e,response:r,error:i})=>{let n=Ma.default.bold(e.submitProps.contractName),o=Ma.default.bold(e.networkName),s=e.networkConfig.browserUrl?Og(e.networkConfig.browserUrl,e.submitProps.address):void 0;t({Contract:n,Network:o,Result:i==null,"Was verified":r==null?void 0:r.alreadyVerified,"Contract URL":s,Error:i?Gt.error(i):void 0});};var As=$t(o3(),1);$t(aw(),1);var Ro=$t(Io(),1);$t(MR(),1);var BR=(t=>(t.error="error",t.warn="warn",t.info="info",t.http="http",t.verbose="verbose",t.debug="debug",t.silly="silly",t))(BR||{});Pe.nativeEnum(BR);var cU="info";var cg=(t=cU,e=As.format.cli())=>(0, As.createLogger)({level:t,format:e,transports:[new As.transports.Console]});(0, As.format)((t,{label:e})=>({...t,message:`${e?`[${e}] `:""}${t.message}`}));({TRUE:Ro.default.rgb(0,153,0),FALSE:Ro.default.rgb(255,0,0),NOT_APPLICABLE:Ro.default.rgb(255,128,0),DEFAULT_KEY:Ro.default.rgb(255,255,255),DEFAULT_VALUE:Ro.default.rgb(167,125,255)});var qR="1.1.11";var HR=new Nn("-l,--log-level <level>","Log level").choices(["error","warn","info","http","verbose","debug","silly"]).default("info"),jR=new Nn("-d,--deployments <path>","Path to the deployments folder"),UR=new Nn("--dry-run","Do not verify anything, just output the verifications that would be performed"),VR=new Nn("-n,--network <network name>","Network to verify").makeOptionMandatory(),$R=new Nn("-u,--api-url <url>","Scan API URL (fully qualified, with protocol and path)"),zR=new Nn("-k,--api-key <key>","Scan API Key"),dU=new Ru("non-target").description("Verifies a contract that does not have its own deployment file, i.e. has not been a target of a deployment").addOption(HR).addOption(UR).addOption(jR).addOption(VR).addOption($R).addOption(zR).requiredOption("--address <address>","Contract address to verify").requiredOption("--name <contract name>","Fully qualified contract name to verify, e.g. contracts/MyToken.sol").requiredOption("--deployment <deployment file name>","Deployment file name, e.g. MyOtherToken.json").option("--arguments <constructor arguments>",'JSON encoded array of constructor arguments, e.g. [1234, "0x0"]',t=>{try{let e=JSON.parse(t);if(!Array.isArray(e))throw new Error(`Constructor arguments must be an array, got ${e}`);return e}catch(e){throw new Sg(`Malformed constructor arguments specified: ${e}`)}}).action(async t=>{let e=cg(t.logLevel),r={dryRun:t.dryRun,paths:{deployments:t.deployments},networks:{[t.network]:{apiUrl:t.apiUrl,apiKey:t.apiKey}},contracts:[{network:t.network,address:t.address,contractName:t.name,deployment:t.deployment,constructorArguments:t.arguments}]};try{await ZE(r,e);}catch(i){e.error(Gt.error`The verification script exited with an error: ${i}`),process.exit(1);}}),pU=new Ru("target").description("Verifies contracts that have been a part of a deployment, i.e. have their own deployment files").addOption(HR).addOption(UR).addOption(jR).addOption(VR).addOption($R).addOption(zR).option("-c,--contracts <contract names>","Comma-separated list of case-sensitive contract names to verify",t=>t!=null&&t.trim()?t.split(",").map(e=>e.trim()):void 0).action(async t=>{let e=cg(t.logLevel),r={dryRun:t.dryRun,paths:{deployments:t.deployments},networks:{[t.network]:{apiUrl:t.apiUrl,apiKey:t.apiKey}},filter:t.contracts};try{await XE(r,e);}catch(i){e.error(Gt.error`The verification script exited with an error: ${i}`),process.exit(1);}});new Ru("@layerzerolabs/verify-contract").version(qR).description("Verify a set of contracts based on hardhat-deploy outputs").addCommand(dU).addCommand(pU,{isDefault:!0}).parseAsync();
473
473
  /*! Bundled license information:
474
474
 
475
475
  js-sha3/src/sha3.js:
package/dist/index.js CHANGED
@@ -44517,8 +44517,9 @@ var getDefaultScanApiUrl = (networkName) => DEFAULT_SCAN_API_URLS.get(networkNam
44517
44517
  var tryGetScanBrowserUrlFromScanUrl = (scanApiUrl) => {
44518
44518
  try {
44519
44519
  const urlObject = new URL(scanApiUrl);
44520
- if (!urlObject.hostname.startsWith("api.") && !urlObject.hostname.startsWith("api-"))
44520
+ if (!urlObject.hostname.startsWith("api.") && !urlObject.hostname.startsWith("api-")) {
44521
44521
  return void 0;
44522
+ }
44522
44523
  urlObject.hostname = urlObject.hostname.replace(/^api[.-]/, "");
44523
44524
  urlObject.pathname = "/";
44524
44525
  return urlObject.toString();
@@ -44607,8 +44608,9 @@ var createRecordLogger = (logger11, separator = " ") => (record) => {
44607
44608
  });
44608
44609
  };
44609
44610
  var formatLoggableValue = (value) => {
44610
- if (value == null)
44611
+ if (value == null) {
44611
44612
  return "-";
44613
+ }
44612
44614
  switch (typeof value) {
44613
44615
  case "boolean":
44614
44616
  return value ? TRUE_SYMBOL : FALSE_SYMBOL;
@@ -44623,8 +44625,9 @@ var FALSE_SYMBOL = COLORS.error`⚠`;
44623
44625
  var import_chalk2 = __toESM(require_source());
44624
44626
  var parseNetworksConfig = (logger11, partialNetworksConfig) => {
44625
44627
  return Object.entries(partialNetworksConfig != null ? partialNetworksConfig : {}).reduce((networksConfig, [networkName, networkConfig]) => {
44626
- if (networkConfig == null)
44628
+ if (networkConfig == null) {
44627
44629
  return networksConfig;
44630
+ }
44628
44631
  const apiUrl = networkConfig.apiUrl || getScanApiUrlFromEnv(networkName) || getDefaultScanApiUrl(networkName);
44629
44632
  assert4__default.default(
44630
44633
  apiUrl,
@@ -44701,8 +44704,9 @@ var LicenseType = /* @__PURE__ */ ((LicenseType2) => {
44701
44704
  var findLicenseType = (sourceCode) => {
44702
44705
  const matches = sourceCode.match(/\/\/\s*SPDX-License-Identifier:\s*(.*)\s*/i);
44703
44706
  const licenseName = matches == null ? void 0 : matches[1];
44704
- if (licenseName == null)
44707
+ if (licenseName == null) {
44705
44708
  return 1 /* None */;
44709
+ }
44706
44710
  if (!(licenseName in LicenseType)) {
44707
44711
  console.warn("Found unknown SPDX license identifier: %s", licenseName);
44708
44712
  }
@@ -53697,14 +53701,16 @@ ${JSON.stringify(response)}`);
53697
53701
  this.logger.verbose(`Received raw polling response from ${this.props.apiUrl}:
53698
53702
 
53699
53703
  ${JSON.stringify(result)}`);
53700
- if (result.status === 1)
53704
+ if (result.status === 1) {
53701
53705
  return {
53702
53706
  alreadyVerified: false
53703
53707
  };
53704
- if (isAlreadyVerifiedResult(result.result))
53708
+ }
53709
+ if (isAlreadyVerifiedResult(result.result)) {
53705
53710
  return {
53706
53711
  alreadyVerified: true
53707
53712
  };
53713
+ }
53708
53714
  if (isPendingResult(result.result)) {
53709
53715
  await sleep(1e4);
53710
53716
  continue;
@@ -53770,16 +53776,21 @@ var createVerificationRequest = ({
53770
53776
  optimizationUsed: optimizerRuns > 0 ? "1" : "0",
53771
53777
  sourceCode
53772
53778
  };
53773
- if (apiKey != null)
53779
+ if (apiKey != null) {
53774
53780
  request.apikey = apiKey;
53775
- if (optimizerRuns != null)
53781
+ }
53782
+ if (optimizerRuns != null) {
53776
53783
  request.runs = String(optimizerRuns);
53777
- if (constructorArguments != null)
53784
+ }
53785
+ if (constructorArguments != null) {
53778
53786
  request.constructorArguements = constructorArguments;
53779
- if (evmVersion != null)
53787
+ }
53788
+ if (evmVersion != null) {
53780
53789
  request.evmversion = evmVersion;
53781
- if (licenseType != null)
53790
+ }
53791
+ if (licenseType != null) {
53782
53792
  request.licenseType = String(licenseType);
53793
+ }
53783
53794
  return request;
53784
53795
  };
53785
53796
  var ScanResponseSchema = z.object({
@@ -56952,8 +56963,9 @@ var Interface = class {
56952
56963
  // src/common/abi.ts
56953
56964
  var parser = __toESM(require_index_cjs());
56954
56965
  var encodeContructorArguments = (abi, args) => {
56955
- if (args == null || args.length === 0)
56966
+ if (args == null || args.length === 0) {
56956
56967
  return void 0;
56968
+ }
56957
56969
  const iface = new Interface(abi);
56958
56970
  const encodedConstructorArguments = iface.encodeDeploy(args);
56959
56971
  return encodedConstructorArguments.slice(2);
@@ -56964,8 +56976,9 @@ var getContructorABIFromSource = (source) => {
56964
56976
  let constructorDefinition;
56965
56977
  parser.visit(ast, {
56966
56978
  FunctionDefinition: (node) => {
56967
- if (node.isConstructor)
56979
+ if (node.isConstructor) {
56968
56980
  constructorDefinition = node;
56981
+ }
56969
56982
  }
56970
56983
  });
56971
56984
  assert4__default.default(constructorDefinition != null, `Could not find constructor definition`);
@@ -57002,8 +57015,9 @@ var parsePathsConfig = (partialPathsConfig) => {
57002
57015
  };
57003
57016
  };
57004
57017
  var parseFilterConfig = (filterConfig) => {
57005
- if (filterConfig == null)
57018
+ if (filterConfig == null) {
57006
57019
  return () => true;
57020
+ }
57007
57021
  switch (typeof filterConfig) {
57008
57022
  case "boolean":
57009
57023
  return () => filterConfig;