UNPKG

@okcontract/sdk-react

Version:

One-stop-shop permissionless SDK for building any blockchain frontend

20 lines 1.82 MB
var QN=Object.defineProperty;var kN=(e,t,n)=>t in e?QN(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var N=(e,t,n)=>kN(e,typeof t!="symbol"?t+"":t,n);var Ir,Cr,BN;import{useState as _N,useEffect as p0,createContext as qA,useContext as JA,useRef as Sw,useMemo as vN}from"react";import{jsx as cl}from"react/jsx-runtime";function SN(e,t){for(var n=0;n<t.length;n++){const i=t[n];if(typeof i!="string"&&!Array.isArray(i)){for(const r in i)if(r!=="default"&&!(r in e)){const s=Object.getOwnPropertyDescriptor(i,r);s&&Object.defineProperty(e,r,s.get?s:{enumerable:!0,get:()=>i[r]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}function m0(e,t){const[n,i]=_N(t);return p0(()=>{if(e==null){i(t);return}const r=e.subscribe(s=>{if(s instanceof Error){console.error(s);return}i(s)});return()=>{r()}},[e,t]),n}const DN="1.0.7";let Si=class ww extends Error{constructor(t,n={}){const i=n.cause instanceof ww?n.cause.details:n.cause?.message?n.cause.message:n.details,r=n.cause instanceof ww&&n.cause.docsPath||n.docsPath,s=[t||"An error occurred.","",...n.metaMessages?[...n.metaMessages,""]:[],...r?[`Docs: https://abitype.dev${r}`]:[],...i?[`Details: ${i}`]:[],`Version: abitype@${DN}`].join(` `);super(s),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiTypeError"}),n.cause&&(this.cause=n.cause),this.details=i,this.docsPath=r,this.metaMessages=n.metaMessages,this.shortMessage=t}};function Ws(e,t){return e.exec(t)?.groups}const Dw=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,Ow=/^u?int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/,Mw=/^\(.+?\).*?$/,Nw=/^tuple(?<array>(\[(\d*)\])*)$/;function I0(e){let t=e.type;if(Nw.test(e.type)&&"components"in e){t="(";const n=e.components.length;for(let r=0;r<n;r++){const s=e.components[r];t+=I0(s),r<n-1&&(t+=", ")}const i=Ws(Nw,e.type);return t+=`)${i?.array??""}`,I0({...e,type:t})}return"indexed"in e&&e.indexed&&(t=`${t} indexed`),e.name?`${t} ${e.name}`:t}function KA(e){let t="";const n=e.length;for(let i=0;i<n;i++){const r=e[i];t+=I0(r),i!==n-1&&(t+=", ")}return t}function ON(e){return e.type==="function"?`function ${e.name}(${KA(e.inputs)})${e.stateMutability&&e.stateMutability!=="nonpayable"?` ${e.stateMutability}`:""}${e.outputs?.length?` returns (${KA(e.outputs)})`:""}`:e.type==="event"?`event ${e.name}(${KA(e.inputs)})`:e.type==="error"?`error ${e.name}(${KA(e.inputs)})`:e.type==="constructor"?`constructor(${KA(e.inputs)})${e.stateMutability==="payable"?" payable":""}`:e.type==="fallback"?`fallback() external${e.stateMutability==="payable"?" payable":""}`:"receive() external payable"}const xw=/^error (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/;function MN(e){return xw.test(e)}function NN(e){return Ws(xw,e)}const Fw=/^event (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/;function xN(e){return Fw.test(e)}function FN(e){return Ws(Fw,e)}const Rw=/^function (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)(?: (?<scope>external|public{1}))?(?: (?<stateMutability>pure|view|nonpayable|payable{1}))?(?: returns\s?\((?<returns>.*?)\))?$/;function RN(e){return Rw.test(e)}function TN(e){return Ws(Rw,e)}const Tw=/^struct (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*) \{(?<properties>.*?)\}$/;function Gw(e){return Tw.test(e)}function GN(e){return Ws(Tw,e)}const Lw=/^constructor\((?<parameters>.*?)\)(?:\s(?<stateMutability>payable{1}))?$/;function LN(e){return Lw.test(e)}function UN(e){return Ws(Lw,e)}const PN=/^fallback\(\) external(?:\s(?<stateMutability>payable{1}))?$/;function HN(e){return PN.test(e)}const jN=/^receive\(\) external payable$/;function zN(e){return jN.test(e)}const YN=new Set(["indexed"]),C0=new Set(["calldata","memory","storage"]);class $N extends Si{constructor({type:t}){super("Unknown type.",{metaMessages:[`Type "${t}" is not a valid ABI type. Perhaps you forgot to include a struct signature?`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownTypeError"})}}class VN extends Si{constructor({type:t}){super("Unknown type.",{metaMessages:[`Type "${t}" is not a valid ABI type.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownSolidityTypeError"})}}class qN extends Si{constructor({param:t}){super("Invalid ABI parameter.",{details:t}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidParameterError"})}}class JN extends Si{constructor({param:t,name:n}){super("Invalid ABI parameter.",{details:t,metaMessages:[`"${n}" is a protected Solidity keyword. More info: https://docs.soliditylang.org/en/latest/cheatsheet.html`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"SolidityProtectedKeywordError"})}}class KN extends Si{constructor({param:t,type:n,modifier:i}){super("Invalid ABI parameter.",{details:t,metaMessages:[`Modifier "${i}" not allowed${n?` in "${n}" type`:""}.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidModifierError"})}}class WN extends Si{constructor({param:t,type:n,modifier:i}){super("Invalid ABI parameter.",{details:t,metaMessages:[`Modifier "${i}" not allowed${n?` in "${n}" type`:""}.`,`Data location can only be specified for array, struct, or mapping types, but "${i}" was given.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidFunctionModifierError"})}}class ZN extends Si{constructor({abiParameter:t}){super("Invalid ABI parameter.",{details:JSON.stringify(t,null,2),metaMessages:["ABI parameter type is invalid."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidAbiTypeParameterError"})}}class WA extends Si{constructor({signature:t,type:n}){super(`Invalid ${n} signature.`,{details:t}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidSignatureError"})}}class XN extends Si{constructor({signature:t}){super("Unknown signature.",{details:t}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownSignatureError"})}}class ex extends Si{constructor({signature:t}){super("Invalid struct signature.",{details:t,metaMessages:["No properties exist."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidStructSignatureError"})}}class tx extends Si{constructor({type:t}){super("Circular reference detected.",{metaMessages:[`Struct "${t}" is a circular reference.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"CircularReferenceError"})}}class nx extends Si{constructor({current:t,depth:n}){super("Unbalanced parentheses.",{metaMessages:[`"${t.trim()}" has too many ${n>0?"opening":"closing"} parentheses.`],details:`Depth "${n}"`}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidParenthesisError"})}}function ix(e,t,n){let i="";if(n)for(const r of Object.entries(n)){if(!r)continue;let s="";for(const o of r[1])s+=`[${o.type}${o.name?`:${o.name}`:""}]`;i+=`(${r[0]}{${s}})`}return t?`${t}:${e}${i}`:e}const b0=new Map([["address",{type:"address"}],["bool",{type:"bool"}],["bytes",{type:"bytes"}],["bytes32",{type:"bytes32"}],["int",{type:"int256"}],["int256",{type:"int256"}],["string",{type:"string"}],["uint",{type:"uint256"}],["uint8",{type:"uint8"}],["uint16",{type:"uint16"}],["uint24",{type:"uint24"}],["uint32",{type:"uint32"}],["uint64",{type:"uint64"}],["uint96",{type:"uint96"}],["uint112",{type:"uint112"}],["uint160",{type:"uint160"}],["uint192",{type:"uint192"}],["uint256",{type:"uint256"}],["address owner",{type:"address",name:"owner"}],["address to",{type:"address",name:"to"}],["bool approved",{type:"bool",name:"approved"}],["bytes _data",{type:"bytes",name:"_data"}],["bytes data",{type:"bytes",name:"data"}],["bytes signature",{type:"bytes",name:"signature"}],["bytes32 hash",{type:"bytes32",name:"hash"}],["bytes32 r",{type:"bytes32",name:"r"}],["bytes32 root",{type:"bytes32",name:"root"}],["bytes32 s",{type:"bytes32",name:"s"}],["string name",{type:"string",name:"name"}],["string symbol",{type:"string",name:"symbol"}],["string tokenURI",{type:"string",name:"tokenURI"}],["uint tokenId",{type:"uint256",name:"tokenId"}],["uint8 v",{type:"uint8",name:"v"}],["uint256 balance",{type:"uint256",name:"balance"}],["uint256 tokenId",{type:"uint256",name:"tokenId"}],["uint256 value",{type:"uint256",name:"value"}],["event:address indexed from",{type:"address",name:"from",indexed:!0}],["event:address indexed to",{type:"address",name:"to",indexed:!0}],["event:uint indexed tokenId",{type:"uint256",name:"tokenId",indexed:!0}],["event:uint256 indexed tokenId",{type:"uint256",name:"tokenId",indexed:!0}]]);function rx(e,t={}){if(RN(e)){const n=TN(e);if(!n)throw new WA({signature:e,type:"function"});const i=Zi(n.parameters),r=[],s=i.length;for(let a=0;a<s;a++)r.push(qo(i[a],{modifiers:C0,structs:t,type:"function"}));const o=[];if(n.returns){const a=Zi(n.returns),l=a.length;for(let A=0;A<l;A++)o.push(qo(a[A],{modifiers:C0,structs:t,type:"function"}))}return{name:n.name,type:"function",stateMutability:n.stateMutability??"nonpayable",inputs:r,outputs:o}}if(xN(e)){const n=FN(e);if(!n)throw new WA({signature:e,type:"event"});const i=Zi(n.parameters),r=[],s=i.length;for(let o=0;o<s;o++)r.push(qo(i[o],{modifiers:YN,structs:t,type:"event"}));return{name:n.name,type:"event",inputs:r}}if(MN(e)){const n=NN(e);if(!n)throw new WA({signature:e,type:"error"});const i=Zi(n.parameters),r=[],s=i.length;for(let o=0;o<s;o++)r.push(qo(i[o],{structs:t,type:"error"}));return{name:n.name,type:"error",inputs:r}}if(LN(e)){const n=UN(e);if(!n)throw new WA({signature:e,type:"constructor"});const i=Zi(n.parameters),r=[],s=i.length;for(let o=0;o<s;o++)r.push(qo(i[o],{structs:t,type:"constructor"}));return{type:"constructor",stateMutability:n.stateMutability??"nonpayable",inputs:r}}if(HN(e))return{type:"fallback"};if(zN(e))return{type:"receive",stateMutability:"payable"};throw new XN({signature:e})}const sx=/^(?<type>[a-zA-Z$_][a-zA-Z0-9$_]*)(?<array>(?:\[\d*?\])+?)?(?:\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\s(?<name>[a-zA-Z$_][a-zA-Z0-9$_]*))?$/,ox=/^\((?<type>.+?)\)(?<array>(?:\[\d*?\])+?)?(?:\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\s(?<name>[a-zA-Z$_][a-zA-Z0-9$_]*))?$/,ax=/^u?int$/;function qo(e,t){const n=ix(e,t?.type,t?.structs);if(b0.has(n))return b0.get(n);const i=Mw.test(e),r=Ws(i?ox:sx,e);if(!r)throw new qN({param:e});if(r.name&&Ax(r.name))throw new JN({param:e,name:r.name});const s=r.name?{name:r.name}:{},o=r.modifier==="indexed"?{indexed:!0}:{},a=t?.structs??{};let l,A={};if(i){l="tuple";const u=Zi(r.type),f=[],h=u.length;for(let d=0;d<h;d++)f.push(qo(u[d],{structs:a}));A={components:f}}else if(r.type in a)l="tuple",A={components:a[r.type]};else if(ax.test(r.type))l=`${r.type}256`;else if(l=r.type,t?.type!=="struct"&&!Uw(l))throw new VN({type:l});if(r.modifier){if(!t?.modifiers?.has?.(r.modifier))throw new KN({param:e,type:t?.type,modifier:r.modifier});if(C0.has(r.modifier)&&!cx(l,!!r.array))throw new WN({param:e,type:t?.type,modifier:r.modifier})}const c={type:`${l}${r.array??""}`,...s,...o,...A};return b0.set(n,c),c}function Zi(e,t=[],n="",i=0){const r=e.trim().length;for(let s=0;s<r;s++){const o=e[s],a=e.slice(s+1);switch(o){case",":return i===0?Zi(a,[...t,n.trim()]):Zi(a,t,`${n}${o}`,i);case"(":return Zi(a,t,`${n}${o}`,i+1);case")":return Zi(a,t,`${n}${o}`,i-1);default:return Zi(a,t,`${n}${o}`,i)}}if(n==="")return t;if(i!==0)throw new nx({current:n,depth:i});return t.push(n.trim()),t}function Uw(e){return e==="address"||e==="bool"||e==="function"||e==="string"||Dw.test(e)||Ow.test(e)}const lx=/^(?:after|alias|anonymous|apply|auto|byte|calldata|case|catch|constant|copyof|default|defined|error|event|external|false|final|function|immutable|implements|in|indexed|inline|internal|let|mapping|match|memory|mutable|null|of|override|partial|private|promise|public|pure|reference|relocatable|return|returns|sizeof|static|storage|struct|super|supports|switch|this|true|try|typedef|typeof|var|view|virtual)$/;function Ax(e){return e==="address"||e==="bool"||e==="function"||e==="string"||e==="tuple"||Dw.test(e)||Ow.test(e)||lx.test(e)}function cx(e,t){return t||e==="bytes"||e==="string"||e==="tuple"}function ux(e){const t={},n=e.length;for(let o=0;o<n;o++){const a=e[o];if(!Gw(a))continue;const l=GN(a);if(!l)throw new WA({signature:a,type:"struct"});const A=l.properties.split(";"),c=[],u=A.length;for(let f=0;f<u;f++){const d=A[f].trim();if(!d)continue;const g=qo(d,{type:"struct"});c.push(g)}if(!c.length)throw new ex({signature:a});t[l.name]=c}const i={},r=Object.entries(t),s=r.length;for(let o=0;o<s;o++){const[a,l]=r[o];i[a]=Pw(l,t)}return i}const fx=/^(?<type>[a-zA-Z$_][a-zA-Z0-9$_]*)(?<array>(?:\[\d*?\])+?)?$/;function Pw(e,t,n=new Set){const i=[],r=e.length;for(let s=0;s<r;s++){const o=e[s];if(Mw.test(o.type))i.push(o);else{const l=Ws(fx,o.type);if(!l?.type)throw new ZN({abiParameter:o});const{array:A,type:c}=l;if(c in t){if(n.has(c))throw new tx({type:c});i.push({...o,type:`tuple${A??""}`,components:Pw(t[c]??[],t,new Set([...n,c]))})}else if(Uw(c))i.push(o);else throw new $N({type:c})}}return i}function ls(e){const t=ux(e),n=[],i=e.length;for(let r=0;r<i;r++){const s=e[r];Gw(s)||n.push(rx(s,t))}return n}function Kn(e,t,n){const i=e[t.name];if(typeof i=="function")return i;const r=e[n];return typeof r=="function"?r:s=>t(e,s)}function Zs(e,{includeName:t=!1}={}){if(e.type!=="function"&&e.type!=="event"&&e.type!=="error")throw new Qx(e.type);return`${e.name}(${Df(e.inputs,{includeName:t})})`}function Df(e,{includeName:t=!1}={}){return e?e.map(n=>hx(n,{includeName:t})).join(t?", ":","):""}function hx(e,{includeName:t}){return e.type.startsWith("tuple")?`(${Df(e.components,{includeName:t})})${e.type.slice(5)}`:e.type+(t&&e.name?` ${e.name}`:"")}function Xs(e,{strict:t=!0}={}){return!e||typeof e!="string"?!1:t?/^0x[0-9a-fA-F]*$/.test(e):e.startsWith("0x")}function Ot(e){return Xs(e,{strict:!1})?Math.ceil((e.length-2)/2):e.length}const Hw="2.22.5";let w0={getDocsUrl:({docsBaseUrl:e,docsPath:t="",docsSlug:n})=>t?`${e??"https://viem.sh"}${t}${n?`#${n}`:""}`:void 0,version:`viem@${Hw}`};class be extends Error{constructor(t,n={}){const i=n.cause instanceof be?n.cause.details:n.cause?.message?n.cause.message:n.details,r=n.cause instanceof be&&n.cause.docsPath||n.docsPath,s=w0.getDocsUrl?.({...n,docsPath:r}),o=[t||"An error occurred.","",...n.metaMessages?[...n.metaMessages,""]:[],...s?[`Docs: ${s}`]:[],...i?[`Details: ${i}`]:[],...w0.version?[`Version: ${w0.version}`]:[]].join(` `);super(o,n.cause?{cause:n.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=i,this.docsPath=r,this.metaMessages=n.metaMessages,this.name=n.name??this.name,this.shortMessage=t,this.version=Hw}walk(t){return jw(this,t)}}function jw(e,t){return t?.(e)?e:e&&typeof e=="object"&&"cause"in e&&e.cause!==void 0?jw(e.cause,t):t?null:e}class dx extends be{constructor({docsPath:t}){super(["A constructor was not found on the ABI.","Make sure you are using the correct ABI and that the constructor exists on it."].join(` `),{docsPath:t,name:"AbiConstructorNotFoundError"})}}class zw extends be{constructor({docsPath:t}){super(["Constructor arguments were provided (`args`), but a constructor parameters (`inputs`) were not found on the ABI.","Make sure you are using the correct ABI, and that the `inputs` attribute on the constructor exists."].join(` `),{docsPath:t,name:"AbiConstructorParamsNotFoundError"})}}class Yw extends be{constructor({data:t,params:n,size:i}){super([`Data size of ${i} bytes is too small for given parameters.`].join(` `),{metaMessages:[`Params: (${Df(n,{includeName:!0})})`,`Data: ${t} (${i} bytes)`],name:"AbiDecodingDataSizeTooSmallError"}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"params",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"size",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.data=t,this.params=n,this.size=i}}class B0 extends be{constructor(){super('Cannot decode zero data ("0x") with ABI parameters.',{name:"AbiDecodingZeroDataError"})}}class gx extends be{constructor({expectedLength:t,givenLength:n,type:i}){super([`ABI encoding array length mismatch for type ${i}.`,`Expected length: ${t}`,`Given length: ${n}`].join(` `),{name:"AbiEncodingArrayLengthMismatchError"})}}class px extends be{constructor({expectedSize:t,value:n}){super(`Size of bytes "${n}" (bytes${Ot(n)}) does not match expected size (bytes${t}).`,{name:"AbiEncodingBytesSizeMismatchError"})}}class $w extends be{constructor({expectedLength:t,givenLength:n}){super(["ABI encoding params/values length mismatch.",`Expected length (params): ${t}`,`Given length (values): ${n}`].join(` `),{name:"AbiEncodingLengthMismatchError"})}}class Vw extends be{constructor(t,{docsPath:n}){super([`Encoded error signature "${t}" not found on ABI.`,"Make sure you are using the correct ABI and that the error exists on it.",`You can look up the decoded signature here: https://openchain.xyz/signatures?query=${t}.`].join(` `),{docsPath:n,name:"AbiErrorSignatureNotFoundError"}),Object.defineProperty(this,"signature",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.signature=t}}class mx extends be{constructor({docsPath:t}){super("Cannot extract event signature from empty topics.",{docsPath:t,name:"AbiEventSignatureEmptyTopicsError"})}}class Ix extends be{constructor(t,{docsPath:n}){super([`Encoded event signature "${t}" not found on ABI.`,"Make sure you are using the correct ABI and that the event exists on it.",`You can look up the signature here: https://openchain.xyz/signatures?query=${t}.`].join(` `),{docsPath:n,name:"AbiEventSignatureNotFoundError"})}}class Of extends be{constructor(t,{docsPath:n}={}){super([`Function ${t?`"${t}" `:""}not found on ABI.`,"Make sure you are using the correct ABI and that the function exists on it."].join(` `),{docsPath:n,name:"AbiFunctionNotFoundError"})}}class Cx extends be{constructor(t,{docsPath:n}){super([`Function "${t}" does not contain any \`outputs\` on ABI.`,"Cannot decode function result without knowing what the parameter types are.","Make sure you are using the correct ABI and that the function exists on it."].join(` `),{docsPath:n,name:"AbiFunctionOutputsNotFoundError"})}}class bx extends be{constructor(t,n){super("Found ambiguous types in overloaded ABI items.",{metaMessages:[`\`${t.type}\` in \`${Zs(t.abiItem)}\`, and`,`\`${n.type}\` in \`${Zs(n.abiItem)}\``,"","These types encode differently and cannot be distinguished at runtime.","Remove one of the ambiguous items in the ABI."],name:"AbiItemAmbiguityError"})}}class qw extends be{constructor({expectedSize:t,givenSize:n}){super(`Expected bytes${t}, got bytes${n}.`,{name:"BytesSizeMismatchError"})}}class Jw extends be{constructor({abiItem:t,data:n,params:i,size:r}){super([`Data size of ${r} bytes is too small for non-indexed event parameters.`].join(` `),{metaMessages:[`Params: (${Df(i,{includeName:!0})})`,`Data: ${n} (${r} bytes)`],name:"DecodeLogDataMismatch"}),Object.defineProperty(this,"abiItem",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"params",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"size",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.abiItem=t,this.data=n,this.params=i,this.size=r}}class wx extends be{constructor({abiItem:t,param:n}){super([`Expected a topic for indexed event parameter${n.name?` "${n.name}"`:""} on event "${Zs(t,{includeName:!0})}".`].join(` `),{name:"DecodeLogTopicsMismatch"}),Object.defineProperty(this,"abiItem",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.abiItem=t}}class Bx extends be{constructor(t,{docsPath:n}){super([`Type "${t}" is not a valid encoding type.`,"Please provide a valid ABI type."].join(` `),{docsPath:n,name:"InvalidAbiEncodingType"})}}class Ex extends be{constructor(t,{docsPath:n}){super([`Type "${t}" is not a valid decoding type.`,"Please provide a valid ABI type."].join(` `),{docsPath:n,name:"InvalidAbiDecodingType"})}}class yx extends be{constructor(t){super([`Value "${t}" is not a valid array.`].join(` `),{name:"InvalidArrayError"})}}class Qx extends be{constructor(t){super([`"${t}" is not a valid definition type.`,'Valid types: "function", "event", "error"'].join(` `),{name:"InvalidDefinitionTypeError"})}}class kx extends be{constructor(t){super(`Type "${t}" is not supported for packed encoding.`,{name:"UnsupportedPackedAbiType"})}}class Kw extends be{constructor({offset:t,position:n,size:i}){super(`Slice ${n==="start"?"starting":"ending"} at offset "${t}" is out-of-bounds (size: ${i}).`,{name:"SliceOffsetOutOfBoundsError"})}}class Ww extends be{constructor({size:t,targetSize:n,type:i}){super(`${i.charAt(0).toUpperCase()}${i.slice(1).toLowerCase()} size (${t}) exceeds padding size (${n}).`,{name:"SizeExceedsPaddingSizeError"})}}class Zw extends be{constructor({size:t,targetSize:n,type:i}){super(`${i.charAt(0).toUpperCase()}${i.slice(1).toLowerCase()} is expected to be ${n} ${i} long, but is ${t} ${i} long.`,{name:"InvalidBytesLengthError"})}}function As(e,{dir:t,size:n=32}={}){return typeof e=="string"?eo(e,{dir:t,size:n}):_x(e,{dir:t,size:n})}function eo(e,{dir:t,size:n=32}={}){if(n===null)return e;const i=e.replace("0x","");if(i.length>n*2)throw new Ww({size:Math.ceil(i.length/2),targetSize:n,type:"hex"});return`0x${i[t==="right"?"padEnd":"padStart"](n*2,"0")}`}function _x(e,{dir:t,size:n=32}={}){if(n===null)return e;if(e.length>n)throw new Ww({size:e.length,targetSize:n,type:"bytes"});const i=new Uint8Array(n);for(let r=0;r<n;r++){const s=t==="right";i[s?r:n-r-1]=e[s?r:e.length-r-1]}return i}class Xw extends be{constructor({max:t,min:n,signed:i,size:r,value:s}){super(`Number "${s}" is not in safe ${r?`${r*8}-bit ${i?"signed":"unsigned"} `:""}integer range ${t?`(${n} to ${t})`:`(above ${n})`}`,{name:"IntegerOutOfRangeError"})}}class vx extends be{constructor(t){super(`Bytes value "${t}" is not a valid boolean. The bytes array must contain a single byte of either a 0 or 1 value.`,{name:"InvalidBytesBooleanError"})}}class Sx extends be{constructor({givenSize:t,maxSize:n}){super(`Size cannot exceed ${n} bytes. Given size: ${t} bytes.`,{name:"SizeOverflowError"})}}function Jo(e,{dir:t="left"}={}){let n=typeof e=="string"?e.replace("0x",""):e,i=0;for(let r=0;r<n.length-1&&n[t==="left"?r:n.length-r-1].toString()==="0";r++)i++;return n=t==="left"?n.slice(i):n.slice(0,n.length-i),typeof e=="string"?(n.length===1&&t==="right"&&(n=`${n}0`),`0x${n.length%2===1?`0${n}`:n}`):n}function br(e,{size:t}){if(Ot(e)>t)throw new Sx({givenSize:Ot(e),maxSize:t})}function Ko(e,t={}){const{signed:n}=t;t.size&&br(e,{size:t.size});const i=BigInt(e);if(!n)return i;const r=(e.length-2)/2,s=(1n<<BigInt(r)*8n-1n)-1n;return i<=s?i:i-BigInt(`0x${"f".padStart(r*2,"f")}`)-1n}function cs(e,t={}){return Number(Ko(e,t))}const Dx=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function He(e,t={}){return typeof e=="number"||typeof e=="bigint"?Je(e,t):typeof e=="string"?Wo(e,t):typeof e=="boolean"?E0(e,t):gn(e,t)}function E0(e,t={}){const n=`0x${Number(e)}`;return typeof t.size=="number"?(br(n,{size:t.size}),As(n,{size:t.size})):n}function gn(e,t={}){let n="";for(let r=0;r<e.length;r++)n+=Dx[e[r]];const i=`0x${n}`;return typeof t.size=="number"?(br(i,{size:t.size}),As(i,{dir:"right",size:t.size})):i}function Je(e,t={}){const{signed:n,size:i}=t,r=BigInt(e);let s;i?n?s=(1n<<BigInt(i)*8n-1n)-1n:s=2n**(BigInt(i)*8n)-1n:typeof e=="number"&&(s=BigInt(Number.MAX_SAFE_INTEGER));const o=typeof s=="bigint"&&n?-s-1n:0;if(s&&r>s||r<o){const l=typeof e=="bigint"?"n":"";throw new Xw({max:s?`${s}${l}`:void 0,min:`${o}${l}`,signed:n,size:i,value:`${e}${l}`})}const a=`0x${(n&&r<0?(1n<<BigInt(i*8))+BigInt(r):r).toString(16)}`;return i?As(a,{size:i}):a}const Ox=new TextEncoder;function Wo(e,t={}){const n=Ox.encode(e);return gn(n,t)}const Mx=new TextEncoder;function ZA(e,t={}){return typeof e=="number"||typeof e=="bigint"?xx(e,t):typeof e=="boolean"?Nx(e,t):Xs(e)?wr(e,t):tB(e,t)}function Nx(e,t={}){const n=new Uint8Array(1);return n[0]=Number(e),typeof t.size=="number"?(br(n,{size:t.size}),As(n,{size:t.size})):n}const us={zero:48,nine:57,A:65,F:70,a:97,f:102};function eB(e){if(e>=us.zero&&e<=us.nine)return e-us.zero;if(e>=us.A&&e<=us.F)return e-(us.A-10);if(e>=us.a&&e<=us.f)return e-(us.a-10)}function wr(e,t={}){let n=e;t.size&&(br(n,{size:t.size}),n=As(n,{dir:"right",size:t.size}));let i=n.slice(2);i.length%2&&(i=`0${i}`);const r=i.length/2,s=new Uint8Array(r);for(let o=0,a=0;o<r;o++){const l=eB(i.charCodeAt(a++)),A=eB(i.charCodeAt(a++));if(l===void 0||A===void 0)throw new be(`Invalid byte sequence ("${i[a-2]}${i[a-1]}" in "${i}").`);s[o]=l*16+A}return s}function xx(e,t){const n=Je(e,t);return wr(n)}function tB(e,t={}){const n=Mx.encode(e);return typeof t.size=="number"?(br(n,{size:t.size}),As(n,{dir:"right",size:t.size})):n}function nB(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function Fx(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function y0(e,...t){if(!Fx(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function Mf(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function iB(e,t){y0(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}const Nf=BigInt(2**32-1),rB=BigInt(32);function Rx(e,t=!1){return t?{h:Number(e&Nf),l:Number(e>>rB&Nf)}:{h:Number(e>>rB&Nf)|0,l:Number(e&Nf)|0}}function Tx(e,t=!1){let n=new Uint32Array(e.length),i=new Uint32Array(e.length);for(let r=0;r<e.length;r++){const{h:s,l:o}=Rx(e[r],t);[n[r],i[r]]=[s,o]}return[n,i]}const Gx=(e,t,n)=>e<<n|t>>>32-n,Lx=(e,t,n)=>t<<n|e>>>32-n,Ux=(e,t,n)=>t<<n-32|e>>>64-n,Px=(e,t,n)=>e<<n-32|t>>>64-n;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Hx=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4)),Q0=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),Br=(e,t)=>e<<32-t|e>>>t,sB=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68,jx=e=>e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255;function oB(e){for(let t=0;t<e.length;t++)e[t]=jx(e[t])}function zx(e){if(typeof e!="string")throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array(new TextEncoder().encode(e))}function k0(e){return typeof e=="string"&&(e=zx(e)),y0(e),e}let aB=class{clone(){return this._cloneInto()}};function lB(e){const t=i=>e().update(k0(i)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}const AB=[],cB=[],uB=[],Yx=BigInt(0),XA=BigInt(1),$x=BigInt(2),Vx=BigInt(7),qx=BigInt(256),Jx=BigInt(113);for(let e=0,t=XA,n=1,i=0;e<24;e++){[n,i]=[i,(2*n+3*i)%5],AB.push(2*(5*i+n)),cB.push((e+1)*(e+2)/2%64);let r=Yx;for(let s=0;s<7;s++)t=(t<<XA^(t>>Vx)*Jx)%qx,t&$x&&(r^=XA<<(XA<<BigInt(s))-XA);uB.push(r)}const[Kx,Wx]=Tx(uB,!0),fB=(e,t,n)=>n>32?Ux(e,t,n):Gx(e,t,n),hB=(e,t,n)=>n>32?Px(e,t,n):Lx(e,t,n);function Zx(e,t=24){const n=new Uint32Array(10);for(let i=24-t;i<24;i++){for(let o=0;o<10;o++)n[o]=e[o]^e[o+10]^e[o+20]^e[o+30]^e[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,l=(o+2)%10,A=n[l],c=n[l+1],u=fB(A,c,1)^n[a],f=hB(A,c,1)^n[a+1];for(let h=0;h<50;h+=10)e[o+h]^=u,e[o+h+1]^=f}let r=e[2],s=e[3];for(let o=0;o<24;o++){const a=cB[o],l=fB(r,s,a),A=hB(r,s,a),c=AB[o];r=e[c],s=e[c+1],e[c]=l,e[c+1]=A}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)n[a]=e[o+a];for(let a=0;a<10;a++)e[o+a]^=~n[(a+2)%10]&n[(a+4)%10]}e[0]^=Kx[i],e[1]^=Wx[i]}n.fill(0)}let Xx=class EN extends aB{constructor(t,n,i,r=!1,s=24){if(super(),this.blockLen=t,this.suffix=n,this.outputLen=i,this.enableXOF=r,this.rounds=s,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,nB(i),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=Hx(this.state)}keccak(){sB||oB(this.state32),Zx(this.state32,this.rounds),sB||oB(this.state32),this.posOut=0,this.pos=0}update(t){Mf(this);const{blockLen:n,state:i}=this;t=k0(t);const r=t.length;for(let s=0;s<r;){const o=Math.min(n-this.pos,r-s);for(let a=0;a<o;a++)i[this.pos++]^=t[s++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:n,pos:i,blockLen:r}=this;t[i]^=n,n&128&&i===r-1&&this.keccak(),t[r-1]^=128,this.keccak()}writeInto(t){Mf(this,!1),y0(t),this.finish();const n=this.state,{blockLen:i}=this;for(let r=0,s=t.length;r<s;){this.posOut>=i&&this.keccak();const o=Math.min(i-this.posOut,s-r);t.set(n.subarray(this.posOut,this.posOut+o),r),this.posOut+=o,r+=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 nB(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(iB(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:n,suffix:i,outputLen:r,rounds:s,enableXOF:o}=this;return t||(t=new EN(n,i,r,o,s)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=s,t.suffix=i,t.outputLen=r,t.enableXOF=o,t.destroyed=this.destroyed,t}};const eF=(e,t,n)=>lB(()=>new Xx(t,e,n)),tF=eF(1,136,256/8);function Rn(e,t){const n=t||"hex",i=tF(Xs(e,{strict:!1})?ZA(e):e);return n==="bytes"?i:He(i)}const nF=e=>Rn(ZA(e));function iF(e){return nF(e)}function rF(e){let t=!0,n="",i=0,r="",s=!1;for(let o=0;o<e.length;o++){const a=e[o];if(["(",")",","].includes(a)&&(t=!0),a==="("&&i++,a===")"&&i--,!!t){if(i===0){if(a===" "&&["event","function",""].includes(r))r="";else if(r+=a,a===")"){s=!0;break}continue}if(a===" "){e[o-1]!==","&&n!==","&&n!==",("&&(n="",t=!1);continue}r+=a,n+=a}}if(!s)throw new be("Unable to normalize signature.");return r}const sF=e=>{const t=typeof e=="string"?e:ON(e);return rF(t)};function dB(e){return iF(sF(e))}const gB=dB;class Wn extends be{constructor({address:t}){super(`Address "${t}" is invalid.`,{metaMessages:["- Address must be a hex value of 20 bytes (40 hex characters).","- Address must match its checksum counterpart."],name:"InvalidAddressError"})}}class xf extends Map{constructor(t){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=t}get(t){const n=super.get(t);return super.has(t)&&n!==void 0&&(this.delete(t),super.set(t,n)),n}set(t,n){if(super.set(t,n),this.maxSize&&this.size>this.maxSize){const i=this.keys().next().value;i&&this.delete(i)}return this}}const _0=new xf(8192);function ec(e,t){if(_0.has(`${e}.${t}`))return _0.get(`${e}.${t}`);const n=e.substring(2).toLowerCase(),i=Rn(tB(n),"bytes"),r=n.split("");for(let o=0;o<40;o+=2)i[o>>1]>>4>=8&&r[o]&&(r[o]=r[o].toUpperCase()),(i[o>>1]&15)>=8&&r[o+1]&&(r[o+1]=r[o+1].toUpperCase());const s=`0x${r.join("")}`;return _0.set(`${e}.${t}`,s),s}function Er(e,t){if(!Ft(e,{strict:!1}))throw new Wn({address:e});return ec(e,t)}const oF=/^0x[a-fA-F0-9]{40}$/,v0=new xf(8192);function Ft(e,t){const{strict:n=!0}=t??{},i=`${e}.${n}`;if(v0.has(i))return v0.get(i);const r=oF.test(e)?e.toLowerCase()===e?!0:n?ec(e)===e:!0:!1;return v0.set(i,r),r}function to(e){return typeof e[0]=="string"?yr(e):aF(e)}function aF(e){let t=0;for(const r of e)t+=r.length;const n=new Uint8Array(t);let i=0;for(const r of e)n.set(r,i),i+=r.length;return n}function yr(e){return`0x${e.reduce((t,n)=>t+n.replace("0x",""),"")}`}function tc(e,t,n,{strict:i}={}){return Xs(e,{strict:!1})?lF(e,t,n,{strict:i}):IB(e,t,n,{strict:i})}function pB(e,t){if(typeof t=="number"&&t>0&&t>Ot(e)-1)throw new Kw({offset:t,position:"start",size:Ot(e)})}function mB(e,t,n){if(typeof t=="number"&&typeof n=="number"&&Ot(e)!==n-t)throw new Kw({offset:n,position:"end",size:Ot(e)})}function IB(e,t,n,{strict:i}={}){pB(e,t);const r=e.slice(t,n);return i&&mB(r,t,n),r}function lF(e,t,n,{strict:i}={}){pB(e,t);const r=`0x${e.replace("0x","").slice((t??0)*2,(n??e.length)*2)}`;return i&&mB(r,t,n),r}const AF=/^(.*)\[([0-9]*)\]$/,CB=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,S0=/^(u?int)(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/;function ul(e,t){if(e.length!==t.length)throw new $w({expectedLength:e.length,givenLength:t.length});const n=cF({params:e,values:t}),i=O0(n);return i.length===0?"0x":i}function cF({params:e,values:t}){const n=[];for(let i=0;i<e.length;i++)n.push(D0({param:e[i],value:t[i]}));return n}function D0({param:e,value:t}){const n=M0(e.type);if(n){const[i,r]=n;return fF(t,{length:i,param:{...e,type:r}})}if(e.type==="tuple")return mF(t,{param:e});if(e.type==="address")return uF(t);if(e.type==="bool")return dF(t);if(e.type.startsWith("uint")||e.type.startsWith("int")){const i=e.type.startsWith("int"),[,,r="256"]=S0.exec(e.type)??[];return gF(t,{signed:i,size:Number(r)})}if(e.type.startsWith("bytes"))return hF(t,{param:e});if(e.type==="string")return pF(t);throw new Bx(e.type,{docsPath:"/docs/contract/encodeAbiParameters"})}function O0(e){let t=0;for(let s=0;s<e.length;s++){const{dynamic:o,encoded:a}=e[s];o?t+=32:t+=Ot(a)}const n=[],i=[];let r=0;for(let s=0;s<e.length;s++){const{dynamic:o,encoded:a}=e[s];o?(n.push(Je(t+r,{size:32})),i.push(a),r+=Ot(a)):n.push(a)}return to([...n,...i])}function uF(e){if(!Ft(e))throw new Wn({address:e});return{dynamic:!1,encoded:eo(e.toLowerCase())}}function fF(e,{length:t,param:n}){const i=t===null;if(!Array.isArray(e))throw new yx(e);if(!i&&e.length!==t)throw new gx({expectedLength:t,givenLength:e.length,type:`${n.type}[${t}]`});let r=!1;const s=[];for(let o=0;o<e.length;o++){const a=D0({param:n,value:e[o]});a.dynamic&&(r=!0),s.push(a)}if(i||r){const o=O0(s);if(i){const a=Je(s.length,{size:32});return{dynamic:!0,encoded:s.length>0?to([a,o]):a}}if(r)return{dynamic:!0,encoded:o}}return{dynamic:!1,encoded:to(s.map(({encoded:o})=>o))}}function hF(e,{param:t}){const[,n]=t.type.split("bytes"),i=Ot(e);if(!n){let r=e;return i%32!==0&&(r=eo(r,{dir:"right",size:Math.ceil((e.length-2)/2/32)*32})),{dynamic:!0,encoded:to([eo(Je(i,{size:32})),r])}}if(i!==Number.parseInt(n))throw new px({expectedSize:Number.parseInt(n),value:e});return{dynamic:!1,encoded:eo(e,{dir:"right"})}}function dF(e){if(typeof e!="boolean")throw new be(`Invalid boolean value: "${e}" (type: ${typeof e}). Expected: \`true\` or \`false\`.`);return{dynamic:!1,encoded:eo(E0(e))}}function gF(e,{signed:t,size:n=256}){if(typeof n=="number"){const i=2n**(BigInt(n)-(t?1n:0n))-1n,r=t?-i-1n:0n;if(e>i||e<r)throw new Xw({max:i.toString(),min:r.toString(),signed:t,size:n/8,value:e.toString()})}return{dynamic:!1,encoded:Je(e,{size:32,signed:t})}}function pF(e){const t=Wo(e),n=Math.ceil(Ot(t)/32),i=[];for(let r=0;r<n;r++)i.push(eo(tc(t,r*32,(r+1)*32),{dir:"right"}));return{dynamic:!0,encoded:to([eo(Je(Ot(t),{size:32})),...i])}}function mF(e,{param:t}){let n=!1;const i=[];for(let r=0;r<t.components.length;r++){const s=t.components[r],o=Array.isArray(e)?r:s.name,a=D0({param:s,value:e[o]});i.push(a),a.dynamic&&(n=!0)}return{dynamic:n,encoded:n?O0(i):to(i.map(({encoded:r})=>r))}}function M0(e){const t=e.match(/^(.*)\[(\d+)?\]$/);return t?[t[2]?Number(t[2]):null,t[1]]:void 0}const nc=e=>tc(dB(e),0,4);function Zo(e){const{abi:t,args:n=[],name:i}=e,r=Xs(i,{strict:!1}),s=t.filter(a=>r?a.type==="function"?nc(a)===i:a.type==="event"?gB(a)===i:!1:"name"in a&&a.name===i);if(s.length===0)return;if(s.length===1)return s[0];let o;for(const a of s){if(!("inputs"in a))continue;if(!n||n.length===0){if(!a.inputs||a.inputs.length===0)return a;continue}if(!a.inputs||a.inputs.length===0||a.inputs.length!==n.length)continue;if(n.every((A,c)=>{const u="inputs"in a&&a.inputs[c];return u?N0(A,u):!1})){if(o&&"inputs"in o&&o.inputs){const A=bB(a.inputs,o.inputs,n);if(A)throw new bx({abiItem:a,type:A[0]},{abiItem:o,type:A[1]})}o=a}}return o||s[0]}function N0(e,t){const n=typeof e,i=t.type;switch(i){case"address":return Ft(e,{strict:!1});case"bool":return n==="boolean";case"function":return n==="string";case"string":return n==="string";default:return i==="tuple"&&"components"in t?Object.values(t.components).every((r,s)=>N0(Object.values(e)[s],r)):/^u?int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/.test(i)?n==="number"||n==="bigint":/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/.test(i)?n==="string"||e instanceof Uint8Array:/[a-z]+[1-9]{0,3}(\[[0-9]{0,}\])+$/.test(i)?Array.isArray(e)&&e.every(r=>N0(r,{...t,type:i.replace(/(\[[0-9]{0,}\])$/,"")})):!1}}function bB(e,t,n){for(const i in e){const r=e[i],s=t[i];if(r.type==="tuple"&&s.type==="tuple"&&"components"in r&&"components"in s)return bB(r.components,s.components,n[i]);const o=[r.type,s.type];if(o.includes("address")&&o.includes("bytes20")?!0:o.includes("address")&&o.includes("string")?Ft(n[i],{strict:!1}):o.includes("address")&&o.includes("bytes")?Ft(n[i],{strict:!1}):!1)return o}}function fs(e){return typeof e=="string"?{address:e,type:"json-rpc"}:e}const wB="/docs/contract/encodeFunctionData";function IF(e){const{abi:t,args:n,functionName:i}=e;let r=t[0];if(i){const s=Zo({abi:t,args:n,name:i});if(!s)throw new Of(i,{docsPath:wB});r=s}if(r.type!=="function")throw new Of(void 0,{docsPath:wB});return{abi:[r],functionName:nc(Zs(r))}}function Ff(e){const{args:t}=e,{abi:n,functionName:i}=e.abi.length===1&&e.functionName?.startsWith("0x")?e:IF(e),r=n[0],s=i,o="inputs"in r&&r.inputs?ul(r.inputs,t??[]):void 0;return yr([s,o??"0x"])}const CF={1:"An `assert` condition failed.",17:"Arithmetic operation resulted in underflow or overflow.",18:"Division or modulo by zero (e.g. `5 / 0` or `23 % 0`).",33:"Attempted to convert to an invalid type.",34:"Attempted to access a storage byte array that is incorrectly encoded.",49:"Performed `.pop()` on an empty array",50:"Array index is out of bounds.",65:"Allocated too much memory or created an array which is too large.",81:"Attempted to call a zero-initialized variable of internal function type."},bF={inputs:[{name:"message",type:"string"}],name:"Error",type:"error"},wF={inputs:[{name:"reason",type:"uint256"}],name:"Panic",type:"error"};class BB extends be{constructor({offset:t}){super(`Offset \`${t}\` cannot be negative.`,{name:"NegativeOffsetError"})}}class EB extends be{constructor({length:t,position:n}){super(`Position \`${n}\` is out of bounds (\`0 < position < ${t}\`).`,{name:"PositionOutOfBoundsError"})}}class BF extends be{constructor({count:t,limit:n}){super(`Recursive read limit of \`${n}\` exceeded (recursive read count: \`${t}\`).`,{name:"RecursiveReadLimitExceededError"})}}const EF={bytes:new Uint8Array,dataView:new DataView(new ArrayBuffer(0)),position:0,positionReadCount:new Map,recursiveReadCount:0,recursiveReadLimit:Number.POSITIVE_INFINITY,assertReadLimit(){if(this.recursiveReadCount>=this.recursiveReadLimit)throw new BF({count:this.recursiveReadCount+1,limit:this.recursiveReadLimit})},assertPosition(e){if(e<0||e>this.bytes.length-1)throw new EB({length:this.bytes.length,position:e})},decrementPosition(e){if(e<0)throw new BB({offset:e});const t=this.position-e;this.assertPosition(t),this.position=t},getReadCount(e){return this.positionReadCount.get(e||this.position)||0},incrementPosition(e){if(e<0)throw new BB({offset:e});const t=this.position+e;this.assertPosition(t),this.position=t},inspectByte(e){const t=e??this.position;return this.assertPosition(t),this.bytes[t]},inspectBytes(e,t){const n=t??this.position;return this.assertPosition(n+e-1),this.bytes.subarray(n,n+e)},inspectUint8(e){const t=e??this.position;return this.assertPosition(t),this.bytes[t]},inspectUint16(e){const t=e??this.position;return this.assertPosition(t+1),this.dataView.getUint16(t)},inspectUint24(e){const t=e??this.position;return this.assertPosition(t+2),(this.dataView.getUint16(t)<<8)+this.dataView.getUint8(t+2)},inspectUint32(e){const t=e??this.position;return this.assertPosition(t+3),this.dataView.getUint32(t)},pushByte(e){this.assertPosition(this.position),this.bytes[this.position]=e,this.position++},pushBytes(e){this.assertPosition(this.position+e.length-1),this.bytes.set(e,this.position),this.position+=e.length},pushUint8(e){this.assertPosition(this.position),this.bytes[this.position]=e,this.position++},pushUint16(e){this.assertPosition(this.position+1),this.dataView.setUint16(this.position,e),this.position+=2},pushUint24(e){this.assertPosition(this.position+2),this.dataView.setUint16(this.position,e>>8),this.dataView.setUint8(this.position+2,e&255),this.position+=3},pushUint32(e){this.assertPosition(this.position+3),this.dataView.setUint32(this.position,e),this.position+=4},readByte(){this.assertReadLimit(),this._touch();const e=this.inspectByte();return this.position++,e},readBytes(e,t){this.assertReadLimit(),this._touch();const n=this.inspectBytes(e);return this.position+=t??e,n},readUint8(){this.assertReadLimit(),this._touch();const e=this.inspectUint8();return this.position+=1,e},readUint16(){this.assertReadLimit(),this._touch();const e=this.inspectUint16();return this.position+=2,e},readUint24(){this.assertReadLimit(),this._touch();const e=this.inspectUint24();return this.position+=3,e},readUint32(){this.assertReadLimit(),this._touch();const e=this.inspectUint32();return this.position+=4,e},get remaining(){return this.bytes.length-this.position},setPosition(e){const t=this.position;return this.assertPosition(e),this.position=e,()=>this.position=t},_touch(){if(this.recursiveReadLimit===Number.POSITIVE_INFINITY)return;const e=this.getReadCount();this.positionReadCount.set(this.position,e+1),e>0&&this.recursiveReadCount++}};function x0(e,{recursiveReadLimit:t=8192}={}){const n=Object.create(EF);return n.bytes=e,n.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength),n.positionReadCount=new Map,n.recursiveReadLimit=t,n}function yF(e,t={}){typeof t.size<"u"&&br(e,{size:t.size});const n=gn(e,t);return Ko(n,t)}function QF(e,t={}){let n=e;if(typeof t.size<"u"&&(br(n,{size:t.size}),n=Jo(n)),n.length>1||n[0]>1)throw new vx(n);return!!n[0]}function hs(e,t={}){typeof t.size<"u"&&br(e,{size:t.size});const n=gn(e,t);return cs(n,t)}function F0(e,t={}){let n=e;return typeof t.size<"u"&&(br(n,{size:t.size}),n=Jo(n,{dir:"right"})),new TextDecoder().decode(n)}function Rf(e,t){const n=typeof t=="string"?wr(t):t,i=x0(n);if(Ot(n)===0&&e.length>0)throw new B0;if(Ot(t)&&Ot(t)<32)throw new Yw({data:typeof t=="string"?t:gn(t),params:e,size:Ot(t)});let r=0;const s=[];for(let o=0;o<e.length;++o){const a=e[o];i.setPosition(r);const[l,A]=fl(i,a,{staticPosition:0});r+=A,s.push(l)}return s}function fl(e,t,{staticPosition:n}){const i=M0(t.type);if(i){const[r,s]=i;return _F(e,{...t,type:s},{length:r,staticPosition:n})}if(t.type==="tuple")return OF(e,t,{staticPosition:n});if(t.type==="address")return kF(e);if(t.type==="bool")return vF(e);if(t.type.startsWith("bytes"))return SF(e,t,{staticPosition:n});if(t.type.startsWith("uint")||t.type.startsWith("int"))return DF(e,t);if(t.type==="string")return MF(e,{staticPosition:n});throw new Ex(t.type,{docsPath:"/docs/contract/decodeAbiParameters"})}const yB=32,R0=32;function kF(e){const t=e.readBytes(32);return[ec(gn(IB(t,-20))),32]}function _F(e,t,{length:n,staticPosition:i}){if(!n){const o=hs(e.readBytes(R0)),a=i+o,l=a+yB;e.setPosition(a);const A=hs(e.readBytes(yB)),c=ic(t);let u=0;const f=[];for(let h=0;h<A;++h){e.setPosition(l+(c?h*32:u));const[d,g]=fl(e,t,{staticPosition:l});u+=g,f.push(d)}return e.setPosition(i+32),[f,32]}if(ic(t)){const o=hs(e.readBytes(R0)),a=i+o,l=[];for(let A=0;A<n;++A){e.setPosition(a+A*32);const[c]=fl(e,t,{staticPosition:a});l.push(c)}return e.setPosition(i+32),[l,32]}let r=0;const s=[];for(let o=0;o<n;++o){const[a,l]=fl(e,t,{staticPosition:i+r});r+=l,s.push(a)}return[s,r]}function vF(e){return[QF(e.readBytes(32),{size:32}),32]}function SF(e,t,{staticPosition:n}){const[i,r]=t.type.split("bytes");if(!r){const o=hs(e.readBytes(32));e.setPosition(n+o);const a=hs(e.readBytes(32));if(a===0)return e.setPosition(n+32),["0x",32];const l=e.readBytes(a);return e.setPosition(n+32),[gn(l),32]}return[gn(e.readBytes(Number.parseInt(r),32)),32]}function DF(e,t){const n=t.type.startsWith("int"),i=Number.parseInt(t.type.split("int")[1]||"256"),r=e.readBytes(32);return[i>48?yF(r,{signed:n}):hs(r,{signed:n}),32]}function OF(e,t,{staticPosition:n}){const i=t.components.length===0||t.components.some(({name:o})=>!o),r=i?[]:{};let s=0;if(ic(t)){const o=hs(e.readBytes(R0)),a=n+o;for(let l=0;l<t.components.length;++l){const A=t.components[l];e.setPosition(a+s);const[c,u]=fl(e,A,{staticPosition:a});s+=u,r[i?l:A?.name]=c}return e.setPosition(n+32),[r,32]}for(let o=0;o<t.components.length;++o){const a=t.components[o],[l,A]=fl(e,a,{staticPosition:n});r[i?o:a?.name]=l,s+=A}return[r,s]}function MF(e,{staticPosition:t}){const n=hs(e.readBytes(32)),i=t+n;e.setPosition(i);const r=hs(e.readBytes(32));if(r===0)return e.setPosition(t+32),["",32];const s=e.readBytes(r,32),o=F0(Jo(s));return e.setPosition(t+32),[o,32]}function ic(e){const{type:t}=e;if(t==="string"||t==="bytes"||t.endsWith("[]"))return!0;if(t==="tuple")return e.components?.some(ic);const n=M0(e.type);return!!(n&&ic({...e,type:n[1]}))}function NF(e){const{abi:t,data:n}=e,i=tc(n,0,4);if(i==="0x")throw new B0;const s=[...t||[],bF,wF].find(o=>o.type==="error"&&i===nc(Zs(o)));if(!s)throw new Vw(i,{docsPath:"/docs/contract/decodeErrorResult"});return{abiItem:s,args:"inputs"in s&&s.inputs&&s.inputs.length>0?Rf(s.inputs,tc(n,4)):void 0,errorName:s.name}}const Qr=(e,t,n)=>JSON.stringify(e,(i,r)=>typeof r=="bigint"?r.toString():r,n);function QB({abiItem:e,args:t,includeFunctionName:n=!0,includeName:i=!1}){if("name"in e&&"inputs"in e&&e.inputs)return`${n?e.name:""}(${e.inputs.map((r,s)=>`${i&&r.name?`${r.name}: `:""}${typeof t[s]=="object"?Qr(t[s]):t[s]}`).join(", ")})`}const xF={gwei:9,wei:18},FF={ether:-9,wei:9};function kB(e,t){let n=e.toString();const i=n.startsWith("-");i&&(n=n.slice(1)),n=n.padStart(t,"0");let[r,s]=[n.slice(0,n.length-t),n.slice(n.length-t)];return s=s.replace(/(0+)$/,""),`${i?"-":""}${r||"0"}${s?`.${s}`:""}`}function _B(e,t="wei"){return kB(e,xF[t])}function Xi(e,t="wei"){return kB(e,FF[t])}class RF extends be{constructor({address:t}){super(`State for account "${t}" is set multiple times.`,{name:"AccountStateConflictError"})}}class TF extends be{constructor(){super("state and stateDiff are set on the same account.",{name:"StateAssignmentConflictError"})}}function Tf(e){const t=Object.entries(e).map(([i,r])=>r===void 0||r===!1?null:[i,r]).filter(Boolean),n=t.reduce((i,[r])=>Math.max(i,r.length),0);return t.map(([i,r])=>` ${`${i}:`.padEnd(n+1)} ${r}`).join(` `)}class GF extends be{constructor(){super(["Cannot specify both a `gasPrice` and a `maxFeePerGas`/`maxPriorityFeePerGas`.","Use `maxFeePerGas`/`maxPriorityFeePerGas` for EIP-1559 compatible networks, and `gasPrice` for others."].join(` `),{name:"FeeConflictError"})}}class LF extends be{constructor({v:t}){super(`Invalid \`v\` value "${t}". Expected 27 or 28.`,{name:"InvalidLegacyVError"})}}class UF extends be{constructor({transaction:t}){super("Cannot infer a transaction type from provided transaction.",{metaMessages:["Provided Transaction:","{",Tf(t),"}","","To infer the type, either provide:","- a `type` to the Transaction, or","- an EIP-1559 Transaction with `maxFeePerGas`, or","- an EIP-2930 Transaction with `gasPrice` & `accessList`, or","- an EIP-4844 Transaction with `blobs`, `blobVersionedHashes`, `sidecars`, or","- an EIP-7702 Transaction with `authorizationList`, or","- a Legacy Transaction with `gasPrice`"],name:"InvalidSerializableTransactionError"})}}class PF extends be{constructor({storageKey:t}){super(`Size for storage key "${t}" is invalid. Expected 32 bytes. Got ${Math.floor((t.length-2)/2)} bytes.`,{name:"InvalidStorageKeySizeError"})}}class HF extends be{constructor(t,{account:n,docsPath:i,chain:r,data:s,gas:o,gasPrice:a,maxFeePerGas:l,maxPriorityFeePerGas:A,nonce:c,to:u,value:f}){const h=Tf({chain:r&&`${r?.name} (id: ${r?.id})`,from:n?.address,to:u,value:typeof f<"u"&&`${_B(f)} ${r?.nativeCurrency?.symbol||"ETH"}`,data:s,gas:o,gasPrice:typeof a<"u"&&`${Xi(a)} gwei`,maxFeePerGas:typeof l<"u"&&`${Xi(l)} gwei`,maxPriorityFeePerGas:typeof A<"u"&&`${Xi(A)} gwei`,nonce:c});super(t.shortMessage,{cause:t,docsPath:i,metaMessages:[...t.metaMessages?[...t.metaMessages," "]:[],"Request Arguments:",h].filter(Boolean),name:"TransactionExecutionError"}),Object.definePropert