@wormhole-foundation/wormhole-connect 0.3.19-beta.3-development → 0.3.19-beta.5-development
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/assets/{ccip-B8sh0red.js → ccip-De5bB7ry.js} +1 -1
- package/dist/assets/{evm-B3YdeaCI.js → evm-DJTN7n-6.js} +4 -4
- package/dist/assets/{index-moDeJTxm.js → index-CdA027fm.js} +1 -1
- package/dist/assets/{index-1ZJmfQkw.js → index-D8xdfMo8.js} +2 -2
- package/dist/assets/{index.es-CXmj0UJy.js → index.es-DsPAzXeV.js} +2 -2
- package/dist/main.js +7 -7
- package/dist/src/components/ManualAddressInput.d.ts.map +1 -1
- package/dist/src/routes/cosmosGateway/cosmosGateway.d.ts +2 -0
- package/dist/src/routes/cosmosGateway/cosmosGateway.d.ts.map +1 -1
- package/dist/src/routes/porticoBridge/porticoBridge.d.ts +2 -0
- package/dist/src/routes/porticoBridge/porticoBridge.d.ts.map +1 -1
- package/dist/src/routes/sdkv2/route.d.ts +1 -1
- package/dist/src/routes/sdkv2/route.d.ts.map +1 -1
- package/dist/src/routes/tbtc/tbtc.d.ts +2 -0
- package/dist/src/routes/tbtc/tbtc.d.ts.map +1 -1
- package/lib/{algorand-BDR3KPTJ.js → algorand-BizCMnCe.js} +1 -1
- package/lib/{algorand-CNPRWbNB.mjs → algorand-CZC9cPKi.mjs} +4 -4
- package/lib/{aptos-BPs26BCC.mjs → aptos-B4ng1XsR.mjs} +1 -1
- package/lib/{aptos-t3uXFwih.mjs → aptos-CRkEBLid.mjs} +4 -4
- package/lib/{aptos-tCZHrDAP.js → aptos-CXyHqFt8.js} +2 -2
- package/lib/{aptos-Br9Q1n2N.js → aptos-i8WEm-Fe.js} +1 -1
- package/lib/{browser-33Nc32cs.mjs → browser-CIwNo6kY.mjs} +2 -2
- package/lib/{browser-Cz60hQ-L.js → browser-DEzmpMBm.js} +1 -1
- package/lib/{ccip-CtmuOQGX.js → ccip-6omn1tDF.js} +1 -1
- package/lib/{ccip-CE49B2YD.mjs → ccip-LzzuUWf7.mjs} +1 -1
- package/lib/{chain-BT07YJHt.js → chain-BteoJHpg.js} +1 -1
- package/lib/{chain-CbwtJlkc.mjs → chain-Cc-vL0Ji.mjs} +1 -1
- package/lib/{cosmos-LlwNYP69.mjs → cosmos-5NiZ8EbB.mjs} +3 -3
- package/lib/{cosmos-t65H2NQC.js → cosmos-DM4Lrmu1.js} +1 -1
- package/lib/{cosmwasm-CiJ3I3AY.js → cosmwasm-8FJsT7LT.js} +2 -2
- package/lib/{cosmwasm-CbTKetWD.mjs → cosmwasm-BHEBPmf7.mjs} +6 -6
- package/lib/{create-Chqnlpoq.js → create-48Wkagqs.js} +1 -1
- package/lib/{create-HNw0Emrd.mjs → create-BIAJIVSg.mjs} +1 -1
- package/lib/{ens-validation.es6-BaZUabxu.js → ens-validation.es6-Bw--s4Qc.js} +1 -1
- package/lib/{ens-validation.es6-CyEOHc9J.mjs → ens-validation.es6-DQFhqeC0.mjs} +2 -2
- package/lib/{evm-lHNM4jqm.mjs → evm-B5hnoH2O.mjs} +6 -6
- package/lib/{evm-CjvzIUCn.mjs → evm-Dd33ef5o.mjs} +6 -6
- package/lib/{evm-CNC7JHe1.js → evm-JNEgzI8_.js} +4 -4
- package/lib/{evm-3AGyBI-h.js → evm-OwiMOsDg.js} +2 -2
- package/lib/{index-BWsL77BI.mjs → index-10BWvX1N.mjs} +3 -3
- package/lib/{index-DPNt5r2L.js → index-670AMJe5.js} +1 -1
- package/lib/{index-C4kvGnSA.mjs → index-B03MiI2p.mjs} +2 -2
- package/lib/{index-BpuXk_6h.js → index-B9pFbfyU.js} +1 -1
- package/lib/{index-35qsyZLz.js → index-BDi5PNJc.js} +1 -1
- package/lib/{index-BCSt_UXY.js → index-BFIX3imu.js} +1 -1
- package/lib/{index-CACyup9A.js → index-BHUxBugG.js} +1 -1
- package/lib/{index-DVVJw5ml.js → index-BHWhOqWI.js} +1 -1
- package/lib/{index-ztQgUCWf.js → index-BJPmRnHn.js} +1 -1
- package/lib/{index-BCnyHegg.mjs → index-Bg59b-Bk.mjs} +4 -4
- package/lib/{index-CbCfazgA.mjs → index-By8Yxkcx.mjs} +5 -5
- package/lib/{index-Tl7zYqHL.js → index-C1oy9Lkm.js} +6 -6
- package/lib/{index-DJzhcNDU.mjs → index-CHqEmT8z.mjs} +6 -6
- package/lib/{index-Bk7wdRtH.mjs → index-CMKVJZ8E.mjs} +3 -3
- package/lib/{index-DRTx-Ru8.mjs → index-CNbmckF9.mjs} +4 -4
- package/lib/{index-D1dHZqit.mjs → index-CU3qSQjR.mjs} +4 -4
- package/lib/{index-CjyrCdi_.mjs → index-CVjCpWVm.mjs} +1 -1
- package/lib/{index-BBtf8VGl.js → index-CYRY8C8f.js} +1 -1
- package/lib/{index-DfJLd65b.mjs → index-Cx7DnGQ7.mjs} +4 -4
- package/lib/{index-CdSy2Lfd.mjs → index-D4oa5qLu.mjs} +85 -62
- package/lib/{index-zKUpU-3R.mjs → index-D7DR5q91.mjs} +4 -4
- package/lib/{index-BH5gBrJu.mjs → index-D83yFXT3.mjs} +3 -3
- package/lib/{index-B6m0ovID.mjs → index-D8SeaoGs.mjs} +2 -2
- package/lib/{index-DGRaAUXo.mjs → index-D8l7OdtE.mjs} +2 -2
- package/lib/{index-Dbwiqljw.js → index-DETB2K9l.js} +1 -1
- package/lib/{index-abvwfKBf.js → index-DGfMxIjQ.js} +1 -1
- package/lib/{index-l_e-RUun.js → index-DLpTO2U3.js} +1 -1
- package/lib/{index-CokIAiMa.mjs → index-DX18kVfL.mjs} +4 -4
- package/lib/{index-dJMYtBle.mjs → index-DX6w1JtB.mjs} +4 -4
- package/lib/{index-B9L2kltl.mjs → index-DbMbSuyg.mjs} +4 -4
- package/lib/{index-DCPwTd_i.js → index-DfYaeaDv.js} +1 -1
- package/lib/{index-0t31FGKV.js → index-DjmghqSr.js} +1 -1
- package/lib/{index-UOSBfEgg.js → index-DlRC-hs-.js} +1 -1
- package/lib/{index-Cp5np38p.mjs → index-G7Dlm7ed.mjs} +1 -1
- package/lib/{index-Bp0NhDcb.js → index-Hyeca4Ym.js} +1 -1
- package/lib/{index-DVH-ZIP6.mjs → index-ROBBwabT.mjs} +4 -4
- package/lib/{index-CO9tmWap.js → index-WhcobQtR.js} +1 -1
- package/lib/{index-DrncQYMG.js → index-X-BikqCf.js} +1 -1
- package/lib/{index-BqGvvv6N.js → index-ZCZHbA1F.js} +1 -1
- package/lib/{index-Cofatf_w.js → index-isN8Fo1n.js} +1 -1
- package/lib/{index-B9gw1I6s.js → index-j8isX5f9.js} +1 -1
- package/lib/{index-CGLAoOXl.mjs → index-jlt17KkN.mjs} +4 -4
- package/lib/{index-BS1tjK_Z.mjs → index-mtuCwj6Z.mjs} +5 -5
- package/lib/{index-Bfw-brA6.js → index-oVIYJXdI.js} +1 -1
- package/lib/{index-CYap2RXm.js → index-tvG-rfJZ.js} +1 -1
- package/lib/{index-DvUq-nIQ.mjs → index-ybRLAtD8.mjs} +5 -5
- package/lib/{index.es-494n2GDU.js → index.es-B33YjOZu.js} +2 -2
- package/lib/{index.es-DnXnnX-i.mjs → index.es-BON8c55F.mjs} +4 -4
- package/lib/index.js +1 -1
- package/lib/index.mjs +1 -1
- package/lib/{libsodium-wrappers-9p7NdjLu.mjs → libsodium-wrappers-DTuXKVrZ.mjs} +1 -1
- package/lib/{libsodium-wrappers-Dechaffz.js → libsodium-wrappers-VihnPAqR.js} +1 -1
- package/lib/{sei-SWKTnPTF.mjs → sei-C6N03jzv.mjs} +2 -2
- package/lib/{sei-DORxBQd-.js → sei-DTeCXpXl.js} +1 -1
- package/lib/{solana-Bd9eRY8E.js → solana--YauUjmQ.js} +2 -2
- package/lib/{solana-T2pgCVfU.mjs → solana-BMm013WW.mjs} +6 -6
- package/lib/{solana-DvbMa7B_.mjs → solana-DdaraOHp.mjs} +3 -3
- package/lib/{solana-KhBV5LOd.js → solana-T3yS-Q_9.js} +1 -1
- package/lib/{solanaEmbed.esm-CnKFJhsj.js → solanaEmbed.esm-DMwXbxXO.js} +1 -1
- package/lib/{solanaEmbed.esm-8eZSo5K2.mjs → solanaEmbed.esm-D_lKLzGu.mjs} +2 -2
- package/lib/src/components/ManualAddressInput.d.ts.map +1 -1
- package/lib/src/routes/cosmosGateway/cosmosGateway.d.ts +2 -0
- package/lib/src/routes/cosmosGateway/cosmosGateway.d.ts.map +1 -1
- package/lib/src/routes/porticoBridge/porticoBridge.d.ts +2 -0
- package/lib/src/routes/porticoBridge/porticoBridge.d.ts.map +1 -1
- package/lib/src/routes/sdkv2/route.d.ts +1 -1
- package/lib/src/routes/sdkv2/route.d.ts.map +1 -1
- package/lib/src/routes/tbtc/tbtc.d.ts +2 -0
- package/lib/src/routes/tbtc/tbtc.d.ts.map +1 -1
- package/lib/{sui-DDu4a1uc.mjs → sui-Btvc4SGv.mjs} +4 -4
- package/lib/{sui-CjRGl9Gg.mjs → sui-CXyWZ2Gp.mjs} +1 -1
- package/lib/{sui-B382sZz0.js → sui-DWLiZoeB.js} +1 -1
- package/lib/{sui-DwH1wYGH.js → sui-DbQOBpeH.js} +2 -2
- package/lib/{unsignedTransaction-BbAfXtog.mjs → unsignedTransaction-CtPR6znR.mjs} +2 -2
- package/lib/{unsignedTransaction-mu6HJcHt.js → unsignedTransaction-DZq5iThY.js} +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var Er=Object.defineProperty;var xr=(r,t,e)=>t in r?Er(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var l=(r,t,e)=>(xr(r,typeof t!="symbol"?t+"":t,e),e),Se=(r,t,e)=>{if(!t.has(r))throw TypeError("Cannot "+e)};var h=(r,t,e)=>(Se(r,t,"read from private field"),e?e.call(r):t.get(r)),v=(r,t,e)=>{if(t.has(r))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(r):t.set(r,e)},A=(r,t,e,n)=>(Se(r,t,"write to private field"),n?n.call(r,e):t.set(r,e),e);var rn=(r,t,e,n)=>({set _(s){A(r,t,s,e)},get _(){return h(r,t,n)}}),P=(r,t,e)=>(Se(r,t,"access private method"),e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("./index-Tl7zYqHL.js"),sn=require("./index-BqGvvv6N.js");require("./index-abvwfKBf.js");const nt=require("./evm-3AGyBI-h.js"),Nr=require("./chain-BT07YJHt.js"),Ar="6.12.1";function Tr(r,t,e){const n=t.split("|").map(i=>i.trim());for(let i=0;i<n.length;i++)switch(t){case"any":return;case"bigint":case"boolean":case"number":case"string":if(typeof r===t)return}const s=new Error(`invalid value for type ${t}`);throw s.code="INVALID_ARGUMENT",s.argument=`value.${e}`,s.value=r,s}async function Le(r){const t=Object.keys(r);return(await Promise.all(t.map(n=>Promise.resolve(r[n])))).reduce((n,s,i)=>(n[t[i]]=s,n),{})}function E(r,t,e){for(let n in t){let s=t[n];const i=e?e[n]:null;i&&Tr(s,i,n),Object.defineProperty(r,n,{enumerable:!0,value:s,writable:!1})}}function Lt(r){if(r==null)return"null";if(Array.isArray(r))return"[ "+r.map(Lt).join(", ")+" ]";if(r instanceof Uint8Array){const t="0123456789abcdef";let e="0x";for(let n=0;n<r.length;n++)e+=t[r[n]>>4],e+=t[r[n]&15];return e}if(typeof r=="object"&&typeof r.toJSON=="function")return Lt(r.toJSON());switch(typeof r){case"boolean":case"symbol":return r.toString();case"bigint":return BigInt(r).toString();case"number":return r.toString();case"string":return JSON.stringify(r);case"object":{const t=Object.keys(r);return t.sort(),"{ "+t.map(e=>`${Lt(e)}: ${Lt(r[e])}`).join(", ")+" }"}}return"[ COULD NOT SERIALIZE ]"}function Wt(r,t){return r&&r.code===t}function Cn(r){return Wt(r,"CALL_EXCEPTION")}function Qt(r,t,e){let n=r;{const i=[];if(e){if("message"in e||"code"in e||"name"in e)throw new Error(`value will overwrite populated values: ${Lt(e)}`);for(const o in e){if(o==="shortMessage")continue;const a=e[o];i.push(o+"="+Lt(a))}}i.push(`code=${t}`),i.push(`version=${Ar}`),i.length&&(r+=" ("+i.join(", ")+")")}let s;switch(t){case"INVALID_ARGUMENT":s=new TypeError(r);break;case"NUMERIC_FAULT":case"BUFFER_OVERRUN":s=new RangeError(r);break;default:s=new Error(r)}return E(s,{code:t}),e&&Object.assign(s,e),s.shortMessage==null&&E(s,{shortMessage:n}),s}function b(r,t,e,n){if(!r)throw Qt(t,e,n)}function p(r,t,e,n){b(r,t,"INVALID_ARGUMENT",{argument:e,value:n})}function Bn(r,t,e){e==null&&(e=""),e&&(e=": "+e),b(r>=t,"missing arguemnt"+e,"MISSING_ARGUMENT",{count:r,expectedCount:t}),b(r<=t,"too many arguments"+e,"UNEXPECTED_ARGUMENT",{count:r,expectedCount:t})}["NFD","NFC","NFKD","NFKC"].reduce((r,t)=>{try{if("test".normalize(t)!=="test")throw new Error("bad");if(t==="NFD"&&"é".normalize("NFD")!=="é")throw new Error("broken");r.push(t)}catch{}return r},[]);function Ke(r,t,e){if(e==null&&(e=""),r!==t){let n=e,s="new";e&&(n+=".",s+=" "+e),b(!1,`private constructor; use ${n}from* methods`,"UNSUPPORTED_OPERATION",{operation:s})}}function Fn(r,t,e){if(r instanceof Uint8Array)return e?new Uint8Array(r):r;if(typeof r=="string"&&r.match(/^0x([0-9a-f][0-9a-f])*$/i)){const n=new Uint8Array((r.length-2)/2);let s=2;for(let i=0;i<n.length;i++)n[i]=parseInt(r.substring(s,s+2),16),s+=2;return n}p(!1,"invalid BytesLike value",t||"value",r)}function lt(r,t){return Fn(r,t,!1)}function et(r,t){return Fn(r,t,!0)}function at(r,t){return!(typeof r!="string"||!r.match(/^0x[0-9A-Fa-f]*$/)||typeof t=="number"&&r.length!==2+2*t||t===!0&&r.length%2!==0)}function kr(r){return at(r,!0)||r instanceof Uint8Array}const on="0123456789abcdef";function I(r){const t=lt(r);let e="0x";for(let n=0;n<t.length;n++){const s=t[n];e+=on[(s&240)>>4]+on[s&15]}return e}function $t(r){return"0x"+r.map(t=>I(t).substring(2)).join("")}function Bt(r,t,e){const n=lt(r);return e!=null&&e>n.length&&b(!1,"cannot slice beyond data bounds","BUFFER_OVERRUN",{buffer:n,length:n.length,offset:e}),I(n.slice(t??0,e??n.length))}function Ln(r,t,e){const n=lt(r);b(t>=n.length,"padding exceeds data length","BUFFER_OVERRUN",{buffer:new Uint8Array(n),length:t,offset:t+1});const s=new Uint8Array(t);return s.fill(0),e?s.set(n,t-n.length):s.set(n,0),I(s)}function vr(r,t){return Ln(r,t,!0)}function Or(r,t){return Ln(r,t,!1)}const Ne=BigInt(0),K=BigInt(1),_t=9007199254740991;function Pr(r,t){const e=Ae(r,"value"),n=BigInt(ht(t,"width"));if(b(e>>n===Ne,"overflow","NUMERIC_FAULT",{operation:"fromTwos",fault:"overflow",value:r}),e>>n-K){const s=(K<<n)-K;return-((~e&s)+K)}return e}function Rr(r,t){let e=bt(r,"value");const n=BigInt(ht(t,"width")),s=K<<n-K;if(e<Ne){e=-e,b(e<=s,"too low","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:r});const i=(K<<n)-K;return(~e&i)+K}else b(e<s,"too high","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:r});return e}function ae(r,t){const e=Ae(r,"value"),n=BigInt(ht(t,"bits"));return e&(K<<n)-K}function bt(r,t){switch(typeof r){case"bigint":return r;case"number":return p(Number.isInteger(r),"underflow",t||"value",r),p(r>=-_t&&r<=_t,"overflow",t||"value",r),BigInt(r);case"string":try{if(r==="")throw new Error("empty string");return r[0]==="-"&&r[1]!=="-"?-BigInt(r.substring(1)):BigInt(r)}catch(e){p(!1,`invalid BigNumberish string: ${e.message}`,t||"value",r)}}p(!1,"invalid BigNumberish value",t||"value",r)}function Ae(r,t){const e=bt(r,t);return b(e>=Ne,"unsigned value cannot be negative","NUMERIC_FAULT",{fault:"overflow",operation:"getUint",value:r}),e}const an="0123456789abcdef";function _n(r){if(r instanceof Uint8Array){let t="0x0";for(const e of r)t+=an[e>>4],t+=an[e&15];return BigInt(t)}return bt(r)}function ht(r,t){switch(typeof r){case"bigint":return p(r>=-_t&&r<=_t,"overflow",t||"value",r),Number(r);case"number":return p(Number.isInteger(r),"underflow",t||"value",r),p(r>=-_t&&r<=_t,"overflow",t||"value",r),r;case"string":try{if(r==="")throw new Error("empty string");return ht(BigInt(r),t)}catch(e){p(!1,`invalid numeric string: ${e.message}`,t||"value",r)}}p(!1,"invalid numeric value",t||"value",r)}function Ir(r){return ht(_n(r))}function $n(r,t){let n=Ae(r,"value").toString(16);if(t==null)n.length%2&&(n="0"+n);else{const s=ht(t,"width");for(b(s*2>=n.length,`value exceeds width (${s} bytes)`,"NUMERIC_FAULT",{operation:"toBeHex",fault:"overflow",value:r});n.length<s*2;)n="0"+n}return"0x"+n}function Ur(r){const t=Ae(r,"value");if(t===Ne)return new Uint8Array([]);let e=t.toString(16);e.length%2&&(e="0"+e);const n=new Uint8Array(e.length/2);for(let s=0;s<n.length;s++){const i=s*2;n[s]=parseInt(e.substring(i,i+2),16)}return n}var Dt;class Sr{constructor(t,e,n){l(this,"filter");l(this,"emitter");v(this,Dt,void 0);A(this,Dt,e),E(this,{emitter:t,filter:n})}async removeListener(){h(this,Dt)!=null&&await this.emitter.off(this.filter,h(this,Dt))}}Dt=new WeakMap;function Cr(r,t,e,n,s){p(!1,`invalid codepoint at offset ${t}; ${r}`,"bytes",e)}function Dn(r,t,e,n,s){if(r==="BAD_PREFIX"||r==="UNEXPECTED_CONTINUE"){let i=0;for(let o=t+1;o<e.length&&e[o]>>6===2;o++)i++;return i}return r==="OVERRUN"?e.length-t-1:0}function Br(r,t,e,n,s){return r==="OVERLONG"?(p(typeof s=="number","invalid bad code point for replacement","badCodepoint",s),n.push(s),0):(n.push(65533),Dn(r,t,e))}const Fr=Object.freeze({error:Cr,ignore:Dn,replace:Br});function Lr(r,t){t==null&&(t=Fr.error);const e=lt(r,"bytes"),n=[];let s=0;for(;s<e.length;){const i=e[s++];if(!(i>>7)){n.push(i);continue}let o=null,a=null;if((i&224)===192)o=1,a=127;else if((i&240)===224)o=2,a=2047;else if((i&248)===240)o=3,a=65535;else{(i&192)===128?s+=t("UNEXPECTED_CONTINUE",s-1,e,n):s+=t("BAD_PREFIX",s-1,e,n);continue}if(s-1+o>=e.length){s+=t("OVERRUN",s-1,e,n);continue}let c=i&(1<<8-o-1)-1;for(let u=0;u<o;u++){let f=e[s];if((f&192)!=128){s+=t("MISSING_CONTINUE",s,e,n),c=null;break}c=c<<6|f&63,s++}if(c!==null){if(c>1114111){s+=t("OUT_OF_RANGE",s-1-o,e,n,c);continue}if(c>=55296&&c<=57343){s+=t("UTF16_SURROGATE",s-1-o,e,n,c);continue}if(c<=a){s+=t("OVERLONG",s-1-o,e,n,c);continue}n.push(c)}}return n}function Vn(r,t){p(typeof r=="string","invalid string value","str",r);let e=[];for(let n=0;n<r.length;n++){const s=r.charCodeAt(n);if(s<128)e.push(s);else if(s<2048)e.push(s>>6|192),e.push(s&63|128);else if((s&64512)==55296){n++;const i=r.charCodeAt(n);p(n<r.length&&(i&64512)===56320,"invalid surrogate pair","str",r);const o=65536+((s&1023)<<10)+(i&1023);e.push(o>>18|240),e.push(o>>12&63|128),e.push(o>>6&63|128),e.push(o&63|128)}else e.push(s>>12|224),e.push(s>>6&63|128),e.push(s&63|128)}return new Uint8Array(e)}function _r(r){return r.map(t=>t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode((t>>10&1023)+55296,(t&1023)+56320))).join("")}function $r(r,t){return _r(Lr(r,t))}const L=32,_e=new Uint8Array(L),Dr=["then"],ce={};function Jt(r,t){const e=new Error(`deferred error during ABI decoding triggered accessing ${r}`);throw e.error=t,e}var pt;const xt=class xt extends Array{constructor(...e){const n=e[0];let s=e[1],i=(e[2]||[]).slice(),o=!0;n!==ce&&(s=e,i=[],o=!1);super(s.length);v(this,pt,void 0);s.forEach((c,u)=>{this[u]=c});const a=i.reduce((c,u)=>(typeof u=="string"&&c.set(u,(c.get(u)||0)+1),c),new Map);if(A(this,pt,Object.freeze(s.map((c,u)=>{const f=i[u];return f!=null&&a.get(f)===1?f:null}))),!!o)return Object.freeze(this),new Proxy(this,{get:(c,u,f)=>{if(typeof u=="string"){if(u.match(/^[0-9]+$/)){const g=ht(u,"%index");if(g<0||g>=this.length)throw new RangeError("out of result range");const m=c[g];return m instanceof Error&&Jt(`index ${g}`,m),m}if(Dr.indexOf(u)>=0)return Reflect.get(c,u,f);const d=c[u];if(d instanceof Function)return function(...g){return d.apply(this===f?c:this,g)};if(!(u in c))return c.getValue.apply(this===f?c:this,[u])}return Reflect.get(c,u,f)}})}toArray(e){const n=[];return this.forEach((s,i)=>{s instanceof Error&&Jt(`index ${i}`,s),e&&s instanceof xt&&(s=s.toArray(e)),n.push(s)}),n}toObject(e){return h(this,pt).reduce((n,s,i)=>{if(b(s!=null,"value at index ${ index } unnamed","UNSUPPORTED_OPERATION",{operation:"toObject()"}),!(s in n)){let o=this.getValue(s);e&&o instanceof xt&&(o=o.toObject(e)),n[s]=o}return n},{})}slice(e,n){e==null&&(e=0),e<0&&(e+=this.length,e<0&&(e=0)),n==null&&(n=this.length),n<0&&(n+=this.length,n<0&&(n=0)),n>this.length&&(n=this.length);const s=[],i=[];for(let o=e;o<n;o++)s.push(this[o]),i.push(h(this,pt)[o]);return new xt(ce,s,i)}filter(e,n){const s=[],i=[];for(let o=0;o<this.length;o++){const a=this[o];a instanceof Error&&Jt(`index ${o}`,a),e.call(n,a,o,this)&&(s.push(a),i.push(h(this,pt)[o]))}return new xt(ce,s,i)}map(e,n){const s=[];for(let i=0;i<this.length;i++){const o=this[i];o instanceof Error&&Jt(`index ${i}`,o),s.push(e.call(n,o,i,this))}return s}getValue(e){const n=h(this,pt).indexOf(e);if(n===-1)return;const s=this[n];return s instanceof Error&&Jt(`property ${JSON.stringify(e)}`,s.error),s}static fromItems(e,n){return new xt(ce,e,n)}};pt=new WeakMap;let ye=xt;function cn(r){let t=Ur(r);return b(t.length<=L,"value out-of-bounds","BUFFER_OVERRUN",{buffer:t,length:L,offset:t.length}),t.length!==L&&(t=et($t([_e.slice(t.length%L),t]))),t}class dt{constructor(t,e,n,s){l(this,"name");l(this,"type");l(this,"localName");l(this,"dynamic");E(this,{name:t,type:e,localName:n,dynamic:s},{name:"string",type:"string",localName:"string",dynamic:"boolean"})}_throwError(t,e){p(!1,t,this.localName,e)}}var ot,Tt,Vt,he;class $e{constructor(){v(this,Vt);v(this,ot,void 0);v(this,Tt,void 0);A(this,ot,[]),A(this,Tt,0)}get data(){return $t(h(this,ot))}get length(){return h(this,Tt)}appendWriter(t){return P(this,Vt,he).call(this,et(t.data))}writeBytes(t){let e=et(t);const n=e.length%L;return n&&(e=et($t([e,_e.slice(n)]))),P(this,Vt,he).call(this,e)}writeValue(t){return P(this,Vt,he).call(this,cn(t))}writeUpdatableValue(){const t=h(this,ot).length;return h(this,ot).push(_e),A(this,Tt,h(this,Tt)+L),e=>{h(this,ot)[t]=cn(e)}}}ot=new WeakMap,Tt=new WeakMap,Vt=new WeakSet,he=function(t){return h(this,ot).push(t),A(this,Tt,h(this,Tt)+t.length),t.length};var $,G,kt,vt,gt,ne,Ve,be,Mn;const je=class je{constructor(t,e,n){v(this,ne);v(this,be);l(this,"allowLoose");v(this,$,void 0);v(this,G,void 0);v(this,kt,void 0);v(this,vt,void 0);v(this,gt,void 0);E(this,{allowLoose:!!e}),A(this,$,et(t)),A(this,kt,0),A(this,vt,null),A(this,gt,n??1024),A(this,G,0)}get data(){return I(h(this,$))}get dataLength(){return h(this,$).length}get consumed(){return h(this,G)}get bytes(){return new Uint8Array(h(this,$))}subReader(t){const e=new je(h(this,$).slice(h(this,G)+t),this.allowLoose,h(this,gt));return A(e,vt,this),e}readBytes(t,e){let n=P(this,be,Mn).call(this,0,t,!!e);return P(this,ne,Ve).call(this,t),A(this,G,h(this,G)+n.length),n.slice(0,t)}readValue(){return _n(this.readBytes(L))}readIndex(){return Ir(this.readBytes(L))}};$=new WeakMap,G=new WeakMap,kt=new WeakMap,vt=new WeakMap,gt=new WeakMap,ne=new WeakSet,Ve=function(t){var e;if(h(this,vt))return P(e=h(this,vt),ne,Ve).call(e,t);A(this,kt,h(this,kt)+t),b(h(this,gt)<1||h(this,kt)<=h(this,gt)*this.dataLength,`compressed ABI data exceeds inflation ratio of ${h(this,gt)} ( see: https://github.com/ethers-io/ethers.js/issues/4537 )`,"BUFFER_OVERRUN",{buffer:et(h(this,$)),offset:h(this,G),length:t,info:{bytesRead:h(this,kt),dataLength:this.dataLength}})},be=new WeakSet,Mn=function(t,e,n){let s=Math.ceil(e/L)*L;return h(this,G)+s>h(this,$).length&&(this.allowLoose&&n&&h(this,G)+e<=h(this,$).length?s=e:b(!1,"data out-of-bounds","BUFFER_OVERRUN",{buffer:et(h(this,$)),length:h(this,$).length,offset:h(this,G)+s})),h(this,$).slice(h(this,G),h(this,G)+s)};let De=je;function un(r){if(!Number.isSafeInteger(r)||r<0)throw new Error(`Wrong positive integer: ${r}`)}function Gn(r,...t){if(!(r instanceof Uint8Array))throw new Error("Expected Uint8Array");if(t.length>0&&!t.includes(r.length))throw new Error(`Expected Uint8Array of length ${t}, not of length=${r.length}`)}function ln(r,t=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(t&&r.finished)throw new Error("Hash#digest() has already been called")}function Vr(r,t){Gn(r);const e=t.outputLen;if(r.length<e)throw new Error(`digestInto() expects output buffer of length at least ${e}`)}/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Mr=r=>r instanceof Uint8Array,Gr=r=>new Uint32Array(r.buffer,r.byteOffset,Math.floor(r.byteLength/4)),Hr=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!Hr)throw new Error("Non little-endian hardware is not supported");function zr(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function Hn(r){if(typeof r=="string"&&(r=zr(r)),!Mr(r))throw new Error(`expected Uint8Array, got ${typeof r}`);return r}class Wr{clone(){return this._cloneInto()}}function Jr(r){const t=n=>r().update(Hn(n)).digest(),e=r();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>r(),t}const ue=BigInt(2**32-1),fn=BigInt(32);function Kr(r,t=!1){return t?{h:Number(r&ue),l:Number(r>>fn&ue)}:{h:Number(r>>fn&ue)|0,l:Number(r&ue)|0}}function Xr(r,t=!1){let e=new Uint32Array(r.length),n=new Uint32Array(r.length);for(let s=0;s<r.length;s++){const{h:i,l:o}=Kr(r[s],t);[e[s],n[s]]=[i,o]}return[e,n]}const Yr=(r,t,e)=>r<<e|t>>>32-e,Zr=(r,t,e)=>t<<e|r>>>32-e,Qr=(r,t,e)=>t<<e-32|r>>>64-e,qr=(r,t,e)=>r<<e-32|t>>>64-e,[zn,Wn,Jn]=[[],[],[]],jr=BigInt(0),Kt=BigInt(1),ts=BigInt(2),es=BigInt(7),ns=BigInt(256),rs=BigInt(113);for(let r=0,t=Kt,e=1,n=0;r<24;r++){[e,n]=[n,(2*e+3*n)%5],zn.push(2*(5*n+e)),Wn.push((r+1)*(r+2)/2%64);let s=jr;for(let i=0;i<7;i++)t=(t<<Kt^(t>>es)*rs)%ns,t&ts&&(s^=Kt<<(Kt<<BigInt(i))-Kt);Jn.push(s)}const[ss,is]=Xr(Jn,!0),hn=(r,t,e)=>e>32?Qr(r,t,e):Yr(r,t,e),dn=(r,t,e)=>e>32?qr(r,t,e):Zr(r,t,e);function os(r,t=24){const e=new Uint32Array(10);for(let n=24-t;n<24;n++){for(let o=0;o<10;o++)e[o]=r[o]^r[o+10]^r[o+20]^r[o+30]^r[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,c=(o+2)%10,u=e[c],f=e[c+1],d=hn(u,f,1)^e[a],g=dn(u,f,1)^e[a+1];for(let m=0;m<50;m+=10)r[o+m]^=d,r[o+m+1]^=g}let s=r[2],i=r[3];for(let o=0;o<24;o++){const a=Wn[o],c=hn(s,i,a),u=dn(s,i,a),f=zn[o];s=r[f],i=r[f+1],r[f]=c,r[f+1]=u}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)e[a]=r[o+a];for(let a=0;a<10;a++)r[o+a]^=~e[(a+2)%10]&e[(a+4)%10]}r[0]^=ss[n],r[1]^=is[n]}e.fill(0)}class Xe extends Wr{constructor(t,e,n,s=!1,i=24){if(super(),this.blockLen=t,this.suffix=e,this.outputLen=n,this.enableXOF=s,this.rounds=i,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,un(n),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=Gr(this.state)}keccak(){os(this.state32,this.rounds),this.posOut=0,this.pos=0}update(t){ln(this);const{blockLen:e,state:n}=this;t=Hn(t);const s=t.length;for(let i=0;i<s;){const o=Math.min(e-this.pos,s-i);for(let a=0;a<o;a++)n[this.pos++]^=t[i++];this.pos===e&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:e,pos:n,blockLen:s}=this;t[n]^=e,e&128&&n===s-1&&this.keccak(),t[s-1]^=128,this.keccak()}writeInto(t){ln(this,!1),Gn(t),this.finish();const e=this.state,{blockLen:n}=this;for(let s=0,i=t.length;s<i;){this.posOut>=n&&this.keccak();const o=Math.min(n-this.posOut,i-s);t.set(e.subarray(this.posOut,this.posOut+o),s),this.posOut+=o,s+=o}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return un(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Vr(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(t){const{blockLen:e,suffix:n,outputLen:s,rounds:i,enableXOF:o}=this;return t||(t=new Xe(e,n,s,o,i)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=i,t.suffix=n,t.outputLen=s,t.enableXOF=o,t.destroyed=this.destroyed,t}}const as=(r,t,e)=>Jr(()=>new Xe(t,r,e)),cs=as(1,136,256/8);let Kn=!1;const Xn=function(r){return cs(r)};let Yn=Xn;function wt(r){const t=lt(r,"data");return I(Yn(t))}wt._=Xn;wt.lock=function(){Kn=!0};wt.register=function(r){if(Kn)throw new TypeError("keccak256 is locked");Yn=r};Object.freeze(wt);const us=BigInt(0),ls=BigInt(36);function pn(r){r=r.toLowerCase();const t=r.substring(2).split(""),e=new Uint8Array(40);for(let s=0;s<40;s++)e[s]=t[s].charCodeAt(0);const n=lt(wt(e));for(let s=0;s<40;s+=2)n[s>>1]>>4>=8&&(t[s]=t[s].toUpperCase()),(n[s>>1]&15)>=8&&(t[s+1]=t[s+1].toUpperCase());return"0x"+t.join("")}const Ye={};for(let r=0;r<10;r++)Ye[String(r)]=String(r);for(let r=0;r<26;r++)Ye[String.fromCharCode(65+r)]=String(10+r);const gn=15;function fs(r){r=r.toUpperCase(),r=r.substring(4)+r.substring(0,2)+"00";let t=r.split("").map(n=>Ye[n]).join("");for(;t.length>=gn;){let n=t.substring(0,gn);t=parseInt(n,10)%97+t.substring(n.length)}let e=String(98-parseInt(t,10)%97);for(;e.length<2;)e="0"+e;return e}const hs=function(){const r={};for(let t=0;t<36;t++){const e="0123456789abcdefghijklmnopqrstuvwxyz"[t];r[e]=BigInt(t)}return r}();function ds(r){r=r.toLowerCase();let t=us;for(let e=0;e<r.length;e++)t=t*ls+hs[r[e]];return t}function Rt(r){if(p(typeof r=="string","invalid address","address",r),r.match(/^(0x)?[0-9a-fA-F]{40}$/)){r.startsWith("0x")||(r="0x"+r);const t=pn(r);return p(!r.match(/([A-F].*[a-f])|([a-f].*[A-F])/)||t===r,"bad address checksum","address",r),t}if(r.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){p(r.substring(2,4)===fs(r),"bad icap checksum","address",r);let t=ds(r.substring(4)).toString(16);for(;t.length<40;)t="0"+t;return pn("0x"+t)}p(!1,"invalid address","address",r)}function Zn(r){return r&&typeof r.getAddress=="function"}async function Ce(r,t){const e=await t;return(e==null||e==="0x0000000000000000000000000000000000000000")&&(b(typeof r!="string","unconfigured name","UNCONFIGURED_NAME",{value:r}),p(!1,"invalid AddressLike value; did not resolve to a value address","target",r)),Rt(e)}function qt(r,t){if(typeof r=="string")return r.match(/^0x[0-9a-f]{40}$/i)?Rt(r):(b(t!=null,"ENS resolution requires a provider","UNSUPPORTED_OPERATION",{operation:"resolveName"}),Ce(r,t.resolveName(r)));if(Zn(r))return Ce(r,r.getAddress());if(r&&typeof r.then=="function")return Ce(r,r);p(!1,"unsupported addressable value","target",r)}const rt={};function y(r,t){let e=!1;return t<0&&(e=!0,t*=-1),new F(rt,`${e?"":"u"}int${t}`,r,{signed:e,width:t})}function T(r,t){return new F(rt,`bytes${t||""}`,r,{size:t})}const yn=Symbol.for("_ethers_typed");var Ot;const st=class st{constructor(t,e,n,s){l(this,"type");l(this,"value");v(this,Ot,void 0);l(this,"_typedSymbol");s==null&&(s=null),Ke(rt,t,"Typed"),E(this,{_typedSymbol:yn,type:e,value:n}),A(this,Ot,s),this.format()}format(){if(this.type==="array")throw new Error("");if(this.type==="dynamicArray")throw new Error("");return this.type==="tuple"?`tuple(${this.value.map(t=>t.format()).join(",")})`:this.type}defaultValue(){return 0}minValue(){return 0}maxValue(){return 0}isBigInt(){return!!this.type.match(/^u?int[0-9]+$/)}isData(){return this.type.startsWith("bytes")}isString(){return this.type==="string"}get tupleName(){if(this.type!=="tuple")throw TypeError("not a tuple");return h(this,Ot)}get arrayLength(){if(this.type!=="array")throw TypeError("not an array");return h(this,Ot)===!0?-1:h(this,Ot)===!1?this.value.length:null}static from(t,e){return new st(rt,t,e)}static uint8(t){return y(t,8)}static uint16(t){return y(t,16)}static uint24(t){return y(t,24)}static uint32(t){return y(t,32)}static uint40(t){return y(t,40)}static uint48(t){return y(t,48)}static uint56(t){return y(t,56)}static uint64(t){return y(t,64)}static uint72(t){return y(t,72)}static uint80(t){return y(t,80)}static uint88(t){return y(t,88)}static uint96(t){return y(t,96)}static uint104(t){return y(t,104)}static uint112(t){return y(t,112)}static uint120(t){return y(t,120)}static uint128(t){return y(t,128)}static uint136(t){return y(t,136)}static uint144(t){return y(t,144)}static uint152(t){return y(t,152)}static uint160(t){return y(t,160)}static uint168(t){return y(t,168)}static uint176(t){return y(t,176)}static uint184(t){return y(t,184)}static uint192(t){return y(t,192)}static uint200(t){return y(t,200)}static uint208(t){return y(t,208)}static uint216(t){return y(t,216)}static uint224(t){return y(t,224)}static uint232(t){return y(t,232)}static uint240(t){return y(t,240)}static uint248(t){return y(t,248)}static uint256(t){return y(t,256)}static uint(t){return y(t,256)}static int8(t){return y(t,-8)}static int16(t){return y(t,-16)}static int24(t){return y(t,-24)}static int32(t){return y(t,-32)}static int40(t){return y(t,-40)}static int48(t){return y(t,-48)}static int56(t){return y(t,-56)}static int64(t){return y(t,-64)}static int72(t){return y(t,-72)}static int80(t){return y(t,-80)}static int88(t){return y(t,-88)}static int96(t){return y(t,-96)}static int104(t){return y(t,-104)}static int112(t){return y(t,-112)}static int120(t){return y(t,-120)}static int128(t){return y(t,-128)}static int136(t){return y(t,-136)}static int144(t){return y(t,-144)}static int152(t){return y(t,-152)}static int160(t){return y(t,-160)}static int168(t){return y(t,-168)}static int176(t){return y(t,-176)}static int184(t){return y(t,-184)}static int192(t){return y(t,-192)}static int200(t){return y(t,-200)}static int208(t){return y(t,-208)}static int216(t){return y(t,-216)}static int224(t){return y(t,-224)}static int232(t){return y(t,-232)}static int240(t){return y(t,-240)}static int248(t){return y(t,-248)}static int256(t){return y(t,-256)}static int(t){return y(t,-256)}static bytes1(t){return T(t,1)}static bytes2(t){return T(t,2)}static bytes3(t){return T(t,3)}static bytes4(t){return T(t,4)}static bytes5(t){return T(t,5)}static bytes6(t){return T(t,6)}static bytes7(t){return T(t,7)}static bytes8(t){return T(t,8)}static bytes9(t){return T(t,9)}static bytes10(t){return T(t,10)}static bytes11(t){return T(t,11)}static bytes12(t){return T(t,12)}static bytes13(t){return T(t,13)}static bytes14(t){return T(t,14)}static bytes15(t){return T(t,15)}static bytes16(t){return T(t,16)}static bytes17(t){return T(t,17)}static bytes18(t){return T(t,18)}static bytes19(t){return T(t,19)}static bytes20(t){return T(t,20)}static bytes21(t){return T(t,21)}static bytes22(t){return T(t,22)}static bytes23(t){return T(t,23)}static bytes24(t){return T(t,24)}static bytes25(t){return T(t,25)}static bytes26(t){return T(t,26)}static bytes27(t){return T(t,27)}static bytes28(t){return T(t,28)}static bytes29(t){return T(t,29)}static bytes30(t){return T(t,30)}static bytes31(t){return T(t,31)}static bytes32(t){return T(t,32)}static address(t){return new st(rt,"address",t)}static bool(t){return new st(rt,"bool",!!t)}static bytes(t){return new st(rt,"bytes",t)}static string(t){return new st(rt,"string",t)}static array(t,e){throw new Error("not implemented yet")}static tuple(t,e){throw new Error("not implemented yet")}static overrides(t){return new st(rt,"overrides",Object.assign({},t))}static isTyped(t){return t&&typeof t=="object"&&"_typedSymbol"in t&&t._typedSymbol===yn}static dereference(t,e){if(st.isTyped(t)){if(t.type!==e)throw new Error(`invalid type: expecetd ${e}, got ${t.type}`);return t.value}return t}};Ot=new WeakMap;let F=st;class ps extends dt{constructor(t){super("address","address",t,!1)}defaultValue(){return"0x0000000000000000000000000000000000000000"}encode(t,e){let n=F.dereference(e,"string");try{n=Rt(n)}catch(s){return this._throwError(s.message,e)}return t.writeValue(n)}decode(t){return Rt($n(t.readValue(),20))}}class gs extends dt{constructor(e){super(e.name,e.type,"_",e.dynamic);l(this,"coder");this.coder=e}defaultValue(){return this.coder.defaultValue()}encode(e,n){return this.coder.encode(e,n)}decode(e){return this.coder.decode(e)}}function Qn(r,t,e){let n=[];if(Array.isArray(e))n=e;else if(e&&typeof e=="object"){let c={};n=t.map(u=>{const f=u.localName;return b(f,"cannot encode object for signature with missing names","INVALID_ARGUMENT",{argument:"values",info:{coder:u},value:e}),b(!c[f],"cannot encode object for signature with duplicate names","INVALID_ARGUMENT",{argument:"values",info:{coder:u},value:e}),c[f]=!0,e[f]})}else p(!1,"invalid tuple value","tuple",e);p(t.length===n.length,"types/value length mismatch","tuple",e);let s=new $e,i=new $e,o=[];t.forEach((c,u)=>{let f=n[u];if(c.dynamic){let d=i.length;c.encode(i,f);let g=s.writeUpdatableValue();o.push(m=>{g(m+d)})}else c.encode(s,f)}),o.forEach(c=>{c(s.length)});let a=r.appendWriter(s);return a+=r.appendWriter(i),a}function qn(r,t){let e=[],n=[],s=r.subReader(0);return t.forEach(i=>{let o=null;if(i.dynamic){let a=r.readIndex(),c=s.subReader(a);try{o=i.decode(c)}catch(u){if(Wt(u,"BUFFER_OVERRUN"))throw u;o=u,o.baseType=i.name,o.name=i.localName,o.type=i.type}}else try{o=i.decode(r)}catch(a){if(Wt(a,"BUFFER_OVERRUN"))throw a;o=a,o.baseType=i.name,o.name=i.localName,o.type=i.type}if(o==null)throw new Error("investigate");e.push(o),n.push(i.localName||null)}),ye.fromItems(e,n)}class ys extends dt{constructor(e,n,s){const i=e.type+"["+(n>=0?n:"")+"]",o=n===-1||e.dynamic;super("array",i,s,o);l(this,"coder");l(this,"length");E(this,{coder:e,length:n})}defaultValue(){const e=this.coder.defaultValue(),n=[];for(let s=0;s<this.length;s++)n.push(e);return n}encode(e,n){const s=F.dereference(n,"array");Array.isArray(s)||this._throwError("expected array value",s);let i=this.length;i===-1&&(i=s.length,e.writeValue(s.length)),Bn(s.length,i,"coder array"+(this.localName?" "+this.localName:""));let o=[];for(let a=0;a<s.length;a++)o.push(this.coder);return Qn(e,o,s)}decode(e){let n=this.length;n===-1&&(n=e.readIndex(),b(n*L<=e.dataLength,"insufficient data length","BUFFER_OVERRUN",{buffer:e.bytes,offset:n*L,length:e.dataLength}));let s=[];for(let i=0;i<n;i++)s.push(new gs(this.coder));return qn(e,s)}}class ms extends dt{constructor(t){super("bool","bool",t,!1)}defaultValue(){return!1}encode(t,e){const n=F.dereference(e,"bool");return t.writeValue(n?1:0)}decode(t){return!!t.readValue()}}class jn extends dt{constructor(t,e){super(t,t,e,!0)}defaultValue(){return"0x"}encode(t,e){e=et(e);let n=t.writeValue(e.length);return n+=t.writeBytes(e),n}decode(t){return t.readBytes(t.readIndex(),!0)}}class ws extends jn{constructor(t){super("bytes",t)}decode(t){return I(super.decode(t))}}class bs extends dt{constructor(e,n){let s="bytes"+String(e);super(s,s,n,!1);l(this,"size");E(this,{size:e},{size:"number"})}defaultValue(){return"0x0000000000000000000000000000000000000000000000000000000000000000".substring(0,2+this.size*2)}encode(e,n){let s=et(F.dereference(n,this.type));return s.length!==this.size&&this._throwError("incorrect data length",n),e.writeBytes(s)}decode(e){return I(e.readBytes(this.size))}}const Es=new Uint8Array([]);class xs extends dt{constructor(t){super("null","",t,!1)}defaultValue(){return null}encode(t,e){return e!=null&&this._throwError("not null",e),t.writeBytes(Es)}decode(t){return t.readBytes(0),null}}const Ns=BigInt(0),As=BigInt(1),Ts=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");class ks extends dt{constructor(e,n,s){const i=(n?"int":"uint")+e*8;super(i,i,s,!1);l(this,"size");l(this,"signed");E(this,{size:e,signed:n},{size:"number",signed:"boolean"})}defaultValue(){return 0}encode(e,n){let s=bt(F.dereference(n,this.type)),i=ae(Ts,L*8);if(this.signed){let o=ae(i,this.size*8-1);(s>o||s<-(o+As))&&this._throwError("value out-of-bounds",n),s=Rr(s,8*L)}else(s<Ns||s>ae(i,this.size*8))&&this._throwError("value out-of-bounds",n);return e.writeValue(s)}decode(e){let n=ae(e.readValue(),this.size*8);return this.signed&&(n=Pr(n,this.size*8)),n}}class vs extends jn{constructor(t){super("string",t)}defaultValue(){return""}encode(t,e){return super.encode(t,Vn(F.dereference(e,"string")))}decode(t){return $r(super.decode(t))}}class le extends dt{constructor(e,n){let s=!1;const i=[];e.forEach(a=>{a.dynamic&&(s=!0),i.push(a.type)});const o="tuple("+i.join(",")+")";super("tuple",o,n,s);l(this,"coders");E(this,{coders:Object.freeze(e.slice())})}defaultValue(){const e=[];this.coders.forEach(s=>{e.push(s.defaultValue())});const n=this.coders.reduce((s,i)=>{const o=i.localName;return o&&(s[o]||(s[o]=0),s[o]++),s},{});return this.coders.forEach((s,i)=>{let o=s.localName;!o||n[o]!==1||(o==="length"&&(o="_length"),e[o]==null&&(e[o]=e[i]))}),Object.freeze(e)}encode(e,n){const s=F.dereference(n,"tuple");return Qn(e,this.coders,s)}decode(e){return qn(e,this.coders)}}function jt(r){return wt(Vn(r))}function Be(r,t){return{address:Rt(r),storageKeys:t.map((e,n)=>(p(at(e,32),"invalid slot",`storageKeys[${n}]`,e),e.toLowerCase()))}}function Os(r){if(Array.isArray(r))return r.map((e,n)=>Array.isArray(e)?(p(e.length===2,"invalid slot set",`value[${n}]`,e),Be(e[0],e[1])):(p(e!=null&&typeof e=="object","invalid address-slot set","value",r),Be(e.address,e.storageKeys)));p(r!=null&&typeof r=="object","invalid access list","value",r);const t=Object.keys(r).map(e=>{const n=r[e].reduce((s,i)=>(s[i]=!0,s),{});return Be(e,Object.keys(n).sort())});return t.sort((e,n)=>e.address.localeCompare(n.address)),t}function _(r){const t=new Set;return r.forEach(e=>t.add(e)),Object.freeze(t)}const Ps="external public payable override",Rs=_(Ps.split(" ")),tr="constant external internal payable private public pure view override",Is=_(tr.split(" ")),er="constructor error event fallback function receive struct",nr=_(er.split(" ")),rr="calldata memory storage payable indexed",Us=_(rr.split(" ")),Ss="tuple returns",Cs=[er,rr,Ss,tr].join(" "),Bs=_(Cs.split(" ")),Fs={"(":"OPEN_PAREN",")":"CLOSE_PAREN","[":"OPEN_BRACKET","]":"CLOSE_BRACKET",",":"COMMA","@":"AT"},Ls=new RegExp("^(\\s*)"),_s=new RegExp("^([0-9]+)"),$s=new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)"),sr=new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)$"),ir=new RegExp("^(address|bool|bytes([0-9]*)|string|u?int([0-9]*))$");var S,J,re,Me;const Ee=class Ee{constructor(t){v(this,re);v(this,S,void 0);v(this,J,void 0);A(this,S,0),A(this,J,t.slice())}get offset(){return h(this,S)}get length(){return h(this,J).length-h(this,S)}clone(){return new Ee(h(this,J))}reset(){A(this,S,0)}popKeyword(t){const e=this.peek();if(e.type!=="KEYWORD"||!t.has(e.text))throw new Error(`expected keyword ${e.text}`);return this.pop().text}popType(t){if(this.peek().type!==t){const e=this.peek();throw new Error(`expected ${t}; got ${e.type} ${JSON.stringify(e.text)}`)}return this.pop().text}popParen(){const t=this.peek();if(t.type!=="OPEN_PAREN")throw new Error("bad start");const e=P(this,re,Me).call(this,h(this,S)+1,t.match+1);return A(this,S,t.match+1),e}popParams(){const t=this.peek();if(t.type!=="OPEN_PAREN")throw new Error("bad start");const e=[];for(;h(this,S)<t.match-1;){const n=this.peek().linkNext;e.push(P(this,re,Me).call(this,h(this,S)+1,n)),A(this,S,n)}return A(this,S,t.match+1),e}peek(){if(h(this,S)>=h(this,J).length)throw new Error("out-of-bounds");return h(this,J)[h(this,S)]}peekKeyword(t){const e=this.peekType("KEYWORD");return e!=null&&t.has(e)?e:null}peekType(t){if(this.length===0)return null;const e=this.peek();return e.type===t?e.text:null}pop(){const t=this.peek();return rn(this,S)._++,t}toString(){const t=[];for(let e=h(this,S);e<h(this,J).length;e++){const n=h(this,J)[e];t.push(`${n.type}:${n.text}`)}return`<TokenString ${t.join(" ")}>`}};S=new WeakMap,J=new WeakMap,re=new WeakSet,Me=function(t=0,e=0){return new Ee(h(this,J).slice(t,e).map(n=>Object.freeze(Object.assign({},n,{match:n.match-t,linkBack:n.linkBack-t,linkNext:n.linkNext-t}))))};let X=Ee;function Et(r){const t=[],e=o=>{const a=i<r.length?JSON.stringify(r[i]):"$EOI";throw new Error(`invalid token ${a} at ${i}: ${o}`)};let n=[],s=[],i=0;for(;i<r.length;){let o=r.substring(i),a=o.match(Ls);a&&(i+=a[1].length,o=r.substring(i));const c={depth:n.length,linkBack:-1,linkNext:-1,match:-1,type:"",text:"",offset:i,value:-1};t.push(c);let u=Fs[o[0]]||"";if(u){if(c.type=u,c.text=o[0],i++,u==="OPEN_PAREN")n.push(t.length-1),s.push(t.length-1);else if(u=="CLOSE_PAREN")n.length===0&&e("no matching open bracket"),c.match=n.pop(),t[c.match].match=t.length-1,c.depth--,c.linkBack=s.pop(),t[c.linkBack].linkNext=t.length-1;else if(u==="COMMA")c.linkBack=s.pop(),t[c.linkBack].linkNext=t.length-1,s.push(t.length-1);else if(u==="OPEN_BRACKET")c.type="BRACKET";else if(u==="CLOSE_BRACKET"){let f=t.pop().text;if(t.length>0&&t[t.length-1].type==="NUMBER"){const d=t.pop().text;f=d+f,t[t.length-1].value=ht(d)}if(t.length===0||t[t.length-1].type!=="BRACKET")throw new Error("missing opening bracket");t[t.length-1].text+=f}continue}if(a=o.match($s),a){if(c.text=a[1],i+=c.text.length,Bs.has(c.text)){c.type="KEYWORD";continue}if(c.text.match(ir)){c.type="TYPE";continue}c.type="ID";continue}if(a=o.match(_s),a){c.text=a[1],c.type="NUMBER",i+=c.text.length;continue}throw new Error(`unexpected token ${JSON.stringify(o[0])} at position ${i}`)}return new X(t.map(o=>Object.freeze(o)))}function mn(r,t){let e=[];for(const n in t.keys())r.has(n)&&e.push(n);if(e.length>1)throw new Error(`conflicting types: ${e.join(", ")}`)}function Te(r,t){if(t.peekKeyword(nr)){const e=t.pop().text;if(e!==r)throw new Error(`expected ${r}, got ${e}`)}return t.popType("ID")}function ft(r,t){const e=new Set;for(;;){const n=r.peekType("KEYWORD");if(n==null||t&&!t.has(n))break;if(r.pop(),e.has(n))throw new Error(`duplicate keywords: ${JSON.stringify(n)}`);e.add(n)}return Object.freeze(e)}function or(r){let t=ft(r,Is);return mn(t,_("constant payable nonpayable".split(" "))),mn(t,_("pure view payable nonpayable".split(" "))),t.has("view")?"view":t.has("pure")?"pure":t.has("payable")?"payable":t.has("nonpayable")?"nonpayable":t.has("constant")?"view":"nonpayable"}function ut(r,t){return r.popParams().map(e=>C.from(e,t))}function ar(r){if(r.peekType("AT")){if(r.pop(),r.peekType("NUMBER"))return bt(r.pop().text);throw new Error("invalid gas")}return null}function It(r){if(r.length)throw new Error(`unexpected tokens at offset ${r.offset}: ${r.toString()}`)}const Ds=new RegExp(/^(.*)\[([0-9]*)\]$/);function wn(r){const t=r.match(ir);if(p(t,"invalid type","type",r),r==="uint")return"uint256";if(r==="int")return"int256";if(t[2]){const e=parseInt(t[2]);p(e!==0&&e<=32,"invalid bytes length","type",r)}else if(t[3]){const e=parseInt(t[3]);p(e!==0&&e<=256&&e%8===0,"invalid numeric width","type",r)}return r}const R={},V=Symbol.for("_ethers_internal"),bn="_ParamTypeInternal",En="_ErrorInternal",xn="_EventInternal",Nn="_ConstructorInternal",An="_FallbackInternal",Tn="_FunctionInternal",kn="_StructInternal";var Mt,de;const z=class z{constructor(t,e,n,s,i,o,a,c){v(this,Mt);l(this,"name");l(this,"type");l(this,"baseType");l(this,"indexed");l(this,"components");l(this,"arrayLength");l(this,"arrayChildren");if(Ke(t,R,"ParamType"),Object.defineProperty(this,V,{value:bn}),o&&(o=Object.freeze(o.slice())),s==="array"){if(a==null||c==null)throw new Error("")}else if(a!=null||c!=null)throw new Error("");if(s==="tuple"){if(o==null)throw new Error("")}else if(o!=null)throw new Error("");E(this,{name:e,type:n,baseType:s,indexed:i,components:o,arrayLength:a,arrayChildren:c})}format(t){if(t==null&&(t="sighash"),t==="json"){const n=this.name||"";if(this.isArray()){const i=JSON.parse(this.arrayChildren.format("json"));return i.name=n,i.type+=`[${this.arrayLength<0?"":String(this.arrayLength)}]`,JSON.stringify(i)}const s={type:this.baseType==="tuple"?"tuple":this.type,name:n};return typeof this.indexed=="boolean"&&(s.indexed=this.indexed),this.isTuple()&&(s.components=this.components.map(i=>JSON.parse(i.format(t)))),JSON.stringify(s)}let e="";return this.isArray()?(e+=this.arrayChildren.format(t),e+=`[${this.arrayLength<0?"":String(this.arrayLength)}]`):this.isTuple()?e+="("+this.components.map(n=>n.format(t)).join(t==="full"?", ":",")+")":e+=this.type,t!=="sighash"&&(this.indexed===!0&&(e+=" indexed"),t==="full"&&this.name&&(e+=" "+this.name)),e}isArray(){return this.baseType==="array"}isTuple(){return this.baseType==="tuple"}isIndexable(){return this.indexed!=null}walk(t,e){if(this.isArray()){if(!Array.isArray(t))throw new Error("invalid array value");if(this.arrayLength!==-1&&t.length!==this.arrayLength)throw new Error("array is wrong length");const n=this;return t.map(s=>n.arrayChildren.walk(s,e))}if(this.isTuple()){if(!Array.isArray(t))throw new Error("invalid tuple value");if(t.length!==this.components.length)throw new Error("array is wrong length");const n=this;return t.map((s,i)=>n.components[i].walk(s,e))}return e(this.type,t)}async walkAsync(t,e){const n=[],s=[t];return P(this,Mt,de).call(this,n,t,e,i=>{s[0]=i}),n.length&&await Promise.all(n),s[0]}static from(t,e){if(z.isParamType(t))return t;if(typeof t=="string")try{return z.from(Et(t),e)}catch{p(!1,"invalid param type","obj",t)}else if(t instanceof X){let a="",c="",u=null;ft(t,_(["tuple"])).has("tuple")||t.peekType("OPEN_PAREN")?(c="tuple",u=t.popParams().map(k=>z.from(k)),a=`tuple(${u.map(k=>k.format()).join(",")})`):(a=wn(t.popType("TYPE")),c=a);let f=null,d=null;for(;t.length&&t.peekType("BRACKET");){const k=t.pop();f=new z(R,"",a,c,null,u,d,f),d=k.value,a+=k.text,c="array",u=null}let g=null;if(ft(t,Us).has("indexed")){if(!e)throw new Error("");g=!0}const x=t.peekType("ID")?t.pop().text:"";if(t.length)throw new Error("leftover tokens");return new z(R,x,a,c,g,u,d,f)}const n=t.name;p(!n||typeof n=="string"&&n.match(sr),"invalid name","obj.name",n);let s=t.indexed;s!=null&&(p(e,"parameter cannot be indexed","obj.indexed",t.indexed),s=!!s);let i=t.type,o=i.match(Ds);if(o){const a=parseInt(o[2]||"-1"),c=z.from({type:o[1],components:t.components});return new z(R,n||"",i,"array",s,null,a,c)}if(i==="tuple"||i.startsWith("tuple(")||i.startsWith("(")){const a=t.components!=null?t.components.map(u=>z.from(u)):null;return new z(R,n||"",i,"tuple",s,a,null,null)}return i=wn(t.type),new z(R,n||"",i,i,s,null,null,null)}static isParamType(t){return t&&t[V]===bn}};Mt=new WeakSet,de=function(t,e,n,s){if(this.isArray()){if(!Array.isArray(e))throw new Error("invalid array value");if(this.arrayLength!==-1&&e.length!==this.arrayLength)throw new Error("array is wrong length");const o=this.arrayChildren,a=e.slice();a.forEach((c,u)=>{var f;P(f=o,Mt,de).call(f,t,c,n,d=>{a[u]=d})}),s(a);return}if(this.isTuple()){const o=this.components;let a;if(Array.isArray(e))a=e.slice();else{if(e==null||typeof e!="object")throw new Error("invalid tuple value");a=o.map(c=>{if(!c.name)throw new Error("cannot use object value with unnamed components");if(!(c.name in e))throw new Error(`missing value for component ${c.name}`);return e[c.name]})}if(a.length!==this.components.length)throw new Error("array is wrong length");a.forEach((c,u)=>{var f;P(f=o[u],Mt,de).call(f,t,c,n,d=>{a[u]=d})}),s(a);return}const i=n(this.type,e);i.then?t.push(async function(){s(await i)}()):s(i)};let C=z;class Ut{constructor(t,e,n){l(this,"type");l(this,"inputs");Ke(t,R,"Fragment"),n=Object.freeze(n.slice()),E(this,{type:e,inputs:n})}static from(t){if(typeof t=="string"){try{Ut.from(JSON.parse(t))}catch{}return Ut.from(Et(t))}if(t instanceof X)switch(t.peekKeyword(nr)){case"constructor":return ct.from(t);case"error":return D.from(t);case"event":return j.from(t);case"fallback":case"receive":return it.from(t);case"function":return tt.from(t);case"struct":return Pt.from(t)}else if(typeof t=="object"){switch(t.type){case"constructor":return ct.from(t);case"error":return D.from(t);case"event":return j.from(t);case"fallback":case"receive":return it.from(t);case"function":return tt.from(t);case"struct":return Pt.from(t)}b(!1,`unsupported type: ${t.type}`,"UNSUPPORTED_OPERATION",{operation:"Fragment.from"})}p(!1,"unsupported frgament object","obj",t)}static isConstructor(t){return ct.isFragment(t)}static isError(t){return D.isFragment(t)}static isEvent(t){return j.isFragment(t)}static isFunction(t){return tt.isFragment(t)}static isStruct(t){return Pt.isFragment(t)}}class ke extends Ut{constructor(e,n,s,i){super(e,n,i);l(this,"name");p(typeof s=="string"&&s.match(sr),"invalid identifier","name",s),i=Object.freeze(i.slice()),E(this,{name:s})}}function te(r,t){return"("+t.map(e=>e.format(r)).join(r==="full"?", ":",")+")"}class D extends ke{constructor(t,e,n){super(t,"error",e,n),Object.defineProperty(this,V,{value:En})}get selector(){return jt(this.format("sighash")).substring(0,10)}format(t){if(t==null&&(t="sighash"),t==="json")return JSON.stringify({type:"error",name:this.name,inputs:this.inputs.map(n=>JSON.parse(n.format(t)))});const e=[];return t!=="sighash"&&e.push("error"),e.push(this.name+te(t,this.inputs)),e.join(" ")}static from(t){if(D.isFragment(t))return t;if(typeof t=="string")return D.from(Et(t));if(t instanceof X){const e=Te("error",t),n=ut(t);return It(t),new D(R,e,n)}return new D(R,t.name,t.inputs?t.inputs.map(C.from):[])}static isFragment(t){return t&&t[V]===En}}class j extends ke{constructor(e,n,s,i){super(e,"event",n,s);l(this,"anonymous");Object.defineProperty(this,V,{value:xn}),E(this,{anonymous:i})}get topicHash(){return jt(this.format("sighash"))}format(e){if(e==null&&(e="sighash"),e==="json")return JSON.stringify({type:"event",anonymous:this.anonymous,name:this.name,inputs:this.inputs.map(s=>JSON.parse(s.format(e)))});const n=[];return e!=="sighash"&&n.push("event"),n.push(this.name+te(e,this.inputs)),e!=="sighash"&&this.anonymous&&n.push("anonymous"),n.join(" ")}static getTopicHash(e,n){return n=(n||[]).map(i=>C.from(i)),new j(R,e,n,!1).topicHash}static from(e){if(j.isFragment(e))return e;if(typeof e=="string")try{return j.from(Et(e))}catch{p(!1,"invalid event fragment","obj",e)}else if(e instanceof X){const n=Te("event",e),s=ut(e,!0),i=!!ft(e,_(["anonymous"])).has("anonymous");return It(e),new j(R,n,s,i)}return new j(R,e.name,e.inputs?e.inputs.map(n=>C.from(n,!0)):[],!!e.anonymous)}static isFragment(e){return e&&e[V]===xn}}class ct extends Ut{constructor(e,n,s,i,o){super(e,n,s);l(this,"payable");l(this,"gas");Object.defineProperty(this,V,{value:Nn}),E(this,{payable:i,gas:o})}format(e){if(b(e!=null&&e!=="sighash","cannot format a constructor for sighash","UNSUPPORTED_OPERATION",{operation:"format(sighash)"}),e==="json")return JSON.stringify({type:"constructor",stateMutability:this.payable?"payable":"undefined",payable:this.payable,gas:this.gas!=null?this.gas:void 0,inputs:this.inputs.map(s=>JSON.parse(s.format(e)))});const n=[`constructor${te(e,this.inputs)}`];return this.payable&&n.push("payable"),this.gas!=null&&n.push(`@${this.gas.toString()}`),n.join(" ")}static from(e){if(ct.isFragment(e))return e;if(typeof e=="string")try{return ct.from(Et(e))}catch{p(!1,"invalid constuctor fragment","obj",e)}else if(e instanceof X){ft(e,_(["constructor"]));const n=ut(e),s=!!ft(e,Rs).has("payable"),i=ar(e);return It(e),new ct(R,"constructor",n,s,i)}return new ct(R,"constructor",e.inputs?e.inputs.map(C.from):[],!!e.payable,e.gas!=null?e.gas:null)}static isFragment(e){return e&&e[V]===Nn}}class it extends Ut{constructor(e,n,s){super(e,"fallback",n);l(this,"payable");Object.defineProperty(this,V,{value:An}),E(this,{payable:s})}format(e){const n=this.inputs.length===0?"receive":"fallback";if(e==="json"){const s=this.payable?"payable":"nonpayable";return JSON.stringify({type:n,stateMutability:s})}return`${n}()${this.payable?" payable":""}`}static from(e){if(it.isFragment(e))return e;if(typeof e=="string")try{return it.from(Et(e))}catch{p(!1,"invalid fallback fragment","obj",e)}else if(e instanceof X){const n=e.toString(),s=e.peekKeyword(_(["fallback","receive"]));if(p(s,"type must be fallback or receive","obj",n),e.popKeyword(_(["fallback","receive"]))==="receive"){const c=ut(e);return p(c.length===0,"receive cannot have arguments","obj.inputs",c),ft(e,_(["payable"])),It(e),new it(R,[],!0)}let o=ut(e);o.length?p(o.length===1&&o[0].type==="bytes","invalid fallback inputs","obj.inputs",o.map(c=>c.format("minimal")).join(", ")):o=[C.from("bytes")];const a=or(e);if(p(a==="nonpayable"||a==="payable","fallback cannot be constants","obj.stateMutability",a),ft(e,_(["returns"])).has("returns")){const c=ut(e);p(c.length===1&&c[0].type==="bytes","invalid fallback outputs","obj.outputs",c.map(u=>u.format("minimal")).join(", "))}return It(e),new it(R,o,a==="payable")}if(e.type==="receive")return new it(R,[],!0);if(e.type==="fallback"){const n=[C.from("bytes")],s=e.stateMutability==="payable";return new it(R,n,s)}p(!1,"invalid fallback description","obj",e)}static isFragment(e){return e&&e[V]===An}}class tt extends ke{constructor(e,n,s,i,o,a){super(e,"function",n,i);l(this,"constant");l(this,"outputs");l(this,"stateMutability");l(this,"payable");l(this,"gas");Object.defineProperty(this,V,{value:Tn}),o=Object.freeze(o.slice()),E(this,{constant:s==="view"||s==="pure",gas:a,outputs:o,payable:s==="payable",stateMutability:s})}get selector(){return jt(this.format("sighash")).substring(0,10)}format(e){if(e==null&&(e="sighash"),e==="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!=null?this.gas:void 0,inputs:this.inputs.map(s=>JSON.parse(s.format(e))),outputs:this.outputs.map(s=>JSON.parse(s.format(e)))});const n=[];return e!=="sighash"&&n.push("function"),n.push(this.name+te(e,this.inputs)),e!=="sighash"&&(this.stateMutability!=="nonpayable"&&n.push(this.stateMutability),this.outputs&&this.outputs.length&&(n.push("returns"),n.push(te(e,this.outputs))),this.gas!=null&&n.push(`@${this.gas.toString()}`)),n.join(" ")}static getSelector(e,n){return n=(n||[]).map(i=>C.from(i)),new tt(R,e,"view",n,[],null).selector}static from(e){if(tt.isFragment(e))return e;if(typeof e=="string")try{return tt.from(Et(e))}catch{p(!1,"invalid function fragment","obj",e)}else if(e instanceof X){const s=Te("function",e),i=ut(e),o=or(e);let a=[];ft(e,_(["returns"])).has("returns")&&(a=ut(e));const c=ar(e);return It(e),new tt(R,s,o,i,a,c)}let n=e.stateMutability;return n==null&&(n="payable",typeof e.constant=="boolean"?(n="view",e.constant||(n="payable",typeof e.payable=="boolean"&&!e.payable&&(n="nonpayable"))):typeof e.payable=="boolean"&&!e.payable&&(n="nonpayable")),new tt(R,e.name,n,e.inputs?e.inputs.map(C.from):[],e.outputs?e.outputs.map(C.from):[],e.gas!=null?e.gas:null)}static isFragment(e){return e&&e[V]===Tn}}class Pt extends ke{constructor(t,e,n){super(t,"struct",e,n),Object.defineProperty(this,V,{value:kn})}format(){throw new Error("@TODO")}static from(t){if(typeof t=="string")try{return Pt.from(Et(t))}catch{p(!1,"invalid struct fragment","obj",t)}else if(t instanceof X){const e=Te("struct",t),n=ut(t);return It(t),new Pt(R,e,n)}return new Pt(R,t.name,t.inputs?t.inputs.map(C.from):[])}static isFragment(t){return t&&t[V]===kn}}const Y=new Map;Y.set(0,"GENERIC_PANIC");Y.set(1,"ASSERT_FALSE");Y.set(17,"OVERFLOW");Y.set(18,"DIVIDE_BY_ZERO");Y.set(33,"ENUM_RANGE_ERROR");Y.set(34,"BAD_STORAGE_DATA");Y.set(49,"STACK_UNDERFLOW");Y.set(50,"ARRAY_RANGE_ERROR");Y.set(65,"OUT_OF_MEMORY");Y.set(81,"UNINITIALIZED_FUNCTION_CALL");const Vs=new RegExp(/^bytes([0-9]*)$/),Ms=new RegExp(/^(u?int)([0-9]*)$/);let Fe=null,vn=1024;function Gs(r,t,e,n){let s="missing revert data",i=null;const o=null;let a=null;if(e){s="execution reverted";const u=lt(e);if(e=I(e),u.length===0)s+=" (no data present; likely require(false) occurred",i="require(false)";else if(u.length%32!==4)s+=" (could not decode reason; invalid data length)";else if(I(u.slice(0,4))==="0x08c379a0")try{i=n.decode(["string"],u.slice(4))[0],a={signature:"Error(string)",name:"Error",args:[i]},s+=`: ${JSON.stringify(i)}`}catch{s+=" (could not decode reason; invalid string data)"}else if(I(u.slice(0,4))==="0x4e487b71")try{const f=Number(n.decode(["uint256"],u.slice(4))[0]);a={signature:"Panic(uint256)",name:"Panic",args:[f]},i=`Panic due to ${Y.get(f)||"UNKNOWN"}(${f})`,s+=`: ${i}`}catch{s+=" (could not decode panic code)"}else s+=" (unknown custom error)"}const c={to:t.to?Rt(t.to):null,data:t.data||"0x"};return t.from&&(c.from=Rt(t.from)),Qt(s,"CALL_EXCEPTION",{action:r,data:e,reason:i,transaction:c,invocation:o,revert:a})}var yt,Ft;const xe=class xe{constructor(){v(this,yt)}getDefaultValue(t){const e=t.map(s=>P(this,yt,Ft).call(this,C.from(s)));return new le(e,"_").defaultValue()}encode(t,e){Bn(e.length,t.length,"types/values length mismatch");const n=t.map(o=>P(this,yt,Ft).call(this,C.from(o))),s=new le(n,"_"),i=new $e;return s.encode(i,e),i.data}decode(t,e,n){const s=t.map(o=>P(this,yt,Ft).call(this,C.from(o)));return new le(s,"_").decode(new De(e,n,vn))}static _setDefaultMaxInflation(t){p(typeof t=="number"&&Number.isInteger(t),"invalid defaultMaxInflation factor","value",t),vn=t}static defaultAbiCoder(){return Fe==null&&(Fe=new xe),Fe}static getBuiltinCallException(t,e,n){return Gs(t,e,n,xe.defaultAbiCoder())}};yt=new WeakSet,Ft=function(t){if(t.isArray())return new ys(P(this,yt,Ft).call(this,t.arrayChildren),t.arrayLength,t.name);if(t.isTuple())return new le(t.components.map(n=>P(this,yt,Ft).call(this,n)),t.name);switch(t.baseType){case"address":return new ps(t.name);case"bool":return new ms(t.name);case"string":return new vs(t.name);case"bytes":return new ws(t.name);case"":return new xs(t.name)}let e=t.type.match(Ms);if(e){let n=parseInt(e[2]||"256");return p(n!==0&&n<=256&&n%8===0,"invalid "+e[1]+" bit length","param",t),new ks(n/8,e[1]==="int",t.name)}if(e=t.type.match(Vs),e){let n=parseInt(e[1]);return p(n!==0&&n<=32,"invalid bytes length","param",t),new bs(n,t.name)}p(!1,"invalid type","type",t.type)};let me=xe;class Hs{constructor(t,e,n){l(this,"fragment");l(this,"name");l(this,"signature");l(this,"topic");l(this,"args");const s=t.name,i=t.format();E(this,{fragment:t,name:s,signature:i,topic:e,args:n})}}class zs{constructor(t,e,n,s){l(this,"fragment");l(this,"name");l(this,"args");l(this,"signature");l(this,"selector");l(this,"value");const i=t.name,o=t.format();E(this,{fragment:t,name:i,args:n,signature:o,selector:e,value:s})}}class Ws{constructor(t,e,n){l(this,"fragment");l(this,"name");l(this,"args");l(this,"signature");l(this,"selector");const s=t.name,i=t.format();E(this,{fragment:t,name:s,args:n,signature:i,selector:e})}}class On{constructor(t){l(this,"hash");l(this,"_isIndexed");E(this,{hash:t,_isIndexed:!0})}static isIndexed(t){return!!(t&&t._isIndexed)}}const Pn={0:"generic panic",1:"assert(false)",17:"arithmetic overflow",18:"division or modulo by zero",33:"enum overflow",34:"invalid encoded storage byte array accessed",49:"out-of-bounds array access; popping on an empty array",50:"out-of-bounds access of an array or bytesN",65:"out of memory",81:"uninitialized function"},Rn={"0x08c379a0":{signature:"Error(string)",name:"Error",inputs:["string"],reason:r=>`reverted with reason string ${JSON.stringify(r)}`},"0x4e487b71":{signature:"Panic(uint256)",name:"Panic",inputs:["uint256"],reason:r=>{let t="unknown panic code";return r>=0&&r<=255&&Pn[r.toString()]&&(t=Pn[r.toString()]),`reverted with panic code 0x${r.toString(16)} (${t})`}}};var Z,Q,q,B,Gt,pe,Ht,ge;const Nt=class Nt{constructor(t){v(this,Gt);v(this,Ht);l(this,"fragments");l(this,"deploy");l(this,"fallback");l(this,"receive");v(this,Z,void 0);v(this,Q,void 0);v(this,q,void 0);v(this,B,void 0);let e=[];typeof t=="string"?e=JSON.parse(t):e=t,A(this,q,new Map),A(this,Z,new Map),A(this,Q,new Map);const n=[];for(const o of e)try{n.push(Ut.from(o))}catch(a){console.log(`[Warning] Invalid Fragment ${JSON.stringify(o)}:`,a.message)}E(this,{fragments:Object.freeze(n)});let s=null,i=!1;A(this,B,this.getAbiCoder()),this.fragments.forEach((o,a)=>{let c;switch(o.type){case"constructor":if(this.deploy){console.log("duplicate definition - constructor");return}E(this,{deploy:o});return;case"fallback":o.inputs.length===0?i=!0:(p(!s||o.payable!==s.payable,"conflicting fallback fragments",`fragments[${a}]`,o),s=o,i=s.payable);return;case"function":c=h(this,q);break;case"event":c=h(this,Q);break;case"error":c=h(this,Z);break;default:return}const u=o.format();c.has(u)||c.set(u,o)}),this.deploy||E(this,{deploy:ct.from("constructor()")}),E(this,{fallback:s,receive:i})}format(t){const e=t?"minimal":"full";return this.fragments.map(s=>s.format(e))}formatJson(){const t=this.fragments.map(e=>e.format("json"));return JSON.stringify(t.map(e=>JSON.parse(e)))}getAbiCoder(){return me.defaultAbiCoder()}getFunctionName(t){const e=P(this,Gt,pe).call(this,t,null,!1);return p(e,"no matching function","key",t),e.name}hasFunction(t){return!!P(this,Gt,pe).call(this,t,null,!1)}getFunction(t,e){return P(this,Gt,pe).call(this,t,e||null,!0)}forEachFunction(t){const e=Array.from(h(this,q).keys());e.sort((n,s)=>n.localeCompare(s));for(let n=0;n<e.length;n++){const s=e[n];t(h(this,q).get(s),n)}}getEventName(t){const e=P(this,Ht,ge).call(this,t,null,!1);return p(e,"no matching event","key",t),e.name}hasEvent(t){return!!P(this,Ht,ge).call(this,t,null,!1)}getEvent(t,e){return P(this,Ht,ge).call(this,t,e||null,!0)}forEachEvent(t){const e=Array.from(h(this,Q).keys());e.sort((n,s)=>n.localeCompare(s));for(let n=0;n<e.length;n++){const s=e[n];t(h(this,Q).get(s),n)}}getError(t,e){if(at(t)){const s=t.toLowerCase();if(Rn[s])return D.from(Rn[s].signature);for(const i of h(this,Z).values())if(s===i.selector)return i;return null}if(t.indexOf("(")===-1){const s=[];for(const[i,o]of h(this,Z))i.split("(")[0]===t&&s.push(o);if(s.length===0)return t==="Error"?D.from("error Error(string)"):t==="Panic"?D.from("error Panic(uint256)"):null;if(s.length>1){const i=s.map(o=>JSON.stringify(o.format())).join(", ");p(!1,`ambiguous error description (i.e. ${i})`,"name",t)}return s[0]}if(t=D.from(t).format(),t==="Error(string)")return D.from("error Error(string)");if(t==="Panic(uint256)")return D.from("error Panic(uint256)");const n=h(this,Z).get(t);return n||null}forEachError(t){const e=Array.from(h(this,Z).keys());e.sort((n,s)=>n.localeCompare(s));for(let n=0;n<e.length;n++){const s=e[n];t(h(this,Z).get(s),n)}}_decodeParams(t,e){return h(this,B).decode(t,e)}_encodeParams(t,e){return h(this,B).encode(t,e)}encodeDeploy(t){return this._encodeParams(this.deploy.inputs,t||[])}decodeErrorResult(t,e){if(typeof t=="string"){const n=this.getError(t);p(n,"unknown error","fragment",t),t=n}return p(Bt(e,0,4)===t.selector,`data signature does not match error ${t.name}.`,"data",e),this._decodeParams(t.inputs,Bt(e,4))}encodeErrorResult(t,e){if(typeof t=="string"){const n=this.getError(t);p(n,"unknown error","fragment",t),t=n}return $t([t.selector,this._encodeParams(t.inputs,e||[])])}decodeFunctionData(t,e){if(typeof t=="string"){const n=this.getFunction(t);p(n,"unknown function","fragment",t),t=n}return p(Bt(e,0,4)===t.selector,`data signature does not match function ${t.name}.`,"data",e),this._decodeParams(t.inputs,Bt(e,4))}encodeFunctionData(t,e){if(typeof t=="string"){const n=this.getFunction(t);p(n,"unknown function","fragment",t),t=n}return $t([t.selector,this._encodeParams(t.inputs,e||[])])}decodeFunctionResult(t,e){if(typeof t=="string"){const i=this.getFunction(t);p(i,"unknown function","fragment",t),t=i}let n="invalid length for result data";const s=et(e);if(s.length%32===0)try{return h(this,B).decode(t.outputs,s)}catch{n="could not decode result data"}b(!1,n,"BAD_DATA",{value:I(s),info:{method:t.name,signature:t.format()}})}makeError(t,e){const n=lt(t,"data"),s=me.getBuiltinCallException("call",e,n);if(s.message.startsWith("execution reverted (unknown custom error)")){const a=I(n.slice(0,4)),c=this.getError(a);if(c)try{const u=h(this,B).decode(c.inputs,n.slice(4));s.revert={name:c.name,signature:c.format(),args:u},s.reason=s.revert.signature,s.message=`execution reverted: ${s.reason}`}catch{s.message="execution reverted (coult not decode custom error)"}}const o=this.parseTransaction(e);return o&&(s.invocation={method:o.name,signature:o.signature,args:o.args}),s}encodeFunctionResult(t,e){if(typeof t=="string"){const n=this.getFunction(t);p(n,"unknown function","fragment",t),t=n}return I(h(this,B).encode(t.outputs,e||[]))}encodeFilterTopics(t,e){if(typeof t=="string"){const i=this.getEvent(t);p(i,"unknown event","eventFragment",t),t=i}b(e.length<=t.inputs.length,`too many arguments for ${t.format()}`,"UNEXPECTED_ARGUMENT",{count:e.length,expectedCount:t.inputs.length});const n=[];t.anonymous||n.push(t.topicHash);const s=(i,o)=>i.type==="string"?jt(o):i.type==="bytes"?wt(I(o)):(i.type==="bool"&&typeof o=="boolean"?o=o?"0x01":"0x00":i.type.match(/^u?int/)?o=$n(o):i.type.match(/^bytes/)?o=Or(o,32):i.type==="address"&&h(this,B).encode(["address"],[o]),vr(I(o),32));for(e.forEach((i,o)=>{const a=t.inputs[o];if(!a.indexed){p(i==null,"cannot filter non-indexed parameters; must be null","contract."+a.name,i);return}i==null?n.push(null):a.baseType==="array"||a.baseType==="tuple"?p(!1,"filtering with tuples or arrays not supported","contract."+a.name,i):Array.isArray(i)?n.push(i.map(c=>s(a,c))):n.push(s(a,i))});n.length&&n[n.length-1]===null;)n.pop();return n}encodeEventLog(t,e){if(typeof t=="string"){const o=this.getEvent(t);p(o,"unknown event","eventFragment",t),t=o}const n=[],s=[],i=[];return t.anonymous||n.push(t.topicHash),p(e.length===t.inputs.length,"event arguments/values mismatch","values",e),t.inputs.forEach((o,a)=>{const c=e[a];if(o.indexed)if(o.type==="string")n.push(jt(c));else if(o.type==="bytes")n.push(wt(c));else{if(o.baseType==="tuple"||o.baseType==="array")throw new Error("not implemented");n.push(h(this,B).encode([o.type],[c]))}else s.push(o),i.push(c)}),{data:h(this,B).encode(s,i),topics:n}}decodeEventLog(t,e,n){if(typeof t=="string"){const m=this.getEvent(t);p(m,"unknown event","eventFragment",t),t=m}if(n!=null&&!t.anonymous){const m=t.topicHash;p(at(n[0],32)&&n[0].toLowerCase()===m,"fragment/topic mismatch","topics[0]",n[0]),n=n.slice(1)}const s=[],i=[],o=[];t.inputs.forEach((m,x)=>{m.indexed?m.type==="string"||m.type==="bytes"||m.baseType==="tuple"||m.baseType==="array"?(s.push(C.from({type:"bytes32",name:m.name})),o.push(!0)):(s.push(m),o.push(!1)):(i.push(m),o.push(!1))});const a=n!=null?h(this,B).decode(s,$t(n)):null,c=h(this,B).decode(i,e,!0),u=[],f=[];let d=0,g=0;return t.inputs.forEach((m,x)=>{let k=null;if(m.indexed)if(a==null)k=new On(null);else if(o[x])k=new On(a[g++]);else try{k=a[g++]}catch(O){k=O}else try{k=c[d++]}catch(O){k=O}u.push(k),f.push(m.name||null)}),ye.fromItems(u,f)}parseTransaction(t){const e=lt(t.data,"tx.data"),n=bt(t.value!=null?t.value:0,"tx.value"),s=this.getFunction(I(e.slice(0,4)));if(!s)return null;const i=h(this,B).decode(s.inputs,e.slice(4));return new zs(s,s.selector,i,n)}parseCallResult(t){throw new Error("@TODO")}parseLog(t){const e=this.getEvent(t.topics[0]);return!e||e.anonymous?null:new Hs(e,e.topicHash,this.decodeEventLog(e,t.data,t.topics))}parseError(t){const e=I(t),n=this.getError(Bt(e,0,4));if(!n)return null;const s=h(this,B).decode(n.inputs,Bt(e,4));return new Ws(n,n.selector,s)}static from(t){return t instanceof Nt?t:typeof t=="string"?new Nt(JSON.parse(t)):typeof t.formatJson=="function"?new Nt(t.formatJson()):typeof t.format=="function"?new Nt(t.format("json")):new Nt(t)}};Z=new WeakMap,Q=new WeakMap,q=new WeakMap,B=new WeakMap,Gt=new WeakSet,pe=function(t,e,n){if(at(t)){const i=t.toLowerCase();for(const o of h(this,q).values())if(i===o.selector)return o;return null}if(t.indexOf("(")===-1){const i=[];for(const[o,a]of h(this,q))o.split("(")[0]===t&&i.push(a);if(e){const o=e.length>0?e[e.length-1]:null;let a=e.length,c=!0;F.isTyped(o)&&o.type==="overrides"&&(c=!1,a--);for(let u=i.length-1;u>=0;u--){const f=i[u].inputs.length;f!==a&&(!c||f!==a-1)&&i.splice(u,1)}for(let u=i.length-1;u>=0;u--){const f=i[u].inputs;for(let d=0;d<e.length;d++)if(F.isTyped(e[d])){if(d>=f.length){if(e[d].type==="overrides")continue;i.splice(u,1);break}if(e[d].type!==f[d].baseType){i.splice(u,1);break}}}}if(i.length===1&&e&&e.length!==i[0].inputs.length){const o=e[e.length-1];(o==null||Array.isArray(o)||typeof o!="object")&&i.splice(0,1)}if(i.length===0)return null;if(i.length>1&&n){const o=i.map(a=>JSON.stringify(a.format())).join(", ");p(!1,`ambiguous function description (i.e. matches ${o})`,"key",t)}return i[0]}const s=h(this,q).get(tt.from(t).format());return s||null},Ht=new WeakSet,ge=function(t,e,n){if(at(t)){const i=t.toLowerCase();for(const o of h(this,Q).values())if(i===o.topicHash)return o;return null}if(t.indexOf("(")===-1){const i=[];for(const[o,a]of h(this,Q))o.split("(")[0]===t&&i.push(a);if(e){for(let o=i.length-1;o>=0;o--)i[o].inputs.length<e.length&&i.splice(o,1);for(let o=i.length-1;o>=0;o--){const a=i[o].inputs;for(let c=0;c<e.length;c++)if(F.isTyped(e[c])&&e[c].type!==a[c].baseType){i.splice(o,1);break}}}if(i.length===0)return null;if(i.length>1&&n){const o=i.map(a=>JSON.stringify(a.format())).join(", ");p(!1,`ambiguous event description (i.e. matches ${o})`,"key",t)}return i[0]}const s=h(this,Q).get(j.from(t).format());return s||null};let ee=Nt;const cr=BigInt(0);function W(r){return r==null?null:r.toString()}function Js(r){const t={};r.to&&(t.to=r.to),r.from&&(t.from=r.from),r.data&&(t.data=I(r.data));const e="chainId,gasLimit,gasPrice,maxFeePerBlobGas,maxFeePerGas,maxPriorityFeePerGas,value".split(/,/);for(const s of e)!(s in r)||r[s]==null||(t[s]=bt(r[s],`request.${s}`));const n="type,nonce".split(/,/);for(const s of n)!(s in r)||r[s]==null||(t[s]=ht(r[s],`request.${s}`));return r.accessList&&(t.accessList=Os(r.accessList)),"blockTag"in r&&(t.blockTag=r.blockTag),"enableCcipRead"in r&&(t.enableCcipRead=!!r.enableCcipRead),"customData"in r&&(t.customData=r.customData),"blobVersionedHashes"in r&&r.blobVersionedHashes&&(t.blobVersionedHashes=r.blobVersionedHashes.slice()),"kzg"in r&&(t.kzg=r.kzg),"blobs"in r&&r.blobs&&(t.blobs=r.blobs.map(s=>kr(s)?I(s):Object.assign({},s))),t}class ve{constructor(t,e){l(this,"provider");l(this,"transactionHash");l(this,"blockHash");l(this,"blockNumber");l(this,"removed");l(this,"address");l(this,"data");l(this,"topics");l(this,"index");l(this,"transactionIndex");this.provider=e;const n=Object.freeze(t.topics.slice());E(this,{transactionHash:t.transactionHash,blockHash:t.blockHash,blockNumber:t.blockNumber,removed:t.removed,address:t.address,data:t.data,topics:n,index:t.index,transactionIndex:t.transactionIndex})}toJSON(){const{address:t,blockHash:e,blockNumber:n,data:s,index:i,removed:o,topics:a,transactionHash:c,transactionIndex:u}=this;return{_type:"log",address:t,blockHash:e,blockNumber:n,data:s,index:i,removed:o,topics:a,transactionHash:c,transactionIndex:u}}async getBlock(){const t=await this.provider.getBlock(this.blockHash);return b(!!t,"failed to find transaction","UNKNOWN_ERROR",{}),t}async getTransaction(){const t=await this.provider.getTransaction(this.transactionHash);return b(!!t,"failed to find transaction","UNKNOWN_ERROR",{}),t}async getTransactionReceipt(){const t=await this.provider.getTransactionReceipt(this.transactionHash);return b(!!t,"failed to find transaction receipt","UNKNOWN_ERROR",{}),t}removedEvent(){return Xs(this)}}var se;class Ks{constructor(t,e){l(this,"provider");l(this,"to");l(this,"from");l(this,"contractAddress");l(this,"hash");l(this,"index");l(this,"blockHash");l(this,"blockNumber");l(this,"logsBloom");l(this,"gasUsed");l(this,"blobGasUsed");l(this,"cumulativeGasUsed");l(this,"gasPrice");l(this,"blobGasPrice");l(this,"type");l(this,"status");l(this,"root");v(this,se,void 0);A(this,se,Object.freeze(t.logs.map(s=>new ve(s,e))));let n=cr;t.effectiveGasPrice!=null?n=t.effectiveGasPrice:t.gasPrice!=null&&(n=t.gasPrice),E(this,{provider:e,to:t.to,from:t.from,contractAddress:t.contractAddress,hash:t.hash,index:t.index,blockHash:t.blockHash,blockNumber:t.blockNumber,logsBloom:t.logsBloom,gasUsed:t.gasUsed,cumulativeGasUsed:t.cumulativeGasUsed,blobGasUsed:t.blobGasUsed,gasPrice:n,blobGasPrice:t.blobGasPrice,type:t.type,status:t.status,root:t.root})}get logs(){return h(this,se)}toJSON(){const{to:t,from:e,contractAddress:n,hash:s,index:i,blockHash:o,blockNumber:a,logsBloom:c,logs:u,status:f,root:d}=this;return{_type:"TransactionReceipt",blockHash:o,blockNumber:a,contractAddress:n,cumulativeGasUsed:W(this.cumulativeGasUsed),from:e,gasPrice:W(this.gasPrice),blobGasUsed:W(this.blobGasUsed),blobGasPrice:W(this.blobGasPrice),gasUsed:W(this.gasUsed),hash:s,index:i,logs:u,logsBloom:c,root:d,status:f,to:t}}get length(){return this.logs.length}[Symbol.iterator](){let t=0;return{next:()=>t<this.length?{value:this.logs[t++],done:!1}:{value:void 0,done:!0}}}get fee(){return this.gasUsed*this.gasPrice}async getBlock(){const t=await this.provider.getBlock(this.blockHash);if(t==null)throw new Error("TODO");return t}async getTransaction(){const t=await this.provider.getTransaction(this.hash);if(t==null)throw new Error("TODO");return t}async getResult(){return await this.provider.getTransactionResult(this.hash)}async confirmations(){return await this.provider.getBlockNumber()-this.blockNumber+1}removedEvent(){return lr(this)}reorderedEvent(t){return b(!t||t.isMined(),"unmined 'other' transction cannot be orphaned","UNSUPPORTED_OPERATION",{operation:"reorderedEvent(other)"}),ur(this,t)}}se=new WeakMap;var mt;const tn=class tn{constructor(t,e){l(this,"provider");l(this,"blockNumber");l(this,"blockHash");l(this,"index");l(this,"hash");l(this,"type");l(this,"to");l(this,"from");l(this,"nonce");l(this,"gasLimit");l(this,"gasPrice");l(this,"maxPriorityFeePerGas");l(this,"maxFeePerGas");l(this,"maxFeePerBlobGas");l(this,"data");l(this,"value");l(this,"chainId");l(this,"signature");l(this,"accessList");l(this,"blobVersionedHashes");v(this,mt,void 0);this.provider=e,this.blockNumber=t.blockNumber!=null?t.blockNumber:null,this.blockHash=t.blockHash!=null?t.blockHash:null,this.hash=t.hash,this.index=t.index,this.type=t.type,this.from=t.from,this.to=t.to||null,this.gasLimit=t.gasLimit,this.nonce=t.nonce,this.data=t.data,this.value=t.value,this.gasPrice=t.gasPrice,this.maxPriorityFeePerGas=t.maxPriorityFeePerGas!=null?t.maxPriorityFeePerGas:null,this.maxFeePerGas=t.maxFeePerGas!=null?t.maxFeePerGas:null,this.maxFeePerBlobGas=t.maxFeePerBlobGas!=null?t.maxFeePerBlobGas:null,this.chainId=t.chainId,this.signature=t.signature,this.accessList=t.accessList!=null?t.accessList:null,this.blobVersionedHashes=t.blobVersionedHashes!=null?t.blobVersionedHashes:null,A(this,mt,-1)}toJSON(){const{blockNumber:t,blockHash:e,index:n,hash:s,type:i,to:o,from:a,nonce:c,data:u,signature:f,accessList:d,blobVersionedHashes:g}=this;return{_type:"TransactionResponse",accessList:d,blockNumber:t,blockHash:e,blobVersionedHashes:g,chainId:W(this.chainId),data:u,from:a,gasLimit:W(this.gasLimit),gasPrice:W(this.gasPrice),hash:s,maxFeePerGas:W(this.maxFeePerGas),maxPriorityFeePerGas:W(this.maxPriorityFeePerGas),maxFeePerBlobGas:W(this.maxFeePerBlobGas),nonce:c,signature:f,to:o,index:n,type:i,value:W(this.value)}}async getBlock(){let t=this.blockNumber;if(t==null){const n=await this.getTransaction();n&&(t=n.blockNumber)}if(t==null)return null;const e=this.provider.getBlock(t);if(e==null)throw new Error("TODO");return e}async getTransaction(){return this.provider.getTransaction(this.hash)}async confirmations(){if(this.blockNumber==null){const{tx:e,blockNumber:n}=await Le({tx:this.getTransaction(),blockNumber:this.provider.getBlockNumber()});return e==null||e.blockNumber==null?0:n-e.blockNumber+1}return await this.provider.getBlockNumber()-this.blockNumber+1}async wait(t,e){const n=t??1,s=e??0;let i=h(this,mt),o=-1,a=i===-1;const c=async()=>{if(a)return null;const{blockNumber:g,nonce:m}=await Le({blockNumber:this.provider.getBlockNumber(),nonce:this.provider.getTransactionCount(this.from)});if(m<this.nonce){i=g;return}if(a)return null;const x=await this.getTransaction();if(!(x&&x.blockNumber!=null))for(o===-1&&(o=i-3,o<h(this,mt)&&(o=h(this,mt)));o<=g;){if(a)return null;const k=await this.provider.getBlock(o,!0);if(k==null)return;for(const O of k)if(O===this.hash)return;for(let O=0;O<k.length;O++){const N=await k.getTransaction(O);if(N.from===this.from&&N.nonce===this.nonce){if(a)return null;const U=await this.provider.getTransactionReceipt(N.hash);if(U==null||g-U.blockNumber+1<n)return;let H="replaced";N.data===this.data&&N.to===this.to&&N.value===this.value?H="repriced":N.data==="0x"&&N.from===N.to&&N.value===cr&&(H="cancelled"),b(!1,"transaction was replaced","TRANSACTION_REPLACED",{cancelled:H==="replaced"||H==="cancelled",reason:H,replacement:N.replaceableTransaction(i),hash:N.hash,receipt:U})}}o++}},u=g=>{if(g==null||g.status!==0)return g;b(!1,"transaction execution reverted","CALL_EXCEPTION",{action:"sendTransaction",data:null,reason:null,invocation:null,revert:null,transaction:{to:g.to,from:g.from,data:""},receipt:g})},f=await this.provider.getTransactionReceipt(this.hash);if(n===0)return u(f);if(f){if(await f.confirmations()>=n)return u(f)}else if(await c(),n===0)return null;return await new Promise((g,m)=>{const x=[],k=()=>{x.forEach(N=>N())};if(x.push(()=>{a=!0}),s>0){const N=setTimeout(()=>{k(),m(Qt("wait for transaction timeout","TIMEOUT"))},s);x.push(()=>{clearTimeout(N)})}const O=async N=>{if(await N.confirmations()>=n){k();try{g(u(N))}catch(U){m(U)}}};if(x.push(()=>{this.provider.off(this.hash,O)}),this.provider.on(this.hash,O),i>=0){const N=async()=>{try{await c()}catch(U){if(Wt(U,"TRANSACTION_REPLACED")){k(),m(U);return}}a||this.provider.once("block",N)};x.push(()=>{this.provider.off("block",N)}),this.provider.once("block",N)}})}isMined(){return this.blockHash!=null}isLegacy(){return this.type===0}isBerlin(){return this.type===1}isLondon(){return this.type===2}isCancun(){return this.type===3}removedEvent(){return b(this.isMined(),"unmined transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),lr(this)}reorderedEvent(t){return b(this.isMined(),"unmined transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),b(!t||t.isMined(),"unmined 'other' transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),ur(this,t)}replaceableTransaction(t){p(Number.isInteger(t)&&t>=0,"invalid startBlock","startBlock",t);const e=new tn(this,this.provider);return A(e,mt,t),e}};mt=new WeakMap;let Ge=tn;function ur(r,t){return{orphan:"reorder-transaction",tx:r,other:t}}function lr(r){return{orphan:"drop-transaction",tx:r}}function Xs(r){return{orphan:"drop-log",log:{transactionHash:r.transactionHash,blockHash:r.blockHash,blockNumber:r.blockNumber,address:r.address,data:r.data,topics:Object.freeze(r.topics.slice()),index:r.index}}}class Ze extends ve{constructor(e,n,s){super(e,e.provider);l(this,"interface");l(this,"fragment");l(this,"args");const i=n.decodeEventLog(s,e.data,e.topics);E(this,{args:i,fragment:s,interface:n})}get eventName(){return this.fragment.name}get eventSignature(){return this.fragment.format()}}class fr extends ve{constructor(e,n){super(e,e.provider);l(this,"error");E(this,{error:n})}}var zt;class Ys extends Ks{constructor(e,n,s){super(s,n);v(this,zt,void 0);A(this,zt,e)}get logs(){return super.logs.map(e=>{const n=e.topics.length?h(this,zt).getEvent(e.topics[0]):null;if(n)try{return new Ze(e,h(this,zt),n)}catch(s){return new fr(e,s)}return e})}}zt=new WeakMap;var ie;class Qe extends Ge{constructor(e,n,s){super(s,n);v(this,ie,void 0);A(this,ie,e)}async wait(e,n){const s=await super.wait(e,n);return s==null?null:new Ys(h(this,ie),this.provider,s)}}ie=new WeakMap;class hr extends Sr{constructor(e,n,s,i){super(e,n,s);l(this,"log");E(this,{log:i})}async getBlock(){return await this.log.getBlock()}async getTransaction(){return await this.log.getTransaction()}async getTransactionReceipt(){return await this.log.getTransactionReceipt()}}class Zs extends hr{constructor(t,e,n,s,i){super(t,e,n,new Ze(i,t.interface,s));const o=t.interface.decodeEventLog(s,this.log.data,this.log.topics);E(this,{args:o,fragment:s})}get eventName(){return this.fragment.name}get eventSignature(){return this.fragment.format()}}const In=BigInt(0);function dr(r){return r&&typeof r.call=="function"}function pr(r){return r&&typeof r.estimateGas=="function"}function Oe(r){return r&&typeof r.resolveName=="function"}function gr(r){return r&&typeof r.sendTransaction=="function"}function yr(r){if(r!=null){if(Oe(r))return r;if(r.provider)return r.provider}}var oe;class Qs{constructor(t,e,n){v(this,oe,void 0);l(this,"fragment");if(E(this,{fragment:e}),e.inputs.length<n.length)throw new Error("too many arguments");const s=St(t.runner,"resolveName"),i=Oe(s)?s:null;A(this,oe,async function(){const o=await Promise.all(e.inputs.map((a,c)=>n[c]==null?null:a.walkAsync(n[c],(f,d)=>f==="address"?Array.isArray(d)?Promise.all(d.map(g=>qt(g,i))):qt(d,i):d)));return t.interface.encodeFilterTopics(e,o)}())}getTopicFilter(){return h(this,oe)}}oe=new WeakMap;function St(r,t){return r==null?null:typeof r[t]=="function"?r:r.provider&&typeof r.provider[t]=="function"?r.provider:null}function At(r){return r==null?null:r.provider||null}async function mr(r,t){const e=F.dereference(r,"overrides");p(typeof e=="object","invalid overrides parameter","overrides",r);const n=Js(e);return p(n.to==null||(t||[]).indexOf("to")>=0,"cannot override to","overrides.to",n.to),p(n.data==null||(t||[]).indexOf("data")>=0,"cannot override data","overrides.data",n.data),n.from&&(n.from=n.from),n}async function qs(r,t,e){const n=St(r,"resolveName"),s=Oe(n)?n:null;return await Promise.all(t.map((i,o)=>i.walkAsync(e[o],(a,c)=>(c=F.dereference(c,a),a==="address"?qt(c,s):c))))}function js(r){const t=async function(o){const a=await mr(o,["data"]);a.to=await r.getAddress(),a.from&&(a.from=await qt(a.from,yr(r.runner)));const c=r.interface,u=bt(a.value||In,"overrides.value")===In,f=(a.data||"0x")==="0x";c.fallback&&!c.fallback.payable&&c.receive&&!f&&!u&&p(!1,"cannot send data to receive or send value to non-payable fallback","overrides",o),p(c.fallback||f,"cannot send data to receive-only contract","overrides.data",a.data);const d=c.receive||c.fallback&&c.fallback.payable;return p(d||u,"cannot send value to non-payable fallback","overrides.value",a.value),p(c.fallback||f,"cannot send data to receive-only contract","overrides.data",a.data),a},e=async function(o){const a=St(r.runner,"call");b(dr(a),"contract runner does not support calling","UNSUPPORTED_OPERATION",{operation:"call"});const c=await t(o);try{return await a.call(c)}catch(u){throw Cn(u)&&u.data?r.interface.makeError(u.data,c):u}},n=async function(o){const a=r.runner;b(gr(a),"contract runner does not support sending transactions","UNSUPPORTED_OPERATION",{operation:"sendTransaction"});const c=await a.sendTransaction(await t(o)),u=At(r.runner);return new Qe(r.interface,u,c)},s=async function(o){const a=St(r.runner,"estimateGas");return b(pr(a),"contract runner does not support gas estimation","UNSUPPORTED_OPERATION",{operation:"estimateGas"}),await a.estimateGas(await t(o))},i=async o=>await n(o);return E(i,{_contract:r,estimateGas:s,populateTransaction:t,send:n,staticCall:e}),i}function ti(r,t){const e=function(...u){const f=r.interface.getFunction(t,u);return b(f,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:t,args:u}}),f},n=async function(...u){const f=e(...u);let d={};if(f.inputs.length+1===u.length&&(d=await mr(u.pop()),d.from&&(d.from=await qt(d.from,yr(r.runner)))),f.inputs.length!==u.length)throw new Error("internal error: fragment inputs doesn't match arguments; should not happen");const g=await qs(r.runner,f.inputs,u);return Object.assign({},d,await Le({to:r.getAddress(),data:r.interface.encodeFunctionData(f,g)}))},s=async function(...u){const f=await a(...u);return f.length===1?f[0]:f},i=async function(...u){const f=r.runner;b(gr(f),"contract runner does not support sending transactions","UNSUPPORTED_OPERATION",{operation:"sendTransaction"});const d=await f.sendTransaction(await n(...u)),g=At(r.runner);return new Qe(r.interface,g,d)},o=async function(...u){const f=St(r.runner,"estimateGas");return b(pr(f),"contract runner does not support gas estimation","UNSUPPORTED_OPERATION",{operation:"estimateGas"}),await f.estimateGas(await n(...u))},a=async function(...u){const f=St(r.runner,"call");b(dr(f),"contract runner does not support calling","UNSUPPORTED_OPERATION",{operation:"call"});const d=await n(...u);let g="0x";try{g=await f.call(d)}catch(x){throw Cn(x)&&x.data?r.interface.makeError(x.data,d):x}const m=e(...u);return r.interface.decodeFunctionResult(m,g)},c=async(...u)=>e(...u).constant?await s(...u):await i(...u);return E(c,{name:r.interface.getFunctionName(t),_contract:r,_key:t,getFragment:e,estimateGas:o,populateTransaction:n,send:i,staticCall:s,staticCallResult:a}),Object.defineProperty(c,"fragment",{configurable:!1,enumerable:!0,get:()=>{const u=r.interface.getFunction(t);return b(u,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:t}}),u}}),c}function ei(r,t){const e=function(...s){const i=r.interface.getEvent(t,s);return b(i,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:t,args:s}}),i},n=function(...s){return new Qs(r,e(...s),s)};return E(n,{name:r.interface.getEventName(t),_contract:r,_key:t,getFragment:e}),Object.defineProperty(n,"fragment",{configurable:!1,enumerable:!0,get:()=>{const s=r.interface.getEvent(t);return b(s,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:t}}),s}}),n}const we=Symbol.for("_ethersInternal_contract"),wr=new WeakMap;function ni(r,t){wr.set(r[we],t)}function M(r){return wr.get(r[we])}function ri(r){return r&&typeof r=="object"&&"getTopicFilter"in r&&typeof r.getTopicFilter=="function"&&r.fragment}async function qe(r,t){let e,n=null;if(Array.isArray(t)){const i=function(o){if(at(o,32))return o;const a=r.interface.getEvent(o);return p(a,"unknown fragment","name",o),a.topicHash};e=t.map(o=>o==null?null:Array.isArray(o)?o.map(i):i(o))}else t==="*"?e=[null]:typeof t=="string"?at(t,32)?e=[t]:(n=r.interface.getEvent(t),p(n,"unknown fragment","event",t),e=[n.topicHash]):ri(t)?e=await t.getTopicFilter():"fragment"in t?(n=t.fragment,e=[n.topicHash]):p(!1,"unknown event name","event",t);e=e.map(i=>{if(i==null)return null;if(Array.isArray(i)){const o=Array.from(new Set(i.map(a=>a.toLowerCase())).values());return o.length===1?o[0]:(o.sort(),o)}return i.toLowerCase()});const s=e.map(i=>i==null?"null":Array.isArray(i)?i.join("|"):i).join("&");return{fragment:n,tag:s,topics:e}}async function Xt(r,t){const{subs:e}=M(r);return e.get((await qe(r,t)).tag)||null}async function Un(r,t,e){const n=At(r.runner);b(n,"contract runner does not support subscribing","UNSUPPORTED_OPERATION",{operation:t});const{fragment:s,tag:i,topics:o}=await qe(r,e),{addr:a,subs:c}=M(r);let u=c.get(i);if(!u){const d={address:a||r,topics:o},g=O=>{let N=s;if(N==null)try{N=r.interface.getEvent(O.topics[0])}catch{}if(N){const U=N,H=s?r.interface.decodeEventLog(s,O.data,O.topics):[];ze(r,e,H,Ct=>new Zs(r,Ct,e,U,O))}else ze(r,e,[],U=>new hr(r,U,e,O))};let m=[];u={tag:i,listeners:[],start:()=>{m.length||m.push(n.on(d,g))},stop:async()=>{if(m.length==0)return;let O=m;m=[],await Promise.all(O),n.off(d,g)}},c.set(i,u)}return u}let He=Promise.resolve();async function si(r,t,e,n){await He;const s=await Xt(r,t);if(!s)return!1;const i=s.listeners.length;return s.listeners=s.listeners.filter(({listener:o,once:a})=>{const c=Array.from(e);n&&c.push(n(a?null:o));try{o.call(r,...c)}catch{}return!a}),s.listeners.length===0&&(s.stop(),M(r).subs.delete(s.tag)),i>0}async function ze(r,t,e,n){try{await He}catch{}const s=si(r,t,e,n);return He=s,await s}const fe=["then"];var ui;const Zt=class Zt{constructor(t,e,n,s){l(this,"target");l(this,"interface");l(this,"runner");l(this,"filters");l(this,ui);l(this,"fallback");p(typeof t=="string"||Zn(t),"invalid value for Contract target","target",t),n==null&&(n=null);const i=ee.from(e);E(this,{target:t,runner:n,interface:i}),Object.defineProperty(this,we,{value:{}});let o,a=null,c=null;if(s){const d=At(n);c=new Qe(this.interface,d,s)}let u=new Map;if(typeof t=="string")if(at(t))a=t,o=Promise.resolve(t);else{const d=St(n,"resolveName");if(!Oe(d))throw Qt("contract runner does not support name resolution","UNSUPPORTED_OPERATION",{operation:"resolveName"});o=d.resolveName(t).then(g=>{if(g==null)throw Qt("an ENS name used for a contract target must be correctly configured","UNCONFIGURED_NAME",{value:t});return M(this).addr=g,g})}else o=t.getAddress().then(d=>{if(d==null)throw new Error("TODO");return M(this).addr=d,d});ni(this,{addrPromise:o,addr:a,deployTx:c,subs:u});const f=new Proxy({},{get:(d,g,m)=>{if(typeof g=="symbol"||fe.indexOf(g)>=0)return Reflect.get(d,g,m);try{return this.getEvent(g)}catch(x){if(!Wt(x,"INVALID_ARGUMENT")||x.argument!=="key")throw x}},has:(d,g)=>fe.indexOf(g)>=0?Reflect.has(d,g):Reflect.has(d,g)||this.interface.hasEvent(String(g))});return E(this,{filters:f}),E(this,{fallback:i.receive||i.fallback?js(this):null}),new Proxy(this,{get:(d,g,m)=>{if(typeof g=="symbol"||g in d||fe.indexOf(g)>=0)return Reflect.get(d,g,m);try{return d.getFunction(g)}catch(x){if(!Wt(x,"INVALID_ARGUMENT")||x.argument!=="key")throw x}},has:(d,g)=>typeof g=="symbol"||g in d||fe.indexOf(g)>=0?Reflect.has(d,g):d.interface.hasFunction(g)})}connect(t){return new Zt(this.target,this.interface,t)}attach(t){return new Zt(t,this.interface,this.runner)}async getAddress(){return await M(this).addrPromise}async getDeployedCode(){const t=At(this.runner);b(t,"runner does not support .provider","UNSUPPORTED_OPERATION",{operation:"getDeployedCode"});const e=await t.getCode(await this.getAddress());return e==="0x"?null:e}async waitForDeployment(){const t=this.deploymentTransaction();if(t)return await t.wait(),this;if(await this.getDeployedCode()!=null)return this;const n=At(this.runner);return b(n!=null,"contract runner does not support .provider","UNSUPPORTED_OPERATION",{operation:"waitForDeployment"}),new Promise((s,i)=>{const o=async()=>{try{if(await this.getDeployedCode()!=null)return s(this);n.once("block",o)}catch(a){i(a)}};o()})}deploymentTransaction(){return M(this).deployTx}getFunction(t){return typeof t!="string"&&(t=t.format()),ti(this,t)}getEvent(t){return typeof t!="string"&&(t=t.format()),ei(this,t)}async queryTransaction(t){throw new Error("@TODO")}async queryFilter(t,e,n){e==null&&(e=0),n==null&&(n="latest");const{addr:s,addrPromise:i}=M(this),o=s||await i,{fragment:a,topics:c}=await qe(this,t),u={address:o,topics:c,fromBlock:e,toBlock:n},f=At(this.runner);return b(f,"contract runner does not have a provider","UNSUPPORTED_OPERATION",{operation:"queryFilter"}),(await f.getLogs(u)).map(d=>{let g=a;if(g==null)try{g=this.interface.getEvent(d.topics[0])}catch{}if(g)try{return new Ze(d,this.interface,g)}catch(m){return new fr(d,m)}return new ve(d,f)})}async on(t,e){const n=await Un(this,"on",t);return n.listeners.push({listener:e,once:!1}),n.start(),this}async once(t,e){const n=await Un(this,"once",t);return n.listeners.push({listener:e,once:!0}),n.start(),this}async emit(t,...e){return await ze(this,t,e,null)}async listenerCount(t){if(t){const s=await Xt(this,t);return s?s.listeners.length:0}const{subs:e}=M(this);let n=0;for(const{listeners:s}of e.values())n+=s.length;return n}async listeners(t){if(t){const s=await Xt(this,t);return s?s.listeners.map(({listener:i})=>i):[]}const{subs:e}=M(this);let n=[];for(const{listeners:s}of e.values())n=n.concat(s.map(({listener:i})=>i));return n}async off(t,e){const n=await Xt(this,t);if(!n)return this;if(e){const s=n.listeners.map(({listener:i})=>i).indexOf(e);s>=0&&n.listeners.splice(s,1)}return(e==null||n.listeners.length===0)&&(n.stop(),M(this).subs.delete(n.tag)),this}async removeAllListeners(t){if(t){const e=await Xt(this,t);if(!e)return this;e.stop(),M(this).subs.delete(e.tag)}else{const{subs:e}=M(this);for(const{tag:n,stop:s}of e.values())s(),e.delete(n)}return this}async addListener(t,e){return await this.on(t,e)}async removeListener(t,e){return await this.off(t,e)}static buildClass(t){class e extends Zt{constructor(s,i=null){super(s,t,i)}}return e}static from(t,e,n){return n==null&&(n=null),new this(t,e,n)}};ui=we;let We=Zt;function ii(){return We}class Sn extends ii(){}const Je=new ee(["function start((bytes32,address,address,address,address,address,uint256,uint256,uint256,uint256)) returns (address,uint16,uint64)","function receiveMessageAndSwap(bytes)"]),oi=new ee(["function quoteExactInputSingle((address,address,uint256,uint24,uint160)) public view returns (uint256,uint160,uint32,uint256)"]),Yt=100,ai="https://gfx.relayers.xlabs.xyz/api/v1/swap/quote",ci="https://thermae.fly.dev/api/order/create";class br{static async createOrder(t,e,n,s,i,o,a,c){var u,f;try{const{minAmountStart:d,minAmountFinish:g}=a.swapAmounts,m=w.canonicalAddress(n),[x,k]=w.resolveWrappedToken(t,e,s),[O,N]=w.resolveWrappedToken(t,n.chain,o),U=w.canonicalAddress(k),H=w.canonicalAddress(N),Ct=w.portico.get(t,e).portico,Re=w.portico.get(t,n.chain).portico,Ie=w.networkChainToNativeChainId.get(t,e),Ue=w.networkChainToNativeChainId.get(t,n.chain),en={startingChainId:Number(Ie),startingToken:U.toLowerCase(),destinationChainId:Number(Ue),destinationToken:H.toLowerCase(),destinationAddress:m,porticoAddress:Ct,destinationPorticoAddress:Re,startingTokenAmount:i.toString(),minAmountStart:d.toString(),minAmountEnd:g.toString(),bridgeNonce:c,relayerFee:a.relayerFee.toString(),feeTierStart:Yt,feeTierEnd:Yt,shouldWrapNative:x,shouldUnwrapNative:O},nn=await w.axios.post(ci,en);return this.validateCreateOrderResponse(nn.data,en),nn.data}catch(d){if(w.axios.isAxiosError(d)){const g=`${(u=d.response)==null?void 0:u.statusText}: ${(f=d.response)==null?void 0:f.data.message}`;throw new Error(`Could not create order: ${g},`)}throw d}}static async quoteRelayer(t,e,n){var c;if(w.isNative(e)||w.isNative(n))throw new Error("how did you get here tho?");const s=w.hex.encode(e.toUniversalAddress().toUint8Array(),!1),i=w.hex.encode(n.toUniversalAddress().toUint8Array(),!1),a={targetChain:w.toChainId(t),sourceToken:s,targetToken:i};try{const u=await w.axios.post(ai,a);return BigInt(u.data.fee)}catch(u){throw w.axios.isAxiosError(u)?new Error(`Error getting relayer fee: ${(c=u.response)==null?void 0:c.statusText}`):u}}}l(br,"validateCreateOrderResponse",(t,e)=>{if(!w.isEqualCaseInsensitive(e.porticoAddress||"",t.transactionTarget))throw new Error("portico address mismatch");const n=Je.decodeFunctionData("start",t.transactionData);if(n.length!==1||n[0].length!==10)throw new Error("decoded length mismatch");const s=w.hex.decode(n[0][0]);if(s.length!==32)throw new Error("flag set length mismatch");const{recipientChain:i,feeTierStart:o,feeTierFinish:a,flags:c}=w.PorticoBridge.deserializeFlagSet(s),{shouldWrapNative:u,shouldUnwrapNative:f}=c,[d,g]=w.platformNativeChainIdToNetworkChain("Evm",BigInt(e.destinationChainId));if(i!==w.toChainId(g))throw new Error("recipient chain mismatch");if(o!==e.feeTierStart)throw new Error("fee tier start mismatch");if(a!==e.feeTierEnd)throw new Error("fee tier end mismatch");if(!!u!==e.shouldWrapNative)throw new Error("should wrap native mismatch");if(!!f!==e.shouldUnwrapNative)throw new Error("should unwrap native mismatch");const m=n[0][1];if(!w.isEqualCaseInsensitive(m,e.startingToken))throw new Error("start token address mismatch");const x=n[0][3];if(!w.isEqualCaseInsensitive(x,e.destinationToken))throw new Error("final token address mismatch");const k=n[0][4];if(!w.isEqualCaseInsensitive(k,e.destinationAddress))throw new Error("recipient address mismatch");const O=n[0][5];if(!w.isEqualCaseInsensitive(O,e.destinationPorticoAddress||""))throw new Error("destination portico address mismatch");if(n[0][6].toString()!==e.startingTokenAmount)throw new Error("amount mismatch");if(n[0][7].toString()!==e.minAmountStart)throw new Error("min amount start mismatch");if(n[0][8].toString()!==e.minAmountEnd)throw new Error("min amount finish mismatch");if(n[0][9].toString()!==e.relayerFee)throw new Error("relayer fee mismatch")});class Pe{constructor(t,e,n,s){l(this,"network");l(this,"chain");l(this,"provider");l(this,"contracts");l(this,"chainId");l(this,"porticoAddress");l(this,"uniswapAddress");l(this,"porticoContract");l(this,"uniswapContract");l(this,"core");if(this.network=t,this.chain=e,this.provider=n,this.contracts=s,!s.portico)throw new Error("Unsupported chain, no contract addresses for: "+e);this.core=new sn.EvmWormholeCore(t,e,n,s);const{portico:i,uniswapQuoterV2:o}=s.portico;this.porticoAddress=i,this.uniswapAddress=o,this.chainId=w.networkChainToNativeChainId.get(t,e),this.porticoContract=new Sn(this.porticoAddress,Je.fragments,this.provider),this.uniswapContract=new Sn(this.uniswapAddress,oi.fragments,this.provider)}static async fromRpc(t,e){const[n,s]=await nt.EvmPlatform.chainFromRpc(t),i=e[s];if(i.network!==n)throw new Error(`Network mismatch: ${i.network} != ${n}`);return new Pe(n,s,t,i.contracts)}async*transfer(t,e,n,s,i,o){const{minAmountStart:a,minAmountFinish:c}=o.swapAmounts;if(a===0n)throw new Error("Invalid min swap amount");if(c===0n)throw new Error("Invalid min swap amount");const u=new nt.EvmAddress(t).toString(),[f,d]=w.resolveWrappedToken(this.network,this.chain,n),[g,m]=w.resolveWrappedToken(this.network,e.chain,i),x=w.canonicalAddress(d),k=w.canonicalAddress(this.getTransferrableToken(x)),O=w.canonicalAddress(e),N=w.canonicalAddress(m),U=w.portico.get(this.network,e.chain).portico,H=new Date().valueOf()%2**4,Ct=w.PorticoBridge.serializeFlagSet({flags:{shouldWrapNative:f,shouldUnwrapNative:g},recipientChain:w.toChainId(e.chain),bridgeNonce:H,feeTierStart:Yt,feeTierFinish:Yt,padding:new Uint8Array(19)}),Re=Je.encodeFunctionData("start",[[Ct,x.toLowerCase(),k,N.toLowerCase(),O,U,s.toString(),a.toString(),c.toString(),o.relayerFee.toString()]]);f||(yield*this.approve(x,u,s,this.porticoAddress));const Ie=await this.core.getMessageFee(),Ue={to:this.porticoAddress,data:Re,value:Ie+(f?s:0n)};yield this.createUnsignedTransaction(nt.addFrom(Ue,u),"PorticoBridge.Transfer")}async*redeem(t,e){const n=await this.porticoContract.getFunction("receiveMessageAndSwap").populateTransaction(w.serialize(e)),s=new nt.EvmAddress(t).toString();yield this.createUnsignedTransaction(nt.addFrom(n,s),"PorticoBridge.Redeem")}async quoteSwap(t,e,n){const[,s]=w.resolveWrappedToken(this.network,this.chain,t),[,i]=w.resolveWrappedToken(this.network,this.chain,e),o=w.canonicalAddress(s),a=w.canonicalAddress(i);return w.isEqualCaseInsensitive(o,a)?n:(await this.uniswapContract.getFunction("quoteExactInputSingle").staticCall([o,a,n,Yt,0]))[0]}async quoteRelay(t,e){return await br.quoteRelayer(this.chain,t,e)}getTransferrableToken(t){var s;if(this.chain==="Ethereum")return w.Wormhole.tokenId("Ethereum",t);const e=w.getTokenByAddress(this.network,this.chain,t);if(!e)throw new Error("Unsupported source token: "+t);const n=(s=w.getTokensBySymbol(this.network,this.chain,e.symbol))==null?void 0:s.find(i=>i.original==="Ethereum");if(!n)throw new Error(`Unsupported symbol for chain ${e.symbol}: ${this.chain} `);return w.Wormhole.tokenId(n.chain,n.address)}async*approve(t,e,n,s){const i=nt.EvmPlatform.getTokenImplementation(this.provider,t);if(await i.allowance(e,s)<n){const a=await i.approve.populateTransaction(s,n);yield this.createUnsignedTransaction(nt.addFrom(a,e),"PorticoBridge.Approve")}}createUnsignedTransaction(t,e){return new sn.EvmUnsignedTransaction(nt.addChainId(t,this.chainId),this.network,this.chain,e,!1)}}Nr.registerProtocol(nt._platform,"PorticoBridge",Pe);exports.EvmPorticoBridge=Pe;
|
|
1
|
+
"use strict";var Er=Object.defineProperty;var xr=(r,t,e)=>t in r?Er(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var l=(r,t,e)=>(xr(r,typeof t!="symbol"?t+"":t,e),e),Se=(r,t,e)=>{if(!t.has(r))throw TypeError("Cannot "+e)};var h=(r,t,e)=>(Se(r,t,"read from private field"),e?e.call(r):t.get(r)),v=(r,t,e)=>{if(t.has(r))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(r):t.set(r,e)},A=(r,t,e,n)=>(Se(r,t,"write to private field"),n?n.call(r,e):t.set(r,e),e);var rn=(r,t,e,n)=>({set _(s){A(r,t,s,e)},get _(){return h(r,t,n)}}),P=(r,t,e)=>(Se(r,t,"access private method"),e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("./index-C1oy9Lkm.js"),sn=require("./index-ZCZHbA1F.js");require("./index-DGfMxIjQ.js");const nt=require("./evm-OwiMOsDg.js"),Nr=require("./chain-BteoJHpg.js"),Ar="6.12.1";function Tr(r,t,e){const n=t.split("|").map(i=>i.trim());for(let i=0;i<n.length;i++)switch(t){case"any":return;case"bigint":case"boolean":case"number":case"string":if(typeof r===t)return}const s=new Error(`invalid value for type ${t}`);throw s.code="INVALID_ARGUMENT",s.argument=`value.${e}`,s.value=r,s}async function Le(r){const t=Object.keys(r);return(await Promise.all(t.map(n=>Promise.resolve(r[n])))).reduce((n,s,i)=>(n[t[i]]=s,n),{})}function E(r,t,e){for(let n in t){let s=t[n];const i=e?e[n]:null;i&&Tr(s,i,n),Object.defineProperty(r,n,{enumerable:!0,value:s,writable:!1})}}function Lt(r){if(r==null)return"null";if(Array.isArray(r))return"[ "+r.map(Lt).join(", ")+" ]";if(r instanceof Uint8Array){const t="0123456789abcdef";let e="0x";for(let n=0;n<r.length;n++)e+=t[r[n]>>4],e+=t[r[n]&15];return e}if(typeof r=="object"&&typeof r.toJSON=="function")return Lt(r.toJSON());switch(typeof r){case"boolean":case"symbol":return r.toString();case"bigint":return BigInt(r).toString();case"number":return r.toString();case"string":return JSON.stringify(r);case"object":{const t=Object.keys(r);return t.sort(),"{ "+t.map(e=>`${Lt(e)}: ${Lt(r[e])}`).join(", ")+" }"}}return"[ COULD NOT SERIALIZE ]"}function Wt(r,t){return r&&r.code===t}function Cn(r){return Wt(r,"CALL_EXCEPTION")}function Qt(r,t,e){let n=r;{const i=[];if(e){if("message"in e||"code"in e||"name"in e)throw new Error(`value will overwrite populated values: ${Lt(e)}`);for(const o in e){if(o==="shortMessage")continue;const a=e[o];i.push(o+"="+Lt(a))}}i.push(`code=${t}`),i.push(`version=${Ar}`),i.length&&(r+=" ("+i.join(", ")+")")}let s;switch(t){case"INVALID_ARGUMENT":s=new TypeError(r);break;case"NUMERIC_FAULT":case"BUFFER_OVERRUN":s=new RangeError(r);break;default:s=new Error(r)}return E(s,{code:t}),e&&Object.assign(s,e),s.shortMessage==null&&E(s,{shortMessage:n}),s}function b(r,t,e,n){if(!r)throw Qt(t,e,n)}function p(r,t,e,n){b(r,t,"INVALID_ARGUMENT",{argument:e,value:n})}function Bn(r,t,e){e==null&&(e=""),e&&(e=": "+e),b(r>=t,"missing arguemnt"+e,"MISSING_ARGUMENT",{count:r,expectedCount:t}),b(r<=t,"too many arguments"+e,"UNEXPECTED_ARGUMENT",{count:r,expectedCount:t})}["NFD","NFC","NFKD","NFKC"].reduce((r,t)=>{try{if("test".normalize(t)!=="test")throw new Error("bad");if(t==="NFD"&&"é".normalize("NFD")!=="é")throw new Error("broken");r.push(t)}catch{}return r},[]);function Ke(r,t,e){if(e==null&&(e=""),r!==t){let n=e,s="new";e&&(n+=".",s+=" "+e),b(!1,`private constructor; use ${n}from* methods`,"UNSUPPORTED_OPERATION",{operation:s})}}function Fn(r,t,e){if(r instanceof Uint8Array)return e?new Uint8Array(r):r;if(typeof r=="string"&&r.match(/^0x([0-9a-f][0-9a-f])*$/i)){const n=new Uint8Array((r.length-2)/2);let s=2;for(let i=0;i<n.length;i++)n[i]=parseInt(r.substring(s,s+2),16),s+=2;return n}p(!1,"invalid BytesLike value",t||"value",r)}function lt(r,t){return Fn(r,t,!1)}function et(r,t){return Fn(r,t,!0)}function at(r,t){return!(typeof r!="string"||!r.match(/^0x[0-9A-Fa-f]*$/)||typeof t=="number"&&r.length!==2+2*t||t===!0&&r.length%2!==0)}function kr(r){return at(r,!0)||r instanceof Uint8Array}const on="0123456789abcdef";function I(r){const t=lt(r);let e="0x";for(let n=0;n<t.length;n++){const s=t[n];e+=on[(s&240)>>4]+on[s&15]}return e}function $t(r){return"0x"+r.map(t=>I(t).substring(2)).join("")}function Bt(r,t,e){const n=lt(r);return e!=null&&e>n.length&&b(!1,"cannot slice beyond data bounds","BUFFER_OVERRUN",{buffer:n,length:n.length,offset:e}),I(n.slice(t??0,e??n.length))}function Ln(r,t,e){const n=lt(r);b(t>=n.length,"padding exceeds data length","BUFFER_OVERRUN",{buffer:new Uint8Array(n),length:t,offset:t+1});const s=new Uint8Array(t);return s.fill(0),e?s.set(n,t-n.length):s.set(n,0),I(s)}function vr(r,t){return Ln(r,t,!0)}function Or(r,t){return Ln(r,t,!1)}const Ne=BigInt(0),K=BigInt(1),_t=9007199254740991;function Pr(r,t){const e=Ae(r,"value"),n=BigInt(ht(t,"width"));if(b(e>>n===Ne,"overflow","NUMERIC_FAULT",{operation:"fromTwos",fault:"overflow",value:r}),e>>n-K){const s=(K<<n)-K;return-((~e&s)+K)}return e}function Rr(r,t){let e=bt(r,"value");const n=BigInt(ht(t,"width")),s=K<<n-K;if(e<Ne){e=-e,b(e<=s,"too low","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:r});const i=(K<<n)-K;return(~e&i)+K}else b(e<s,"too high","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:r});return e}function ae(r,t){const e=Ae(r,"value"),n=BigInt(ht(t,"bits"));return e&(K<<n)-K}function bt(r,t){switch(typeof r){case"bigint":return r;case"number":return p(Number.isInteger(r),"underflow",t||"value",r),p(r>=-_t&&r<=_t,"overflow",t||"value",r),BigInt(r);case"string":try{if(r==="")throw new Error("empty string");return r[0]==="-"&&r[1]!=="-"?-BigInt(r.substring(1)):BigInt(r)}catch(e){p(!1,`invalid BigNumberish string: ${e.message}`,t||"value",r)}}p(!1,"invalid BigNumberish value",t||"value",r)}function Ae(r,t){const e=bt(r,t);return b(e>=Ne,"unsigned value cannot be negative","NUMERIC_FAULT",{fault:"overflow",operation:"getUint",value:r}),e}const an="0123456789abcdef";function _n(r){if(r instanceof Uint8Array){let t="0x0";for(const e of r)t+=an[e>>4],t+=an[e&15];return BigInt(t)}return bt(r)}function ht(r,t){switch(typeof r){case"bigint":return p(r>=-_t&&r<=_t,"overflow",t||"value",r),Number(r);case"number":return p(Number.isInteger(r),"underflow",t||"value",r),p(r>=-_t&&r<=_t,"overflow",t||"value",r),r;case"string":try{if(r==="")throw new Error("empty string");return ht(BigInt(r),t)}catch(e){p(!1,`invalid numeric string: ${e.message}`,t||"value",r)}}p(!1,"invalid numeric value",t||"value",r)}function Ir(r){return ht(_n(r))}function $n(r,t){let n=Ae(r,"value").toString(16);if(t==null)n.length%2&&(n="0"+n);else{const s=ht(t,"width");for(b(s*2>=n.length,`value exceeds width (${s} bytes)`,"NUMERIC_FAULT",{operation:"toBeHex",fault:"overflow",value:r});n.length<s*2;)n="0"+n}return"0x"+n}function Ur(r){const t=Ae(r,"value");if(t===Ne)return new Uint8Array([]);let e=t.toString(16);e.length%2&&(e="0"+e);const n=new Uint8Array(e.length/2);for(let s=0;s<n.length;s++){const i=s*2;n[s]=parseInt(e.substring(i,i+2),16)}return n}var Dt;class Sr{constructor(t,e,n){l(this,"filter");l(this,"emitter");v(this,Dt,void 0);A(this,Dt,e),E(this,{emitter:t,filter:n})}async removeListener(){h(this,Dt)!=null&&await this.emitter.off(this.filter,h(this,Dt))}}Dt=new WeakMap;function Cr(r,t,e,n,s){p(!1,`invalid codepoint at offset ${t}; ${r}`,"bytes",e)}function Dn(r,t,e,n,s){if(r==="BAD_PREFIX"||r==="UNEXPECTED_CONTINUE"){let i=0;for(let o=t+1;o<e.length&&e[o]>>6===2;o++)i++;return i}return r==="OVERRUN"?e.length-t-1:0}function Br(r,t,e,n,s){return r==="OVERLONG"?(p(typeof s=="number","invalid bad code point for replacement","badCodepoint",s),n.push(s),0):(n.push(65533),Dn(r,t,e))}const Fr=Object.freeze({error:Cr,ignore:Dn,replace:Br});function Lr(r,t){t==null&&(t=Fr.error);const e=lt(r,"bytes"),n=[];let s=0;for(;s<e.length;){const i=e[s++];if(!(i>>7)){n.push(i);continue}let o=null,a=null;if((i&224)===192)o=1,a=127;else if((i&240)===224)o=2,a=2047;else if((i&248)===240)o=3,a=65535;else{(i&192)===128?s+=t("UNEXPECTED_CONTINUE",s-1,e,n):s+=t("BAD_PREFIX",s-1,e,n);continue}if(s-1+o>=e.length){s+=t("OVERRUN",s-1,e,n);continue}let c=i&(1<<8-o-1)-1;for(let u=0;u<o;u++){let f=e[s];if((f&192)!=128){s+=t("MISSING_CONTINUE",s,e,n),c=null;break}c=c<<6|f&63,s++}if(c!==null){if(c>1114111){s+=t("OUT_OF_RANGE",s-1-o,e,n,c);continue}if(c>=55296&&c<=57343){s+=t("UTF16_SURROGATE",s-1-o,e,n,c);continue}if(c<=a){s+=t("OVERLONG",s-1-o,e,n,c);continue}n.push(c)}}return n}function Vn(r,t){p(typeof r=="string","invalid string value","str",r);let e=[];for(let n=0;n<r.length;n++){const s=r.charCodeAt(n);if(s<128)e.push(s);else if(s<2048)e.push(s>>6|192),e.push(s&63|128);else if((s&64512)==55296){n++;const i=r.charCodeAt(n);p(n<r.length&&(i&64512)===56320,"invalid surrogate pair","str",r);const o=65536+((s&1023)<<10)+(i&1023);e.push(o>>18|240),e.push(o>>12&63|128),e.push(o>>6&63|128),e.push(o&63|128)}else e.push(s>>12|224),e.push(s>>6&63|128),e.push(s&63|128)}return new Uint8Array(e)}function _r(r){return r.map(t=>t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode((t>>10&1023)+55296,(t&1023)+56320))).join("")}function $r(r,t){return _r(Lr(r,t))}const L=32,_e=new Uint8Array(L),Dr=["then"],ce={};function Jt(r,t){const e=new Error(`deferred error during ABI decoding triggered accessing ${r}`);throw e.error=t,e}var pt;const xt=class xt extends Array{constructor(...e){const n=e[0];let s=e[1],i=(e[2]||[]).slice(),o=!0;n!==ce&&(s=e,i=[],o=!1);super(s.length);v(this,pt,void 0);s.forEach((c,u)=>{this[u]=c});const a=i.reduce((c,u)=>(typeof u=="string"&&c.set(u,(c.get(u)||0)+1),c),new Map);if(A(this,pt,Object.freeze(s.map((c,u)=>{const f=i[u];return f!=null&&a.get(f)===1?f:null}))),!!o)return Object.freeze(this),new Proxy(this,{get:(c,u,f)=>{if(typeof u=="string"){if(u.match(/^[0-9]+$/)){const g=ht(u,"%index");if(g<0||g>=this.length)throw new RangeError("out of result range");const m=c[g];return m instanceof Error&&Jt(`index ${g}`,m),m}if(Dr.indexOf(u)>=0)return Reflect.get(c,u,f);const d=c[u];if(d instanceof Function)return function(...g){return d.apply(this===f?c:this,g)};if(!(u in c))return c.getValue.apply(this===f?c:this,[u])}return Reflect.get(c,u,f)}})}toArray(e){const n=[];return this.forEach((s,i)=>{s instanceof Error&&Jt(`index ${i}`,s),e&&s instanceof xt&&(s=s.toArray(e)),n.push(s)}),n}toObject(e){return h(this,pt).reduce((n,s,i)=>{if(b(s!=null,"value at index ${ index } unnamed","UNSUPPORTED_OPERATION",{operation:"toObject()"}),!(s in n)){let o=this.getValue(s);e&&o instanceof xt&&(o=o.toObject(e)),n[s]=o}return n},{})}slice(e,n){e==null&&(e=0),e<0&&(e+=this.length,e<0&&(e=0)),n==null&&(n=this.length),n<0&&(n+=this.length,n<0&&(n=0)),n>this.length&&(n=this.length);const s=[],i=[];for(let o=e;o<n;o++)s.push(this[o]),i.push(h(this,pt)[o]);return new xt(ce,s,i)}filter(e,n){const s=[],i=[];for(let o=0;o<this.length;o++){const a=this[o];a instanceof Error&&Jt(`index ${o}`,a),e.call(n,a,o,this)&&(s.push(a),i.push(h(this,pt)[o]))}return new xt(ce,s,i)}map(e,n){const s=[];for(let i=0;i<this.length;i++){const o=this[i];o instanceof Error&&Jt(`index ${i}`,o),s.push(e.call(n,o,i,this))}return s}getValue(e){const n=h(this,pt).indexOf(e);if(n===-1)return;const s=this[n];return s instanceof Error&&Jt(`property ${JSON.stringify(e)}`,s.error),s}static fromItems(e,n){return new xt(ce,e,n)}};pt=new WeakMap;let ye=xt;function cn(r){let t=Ur(r);return b(t.length<=L,"value out-of-bounds","BUFFER_OVERRUN",{buffer:t,length:L,offset:t.length}),t.length!==L&&(t=et($t([_e.slice(t.length%L),t]))),t}class dt{constructor(t,e,n,s){l(this,"name");l(this,"type");l(this,"localName");l(this,"dynamic");E(this,{name:t,type:e,localName:n,dynamic:s},{name:"string",type:"string",localName:"string",dynamic:"boolean"})}_throwError(t,e){p(!1,t,this.localName,e)}}var ot,Tt,Vt,he;class $e{constructor(){v(this,Vt);v(this,ot,void 0);v(this,Tt,void 0);A(this,ot,[]),A(this,Tt,0)}get data(){return $t(h(this,ot))}get length(){return h(this,Tt)}appendWriter(t){return P(this,Vt,he).call(this,et(t.data))}writeBytes(t){let e=et(t);const n=e.length%L;return n&&(e=et($t([e,_e.slice(n)]))),P(this,Vt,he).call(this,e)}writeValue(t){return P(this,Vt,he).call(this,cn(t))}writeUpdatableValue(){const t=h(this,ot).length;return h(this,ot).push(_e),A(this,Tt,h(this,Tt)+L),e=>{h(this,ot)[t]=cn(e)}}}ot=new WeakMap,Tt=new WeakMap,Vt=new WeakSet,he=function(t){return h(this,ot).push(t),A(this,Tt,h(this,Tt)+t.length),t.length};var $,G,kt,vt,gt,ne,Ve,be,Mn;const je=class je{constructor(t,e,n){v(this,ne);v(this,be);l(this,"allowLoose");v(this,$,void 0);v(this,G,void 0);v(this,kt,void 0);v(this,vt,void 0);v(this,gt,void 0);E(this,{allowLoose:!!e}),A(this,$,et(t)),A(this,kt,0),A(this,vt,null),A(this,gt,n??1024),A(this,G,0)}get data(){return I(h(this,$))}get dataLength(){return h(this,$).length}get consumed(){return h(this,G)}get bytes(){return new Uint8Array(h(this,$))}subReader(t){const e=new je(h(this,$).slice(h(this,G)+t),this.allowLoose,h(this,gt));return A(e,vt,this),e}readBytes(t,e){let n=P(this,be,Mn).call(this,0,t,!!e);return P(this,ne,Ve).call(this,t),A(this,G,h(this,G)+n.length),n.slice(0,t)}readValue(){return _n(this.readBytes(L))}readIndex(){return Ir(this.readBytes(L))}};$=new WeakMap,G=new WeakMap,kt=new WeakMap,vt=new WeakMap,gt=new WeakMap,ne=new WeakSet,Ve=function(t){var e;if(h(this,vt))return P(e=h(this,vt),ne,Ve).call(e,t);A(this,kt,h(this,kt)+t),b(h(this,gt)<1||h(this,kt)<=h(this,gt)*this.dataLength,`compressed ABI data exceeds inflation ratio of ${h(this,gt)} ( see: https://github.com/ethers-io/ethers.js/issues/4537 )`,"BUFFER_OVERRUN",{buffer:et(h(this,$)),offset:h(this,G),length:t,info:{bytesRead:h(this,kt),dataLength:this.dataLength}})},be=new WeakSet,Mn=function(t,e,n){let s=Math.ceil(e/L)*L;return h(this,G)+s>h(this,$).length&&(this.allowLoose&&n&&h(this,G)+e<=h(this,$).length?s=e:b(!1,"data out-of-bounds","BUFFER_OVERRUN",{buffer:et(h(this,$)),length:h(this,$).length,offset:h(this,G)+s})),h(this,$).slice(h(this,G),h(this,G)+s)};let De=je;function un(r){if(!Number.isSafeInteger(r)||r<0)throw new Error(`Wrong positive integer: ${r}`)}function Gn(r,...t){if(!(r instanceof Uint8Array))throw new Error("Expected Uint8Array");if(t.length>0&&!t.includes(r.length))throw new Error(`Expected Uint8Array of length ${t}, not of length=${r.length}`)}function ln(r,t=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(t&&r.finished)throw new Error("Hash#digest() has already been called")}function Vr(r,t){Gn(r);const e=t.outputLen;if(r.length<e)throw new Error(`digestInto() expects output buffer of length at least ${e}`)}/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Mr=r=>r instanceof Uint8Array,Gr=r=>new Uint32Array(r.buffer,r.byteOffset,Math.floor(r.byteLength/4)),Hr=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!Hr)throw new Error("Non little-endian hardware is not supported");function zr(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function Hn(r){if(typeof r=="string"&&(r=zr(r)),!Mr(r))throw new Error(`expected Uint8Array, got ${typeof r}`);return r}class Wr{clone(){return this._cloneInto()}}function Jr(r){const t=n=>r().update(Hn(n)).digest(),e=r();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>r(),t}const ue=BigInt(2**32-1),fn=BigInt(32);function Kr(r,t=!1){return t?{h:Number(r&ue),l:Number(r>>fn&ue)}:{h:Number(r>>fn&ue)|0,l:Number(r&ue)|0}}function Xr(r,t=!1){let e=new Uint32Array(r.length),n=new Uint32Array(r.length);for(let s=0;s<r.length;s++){const{h:i,l:o}=Kr(r[s],t);[e[s],n[s]]=[i,o]}return[e,n]}const Yr=(r,t,e)=>r<<e|t>>>32-e,Zr=(r,t,e)=>t<<e|r>>>32-e,Qr=(r,t,e)=>t<<e-32|r>>>64-e,qr=(r,t,e)=>r<<e-32|t>>>64-e,[zn,Wn,Jn]=[[],[],[]],jr=BigInt(0),Kt=BigInt(1),ts=BigInt(2),es=BigInt(7),ns=BigInt(256),rs=BigInt(113);for(let r=0,t=Kt,e=1,n=0;r<24;r++){[e,n]=[n,(2*e+3*n)%5],zn.push(2*(5*n+e)),Wn.push((r+1)*(r+2)/2%64);let s=jr;for(let i=0;i<7;i++)t=(t<<Kt^(t>>es)*rs)%ns,t&ts&&(s^=Kt<<(Kt<<BigInt(i))-Kt);Jn.push(s)}const[ss,is]=Xr(Jn,!0),hn=(r,t,e)=>e>32?Qr(r,t,e):Yr(r,t,e),dn=(r,t,e)=>e>32?qr(r,t,e):Zr(r,t,e);function os(r,t=24){const e=new Uint32Array(10);for(let n=24-t;n<24;n++){for(let o=0;o<10;o++)e[o]=r[o]^r[o+10]^r[o+20]^r[o+30]^r[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,c=(o+2)%10,u=e[c],f=e[c+1],d=hn(u,f,1)^e[a],g=dn(u,f,1)^e[a+1];for(let m=0;m<50;m+=10)r[o+m]^=d,r[o+m+1]^=g}let s=r[2],i=r[3];for(let o=0;o<24;o++){const a=Wn[o],c=hn(s,i,a),u=dn(s,i,a),f=zn[o];s=r[f],i=r[f+1],r[f]=c,r[f+1]=u}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)e[a]=r[o+a];for(let a=0;a<10;a++)r[o+a]^=~e[(a+2)%10]&e[(a+4)%10]}r[0]^=ss[n],r[1]^=is[n]}e.fill(0)}class Xe extends Wr{constructor(t,e,n,s=!1,i=24){if(super(),this.blockLen=t,this.suffix=e,this.outputLen=n,this.enableXOF=s,this.rounds=i,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,un(n),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=Gr(this.state)}keccak(){os(this.state32,this.rounds),this.posOut=0,this.pos=0}update(t){ln(this);const{blockLen:e,state:n}=this;t=Hn(t);const s=t.length;for(let i=0;i<s;){const o=Math.min(e-this.pos,s-i);for(let a=0;a<o;a++)n[this.pos++]^=t[i++];this.pos===e&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:e,pos:n,blockLen:s}=this;t[n]^=e,e&128&&n===s-1&&this.keccak(),t[s-1]^=128,this.keccak()}writeInto(t){ln(this,!1),Gn(t),this.finish();const e=this.state,{blockLen:n}=this;for(let s=0,i=t.length;s<i;){this.posOut>=n&&this.keccak();const o=Math.min(n-this.posOut,i-s);t.set(e.subarray(this.posOut,this.posOut+o),s),this.posOut+=o,s+=o}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return un(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Vr(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(t){const{blockLen:e,suffix:n,outputLen:s,rounds:i,enableXOF:o}=this;return t||(t=new Xe(e,n,s,o,i)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=i,t.suffix=n,t.outputLen=s,t.enableXOF=o,t.destroyed=this.destroyed,t}}const as=(r,t,e)=>Jr(()=>new Xe(t,r,e)),cs=as(1,136,256/8);let Kn=!1;const Xn=function(r){return cs(r)};let Yn=Xn;function wt(r){const t=lt(r,"data");return I(Yn(t))}wt._=Xn;wt.lock=function(){Kn=!0};wt.register=function(r){if(Kn)throw new TypeError("keccak256 is locked");Yn=r};Object.freeze(wt);const us=BigInt(0),ls=BigInt(36);function pn(r){r=r.toLowerCase();const t=r.substring(2).split(""),e=new Uint8Array(40);for(let s=0;s<40;s++)e[s]=t[s].charCodeAt(0);const n=lt(wt(e));for(let s=0;s<40;s+=2)n[s>>1]>>4>=8&&(t[s]=t[s].toUpperCase()),(n[s>>1]&15)>=8&&(t[s+1]=t[s+1].toUpperCase());return"0x"+t.join("")}const Ye={};for(let r=0;r<10;r++)Ye[String(r)]=String(r);for(let r=0;r<26;r++)Ye[String.fromCharCode(65+r)]=String(10+r);const gn=15;function fs(r){r=r.toUpperCase(),r=r.substring(4)+r.substring(0,2)+"00";let t=r.split("").map(n=>Ye[n]).join("");for(;t.length>=gn;){let n=t.substring(0,gn);t=parseInt(n,10)%97+t.substring(n.length)}let e=String(98-parseInt(t,10)%97);for(;e.length<2;)e="0"+e;return e}const hs=function(){const r={};for(let t=0;t<36;t++){const e="0123456789abcdefghijklmnopqrstuvwxyz"[t];r[e]=BigInt(t)}return r}();function ds(r){r=r.toLowerCase();let t=us;for(let e=0;e<r.length;e++)t=t*ls+hs[r[e]];return t}function Rt(r){if(p(typeof r=="string","invalid address","address",r),r.match(/^(0x)?[0-9a-fA-F]{40}$/)){r.startsWith("0x")||(r="0x"+r);const t=pn(r);return p(!r.match(/([A-F].*[a-f])|([a-f].*[A-F])/)||t===r,"bad address checksum","address",r),t}if(r.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){p(r.substring(2,4)===fs(r),"bad icap checksum","address",r);let t=ds(r.substring(4)).toString(16);for(;t.length<40;)t="0"+t;return pn("0x"+t)}p(!1,"invalid address","address",r)}function Zn(r){return r&&typeof r.getAddress=="function"}async function Ce(r,t){const e=await t;return(e==null||e==="0x0000000000000000000000000000000000000000")&&(b(typeof r!="string","unconfigured name","UNCONFIGURED_NAME",{value:r}),p(!1,"invalid AddressLike value; did not resolve to a value address","target",r)),Rt(e)}function qt(r,t){if(typeof r=="string")return r.match(/^0x[0-9a-f]{40}$/i)?Rt(r):(b(t!=null,"ENS resolution requires a provider","UNSUPPORTED_OPERATION",{operation:"resolveName"}),Ce(r,t.resolveName(r)));if(Zn(r))return Ce(r,r.getAddress());if(r&&typeof r.then=="function")return Ce(r,r);p(!1,"unsupported addressable value","target",r)}const rt={};function y(r,t){let e=!1;return t<0&&(e=!0,t*=-1),new F(rt,`${e?"":"u"}int${t}`,r,{signed:e,width:t})}function T(r,t){return new F(rt,`bytes${t||""}`,r,{size:t})}const yn=Symbol.for("_ethers_typed");var Ot;const st=class st{constructor(t,e,n,s){l(this,"type");l(this,"value");v(this,Ot,void 0);l(this,"_typedSymbol");s==null&&(s=null),Ke(rt,t,"Typed"),E(this,{_typedSymbol:yn,type:e,value:n}),A(this,Ot,s),this.format()}format(){if(this.type==="array")throw new Error("");if(this.type==="dynamicArray")throw new Error("");return this.type==="tuple"?`tuple(${this.value.map(t=>t.format()).join(",")})`:this.type}defaultValue(){return 0}minValue(){return 0}maxValue(){return 0}isBigInt(){return!!this.type.match(/^u?int[0-9]+$/)}isData(){return this.type.startsWith("bytes")}isString(){return this.type==="string"}get tupleName(){if(this.type!=="tuple")throw TypeError("not a tuple");return h(this,Ot)}get arrayLength(){if(this.type!=="array")throw TypeError("not an array");return h(this,Ot)===!0?-1:h(this,Ot)===!1?this.value.length:null}static from(t,e){return new st(rt,t,e)}static uint8(t){return y(t,8)}static uint16(t){return y(t,16)}static uint24(t){return y(t,24)}static uint32(t){return y(t,32)}static uint40(t){return y(t,40)}static uint48(t){return y(t,48)}static uint56(t){return y(t,56)}static uint64(t){return y(t,64)}static uint72(t){return y(t,72)}static uint80(t){return y(t,80)}static uint88(t){return y(t,88)}static uint96(t){return y(t,96)}static uint104(t){return y(t,104)}static uint112(t){return y(t,112)}static uint120(t){return y(t,120)}static uint128(t){return y(t,128)}static uint136(t){return y(t,136)}static uint144(t){return y(t,144)}static uint152(t){return y(t,152)}static uint160(t){return y(t,160)}static uint168(t){return y(t,168)}static uint176(t){return y(t,176)}static uint184(t){return y(t,184)}static uint192(t){return y(t,192)}static uint200(t){return y(t,200)}static uint208(t){return y(t,208)}static uint216(t){return y(t,216)}static uint224(t){return y(t,224)}static uint232(t){return y(t,232)}static uint240(t){return y(t,240)}static uint248(t){return y(t,248)}static uint256(t){return y(t,256)}static uint(t){return y(t,256)}static int8(t){return y(t,-8)}static int16(t){return y(t,-16)}static int24(t){return y(t,-24)}static int32(t){return y(t,-32)}static int40(t){return y(t,-40)}static int48(t){return y(t,-48)}static int56(t){return y(t,-56)}static int64(t){return y(t,-64)}static int72(t){return y(t,-72)}static int80(t){return y(t,-80)}static int88(t){return y(t,-88)}static int96(t){return y(t,-96)}static int104(t){return y(t,-104)}static int112(t){return y(t,-112)}static int120(t){return y(t,-120)}static int128(t){return y(t,-128)}static int136(t){return y(t,-136)}static int144(t){return y(t,-144)}static int152(t){return y(t,-152)}static int160(t){return y(t,-160)}static int168(t){return y(t,-168)}static int176(t){return y(t,-176)}static int184(t){return y(t,-184)}static int192(t){return y(t,-192)}static int200(t){return y(t,-200)}static int208(t){return y(t,-208)}static int216(t){return y(t,-216)}static int224(t){return y(t,-224)}static int232(t){return y(t,-232)}static int240(t){return y(t,-240)}static int248(t){return y(t,-248)}static int256(t){return y(t,-256)}static int(t){return y(t,-256)}static bytes1(t){return T(t,1)}static bytes2(t){return T(t,2)}static bytes3(t){return T(t,3)}static bytes4(t){return T(t,4)}static bytes5(t){return T(t,5)}static bytes6(t){return T(t,6)}static bytes7(t){return T(t,7)}static bytes8(t){return T(t,8)}static bytes9(t){return T(t,9)}static bytes10(t){return T(t,10)}static bytes11(t){return T(t,11)}static bytes12(t){return T(t,12)}static bytes13(t){return T(t,13)}static bytes14(t){return T(t,14)}static bytes15(t){return T(t,15)}static bytes16(t){return T(t,16)}static bytes17(t){return T(t,17)}static bytes18(t){return T(t,18)}static bytes19(t){return T(t,19)}static bytes20(t){return T(t,20)}static bytes21(t){return T(t,21)}static bytes22(t){return T(t,22)}static bytes23(t){return T(t,23)}static bytes24(t){return T(t,24)}static bytes25(t){return T(t,25)}static bytes26(t){return T(t,26)}static bytes27(t){return T(t,27)}static bytes28(t){return T(t,28)}static bytes29(t){return T(t,29)}static bytes30(t){return T(t,30)}static bytes31(t){return T(t,31)}static bytes32(t){return T(t,32)}static address(t){return new st(rt,"address",t)}static bool(t){return new st(rt,"bool",!!t)}static bytes(t){return new st(rt,"bytes",t)}static string(t){return new st(rt,"string",t)}static array(t,e){throw new Error("not implemented yet")}static tuple(t,e){throw new Error("not implemented yet")}static overrides(t){return new st(rt,"overrides",Object.assign({},t))}static isTyped(t){return t&&typeof t=="object"&&"_typedSymbol"in t&&t._typedSymbol===yn}static dereference(t,e){if(st.isTyped(t)){if(t.type!==e)throw new Error(`invalid type: expecetd ${e}, got ${t.type}`);return t.value}return t}};Ot=new WeakMap;let F=st;class ps extends dt{constructor(t){super("address","address",t,!1)}defaultValue(){return"0x0000000000000000000000000000000000000000"}encode(t,e){let n=F.dereference(e,"string");try{n=Rt(n)}catch(s){return this._throwError(s.message,e)}return t.writeValue(n)}decode(t){return Rt($n(t.readValue(),20))}}class gs extends dt{constructor(e){super(e.name,e.type,"_",e.dynamic);l(this,"coder");this.coder=e}defaultValue(){return this.coder.defaultValue()}encode(e,n){return this.coder.encode(e,n)}decode(e){return this.coder.decode(e)}}function Qn(r,t,e){let n=[];if(Array.isArray(e))n=e;else if(e&&typeof e=="object"){let c={};n=t.map(u=>{const f=u.localName;return b(f,"cannot encode object for signature with missing names","INVALID_ARGUMENT",{argument:"values",info:{coder:u},value:e}),b(!c[f],"cannot encode object for signature with duplicate names","INVALID_ARGUMENT",{argument:"values",info:{coder:u},value:e}),c[f]=!0,e[f]})}else p(!1,"invalid tuple value","tuple",e);p(t.length===n.length,"types/value length mismatch","tuple",e);let s=new $e,i=new $e,o=[];t.forEach((c,u)=>{let f=n[u];if(c.dynamic){let d=i.length;c.encode(i,f);let g=s.writeUpdatableValue();o.push(m=>{g(m+d)})}else c.encode(s,f)}),o.forEach(c=>{c(s.length)});let a=r.appendWriter(s);return a+=r.appendWriter(i),a}function qn(r,t){let e=[],n=[],s=r.subReader(0);return t.forEach(i=>{let o=null;if(i.dynamic){let a=r.readIndex(),c=s.subReader(a);try{o=i.decode(c)}catch(u){if(Wt(u,"BUFFER_OVERRUN"))throw u;o=u,o.baseType=i.name,o.name=i.localName,o.type=i.type}}else try{o=i.decode(r)}catch(a){if(Wt(a,"BUFFER_OVERRUN"))throw a;o=a,o.baseType=i.name,o.name=i.localName,o.type=i.type}if(o==null)throw new Error("investigate");e.push(o),n.push(i.localName||null)}),ye.fromItems(e,n)}class ys extends dt{constructor(e,n,s){const i=e.type+"["+(n>=0?n:"")+"]",o=n===-1||e.dynamic;super("array",i,s,o);l(this,"coder");l(this,"length");E(this,{coder:e,length:n})}defaultValue(){const e=this.coder.defaultValue(),n=[];for(let s=0;s<this.length;s++)n.push(e);return n}encode(e,n){const s=F.dereference(n,"array");Array.isArray(s)||this._throwError("expected array value",s);let i=this.length;i===-1&&(i=s.length,e.writeValue(s.length)),Bn(s.length,i,"coder array"+(this.localName?" "+this.localName:""));let o=[];for(let a=0;a<s.length;a++)o.push(this.coder);return Qn(e,o,s)}decode(e){let n=this.length;n===-1&&(n=e.readIndex(),b(n*L<=e.dataLength,"insufficient data length","BUFFER_OVERRUN",{buffer:e.bytes,offset:n*L,length:e.dataLength}));let s=[];for(let i=0;i<n;i++)s.push(new gs(this.coder));return qn(e,s)}}class ms extends dt{constructor(t){super("bool","bool",t,!1)}defaultValue(){return!1}encode(t,e){const n=F.dereference(e,"bool");return t.writeValue(n?1:0)}decode(t){return!!t.readValue()}}class jn extends dt{constructor(t,e){super(t,t,e,!0)}defaultValue(){return"0x"}encode(t,e){e=et(e);let n=t.writeValue(e.length);return n+=t.writeBytes(e),n}decode(t){return t.readBytes(t.readIndex(),!0)}}class ws extends jn{constructor(t){super("bytes",t)}decode(t){return I(super.decode(t))}}class bs extends dt{constructor(e,n){let s="bytes"+String(e);super(s,s,n,!1);l(this,"size");E(this,{size:e},{size:"number"})}defaultValue(){return"0x0000000000000000000000000000000000000000000000000000000000000000".substring(0,2+this.size*2)}encode(e,n){let s=et(F.dereference(n,this.type));return s.length!==this.size&&this._throwError("incorrect data length",n),e.writeBytes(s)}decode(e){return I(e.readBytes(this.size))}}const Es=new Uint8Array([]);class xs extends dt{constructor(t){super("null","",t,!1)}defaultValue(){return null}encode(t,e){return e!=null&&this._throwError("not null",e),t.writeBytes(Es)}decode(t){return t.readBytes(0),null}}const Ns=BigInt(0),As=BigInt(1),Ts=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");class ks extends dt{constructor(e,n,s){const i=(n?"int":"uint")+e*8;super(i,i,s,!1);l(this,"size");l(this,"signed");E(this,{size:e,signed:n},{size:"number",signed:"boolean"})}defaultValue(){return 0}encode(e,n){let s=bt(F.dereference(n,this.type)),i=ae(Ts,L*8);if(this.signed){let o=ae(i,this.size*8-1);(s>o||s<-(o+As))&&this._throwError("value out-of-bounds",n),s=Rr(s,8*L)}else(s<Ns||s>ae(i,this.size*8))&&this._throwError("value out-of-bounds",n);return e.writeValue(s)}decode(e){let n=ae(e.readValue(),this.size*8);return this.signed&&(n=Pr(n,this.size*8)),n}}class vs extends jn{constructor(t){super("string",t)}defaultValue(){return""}encode(t,e){return super.encode(t,Vn(F.dereference(e,"string")))}decode(t){return $r(super.decode(t))}}class le extends dt{constructor(e,n){let s=!1;const i=[];e.forEach(a=>{a.dynamic&&(s=!0),i.push(a.type)});const o="tuple("+i.join(",")+")";super("tuple",o,n,s);l(this,"coders");E(this,{coders:Object.freeze(e.slice())})}defaultValue(){const e=[];this.coders.forEach(s=>{e.push(s.defaultValue())});const n=this.coders.reduce((s,i)=>{const o=i.localName;return o&&(s[o]||(s[o]=0),s[o]++),s},{});return this.coders.forEach((s,i)=>{let o=s.localName;!o||n[o]!==1||(o==="length"&&(o="_length"),e[o]==null&&(e[o]=e[i]))}),Object.freeze(e)}encode(e,n){const s=F.dereference(n,"tuple");return Qn(e,this.coders,s)}decode(e){return qn(e,this.coders)}}function jt(r){return wt(Vn(r))}function Be(r,t){return{address:Rt(r),storageKeys:t.map((e,n)=>(p(at(e,32),"invalid slot",`storageKeys[${n}]`,e),e.toLowerCase()))}}function Os(r){if(Array.isArray(r))return r.map((e,n)=>Array.isArray(e)?(p(e.length===2,"invalid slot set",`value[${n}]`,e),Be(e[0],e[1])):(p(e!=null&&typeof e=="object","invalid address-slot set","value",r),Be(e.address,e.storageKeys)));p(r!=null&&typeof r=="object","invalid access list","value",r);const t=Object.keys(r).map(e=>{const n=r[e].reduce((s,i)=>(s[i]=!0,s),{});return Be(e,Object.keys(n).sort())});return t.sort((e,n)=>e.address.localeCompare(n.address)),t}function _(r){const t=new Set;return r.forEach(e=>t.add(e)),Object.freeze(t)}const Ps="external public payable override",Rs=_(Ps.split(" ")),tr="constant external internal payable private public pure view override",Is=_(tr.split(" ")),er="constructor error event fallback function receive struct",nr=_(er.split(" ")),rr="calldata memory storage payable indexed",Us=_(rr.split(" ")),Ss="tuple returns",Cs=[er,rr,Ss,tr].join(" "),Bs=_(Cs.split(" ")),Fs={"(":"OPEN_PAREN",")":"CLOSE_PAREN","[":"OPEN_BRACKET","]":"CLOSE_BRACKET",",":"COMMA","@":"AT"},Ls=new RegExp("^(\\s*)"),_s=new RegExp("^([0-9]+)"),$s=new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)"),sr=new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)$"),ir=new RegExp("^(address|bool|bytes([0-9]*)|string|u?int([0-9]*))$");var S,J,re,Me;const Ee=class Ee{constructor(t){v(this,re);v(this,S,void 0);v(this,J,void 0);A(this,S,0),A(this,J,t.slice())}get offset(){return h(this,S)}get length(){return h(this,J).length-h(this,S)}clone(){return new Ee(h(this,J))}reset(){A(this,S,0)}popKeyword(t){const e=this.peek();if(e.type!=="KEYWORD"||!t.has(e.text))throw new Error(`expected keyword ${e.text}`);return this.pop().text}popType(t){if(this.peek().type!==t){const e=this.peek();throw new Error(`expected ${t}; got ${e.type} ${JSON.stringify(e.text)}`)}return this.pop().text}popParen(){const t=this.peek();if(t.type!=="OPEN_PAREN")throw new Error("bad start");const e=P(this,re,Me).call(this,h(this,S)+1,t.match+1);return A(this,S,t.match+1),e}popParams(){const t=this.peek();if(t.type!=="OPEN_PAREN")throw new Error("bad start");const e=[];for(;h(this,S)<t.match-1;){const n=this.peek().linkNext;e.push(P(this,re,Me).call(this,h(this,S)+1,n)),A(this,S,n)}return A(this,S,t.match+1),e}peek(){if(h(this,S)>=h(this,J).length)throw new Error("out-of-bounds");return h(this,J)[h(this,S)]}peekKeyword(t){const e=this.peekType("KEYWORD");return e!=null&&t.has(e)?e:null}peekType(t){if(this.length===0)return null;const e=this.peek();return e.type===t?e.text:null}pop(){const t=this.peek();return rn(this,S)._++,t}toString(){const t=[];for(let e=h(this,S);e<h(this,J).length;e++){const n=h(this,J)[e];t.push(`${n.type}:${n.text}`)}return`<TokenString ${t.join(" ")}>`}};S=new WeakMap,J=new WeakMap,re=new WeakSet,Me=function(t=0,e=0){return new Ee(h(this,J).slice(t,e).map(n=>Object.freeze(Object.assign({},n,{match:n.match-t,linkBack:n.linkBack-t,linkNext:n.linkNext-t}))))};let X=Ee;function Et(r){const t=[],e=o=>{const a=i<r.length?JSON.stringify(r[i]):"$EOI";throw new Error(`invalid token ${a} at ${i}: ${o}`)};let n=[],s=[],i=0;for(;i<r.length;){let o=r.substring(i),a=o.match(Ls);a&&(i+=a[1].length,o=r.substring(i));const c={depth:n.length,linkBack:-1,linkNext:-1,match:-1,type:"",text:"",offset:i,value:-1};t.push(c);let u=Fs[o[0]]||"";if(u){if(c.type=u,c.text=o[0],i++,u==="OPEN_PAREN")n.push(t.length-1),s.push(t.length-1);else if(u=="CLOSE_PAREN")n.length===0&&e("no matching open bracket"),c.match=n.pop(),t[c.match].match=t.length-1,c.depth--,c.linkBack=s.pop(),t[c.linkBack].linkNext=t.length-1;else if(u==="COMMA")c.linkBack=s.pop(),t[c.linkBack].linkNext=t.length-1,s.push(t.length-1);else if(u==="OPEN_BRACKET")c.type="BRACKET";else if(u==="CLOSE_BRACKET"){let f=t.pop().text;if(t.length>0&&t[t.length-1].type==="NUMBER"){const d=t.pop().text;f=d+f,t[t.length-1].value=ht(d)}if(t.length===0||t[t.length-1].type!=="BRACKET")throw new Error("missing opening bracket");t[t.length-1].text+=f}continue}if(a=o.match($s),a){if(c.text=a[1],i+=c.text.length,Bs.has(c.text)){c.type="KEYWORD";continue}if(c.text.match(ir)){c.type="TYPE";continue}c.type="ID";continue}if(a=o.match(_s),a){c.text=a[1],c.type="NUMBER",i+=c.text.length;continue}throw new Error(`unexpected token ${JSON.stringify(o[0])} at position ${i}`)}return new X(t.map(o=>Object.freeze(o)))}function mn(r,t){let e=[];for(const n in t.keys())r.has(n)&&e.push(n);if(e.length>1)throw new Error(`conflicting types: ${e.join(", ")}`)}function Te(r,t){if(t.peekKeyword(nr)){const e=t.pop().text;if(e!==r)throw new Error(`expected ${r}, got ${e}`)}return t.popType("ID")}function ft(r,t){const e=new Set;for(;;){const n=r.peekType("KEYWORD");if(n==null||t&&!t.has(n))break;if(r.pop(),e.has(n))throw new Error(`duplicate keywords: ${JSON.stringify(n)}`);e.add(n)}return Object.freeze(e)}function or(r){let t=ft(r,Is);return mn(t,_("constant payable nonpayable".split(" "))),mn(t,_("pure view payable nonpayable".split(" "))),t.has("view")?"view":t.has("pure")?"pure":t.has("payable")?"payable":t.has("nonpayable")?"nonpayable":t.has("constant")?"view":"nonpayable"}function ut(r,t){return r.popParams().map(e=>C.from(e,t))}function ar(r){if(r.peekType("AT")){if(r.pop(),r.peekType("NUMBER"))return bt(r.pop().text);throw new Error("invalid gas")}return null}function It(r){if(r.length)throw new Error(`unexpected tokens at offset ${r.offset}: ${r.toString()}`)}const Ds=new RegExp(/^(.*)\[([0-9]*)\]$/);function wn(r){const t=r.match(ir);if(p(t,"invalid type","type",r),r==="uint")return"uint256";if(r==="int")return"int256";if(t[2]){const e=parseInt(t[2]);p(e!==0&&e<=32,"invalid bytes length","type",r)}else if(t[3]){const e=parseInt(t[3]);p(e!==0&&e<=256&&e%8===0,"invalid numeric width","type",r)}return r}const R={},V=Symbol.for("_ethers_internal"),bn="_ParamTypeInternal",En="_ErrorInternal",xn="_EventInternal",Nn="_ConstructorInternal",An="_FallbackInternal",Tn="_FunctionInternal",kn="_StructInternal";var Mt,de;const z=class z{constructor(t,e,n,s,i,o,a,c){v(this,Mt);l(this,"name");l(this,"type");l(this,"baseType");l(this,"indexed");l(this,"components");l(this,"arrayLength");l(this,"arrayChildren");if(Ke(t,R,"ParamType"),Object.defineProperty(this,V,{value:bn}),o&&(o=Object.freeze(o.slice())),s==="array"){if(a==null||c==null)throw new Error("")}else if(a!=null||c!=null)throw new Error("");if(s==="tuple"){if(o==null)throw new Error("")}else if(o!=null)throw new Error("");E(this,{name:e,type:n,baseType:s,indexed:i,components:o,arrayLength:a,arrayChildren:c})}format(t){if(t==null&&(t="sighash"),t==="json"){const n=this.name||"";if(this.isArray()){const i=JSON.parse(this.arrayChildren.format("json"));return i.name=n,i.type+=`[${this.arrayLength<0?"":String(this.arrayLength)}]`,JSON.stringify(i)}const s={type:this.baseType==="tuple"?"tuple":this.type,name:n};return typeof this.indexed=="boolean"&&(s.indexed=this.indexed),this.isTuple()&&(s.components=this.components.map(i=>JSON.parse(i.format(t)))),JSON.stringify(s)}let e="";return this.isArray()?(e+=this.arrayChildren.format(t),e+=`[${this.arrayLength<0?"":String(this.arrayLength)}]`):this.isTuple()?e+="("+this.components.map(n=>n.format(t)).join(t==="full"?", ":",")+")":e+=this.type,t!=="sighash"&&(this.indexed===!0&&(e+=" indexed"),t==="full"&&this.name&&(e+=" "+this.name)),e}isArray(){return this.baseType==="array"}isTuple(){return this.baseType==="tuple"}isIndexable(){return this.indexed!=null}walk(t,e){if(this.isArray()){if(!Array.isArray(t))throw new Error("invalid array value");if(this.arrayLength!==-1&&t.length!==this.arrayLength)throw new Error("array is wrong length");const n=this;return t.map(s=>n.arrayChildren.walk(s,e))}if(this.isTuple()){if(!Array.isArray(t))throw new Error("invalid tuple value");if(t.length!==this.components.length)throw new Error("array is wrong length");const n=this;return t.map((s,i)=>n.components[i].walk(s,e))}return e(this.type,t)}async walkAsync(t,e){const n=[],s=[t];return P(this,Mt,de).call(this,n,t,e,i=>{s[0]=i}),n.length&&await Promise.all(n),s[0]}static from(t,e){if(z.isParamType(t))return t;if(typeof t=="string")try{return z.from(Et(t),e)}catch{p(!1,"invalid param type","obj",t)}else if(t instanceof X){let a="",c="",u=null;ft(t,_(["tuple"])).has("tuple")||t.peekType("OPEN_PAREN")?(c="tuple",u=t.popParams().map(k=>z.from(k)),a=`tuple(${u.map(k=>k.format()).join(",")})`):(a=wn(t.popType("TYPE")),c=a);let f=null,d=null;for(;t.length&&t.peekType("BRACKET");){const k=t.pop();f=new z(R,"",a,c,null,u,d,f),d=k.value,a+=k.text,c="array",u=null}let g=null;if(ft(t,Us).has("indexed")){if(!e)throw new Error("");g=!0}const x=t.peekType("ID")?t.pop().text:"";if(t.length)throw new Error("leftover tokens");return new z(R,x,a,c,g,u,d,f)}const n=t.name;p(!n||typeof n=="string"&&n.match(sr),"invalid name","obj.name",n);let s=t.indexed;s!=null&&(p(e,"parameter cannot be indexed","obj.indexed",t.indexed),s=!!s);let i=t.type,o=i.match(Ds);if(o){const a=parseInt(o[2]||"-1"),c=z.from({type:o[1],components:t.components});return new z(R,n||"",i,"array",s,null,a,c)}if(i==="tuple"||i.startsWith("tuple(")||i.startsWith("(")){const a=t.components!=null?t.components.map(u=>z.from(u)):null;return new z(R,n||"",i,"tuple",s,a,null,null)}return i=wn(t.type),new z(R,n||"",i,i,s,null,null,null)}static isParamType(t){return t&&t[V]===bn}};Mt=new WeakSet,de=function(t,e,n,s){if(this.isArray()){if(!Array.isArray(e))throw new Error("invalid array value");if(this.arrayLength!==-1&&e.length!==this.arrayLength)throw new Error("array is wrong length");const o=this.arrayChildren,a=e.slice();a.forEach((c,u)=>{var f;P(f=o,Mt,de).call(f,t,c,n,d=>{a[u]=d})}),s(a);return}if(this.isTuple()){const o=this.components;let a;if(Array.isArray(e))a=e.slice();else{if(e==null||typeof e!="object")throw new Error("invalid tuple value");a=o.map(c=>{if(!c.name)throw new Error("cannot use object value with unnamed components");if(!(c.name in e))throw new Error(`missing value for component ${c.name}`);return e[c.name]})}if(a.length!==this.components.length)throw new Error("array is wrong length");a.forEach((c,u)=>{var f;P(f=o[u],Mt,de).call(f,t,c,n,d=>{a[u]=d})}),s(a);return}const i=n(this.type,e);i.then?t.push(async function(){s(await i)}()):s(i)};let C=z;class Ut{constructor(t,e,n){l(this,"type");l(this,"inputs");Ke(t,R,"Fragment"),n=Object.freeze(n.slice()),E(this,{type:e,inputs:n})}static from(t){if(typeof t=="string"){try{Ut.from(JSON.parse(t))}catch{}return Ut.from(Et(t))}if(t instanceof X)switch(t.peekKeyword(nr)){case"constructor":return ct.from(t);case"error":return D.from(t);case"event":return j.from(t);case"fallback":case"receive":return it.from(t);case"function":return tt.from(t);case"struct":return Pt.from(t)}else if(typeof t=="object"){switch(t.type){case"constructor":return ct.from(t);case"error":return D.from(t);case"event":return j.from(t);case"fallback":case"receive":return it.from(t);case"function":return tt.from(t);case"struct":return Pt.from(t)}b(!1,`unsupported type: ${t.type}`,"UNSUPPORTED_OPERATION",{operation:"Fragment.from"})}p(!1,"unsupported frgament object","obj",t)}static isConstructor(t){return ct.isFragment(t)}static isError(t){return D.isFragment(t)}static isEvent(t){return j.isFragment(t)}static isFunction(t){return tt.isFragment(t)}static isStruct(t){return Pt.isFragment(t)}}class ke extends Ut{constructor(e,n,s,i){super(e,n,i);l(this,"name");p(typeof s=="string"&&s.match(sr),"invalid identifier","name",s),i=Object.freeze(i.slice()),E(this,{name:s})}}function te(r,t){return"("+t.map(e=>e.format(r)).join(r==="full"?", ":",")+")"}class D extends ke{constructor(t,e,n){super(t,"error",e,n),Object.defineProperty(this,V,{value:En})}get selector(){return jt(this.format("sighash")).substring(0,10)}format(t){if(t==null&&(t="sighash"),t==="json")return JSON.stringify({type:"error",name:this.name,inputs:this.inputs.map(n=>JSON.parse(n.format(t)))});const e=[];return t!=="sighash"&&e.push("error"),e.push(this.name+te(t,this.inputs)),e.join(" ")}static from(t){if(D.isFragment(t))return t;if(typeof t=="string")return D.from(Et(t));if(t instanceof X){const e=Te("error",t),n=ut(t);return It(t),new D(R,e,n)}return new D(R,t.name,t.inputs?t.inputs.map(C.from):[])}static isFragment(t){return t&&t[V]===En}}class j extends ke{constructor(e,n,s,i){super(e,"event",n,s);l(this,"anonymous");Object.defineProperty(this,V,{value:xn}),E(this,{anonymous:i})}get topicHash(){return jt(this.format("sighash"))}format(e){if(e==null&&(e="sighash"),e==="json")return JSON.stringify({type:"event",anonymous:this.anonymous,name:this.name,inputs:this.inputs.map(s=>JSON.parse(s.format(e)))});const n=[];return e!=="sighash"&&n.push("event"),n.push(this.name+te(e,this.inputs)),e!=="sighash"&&this.anonymous&&n.push("anonymous"),n.join(" ")}static getTopicHash(e,n){return n=(n||[]).map(i=>C.from(i)),new j(R,e,n,!1).topicHash}static from(e){if(j.isFragment(e))return e;if(typeof e=="string")try{return j.from(Et(e))}catch{p(!1,"invalid event fragment","obj",e)}else if(e instanceof X){const n=Te("event",e),s=ut(e,!0),i=!!ft(e,_(["anonymous"])).has("anonymous");return It(e),new j(R,n,s,i)}return new j(R,e.name,e.inputs?e.inputs.map(n=>C.from(n,!0)):[],!!e.anonymous)}static isFragment(e){return e&&e[V]===xn}}class ct extends Ut{constructor(e,n,s,i,o){super(e,n,s);l(this,"payable");l(this,"gas");Object.defineProperty(this,V,{value:Nn}),E(this,{payable:i,gas:o})}format(e){if(b(e!=null&&e!=="sighash","cannot format a constructor for sighash","UNSUPPORTED_OPERATION",{operation:"format(sighash)"}),e==="json")return JSON.stringify({type:"constructor",stateMutability:this.payable?"payable":"undefined",payable:this.payable,gas:this.gas!=null?this.gas:void 0,inputs:this.inputs.map(s=>JSON.parse(s.format(e)))});const n=[`constructor${te(e,this.inputs)}`];return this.payable&&n.push("payable"),this.gas!=null&&n.push(`@${this.gas.toString()}`),n.join(" ")}static from(e){if(ct.isFragment(e))return e;if(typeof e=="string")try{return ct.from(Et(e))}catch{p(!1,"invalid constuctor fragment","obj",e)}else if(e instanceof X){ft(e,_(["constructor"]));const n=ut(e),s=!!ft(e,Rs).has("payable"),i=ar(e);return It(e),new ct(R,"constructor",n,s,i)}return new ct(R,"constructor",e.inputs?e.inputs.map(C.from):[],!!e.payable,e.gas!=null?e.gas:null)}static isFragment(e){return e&&e[V]===Nn}}class it extends Ut{constructor(e,n,s){super(e,"fallback",n);l(this,"payable");Object.defineProperty(this,V,{value:An}),E(this,{payable:s})}format(e){const n=this.inputs.length===0?"receive":"fallback";if(e==="json"){const s=this.payable?"payable":"nonpayable";return JSON.stringify({type:n,stateMutability:s})}return`${n}()${this.payable?" payable":""}`}static from(e){if(it.isFragment(e))return e;if(typeof e=="string")try{return it.from(Et(e))}catch{p(!1,"invalid fallback fragment","obj",e)}else if(e instanceof X){const n=e.toString(),s=e.peekKeyword(_(["fallback","receive"]));if(p(s,"type must be fallback or receive","obj",n),e.popKeyword(_(["fallback","receive"]))==="receive"){const c=ut(e);return p(c.length===0,"receive cannot have arguments","obj.inputs",c),ft(e,_(["payable"])),It(e),new it(R,[],!0)}let o=ut(e);o.length?p(o.length===1&&o[0].type==="bytes","invalid fallback inputs","obj.inputs",o.map(c=>c.format("minimal")).join(", ")):o=[C.from("bytes")];const a=or(e);if(p(a==="nonpayable"||a==="payable","fallback cannot be constants","obj.stateMutability",a),ft(e,_(["returns"])).has("returns")){const c=ut(e);p(c.length===1&&c[0].type==="bytes","invalid fallback outputs","obj.outputs",c.map(u=>u.format("minimal")).join(", "))}return It(e),new it(R,o,a==="payable")}if(e.type==="receive")return new it(R,[],!0);if(e.type==="fallback"){const n=[C.from("bytes")],s=e.stateMutability==="payable";return new it(R,n,s)}p(!1,"invalid fallback description","obj",e)}static isFragment(e){return e&&e[V]===An}}class tt extends ke{constructor(e,n,s,i,o,a){super(e,"function",n,i);l(this,"constant");l(this,"outputs");l(this,"stateMutability");l(this,"payable");l(this,"gas");Object.defineProperty(this,V,{value:Tn}),o=Object.freeze(o.slice()),E(this,{constant:s==="view"||s==="pure",gas:a,outputs:o,payable:s==="payable",stateMutability:s})}get selector(){return jt(this.format("sighash")).substring(0,10)}format(e){if(e==null&&(e="sighash"),e==="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!=null?this.gas:void 0,inputs:this.inputs.map(s=>JSON.parse(s.format(e))),outputs:this.outputs.map(s=>JSON.parse(s.format(e)))});const n=[];return e!=="sighash"&&n.push("function"),n.push(this.name+te(e,this.inputs)),e!=="sighash"&&(this.stateMutability!=="nonpayable"&&n.push(this.stateMutability),this.outputs&&this.outputs.length&&(n.push("returns"),n.push(te(e,this.outputs))),this.gas!=null&&n.push(`@${this.gas.toString()}`)),n.join(" ")}static getSelector(e,n){return n=(n||[]).map(i=>C.from(i)),new tt(R,e,"view",n,[],null).selector}static from(e){if(tt.isFragment(e))return e;if(typeof e=="string")try{return tt.from(Et(e))}catch{p(!1,"invalid function fragment","obj",e)}else if(e instanceof X){const s=Te("function",e),i=ut(e),o=or(e);let a=[];ft(e,_(["returns"])).has("returns")&&(a=ut(e));const c=ar(e);return It(e),new tt(R,s,o,i,a,c)}let n=e.stateMutability;return n==null&&(n="payable",typeof e.constant=="boolean"?(n="view",e.constant||(n="payable",typeof e.payable=="boolean"&&!e.payable&&(n="nonpayable"))):typeof e.payable=="boolean"&&!e.payable&&(n="nonpayable")),new tt(R,e.name,n,e.inputs?e.inputs.map(C.from):[],e.outputs?e.outputs.map(C.from):[],e.gas!=null?e.gas:null)}static isFragment(e){return e&&e[V]===Tn}}class Pt extends ke{constructor(t,e,n){super(t,"struct",e,n),Object.defineProperty(this,V,{value:kn})}format(){throw new Error("@TODO")}static from(t){if(typeof t=="string")try{return Pt.from(Et(t))}catch{p(!1,"invalid struct fragment","obj",t)}else if(t instanceof X){const e=Te("struct",t),n=ut(t);return It(t),new Pt(R,e,n)}return new Pt(R,t.name,t.inputs?t.inputs.map(C.from):[])}static isFragment(t){return t&&t[V]===kn}}const Y=new Map;Y.set(0,"GENERIC_PANIC");Y.set(1,"ASSERT_FALSE");Y.set(17,"OVERFLOW");Y.set(18,"DIVIDE_BY_ZERO");Y.set(33,"ENUM_RANGE_ERROR");Y.set(34,"BAD_STORAGE_DATA");Y.set(49,"STACK_UNDERFLOW");Y.set(50,"ARRAY_RANGE_ERROR");Y.set(65,"OUT_OF_MEMORY");Y.set(81,"UNINITIALIZED_FUNCTION_CALL");const Vs=new RegExp(/^bytes([0-9]*)$/),Ms=new RegExp(/^(u?int)([0-9]*)$/);let Fe=null,vn=1024;function Gs(r,t,e,n){let s="missing revert data",i=null;const o=null;let a=null;if(e){s="execution reverted";const u=lt(e);if(e=I(e),u.length===0)s+=" (no data present; likely require(false) occurred",i="require(false)";else if(u.length%32!==4)s+=" (could not decode reason; invalid data length)";else if(I(u.slice(0,4))==="0x08c379a0")try{i=n.decode(["string"],u.slice(4))[0],a={signature:"Error(string)",name:"Error",args:[i]},s+=`: ${JSON.stringify(i)}`}catch{s+=" (could not decode reason; invalid string data)"}else if(I(u.slice(0,4))==="0x4e487b71")try{const f=Number(n.decode(["uint256"],u.slice(4))[0]);a={signature:"Panic(uint256)",name:"Panic",args:[f]},i=`Panic due to ${Y.get(f)||"UNKNOWN"}(${f})`,s+=`: ${i}`}catch{s+=" (could not decode panic code)"}else s+=" (unknown custom error)"}const c={to:t.to?Rt(t.to):null,data:t.data||"0x"};return t.from&&(c.from=Rt(t.from)),Qt(s,"CALL_EXCEPTION",{action:r,data:e,reason:i,transaction:c,invocation:o,revert:a})}var yt,Ft;const xe=class xe{constructor(){v(this,yt)}getDefaultValue(t){const e=t.map(s=>P(this,yt,Ft).call(this,C.from(s)));return new le(e,"_").defaultValue()}encode(t,e){Bn(e.length,t.length,"types/values length mismatch");const n=t.map(o=>P(this,yt,Ft).call(this,C.from(o))),s=new le(n,"_"),i=new $e;return s.encode(i,e),i.data}decode(t,e,n){const s=t.map(o=>P(this,yt,Ft).call(this,C.from(o)));return new le(s,"_").decode(new De(e,n,vn))}static _setDefaultMaxInflation(t){p(typeof t=="number"&&Number.isInteger(t),"invalid defaultMaxInflation factor","value",t),vn=t}static defaultAbiCoder(){return Fe==null&&(Fe=new xe),Fe}static getBuiltinCallException(t,e,n){return Gs(t,e,n,xe.defaultAbiCoder())}};yt=new WeakSet,Ft=function(t){if(t.isArray())return new ys(P(this,yt,Ft).call(this,t.arrayChildren),t.arrayLength,t.name);if(t.isTuple())return new le(t.components.map(n=>P(this,yt,Ft).call(this,n)),t.name);switch(t.baseType){case"address":return new ps(t.name);case"bool":return new ms(t.name);case"string":return new vs(t.name);case"bytes":return new ws(t.name);case"":return new xs(t.name)}let e=t.type.match(Ms);if(e){let n=parseInt(e[2]||"256");return p(n!==0&&n<=256&&n%8===0,"invalid "+e[1]+" bit length","param",t),new ks(n/8,e[1]==="int",t.name)}if(e=t.type.match(Vs),e){let n=parseInt(e[1]);return p(n!==0&&n<=32,"invalid bytes length","param",t),new bs(n,t.name)}p(!1,"invalid type","type",t.type)};let me=xe;class Hs{constructor(t,e,n){l(this,"fragment");l(this,"name");l(this,"signature");l(this,"topic");l(this,"args");const s=t.name,i=t.format();E(this,{fragment:t,name:s,signature:i,topic:e,args:n})}}class zs{constructor(t,e,n,s){l(this,"fragment");l(this,"name");l(this,"args");l(this,"signature");l(this,"selector");l(this,"value");const i=t.name,o=t.format();E(this,{fragment:t,name:i,args:n,signature:o,selector:e,value:s})}}class Ws{constructor(t,e,n){l(this,"fragment");l(this,"name");l(this,"args");l(this,"signature");l(this,"selector");const s=t.name,i=t.format();E(this,{fragment:t,name:s,args:n,signature:i,selector:e})}}class On{constructor(t){l(this,"hash");l(this,"_isIndexed");E(this,{hash:t,_isIndexed:!0})}static isIndexed(t){return!!(t&&t._isIndexed)}}const Pn={0:"generic panic",1:"assert(false)",17:"arithmetic overflow",18:"division or modulo by zero",33:"enum overflow",34:"invalid encoded storage byte array accessed",49:"out-of-bounds array access; popping on an empty array",50:"out-of-bounds access of an array or bytesN",65:"out of memory",81:"uninitialized function"},Rn={"0x08c379a0":{signature:"Error(string)",name:"Error",inputs:["string"],reason:r=>`reverted with reason string ${JSON.stringify(r)}`},"0x4e487b71":{signature:"Panic(uint256)",name:"Panic",inputs:["uint256"],reason:r=>{let t="unknown panic code";return r>=0&&r<=255&&Pn[r.toString()]&&(t=Pn[r.toString()]),`reverted with panic code 0x${r.toString(16)} (${t})`}}};var Z,Q,q,B,Gt,pe,Ht,ge;const Nt=class Nt{constructor(t){v(this,Gt);v(this,Ht);l(this,"fragments");l(this,"deploy");l(this,"fallback");l(this,"receive");v(this,Z,void 0);v(this,Q,void 0);v(this,q,void 0);v(this,B,void 0);let e=[];typeof t=="string"?e=JSON.parse(t):e=t,A(this,q,new Map),A(this,Z,new Map),A(this,Q,new Map);const n=[];for(const o of e)try{n.push(Ut.from(o))}catch(a){console.log(`[Warning] Invalid Fragment ${JSON.stringify(o)}:`,a.message)}E(this,{fragments:Object.freeze(n)});let s=null,i=!1;A(this,B,this.getAbiCoder()),this.fragments.forEach((o,a)=>{let c;switch(o.type){case"constructor":if(this.deploy){console.log("duplicate definition - constructor");return}E(this,{deploy:o});return;case"fallback":o.inputs.length===0?i=!0:(p(!s||o.payable!==s.payable,"conflicting fallback fragments",`fragments[${a}]`,o),s=o,i=s.payable);return;case"function":c=h(this,q);break;case"event":c=h(this,Q);break;case"error":c=h(this,Z);break;default:return}const u=o.format();c.has(u)||c.set(u,o)}),this.deploy||E(this,{deploy:ct.from("constructor()")}),E(this,{fallback:s,receive:i})}format(t){const e=t?"minimal":"full";return this.fragments.map(s=>s.format(e))}formatJson(){const t=this.fragments.map(e=>e.format("json"));return JSON.stringify(t.map(e=>JSON.parse(e)))}getAbiCoder(){return me.defaultAbiCoder()}getFunctionName(t){const e=P(this,Gt,pe).call(this,t,null,!1);return p(e,"no matching function","key",t),e.name}hasFunction(t){return!!P(this,Gt,pe).call(this,t,null,!1)}getFunction(t,e){return P(this,Gt,pe).call(this,t,e||null,!0)}forEachFunction(t){const e=Array.from(h(this,q).keys());e.sort((n,s)=>n.localeCompare(s));for(let n=0;n<e.length;n++){const s=e[n];t(h(this,q).get(s),n)}}getEventName(t){const e=P(this,Ht,ge).call(this,t,null,!1);return p(e,"no matching event","key",t),e.name}hasEvent(t){return!!P(this,Ht,ge).call(this,t,null,!1)}getEvent(t,e){return P(this,Ht,ge).call(this,t,e||null,!0)}forEachEvent(t){const e=Array.from(h(this,Q).keys());e.sort((n,s)=>n.localeCompare(s));for(let n=0;n<e.length;n++){const s=e[n];t(h(this,Q).get(s),n)}}getError(t,e){if(at(t)){const s=t.toLowerCase();if(Rn[s])return D.from(Rn[s].signature);for(const i of h(this,Z).values())if(s===i.selector)return i;return null}if(t.indexOf("(")===-1){const s=[];for(const[i,o]of h(this,Z))i.split("(")[0]===t&&s.push(o);if(s.length===0)return t==="Error"?D.from("error Error(string)"):t==="Panic"?D.from("error Panic(uint256)"):null;if(s.length>1){const i=s.map(o=>JSON.stringify(o.format())).join(", ");p(!1,`ambiguous error description (i.e. ${i})`,"name",t)}return s[0]}if(t=D.from(t).format(),t==="Error(string)")return D.from("error Error(string)");if(t==="Panic(uint256)")return D.from("error Panic(uint256)");const n=h(this,Z).get(t);return n||null}forEachError(t){const e=Array.from(h(this,Z).keys());e.sort((n,s)=>n.localeCompare(s));for(let n=0;n<e.length;n++){const s=e[n];t(h(this,Z).get(s),n)}}_decodeParams(t,e){return h(this,B).decode(t,e)}_encodeParams(t,e){return h(this,B).encode(t,e)}encodeDeploy(t){return this._encodeParams(this.deploy.inputs,t||[])}decodeErrorResult(t,e){if(typeof t=="string"){const n=this.getError(t);p(n,"unknown error","fragment",t),t=n}return p(Bt(e,0,4)===t.selector,`data signature does not match error ${t.name}.`,"data",e),this._decodeParams(t.inputs,Bt(e,4))}encodeErrorResult(t,e){if(typeof t=="string"){const n=this.getError(t);p(n,"unknown error","fragment",t),t=n}return $t([t.selector,this._encodeParams(t.inputs,e||[])])}decodeFunctionData(t,e){if(typeof t=="string"){const n=this.getFunction(t);p(n,"unknown function","fragment",t),t=n}return p(Bt(e,0,4)===t.selector,`data signature does not match function ${t.name}.`,"data",e),this._decodeParams(t.inputs,Bt(e,4))}encodeFunctionData(t,e){if(typeof t=="string"){const n=this.getFunction(t);p(n,"unknown function","fragment",t),t=n}return $t([t.selector,this._encodeParams(t.inputs,e||[])])}decodeFunctionResult(t,e){if(typeof t=="string"){const i=this.getFunction(t);p(i,"unknown function","fragment",t),t=i}let n="invalid length for result data";const s=et(e);if(s.length%32===0)try{return h(this,B).decode(t.outputs,s)}catch{n="could not decode result data"}b(!1,n,"BAD_DATA",{value:I(s),info:{method:t.name,signature:t.format()}})}makeError(t,e){const n=lt(t,"data"),s=me.getBuiltinCallException("call",e,n);if(s.message.startsWith("execution reverted (unknown custom error)")){const a=I(n.slice(0,4)),c=this.getError(a);if(c)try{const u=h(this,B).decode(c.inputs,n.slice(4));s.revert={name:c.name,signature:c.format(),args:u},s.reason=s.revert.signature,s.message=`execution reverted: ${s.reason}`}catch{s.message="execution reverted (coult not decode custom error)"}}const o=this.parseTransaction(e);return o&&(s.invocation={method:o.name,signature:o.signature,args:o.args}),s}encodeFunctionResult(t,e){if(typeof t=="string"){const n=this.getFunction(t);p(n,"unknown function","fragment",t),t=n}return I(h(this,B).encode(t.outputs,e||[]))}encodeFilterTopics(t,e){if(typeof t=="string"){const i=this.getEvent(t);p(i,"unknown event","eventFragment",t),t=i}b(e.length<=t.inputs.length,`too many arguments for ${t.format()}`,"UNEXPECTED_ARGUMENT",{count:e.length,expectedCount:t.inputs.length});const n=[];t.anonymous||n.push(t.topicHash);const s=(i,o)=>i.type==="string"?jt(o):i.type==="bytes"?wt(I(o)):(i.type==="bool"&&typeof o=="boolean"?o=o?"0x01":"0x00":i.type.match(/^u?int/)?o=$n(o):i.type.match(/^bytes/)?o=Or(o,32):i.type==="address"&&h(this,B).encode(["address"],[o]),vr(I(o),32));for(e.forEach((i,o)=>{const a=t.inputs[o];if(!a.indexed){p(i==null,"cannot filter non-indexed parameters; must be null","contract."+a.name,i);return}i==null?n.push(null):a.baseType==="array"||a.baseType==="tuple"?p(!1,"filtering with tuples or arrays not supported","contract."+a.name,i):Array.isArray(i)?n.push(i.map(c=>s(a,c))):n.push(s(a,i))});n.length&&n[n.length-1]===null;)n.pop();return n}encodeEventLog(t,e){if(typeof t=="string"){const o=this.getEvent(t);p(o,"unknown event","eventFragment",t),t=o}const n=[],s=[],i=[];return t.anonymous||n.push(t.topicHash),p(e.length===t.inputs.length,"event arguments/values mismatch","values",e),t.inputs.forEach((o,a)=>{const c=e[a];if(o.indexed)if(o.type==="string")n.push(jt(c));else if(o.type==="bytes")n.push(wt(c));else{if(o.baseType==="tuple"||o.baseType==="array")throw new Error("not implemented");n.push(h(this,B).encode([o.type],[c]))}else s.push(o),i.push(c)}),{data:h(this,B).encode(s,i),topics:n}}decodeEventLog(t,e,n){if(typeof t=="string"){const m=this.getEvent(t);p(m,"unknown event","eventFragment",t),t=m}if(n!=null&&!t.anonymous){const m=t.topicHash;p(at(n[0],32)&&n[0].toLowerCase()===m,"fragment/topic mismatch","topics[0]",n[0]),n=n.slice(1)}const s=[],i=[],o=[];t.inputs.forEach((m,x)=>{m.indexed?m.type==="string"||m.type==="bytes"||m.baseType==="tuple"||m.baseType==="array"?(s.push(C.from({type:"bytes32",name:m.name})),o.push(!0)):(s.push(m),o.push(!1)):(i.push(m),o.push(!1))});const a=n!=null?h(this,B).decode(s,$t(n)):null,c=h(this,B).decode(i,e,!0),u=[],f=[];let d=0,g=0;return t.inputs.forEach((m,x)=>{let k=null;if(m.indexed)if(a==null)k=new On(null);else if(o[x])k=new On(a[g++]);else try{k=a[g++]}catch(O){k=O}else try{k=c[d++]}catch(O){k=O}u.push(k),f.push(m.name||null)}),ye.fromItems(u,f)}parseTransaction(t){const e=lt(t.data,"tx.data"),n=bt(t.value!=null?t.value:0,"tx.value"),s=this.getFunction(I(e.slice(0,4)));if(!s)return null;const i=h(this,B).decode(s.inputs,e.slice(4));return new zs(s,s.selector,i,n)}parseCallResult(t){throw new Error("@TODO")}parseLog(t){const e=this.getEvent(t.topics[0]);return!e||e.anonymous?null:new Hs(e,e.topicHash,this.decodeEventLog(e,t.data,t.topics))}parseError(t){const e=I(t),n=this.getError(Bt(e,0,4));if(!n)return null;const s=h(this,B).decode(n.inputs,Bt(e,4));return new Ws(n,n.selector,s)}static from(t){return t instanceof Nt?t:typeof t=="string"?new Nt(JSON.parse(t)):typeof t.formatJson=="function"?new Nt(t.formatJson()):typeof t.format=="function"?new Nt(t.format("json")):new Nt(t)}};Z=new WeakMap,Q=new WeakMap,q=new WeakMap,B=new WeakMap,Gt=new WeakSet,pe=function(t,e,n){if(at(t)){const i=t.toLowerCase();for(const o of h(this,q).values())if(i===o.selector)return o;return null}if(t.indexOf("(")===-1){const i=[];for(const[o,a]of h(this,q))o.split("(")[0]===t&&i.push(a);if(e){const o=e.length>0?e[e.length-1]:null;let a=e.length,c=!0;F.isTyped(o)&&o.type==="overrides"&&(c=!1,a--);for(let u=i.length-1;u>=0;u--){const f=i[u].inputs.length;f!==a&&(!c||f!==a-1)&&i.splice(u,1)}for(let u=i.length-1;u>=0;u--){const f=i[u].inputs;for(let d=0;d<e.length;d++)if(F.isTyped(e[d])){if(d>=f.length){if(e[d].type==="overrides")continue;i.splice(u,1);break}if(e[d].type!==f[d].baseType){i.splice(u,1);break}}}}if(i.length===1&&e&&e.length!==i[0].inputs.length){const o=e[e.length-1];(o==null||Array.isArray(o)||typeof o!="object")&&i.splice(0,1)}if(i.length===0)return null;if(i.length>1&&n){const o=i.map(a=>JSON.stringify(a.format())).join(", ");p(!1,`ambiguous function description (i.e. matches ${o})`,"key",t)}return i[0]}const s=h(this,q).get(tt.from(t).format());return s||null},Ht=new WeakSet,ge=function(t,e,n){if(at(t)){const i=t.toLowerCase();for(const o of h(this,Q).values())if(i===o.topicHash)return o;return null}if(t.indexOf("(")===-1){const i=[];for(const[o,a]of h(this,Q))o.split("(")[0]===t&&i.push(a);if(e){for(let o=i.length-1;o>=0;o--)i[o].inputs.length<e.length&&i.splice(o,1);for(let o=i.length-1;o>=0;o--){const a=i[o].inputs;for(let c=0;c<e.length;c++)if(F.isTyped(e[c])&&e[c].type!==a[c].baseType){i.splice(o,1);break}}}if(i.length===0)return null;if(i.length>1&&n){const o=i.map(a=>JSON.stringify(a.format())).join(", ");p(!1,`ambiguous event description (i.e. matches ${o})`,"key",t)}return i[0]}const s=h(this,Q).get(j.from(t).format());return s||null};let ee=Nt;const cr=BigInt(0);function W(r){return r==null?null:r.toString()}function Js(r){const t={};r.to&&(t.to=r.to),r.from&&(t.from=r.from),r.data&&(t.data=I(r.data));const e="chainId,gasLimit,gasPrice,maxFeePerBlobGas,maxFeePerGas,maxPriorityFeePerGas,value".split(/,/);for(const s of e)!(s in r)||r[s]==null||(t[s]=bt(r[s],`request.${s}`));const n="type,nonce".split(/,/);for(const s of n)!(s in r)||r[s]==null||(t[s]=ht(r[s],`request.${s}`));return r.accessList&&(t.accessList=Os(r.accessList)),"blockTag"in r&&(t.blockTag=r.blockTag),"enableCcipRead"in r&&(t.enableCcipRead=!!r.enableCcipRead),"customData"in r&&(t.customData=r.customData),"blobVersionedHashes"in r&&r.blobVersionedHashes&&(t.blobVersionedHashes=r.blobVersionedHashes.slice()),"kzg"in r&&(t.kzg=r.kzg),"blobs"in r&&r.blobs&&(t.blobs=r.blobs.map(s=>kr(s)?I(s):Object.assign({},s))),t}class ve{constructor(t,e){l(this,"provider");l(this,"transactionHash");l(this,"blockHash");l(this,"blockNumber");l(this,"removed");l(this,"address");l(this,"data");l(this,"topics");l(this,"index");l(this,"transactionIndex");this.provider=e;const n=Object.freeze(t.topics.slice());E(this,{transactionHash:t.transactionHash,blockHash:t.blockHash,blockNumber:t.blockNumber,removed:t.removed,address:t.address,data:t.data,topics:n,index:t.index,transactionIndex:t.transactionIndex})}toJSON(){const{address:t,blockHash:e,blockNumber:n,data:s,index:i,removed:o,topics:a,transactionHash:c,transactionIndex:u}=this;return{_type:"log",address:t,blockHash:e,blockNumber:n,data:s,index:i,removed:o,topics:a,transactionHash:c,transactionIndex:u}}async getBlock(){const t=await this.provider.getBlock(this.blockHash);return b(!!t,"failed to find transaction","UNKNOWN_ERROR",{}),t}async getTransaction(){const t=await this.provider.getTransaction(this.transactionHash);return b(!!t,"failed to find transaction","UNKNOWN_ERROR",{}),t}async getTransactionReceipt(){const t=await this.provider.getTransactionReceipt(this.transactionHash);return b(!!t,"failed to find transaction receipt","UNKNOWN_ERROR",{}),t}removedEvent(){return Xs(this)}}var se;class Ks{constructor(t,e){l(this,"provider");l(this,"to");l(this,"from");l(this,"contractAddress");l(this,"hash");l(this,"index");l(this,"blockHash");l(this,"blockNumber");l(this,"logsBloom");l(this,"gasUsed");l(this,"blobGasUsed");l(this,"cumulativeGasUsed");l(this,"gasPrice");l(this,"blobGasPrice");l(this,"type");l(this,"status");l(this,"root");v(this,se,void 0);A(this,se,Object.freeze(t.logs.map(s=>new ve(s,e))));let n=cr;t.effectiveGasPrice!=null?n=t.effectiveGasPrice:t.gasPrice!=null&&(n=t.gasPrice),E(this,{provider:e,to:t.to,from:t.from,contractAddress:t.contractAddress,hash:t.hash,index:t.index,blockHash:t.blockHash,blockNumber:t.blockNumber,logsBloom:t.logsBloom,gasUsed:t.gasUsed,cumulativeGasUsed:t.cumulativeGasUsed,blobGasUsed:t.blobGasUsed,gasPrice:n,blobGasPrice:t.blobGasPrice,type:t.type,status:t.status,root:t.root})}get logs(){return h(this,se)}toJSON(){const{to:t,from:e,contractAddress:n,hash:s,index:i,blockHash:o,blockNumber:a,logsBloom:c,logs:u,status:f,root:d}=this;return{_type:"TransactionReceipt",blockHash:o,blockNumber:a,contractAddress:n,cumulativeGasUsed:W(this.cumulativeGasUsed),from:e,gasPrice:W(this.gasPrice),blobGasUsed:W(this.blobGasUsed),blobGasPrice:W(this.blobGasPrice),gasUsed:W(this.gasUsed),hash:s,index:i,logs:u,logsBloom:c,root:d,status:f,to:t}}get length(){return this.logs.length}[Symbol.iterator](){let t=0;return{next:()=>t<this.length?{value:this.logs[t++],done:!1}:{value:void 0,done:!0}}}get fee(){return this.gasUsed*this.gasPrice}async getBlock(){const t=await this.provider.getBlock(this.blockHash);if(t==null)throw new Error("TODO");return t}async getTransaction(){const t=await this.provider.getTransaction(this.hash);if(t==null)throw new Error("TODO");return t}async getResult(){return await this.provider.getTransactionResult(this.hash)}async confirmations(){return await this.provider.getBlockNumber()-this.blockNumber+1}removedEvent(){return lr(this)}reorderedEvent(t){return b(!t||t.isMined(),"unmined 'other' transction cannot be orphaned","UNSUPPORTED_OPERATION",{operation:"reorderedEvent(other)"}),ur(this,t)}}se=new WeakMap;var mt;const tn=class tn{constructor(t,e){l(this,"provider");l(this,"blockNumber");l(this,"blockHash");l(this,"index");l(this,"hash");l(this,"type");l(this,"to");l(this,"from");l(this,"nonce");l(this,"gasLimit");l(this,"gasPrice");l(this,"maxPriorityFeePerGas");l(this,"maxFeePerGas");l(this,"maxFeePerBlobGas");l(this,"data");l(this,"value");l(this,"chainId");l(this,"signature");l(this,"accessList");l(this,"blobVersionedHashes");v(this,mt,void 0);this.provider=e,this.blockNumber=t.blockNumber!=null?t.blockNumber:null,this.blockHash=t.blockHash!=null?t.blockHash:null,this.hash=t.hash,this.index=t.index,this.type=t.type,this.from=t.from,this.to=t.to||null,this.gasLimit=t.gasLimit,this.nonce=t.nonce,this.data=t.data,this.value=t.value,this.gasPrice=t.gasPrice,this.maxPriorityFeePerGas=t.maxPriorityFeePerGas!=null?t.maxPriorityFeePerGas:null,this.maxFeePerGas=t.maxFeePerGas!=null?t.maxFeePerGas:null,this.maxFeePerBlobGas=t.maxFeePerBlobGas!=null?t.maxFeePerBlobGas:null,this.chainId=t.chainId,this.signature=t.signature,this.accessList=t.accessList!=null?t.accessList:null,this.blobVersionedHashes=t.blobVersionedHashes!=null?t.blobVersionedHashes:null,A(this,mt,-1)}toJSON(){const{blockNumber:t,blockHash:e,index:n,hash:s,type:i,to:o,from:a,nonce:c,data:u,signature:f,accessList:d,blobVersionedHashes:g}=this;return{_type:"TransactionResponse",accessList:d,blockNumber:t,blockHash:e,blobVersionedHashes:g,chainId:W(this.chainId),data:u,from:a,gasLimit:W(this.gasLimit),gasPrice:W(this.gasPrice),hash:s,maxFeePerGas:W(this.maxFeePerGas),maxPriorityFeePerGas:W(this.maxPriorityFeePerGas),maxFeePerBlobGas:W(this.maxFeePerBlobGas),nonce:c,signature:f,to:o,index:n,type:i,value:W(this.value)}}async getBlock(){let t=this.blockNumber;if(t==null){const n=await this.getTransaction();n&&(t=n.blockNumber)}if(t==null)return null;const e=this.provider.getBlock(t);if(e==null)throw new Error("TODO");return e}async getTransaction(){return this.provider.getTransaction(this.hash)}async confirmations(){if(this.blockNumber==null){const{tx:e,blockNumber:n}=await Le({tx:this.getTransaction(),blockNumber:this.provider.getBlockNumber()});return e==null||e.blockNumber==null?0:n-e.blockNumber+1}return await this.provider.getBlockNumber()-this.blockNumber+1}async wait(t,e){const n=t??1,s=e??0;let i=h(this,mt),o=-1,a=i===-1;const c=async()=>{if(a)return null;const{blockNumber:g,nonce:m}=await Le({blockNumber:this.provider.getBlockNumber(),nonce:this.provider.getTransactionCount(this.from)});if(m<this.nonce){i=g;return}if(a)return null;const x=await this.getTransaction();if(!(x&&x.blockNumber!=null))for(o===-1&&(o=i-3,o<h(this,mt)&&(o=h(this,mt)));o<=g;){if(a)return null;const k=await this.provider.getBlock(o,!0);if(k==null)return;for(const O of k)if(O===this.hash)return;for(let O=0;O<k.length;O++){const N=await k.getTransaction(O);if(N.from===this.from&&N.nonce===this.nonce){if(a)return null;const U=await this.provider.getTransactionReceipt(N.hash);if(U==null||g-U.blockNumber+1<n)return;let H="replaced";N.data===this.data&&N.to===this.to&&N.value===this.value?H="repriced":N.data==="0x"&&N.from===N.to&&N.value===cr&&(H="cancelled"),b(!1,"transaction was replaced","TRANSACTION_REPLACED",{cancelled:H==="replaced"||H==="cancelled",reason:H,replacement:N.replaceableTransaction(i),hash:N.hash,receipt:U})}}o++}},u=g=>{if(g==null||g.status!==0)return g;b(!1,"transaction execution reverted","CALL_EXCEPTION",{action:"sendTransaction",data:null,reason:null,invocation:null,revert:null,transaction:{to:g.to,from:g.from,data:""},receipt:g})},f=await this.provider.getTransactionReceipt(this.hash);if(n===0)return u(f);if(f){if(await f.confirmations()>=n)return u(f)}else if(await c(),n===0)return null;return await new Promise((g,m)=>{const x=[],k=()=>{x.forEach(N=>N())};if(x.push(()=>{a=!0}),s>0){const N=setTimeout(()=>{k(),m(Qt("wait for transaction timeout","TIMEOUT"))},s);x.push(()=>{clearTimeout(N)})}const O=async N=>{if(await N.confirmations()>=n){k();try{g(u(N))}catch(U){m(U)}}};if(x.push(()=>{this.provider.off(this.hash,O)}),this.provider.on(this.hash,O),i>=0){const N=async()=>{try{await c()}catch(U){if(Wt(U,"TRANSACTION_REPLACED")){k(),m(U);return}}a||this.provider.once("block",N)};x.push(()=>{this.provider.off("block",N)}),this.provider.once("block",N)}})}isMined(){return this.blockHash!=null}isLegacy(){return this.type===0}isBerlin(){return this.type===1}isLondon(){return this.type===2}isCancun(){return this.type===3}removedEvent(){return b(this.isMined(),"unmined transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),lr(this)}reorderedEvent(t){return b(this.isMined(),"unmined transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),b(!t||t.isMined(),"unmined 'other' transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),ur(this,t)}replaceableTransaction(t){p(Number.isInteger(t)&&t>=0,"invalid startBlock","startBlock",t);const e=new tn(this,this.provider);return A(e,mt,t),e}};mt=new WeakMap;let Ge=tn;function ur(r,t){return{orphan:"reorder-transaction",tx:r,other:t}}function lr(r){return{orphan:"drop-transaction",tx:r}}function Xs(r){return{orphan:"drop-log",log:{transactionHash:r.transactionHash,blockHash:r.blockHash,blockNumber:r.blockNumber,address:r.address,data:r.data,topics:Object.freeze(r.topics.slice()),index:r.index}}}class Ze extends ve{constructor(e,n,s){super(e,e.provider);l(this,"interface");l(this,"fragment");l(this,"args");const i=n.decodeEventLog(s,e.data,e.topics);E(this,{args:i,fragment:s,interface:n})}get eventName(){return this.fragment.name}get eventSignature(){return this.fragment.format()}}class fr extends ve{constructor(e,n){super(e,e.provider);l(this,"error");E(this,{error:n})}}var zt;class Ys extends Ks{constructor(e,n,s){super(s,n);v(this,zt,void 0);A(this,zt,e)}get logs(){return super.logs.map(e=>{const n=e.topics.length?h(this,zt).getEvent(e.topics[0]):null;if(n)try{return new Ze(e,h(this,zt),n)}catch(s){return new fr(e,s)}return e})}}zt=new WeakMap;var ie;class Qe extends Ge{constructor(e,n,s){super(s,n);v(this,ie,void 0);A(this,ie,e)}async wait(e,n){const s=await super.wait(e,n);return s==null?null:new Ys(h(this,ie),this.provider,s)}}ie=new WeakMap;class hr extends Sr{constructor(e,n,s,i){super(e,n,s);l(this,"log");E(this,{log:i})}async getBlock(){return await this.log.getBlock()}async getTransaction(){return await this.log.getTransaction()}async getTransactionReceipt(){return await this.log.getTransactionReceipt()}}class Zs extends hr{constructor(t,e,n,s,i){super(t,e,n,new Ze(i,t.interface,s));const o=t.interface.decodeEventLog(s,this.log.data,this.log.topics);E(this,{args:o,fragment:s})}get eventName(){return this.fragment.name}get eventSignature(){return this.fragment.format()}}const In=BigInt(0);function dr(r){return r&&typeof r.call=="function"}function pr(r){return r&&typeof r.estimateGas=="function"}function Oe(r){return r&&typeof r.resolveName=="function"}function gr(r){return r&&typeof r.sendTransaction=="function"}function yr(r){if(r!=null){if(Oe(r))return r;if(r.provider)return r.provider}}var oe;class Qs{constructor(t,e,n){v(this,oe,void 0);l(this,"fragment");if(E(this,{fragment:e}),e.inputs.length<n.length)throw new Error("too many arguments");const s=St(t.runner,"resolveName"),i=Oe(s)?s:null;A(this,oe,async function(){const o=await Promise.all(e.inputs.map((a,c)=>n[c]==null?null:a.walkAsync(n[c],(f,d)=>f==="address"?Array.isArray(d)?Promise.all(d.map(g=>qt(g,i))):qt(d,i):d)));return t.interface.encodeFilterTopics(e,o)}())}getTopicFilter(){return h(this,oe)}}oe=new WeakMap;function St(r,t){return r==null?null:typeof r[t]=="function"?r:r.provider&&typeof r.provider[t]=="function"?r.provider:null}function At(r){return r==null?null:r.provider||null}async function mr(r,t){const e=F.dereference(r,"overrides");p(typeof e=="object","invalid overrides parameter","overrides",r);const n=Js(e);return p(n.to==null||(t||[]).indexOf("to")>=0,"cannot override to","overrides.to",n.to),p(n.data==null||(t||[]).indexOf("data")>=0,"cannot override data","overrides.data",n.data),n.from&&(n.from=n.from),n}async function qs(r,t,e){const n=St(r,"resolveName"),s=Oe(n)?n:null;return await Promise.all(t.map((i,o)=>i.walkAsync(e[o],(a,c)=>(c=F.dereference(c,a),a==="address"?qt(c,s):c))))}function js(r){const t=async function(o){const a=await mr(o,["data"]);a.to=await r.getAddress(),a.from&&(a.from=await qt(a.from,yr(r.runner)));const c=r.interface,u=bt(a.value||In,"overrides.value")===In,f=(a.data||"0x")==="0x";c.fallback&&!c.fallback.payable&&c.receive&&!f&&!u&&p(!1,"cannot send data to receive or send value to non-payable fallback","overrides",o),p(c.fallback||f,"cannot send data to receive-only contract","overrides.data",a.data);const d=c.receive||c.fallback&&c.fallback.payable;return p(d||u,"cannot send value to non-payable fallback","overrides.value",a.value),p(c.fallback||f,"cannot send data to receive-only contract","overrides.data",a.data),a},e=async function(o){const a=St(r.runner,"call");b(dr(a),"contract runner does not support calling","UNSUPPORTED_OPERATION",{operation:"call"});const c=await t(o);try{return await a.call(c)}catch(u){throw Cn(u)&&u.data?r.interface.makeError(u.data,c):u}},n=async function(o){const a=r.runner;b(gr(a),"contract runner does not support sending transactions","UNSUPPORTED_OPERATION",{operation:"sendTransaction"});const c=await a.sendTransaction(await t(o)),u=At(r.runner);return new Qe(r.interface,u,c)},s=async function(o){const a=St(r.runner,"estimateGas");return b(pr(a),"contract runner does not support gas estimation","UNSUPPORTED_OPERATION",{operation:"estimateGas"}),await a.estimateGas(await t(o))},i=async o=>await n(o);return E(i,{_contract:r,estimateGas:s,populateTransaction:t,send:n,staticCall:e}),i}function ti(r,t){const e=function(...u){const f=r.interface.getFunction(t,u);return b(f,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:t,args:u}}),f},n=async function(...u){const f=e(...u);let d={};if(f.inputs.length+1===u.length&&(d=await mr(u.pop()),d.from&&(d.from=await qt(d.from,yr(r.runner)))),f.inputs.length!==u.length)throw new Error("internal error: fragment inputs doesn't match arguments; should not happen");const g=await qs(r.runner,f.inputs,u);return Object.assign({},d,await Le({to:r.getAddress(),data:r.interface.encodeFunctionData(f,g)}))},s=async function(...u){const f=await a(...u);return f.length===1?f[0]:f},i=async function(...u){const f=r.runner;b(gr(f),"contract runner does not support sending transactions","UNSUPPORTED_OPERATION",{operation:"sendTransaction"});const d=await f.sendTransaction(await n(...u)),g=At(r.runner);return new Qe(r.interface,g,d)},o=async function(...u){const f=St(r.runner,"estimateGas");return b(pr(f),"contract runner does not support gas estimation","UNSUPPORTED_OPERATION",{operation:"estimateGas"}),await f.estimateGas(await n(...u))},a=async function(...u){const f=St(r.runner,"call");b(dr(f),"contract runner does not support calling","UNSUPPORTED_OPERATION",{operation:"call"});const d=await n(...u);let g="0x";try{g=await f.call(d)}catch(x){throw Cn(x)&&x.data?r.interface.makeError(x.data,d):x}const m=e(...u);return r.interface.decodeFunctionResult(m,g)},c=async(...u)=>e(...u).constant?await s(...u):await i(...u);return E(c,{name:r.interface.getFunctionName(t),_contract:r,_key:t,getFragment:e,estimateGas:o,populateTransaction:n,send:i,staticCall:s,staticCallResult:a}),Object.defineProperty(c,"fragment",{configurable:!1,enumerable:!0,get:()=>{const u=r.interface.getFunction(t);return b(u,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:t}}),u}}),c}function ei(r,t){const e=function(...s){const i=r.interface.getEvent(t,s);return b(i,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:t,args:s}}),i},n=function(...s){return new Qs(r,e(...s),s)};return E(n,{name:r.interface.getEventName(t),_contract:r,_key:t,getFragment:e}),Object.defineProperty(n,"fragment",{configurable:!1,enumerable:!0,get:()=>{const s=r.interface.getEvent(t);return b(s,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:t}}),s}}),n}const we=Symbol.for("_ethersInternal_contract"),wr=new WeakMap;function ni(r,t){wr.set(r[we],t)}function M(r){return wr.get(r[we])}function ri(r){return r&&typeof r=="object"&&"getTopicFilter"in r&&typeof r.getTopicFilter=="function"&&r.fragment}async function qe(r,t){let e,n=null;if(Array.isArray(t)){const i=function(o){if(at(o,32))return o;const a=r.interface.getEvent(o);return p(a,"unknown fragment","name",o),a.topicHash};e=t.map(o=>o==null?null:Array.isArray(o)?o.map(i):i(o))}else t==="*"?e=[null]:typeof t=="string"?at(t,32)?e=[t]:(n=r.interface.getEvent(t),p(n,"unknown fragment","event",t),e=[n.topicHash]):ri(t)?e=await t.getTopicFilter():"fragment"in t?(n=t.fragment,e=[n.topicHash]):p(!1,"unknown event name","event",t);e=e.map(i=>{if(i==null)return null;if(Array.isArray(i)){const o=Array.from(new Set(i.map(a=>a.toLowerCase())).values());return o.length===1?o[0]:(o.sort(),o)}return i.toLowerCase()});const s=e.map(i=>i==null?"null":Array.isArray(i)?i.join("|"):i).join("&");return{fragment:n,tag:s,topics:e}}async function Xt(r,t){const{subs:e}=M(r);return e.get((await qe(r,t)).tag)||null}async function Un(r,t,e){const n=At(r.runner);b(n,"contract runner does not support subscribing","UNSUPPORTED_OPERATION",{operation:t});const{fragment:s,tag:i,topics:o}=await qe(r,e),{addr:a,subs:c}=M(r);let u=c.get(i);if(!u){const d={address:a||r,topics:o},g=O=>{let N=s;if(N==null)try{N=r.interface.getEvent(O.topics[0])}catch{}if(N){const U=N,H=s?r.interface.decodeEventLog(s,O.data,O.topics):[];ze(r,e,H,Ct=>new Zs(r,Ct,e,U,O))}else ze(r,e,[],U=>new hr(r,U,e,O))};let m=[];u={tag:i,listeners:[],start:()=>{m.length||m.push(n.on(d,g))},stop:async()=>{if(m.length==0)return;let O=m;m=[],await Promise.all(O),n.off(d,g)}},c.set(i,u)}return u}let He=Promise.resolve();async function si(r,t,e,n){await He;const s=await Xt(r,t);if(!s)return!1;const i=s.listeners.length;return s.listeners=s.listeners.filter(({listener:o,once:a})=>{const c=Array.from(e);n&&c.push(n(a?null:o));try{o.call(r,...c)}catch{}return!a}),s.listeners.length===0&&(s.stop(),M(r).subs.delete(s.tag)),i>0}async function ze(r,t,e,n){try{await He}catch{}const s=si(r,t,e,n);return He=s,await s}const fe=["then"];var ui;const Zt=class Zt{constructor(t,e,n,s){l(this,"target");l(this,"interface");l(this,"runner");l(this,"filters");l(this,ui);l(this,"fallback");p(typeof t=="string"||Zn(t),"invalid value for Contract target","target",t),n==null&&(n=null);const i=ee.from(e);E(this,{target:t,runner:n,interface:i}),Object.defineProperty(this,we,{value:{}});let o,a=null,c=null;if(s){const d=At(n);c=new Qe(this.interface,d,s)}let u=new Map;if(typeof t=="string")if(at(t))a=t,o=Promise.resolve(t);else{const d=St(n,"resolveName");if(!Oe(d))throw Qt("contract runner does not support name resolution","UNSUPPORTED_OPERATION",{operation:"resolveName"});o=d.resolveName(t).then(g=>{if(g==null)throw Qt("an ENS name used for a contract target must be correctly configured","UNCONFIGURED_NAME",{value:t});return M(this).addr=g,g})}else o=t.getAddress().then(d=>{if(d==null)throw new Error("TODO");return M(this).addr=d,d});ni(this,{addrPromise:o,addr:a,deployTx:c,subs:u});const f=new Proxy({},{get:(d,g,m)=>{if(typeof g=="symbol"||fe.indexOf(g)>=0)return Reflect.get(d,g,m);try{return this.getEvent(g)}catch(x){if(!Wt(x,"INVALID_ARGUMENT")||x.argument!=="key")throw x}},has:(d,g)=>fe.indexOf(g)>=0?Reflect.has(d,g):Reflect.has(d,g)||this.interface.hasEvent(String(g))});return E(this,{filters:f}),E(this,{fallback:i.receive||i.fallback?js(this):null}),new Proxy(this,{get:(d,g,m)=>{if(typeof g=="symbol"||g in d||fe.indexOf(g)>=0)return Reflect.get(d,g,m);try{return d.getFunction(g)}catch(x){if(!Wt(x,"INVALID_ARGUMENT")||x.argument!=="key")throw x}},has:(d,g)=>typeof g=="symbol"||g in d||fe.indexOf(g)>=0?Reflect.has(d,g):d.interface.hasFunction(g)})}connect(t){return new Zt(this.target,this.interface,t)}attach(t){return new Zt(t,this.interface,this.runner)}async getAddress(){return await M(this).addrPromise}async getDeployedCode(){const t=At(this.runner);b(t,"runner does not support .provider","UNSUPPORTED_OPERATION",{operation:"getDeployedCode"});const e=await t.getCode(await this.getAddress());return e==="0x"?null:e}async waitForDeployment(){const t=this.deploymentTransaction();if(t)return await t.wait(),this;if(await this.getDeployedCode()!=null)return this;const n=At(this.runner);return b(n!=null,"contract runner does not support .provider","UNSUPPORTED_OPERATION",{operation:"waitForDeployment"}),new Promise((s,i)=>{const o=async()=>{try{if(await this.getDeployedCode()!=null)return s(this);n.once("block",o)}catch(a){i(a)}};o()})}deploymentTransaction(){return M(this).deployTx}getFunction(t){return typeof t!="string"&&(t=t.format()),ti(this,t)}getEvent(t){return typeof t!="string"&&(t=t.format()),ei(this,t)}async queryTransaction(t){throw new Error("@TODO")}async queryFilter(t,e,n){e==null&&(e=0),n==null&&(n="latest");const{addr:s,addrPromise:i}=M(this),o=s||await i,{fragment:a,topics:c}=await qe(this,t),u={address:o,topics:c,fromBlock:e,toBlock:n},f=At(this.runner);return b(f,"contract runner does not have a provider","UNSUPPORTED_OPERATION",{operation:"queryFilter"}),(await f.getLogs(u)).map(d=>{let g=a;if(g==null)try{g=this.interface.getEvent(d.topics[0])}catch{}if(g)try{return new Ze(d,this.interface,g)}catch(m){return new fr(d,m)}return new ve(d,f)})}async on(t,e){const n=await Un(this,"on",t);return n.listeners.push({listener:e,once:!1}),n.start(),this}async once(t,e){const n=await Un(this,"once",t);return n.listeners.push({listener:e,once:!0}),n.start(),this}async emit(t,...e){return await ze(this,t,e,null)}async listenerCount(t){if(t){const s=await Xt(this,t);return s?s.listeners.length:0}const{subs:e}=M(this);let n=0;for(const{listeners:s}of e.values())n+=s.length;return n}async listeners(t){if(t){const s=await Xt(this,t);return s?s.listeners.map(({listener:i})=>i):[]}const{subs:e}=M(this);let n=[];for(const{listeners:s}of e.values())n=n.concat(s.map(({listener:i})=>i));return n}async off(t,e){const n=await Xt(this,t);if(!n)return this;if(e){const s=n.listeners.map(({listener:i})=>i).indexOf(e);s>=0&&n.listeners.splice(s,1)}return(e==null||n.listeners.length===0)&&(n.stop(),M(this).subs.delete(n.tag)),this}async removeAllListeners(t){if(t){const e=await Xt(this,t);if(!e)return this;e.stop(),M(this).subs.delete(e.tag)}else{const{subs:e}=M(this);for(const{tag:n,stop:s}of e.values())s(),e.delete(n)}return this}async addListener(t,e){return await this.on(t,e)}async removeListener(t,e){return await this.off(t,e)}static buildClass(t){class e extends Zt{constructor(s,i=null){super(s,t,i)}}return e}static from(t,e,n){return n==null&&(n=null),new this(t,e,n)}};ui=we;let We=Zt;function ii(){return We}class Sn extends ii(){}const Je=new ee(["function start((bytes32,address,address,address,address,address,uint256,uint256,uint256,uint256)) returns (address,uint16,uint64)","function receiveMessageAndSwap(bytes)"]),oi=new ee(["function quoteExactInputSingle((address,address,uint256,uint24,uint160)) public view returns (uint256,uint160,uint32,uint256)"]),Yt=100,ai="https://gfx.relayers.xlabs.xyz/api/v1/swap/quote",ci="https://thermae.fly.dev/api/order/create";class br{static async createOrder(t,e,n,s,i,o,a,c){var u,f;try{const{minAmountStart:d,minAmountFinish:g}=a.swapAmounts,m=w.canonicalAddress(n),[x,k]=w.resolveWrappedToken(t,e,s),[O,N]=w.resolveWrappedToken(t,n.chain,o),U=w.canonicalAddress(k),H=w.canonicalAddress(N),Ct=w.portico.get(t,e).portico,Re=w.portico.get(t,n.chain).portico,Ie=w.networkChainToNativeChainId.get(t,e),Ue=w.networkChainToNativeChainId.get(t,n.chain),en={startingChainId:Number(Ie),startingToken:U.toLowerCase(),destinationChainId:Number(Ue),destinationToken:H.toLowerCase(),destinationAddress:m,porticoAddress:Ct,destinationPorticoAddress:Re,startingTokenAmount:i.toString(),minAmountStart:d.toString(),minAmountEnd:g.toString(),bridgeNonce:c,relayerFee:a.relayerFee.toString(),feeTierStart:Yt,feeTierEnd:Yt,shouldWrapNative:x,shouldUnwrapNative:O},nn=await w.axios.post(ci,en);return this.validateCreateOrderResponse(nn.data,en),nn.data}catch(d){if(w.axios.isAxiosError(d)){const g=`${(u=d.response)==null?void 0:u.statusText}: ${(f=d.response)==null?void 0:f.data.message}`;throw new Error(`Could not create order: ${g},`)}throw d}}static async quoteRelayer(t,e,n){var c;if(w.isNative(e)||w.isNative(n))throw new Error("how did you get here tho?");const s=w.hex.encode(e.toUniversalAddress().toUint8Array(),!1),i=w.hex.encode(n.toUniversalAddress().toUint8Array(),!1),a={targetChain:w.toChainId(t),sourceToken:s,targetToken:i};try{const u=await w.axios.post(ai,a);return BigInt(u.data.fee)}catch(u){throw w.axios.isAxiosError(u)?new Error(`Error getting relayer fee: ${(c=u.response)==null?void 0:c.statusText}`):u}}}l(br,"validateCreateOrderResponse",(t,e)=>{if(!w.isEqualCaseInsensitive(e.porticoAddress||"",t.transactionTarget))throw new Error("portico address mismatch");const n=Je.decodeFunctionData("start",t.transactionData);if(n.length!==1||n[0].length!==10)throw new Error("decoded length mismatch");const s=w.hex.decode(n[0][0]);if(s.length!==32)throw new Error("flag set length mismatch");const{recipientChain:i,feeTierStart:o,feeTierFinish:a,flags:c}=w.PorticoBridge.deserializeFlagSet(s),{shouldWrapNative:u,shouldUnwrapNative:f}=c,[d,g]=w.platformNativeChainIdToNetworkChain("Evm",BigInt(e.destinationChainId));if(i!==w.toChainId(g))throw new Error("recipient chain mismatch");if(o!==e.feeTierStart)throw new Error("fee tier start mismatch");if(a!==e.feeTierEnd)throw new Error("fee tier end mismatch");if(!!u!==e.shouldWrapNative)throw new Error("should wrap native mismatch");if(!!f!==e.shouldUnwrapNative)throw new Error("should unwrap native mismatch");const m=n[0][1];if(!w.isEqualCaseInsensitive(m,e.startingToken))throw new Error("start token address mismatch");const x=n[0][3];if(!w.isEqualCaseInsensitive(x,e.destinationToken))throw new Error("final token address mismatch");const k=n[0][4];if(!w.isEqualCaseInsensitive(k,e.destinationAddress))throw new Error("recipient address mismatch");const O=n[0][5];if(!w.isEqualCaseInsensitive(O,e.destinationPorticoAddress||""))throw new Error("destination portico address mismatch");if(n[0][6].toString()!==e.startingTokenAmount)throw new Error("amount mismatch");if(n[0][7].toString()!==e.minAmountStart)throw new Error("min amount start mismatch");if(n[0][8].toString()!==e.minAmountEnd)throw new Error("min amount finish mismatch");if(n[0][9].toString()!==e.relayerFee)throw new Error("relayer fee mismatch")});class Pe{constructor(t,e,n,s){l(this,"network");l(this,"chain");l(this,"provider");l(this,"contracts");l(this,"chainId");l(this,"porticoAddress");l(this,"uniswapAddress");l(this,"porticoContract");l(this,"uniswapContract");l(this,"core");if(this.network=t,this.chain=e,this.provider=n,this.contracts=s,!s.portico)throw new Error("Unsupported chain, no contract addresses for: "+e);this.core=new sn.EvmWormholeCore(t,e,n,s);const{portico:i,uniswapQuoterV2:o}=s.portico;this.porticoAddress=i,this.uniswapAddress=o,this.chainId=w.networkChainToNativeChainId.get(t,e),this.porticoContract=new Sn(this.porticoAddress,Je.fragments,this.provider),this.uniswapContract=new Sn(this.uniswapAddress,oi.fragments,this.provider)}static async fromRpc(t,e){const[n,s]=await nt.EvmPlatform.chainFromRpc(t),i=e[s];if(i.network!==n)throw new Error(`Network mismatch: ${i.network} != ${n}`);return new Pe(n,s,t,i.contracts)}async*transfer(t,e,n,s,i,o){const{minAmountStart:a,minAmountFinish:c}=o.swapAmounts;if(a===0n)throw new Error("Invalid min swap amount");if(c===0n)throw new Error("Invalid min swap amount");const u=new nt.EvmAddress(t).toString(),[f,d]=w.resolveWrappedToken(this.network,this.chain,n),[g,m]=w.resolveWrappedToken(this.network,e.chain,i),x=w.canonicalAddress(d),k=w.canonicalAddress(this.getTransferrableToken(x)),O=w.canonicalAddress(e),N=w.canonicalAddress(m),U=w.portico.get(this.network,e.chain).portico,H=new Date().valueOf()%2**4,Ct=w.PorticoBridge.serializeFlagSet({flags:{shouldWrapNative:f,shouldUnwrapNative:g},recipientChain:w.toChainId(e.chain),bridgeNonce:H,feeTierStart:Yt,feeTierFinish:Yt,padding:new Uint8Array(19)}),Re=Je.encodeFunctionData("start",[[Ct,x.toLowerCase(),k,N.toLowerCase(),O,U,s.toString(),a.toString(),c.toString(),o.relayerFee.toString()]]);f||(yield*this.approve(x,u,s,this.porticoAddress));const Ie=await this.core.getMessageFee(),Ue={to:this.porticoAddress,data:Re,value:Ie+(f?s:0n)};yield this.createUnsignedTransaction(nt.addFrom(Ue,u),"PorticoBridge.Transfer")}async*redeem(t,e){const n=await this.porticoContract.getFunction("receiveMessageAndSwap").populateTransaction(w.serialize(e)),s=new nt.EvmAddress(t).toString();yield this.createUnsignedTransaction(nt.addFrom(n,s),"PorticoBridge.Redeem")}async quoteSwap(t,e,n){const[,s]=w.resolveWrappedToken(this.network,this.chain,t),[,i]=w.resolveWrappedToken(this.network,this.chain,e),o=w.canonicalAddress(s),a=w.canonicalAddress(i);return w.isEqualCaseInsensitive(o,a)?n:(await this.uniswapContract.getFunction("quoteExactInputSingle").staticCall([o,a,n,Yt,0]))[0]}async quoteRelay(t,e){return await br.quoteRelayer(this.chain,t,e)}getTransferrableToken(t){var s;if(this.chain==="Ethereum")return w.Wormhole.tokenId("Ethereum",t);const e=w.getTokenByAddress(this.network,this.chain,t);if(!e)throw new Error("Unsupported source token: "+t);const n=(s=w.getTokensBySymbol(this.network,this.chain,e.symbol))==null?void 0:s.find(i=>i.original==="Ethereum");if(!n)throw new Error(`Unsupported symbol for chain ${e.symbol}: ${this.chain} `);return w.Wormhole.tokenId(n.chain,n.address)}async*approve(t,e,n,s){const i=nt.EvmPlatform.getTokenImplementation(this.provider,t);if(await i.allowance(e,s)<n){const a=await i.approve.populateTransaction(s,n);yield this.createUnsignedTransaction(nt.addFrom(a,e),"PorticoBridge.Approve")}}createUnsignedTransaction(t,e){return new sn.EvmUnsignedTransaction(nt.addChainId(t,this.chainId),this.network,this.chain,e,!1)}}Nr.registerProtocol(nt._platform,"PorticoBridge",Pe);exports.EvmPorticoBridge=Pe;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var h=Object.defineProperty;var m=(a,e,r)=>e in a?h(a,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):a[e]=r;var o=(a,e,r)=>(m(a,typeof e!="symbol"?e+"":e,r),r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("./sui-
|
|
1
|
+
"use strict";var h=Object.defineProperty;var m=(a,e,r)=>e in a?h(a,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):a[e]=r;var o=(a,e,r)=>(m(a,typeof e!="symbol"?e+"":e,r),r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("./sui-DbQOBpeH.js"),u=require("./index-C1oy9Lkm.js"),w=require("./create-48Wkagqs.js"),g=require("./chain-BteoJHpg.js");class c{constructor(e,r,t,n){o(this,"network");o(this,"chain");o(this,"provider");o(this,"contracts");o(this,"chainId");o(this,"coreBridgePackageId");this.network=e,this.chain=r,this.provider=t,this.contracts=n,this.chainId=u.toChainId(r);const s=n.coreBridge;if(!s)throw new Error(`CoreBridge contract Address for chain ${r} not found`);this.coreBridgePackageId=s}getGuardianSet(e){throw new Error("Method not implemented.")}getMessageFee(){throw new Error("Method not implemented.")}static async fromRpc(e,r){const[t,n]=await d.SuiPlatform.chainFromRpc(e),s=r[n];if(s.network!==t)throw new Error(`Network mismatch: ${s.network} !== ${t}`);return new c(t,n,e,s.contracts)}async*verifyMessage(e,r){throw new Error("Method not implemented.")}async*publishMessage(e,r){throw new Error("Method not implemented.")}async parseTransaction(e){return(await this.parseMessages(e)).map(t=>({emitter:t.emitterAddress,sequence:t.sequence,chain:this.chain}))}async getGuardianSetIndex(){throw new Error("Method not implemented.")}async parseMessages(e){var n;const t=(n=(await this.provider.getTransactionBlock({digest:e,options:{showEvents:!0,showEffects:!0,showInput:!0}})).events)==null?void 0:n.filter(s=>s.type.endsWith("WormholeMessage"));if(!t||t.length==0)throw new Error("WormholeMessage not found");return t.map(s=>{const i=s.parsedJson;return w.createVAA("Uint8Array",{emitterChain:this.chain,emitterAddress:new d.SuiAddress(i.sender).toUniversalAddress(),sequence:BigInt(i.sequence),guardianSet:0,timestamp:Number(i.timestamp),consistencyLevel:i.consistency_level,nonce:i.nonce,signatures:[],payload:new Uint8Array(i.payload)})})}}g.registerProtocol(d._platform,"WormholeCore",c);exports.SuiWormholeCore=c;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var u=Object.defineProperty;var w=(i,e,r)=>e in i?u(i,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[e]=r;var c=(i,e,r)=>(w(i,typeof e!="symbol"?e+"":e,r),r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("./cosmwasm-
|
|
1
|
+
"use strict";var u=Object.defineProperty;var w=(i,e,r)=>e in i?u(i,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[e]=r;var c=(i,e,r)=>(w(i,typeof e!="symbol"?e+"":e,r),r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("./cosmwasm-8FJsT7LT.js"),l=require("./create-48Wkagqs.js"),h=require("./index-C1oy9Lkm.js"),g=require("./chain-BteoJHpg.js");class o{constructor(e,r,s,t){c(this,"network");c(this,"chain");c(this,"rpc");c(this,"contracts");c(this,"coreAddress");this.network=e,this.chain=r,this.rpc=s,this.contracts=t;const n=this.contracts.coreBridge;if(!n)throw new Error(`Wormhole Token Bridge contract for domain ${r} not found`);this.coreAddress=n}getGuardianSet(e){throw new Error("Method not implemented.")}getGuardianSetIndex(){throw new Error("Method not implemented.")}getMessageFee(){throw new Error("Method not implemented.")}static async fromRpc(e,r){const[s,t]=await m.CosmwasmPlatform.chainFromRpc(e),n=r[t];if(n.network!==s)throw new Error(`Network mismatch: ${n.network} != ${s}`);return new o(s,t,e,n.contracts)}async*publishMessage(e,r,s,t){throw new Error("Method not implemented.")}async*verifyMessage(e,r){throw new Error("Not implemented.")}async parseTransaction(e){const r=await this.rpc.getTx(e);if(!r)throw new Error("No transaction found for txid: "+e);return[o.parseWormholeMessageId(this.chain,this.coreAddress,r)]}async parseMessages(e){const r=await this.rpc.getTx(e);if(!r)throw new Error("No transaction found for txid: "+e);return[o.parseWormholeMessage(this.chain,this.coreAddress,r)]}static parseWormholeMessage(e,r,s){const t=s.events.filter(a=>a.type==="wasm"&&a.attributes[0].key==="_contract_address"&&a.attributes[0].value===r);if(t.length===0)throw new Error("No wormhole message found in tx");t.length>1&&console.error(`Expected single message, found ${t.length}`);const[n]=t,d=Object.fromEntries(n.attributes.map(a=>[a.key.split(".")[1],a.value]));return l.createVAA("Uint8Array",{emitterChain:e,emitterAddress:new h.UniversalAddress(h.hex.decode(d.sender)),sequence:BigInt(d.sequence),guardianSet:0,timestamp:Number(d.block_time),consistencyLevel:0,nonce:Number(d.nonce),signatures:[],payload:h.hex.decode(d.message)})}static parseWormholeMessageId(e,r,s){const t=o.parseWormholeMessage(e,r,s);return{chain:t.emitterChain,emitter:t.emitterAddress,sequence:t.sequence}}}g.registerProtocol(m._platform,"WormholeCore",o);exports.CosmwasmWormholeCore=o;
|