@startale/app-sdk 1.1.0 → 1.2.0
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/app-sdk.js
CHANGED
package/dist/app-sdk.min.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).startaleAppSdk={})}(this,function(t){"use strict";const e="https://rpc.wallet.coinbase.com",n="@startale/app-sdk",r="1.1.0";function a(t,e){let n;try{n=t()}catch(t){return}const r={getItem:t=>{var e;const r=t=>null===t?null:JSON.parse(t,void 0),a=null!=(e=n.getItem(t))?e:null;return a instanceof Promise?a.then(r):r(a)},setItem:(t,e)=>n.setItem(t,JSON.stringify(e,void 0)),removeItem:t=>n.removeItem(t)};return r}const s=t=>e=>{try{const n=t(e);return n instanceof Promise?n:{then:t=>s(t)(n),catch(t){return this}}}catch(t){return{then(t){return this},catch:e=>s(e)(t)}}},i=(t,e)=>(n,r,i)=>{let o={storage:a(()=>localStorage),partialize:t=>t,version:0,merge:(t,e)=>({...e,...t}),...e},c=!1;const u=new Set,d=new Set;let l=o.storage;if(!l)return t((...t)=>{console.warn(`[zustand persist middleware] Unable to update item '${o.name}', the given storage is currently unavailable.`),n(...t)},r,i);const f=()=>{const t=o.partialize({...r()});return l.setItem(o.name,{state:t,version:o.version})},p=i.setState;i.setState=(t,e)=>{p(t,e),f()};const m=t((...t)=>{n(...t),f()},r,i);let h;i.getInitialState=()=>m;const b=()=>{var t,e;if(!l)return;c=!1,u.forEach(t=>{var e;return t(null!=(e=r())?e:m)});const a=(null==(e=o.onRehydrateStorage)?void 0:e.call(o,null!=(t=r())?t:m))||void 0;return s(l.getItem.bind(l))(o.name).then(t=>{if(t){if("number"!=typeof t.version||t.version===o.version)return[!1,t.state];if(o.migrate){const e=o.migrate(t.state,t.version);return e instanceof Promise?e.then(t=>[!0,t]):[!0,e]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}return[!1,void 0]}).then(t=>{var e;const[a,s]=t;if(h=o.merge(s,null!=(e=r())?e:m),n(h,!0),a)return f()}).then(()=>{null==a||a(h,void 0),h=r(),c=!0,d.forEach(t=>t(h))}).catch(t=>{null==a||a(void 0,t)})};return i.persist={setOptions:t=>{o={...o,...t},t.storage&&(l=t.storage)},clearStorage:()=>{null==l||l.removeItem(o.name)},getOptions:()=>o,rehydrate:()=>b(),hasHydrated:()=>c,onHydrate:t=>(u.add(t),()=>{u.delete(t)}),onFinishHydration:t=>(d.add(t),()=>{d.delete(t)})},o.skipHydration||b(),h||m},o=t=>{let e;const n=new Set,r=(t,r)=>{const a="function"==typeof t?t(e):t;if(!Object.is(a,e)){const t=e;e=(null!=r?r:"object"!=typeof a||null===a)?a:Object.assign({},e,a),n.forEach(n=>n(e,t))}},a=()=>e,s={setState:r,getState:a,getInitialState:()=>i,subscribe:t=>(n.add(t),()=>n.delete(t))},i=e=t(r,a,s);return s},c=t=>t?o(t):o,u=c(i((...t)=>Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},{chains:[]}),{keys:{}}),{account:{}}),{subAccount:void 0}),{spendPermissions:[]}),(()=>({config:{version:r}}))(...t)),{subAccountConfig:{}}),{userInfo:{}}),{name:"startale-app-sdk.store",storage:a(()=>localStorage),partialize:t=>({chains:t.chains,keys:t.keys,account:t.account,subAccount:t.subAccount,spendPermissions:t.spendPermissions,config:t.config,userInfo:t.userInfo})})),d={get:()=>u.getState().spendPermissions,set:t=>{u.setState({spendPermissions:t})},clear:()=>{u.setState({spendPermissions:[]})}},l={get:()=>u.getState().config,set:t=>{u.setState(e=>({config:Object.assign(Object.assign({},e.config),t)}))}},f={subAccounts:{get:()=>u.getState().subAccount,set:t=>{u.setState(e=>({subAccount:e.subAccount?Object.assign(Object.assign({},e.subAccount),t):Object.assign({address:t.address},t)}))},clear:()=>{u.setState({subAccount:void 0})}},subAccountsConfig:{get:()=>u.getState().subAccountConfig,set:t=>{u.setState(e=>({subAccountConfig:Object.assign(Object.assign({},e.subAccountConfig),t)}))},clear:()=>{u.setState({subAccountConfig:{}})}},spendPermissions:d,account:{get:()=>u.getState().account,set:t=>{u.setState(e=>({account:Object.assign(Object.assign({},e.account),t)}))},clear:()=>{u.setState({account:{}})}},chains:{get:()=>u.getState().chains,set:t=>{u.setState({chains:t})},clear:()=>{u.setState({chains:[]})}},keys:{get:t=>u.getState().keys[t],set:(t,e)=>{u.setState(n=>({keys:Object.assign(Object.assign({},n.keys),{[t]:e})}))},clear:()=>{u.setState({keys:{}})}},config:l,userInfo:{get:()=>u.getState().userInfo,set:t=>{u.setState(e=>({userInfo:t}))},clear:()=>{u.setState({userInfo:{}})}}},p=Object.assign(Object.assign({},u),f),m=()=>{var t,e,n;if("undefined"!=typeof window){const r=null!==(n=null!==(t=p.config.get().deviceId)&&void 0!==t?t:null===(e=window.crypto)||void 0===e?void 0:e.randomUUID())&&void 0!==n?n:"";if(window.ClientAnalytics){const{init:t,identify:e,PlatformName:n}=window.ClientAnalytics;t({isProd:!0,amplitudeApiKey:"c66737ad47ec354ced777935b0af822e",platform:n.web,projectName:"base_account_sdk",showDebugLogging:!1,version:"1.0.0",apiEndpoint:"https://cca-lite.coinbase.com"}),e({deviceId:r}),p.config.set({deviceId:r})}}},h=[{inputs:[],stateMutability:"nonpayable",type:"constructor"},{inputs:[{name:"owner",type:"bytes"}],name:"AlreadyOwner",type:"error"},{inputs:[],name:"Initialized",type:"error"},{inputs:[{name:"owner",type:"bytes"}],name:"InvalidEthereumAddressOwner",type:"error"},{inputs:[{name:"key",type:"uint256"}],name:"InvalidNonceKey",type:"error"},{inputs:[{name:"owner",type:"bytes"}],name:"InvalidOwnerBytesLength",type:"error"},{inputs:[],name:"LastOwner",type:"error"},{inputs:[{name:"index",type:"uint256"}],name:"NoOwnerAtIndex",type:"error"},{inputs:[{name:"ownersRemaining",type:"uint256"}],name:"NotLastOwner",type:"error"},{inputs:[{name:"selector",type:"bytes4"}],name:"SelectorNotAllowed",type:"error"},{inputs:[],name:"Unauthorized",type:"error"},{inputs:[],name:"UnauthorizedCallContext",type:"error"},{inputs:[],name:"UpgradeFailed",type:"error"},{inputs:[{name:"index",type:"uint256"},{name:"expectedOwner",type:"bytes"},{name:"actualOwner",type:"bytes"}],name:"WrongOwnerAtIndex",type:"error"},{anonymous:!1,inputs:[{indexed:!0,name:"index",type:"uint256"},{indexed:!1,name:"owner",type:"bytes"}],name:"AddOwner",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"index",type:"uint256"},{indexed:!1,name:"owner",type:"bytes"}],name:"RemoveOwner",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"implementation",type:"address"}],name:"Upgraded",type:"event"},{stateMutability:"payable",type:"fallback"},{inputs:[],name:"REPLAYABLE_NONCE_KEY",outputs:[{name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{name:"owner",type:"address"}],name:"addOwnerAddress",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{name:"x",type:"bytes32"},{name:"y",type:"bytes32"}],name:"addOwnerPublicKey",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{name:"functionSelector",type:"bytes4"}],name:"canSkipChainIdValidation",outputs:[{name:"",type:"bool"}],stateMutability:"pure",type:"function"},{inputs:[],name:"domainSeparator",outputs:[{name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"eip712Domain",outputs:[{name:"fields",type:"bytes1"},{name:"name",type:"string"},{name:"version",type:"string"},{name:"chainId",type:"uint256"},{name:"verifyingContract",type:"address"},{name:"salt",type:"bytes32"},{name:"extensions",type:"uint256[]"}],stateMutability:"view",type:"function"},{inputs:[],name:"entryPoint",outputs:[{name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{name:"target",type:"address"},{name:"value",type:"uint256"},{name:"data",type:"bytes"}],name:"execute",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{components:[{name:"target",type:"address"},{name:"value",type:"uint256"},{name:"data",type:"bytes"}],name:"calls",type:"tuple[]"}],name:"executeBatch",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{name:"calls",type:"bytes[]"}],name:"executeWithoutChainIdValidation",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{components:[{name:"sender",type:"address"},{name:"nonce",type:"uint256"},{name:"initCode",type:"bytes"},{name:"callData",type:"bytes"},{name:"callGasLimit",type:"uint256"},{name:"verificationGasLimit",type:"uint256"},{name:"preVerificationGas",type:"uint256"},{name:"maxFeePerGas",type:"uint256"},{name:"maxPriorityFeePerGas",type:"uint256"},{name:"paymasterAndData",type:"bytes"},{name:"signature",type:"bytes"}],name:"userOp",type:"tuple"}],name:"getUserOpHashWithoutChainId",outputs:[{name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"implementation",outputs:[{name:"$",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{name:"owners",type:"bytes[]"}],name:"initialize",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{name:"account",type:"address"}],name:"isOwnerAddress",outputs:[{name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{name:"account",type:"bytes"}],name:"isOwnerBytes",outputs:[{name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{name:"x",type:"bytes32"},{name:"y",type:"bytes32"}],name:"isOwnerPublicKey",outputs:[{name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{name:"hash",type:"bytes32"},{name:"signature",type:"bytes"}],name:"isValidSignature",outputs:[{name:"result",type:"bytes4"}],stateMutability:"view",type:"function"},{inputs:[],name:"nextOwnerIndex",outputs:[{name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{name:"index",type:"uint256"}],name:"ownerAtIndex",outputs:[{name:"",type:"bytes"}],stateMutability:"view",type:"function"},{inputs:[],name:"ownerCount",outputs:[{name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"proxiableUUID",outputs:[{name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{name:"index",type:"uint256"},{name:"owner",type:"bytes"}],name:"removeLastOwner",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{name:"index",type:"uint256"},{name:"owner",type:"bytes"}],name:"removeOwnerAtIndex",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"removedOwnersCount",outputs:[{name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{name:"hash",type:"bytes32"}],name:"replaySafeHash",outputs:[{name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{name:"newImplementation",type:"address"},{name:"data",type:"bytes"}],name:"upgradeToAndCall",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{components:[{name:"sender",type:"address"},{name:"nonce",type:"uint256"},{name:"initCode",type:"bytes"},{name:"callData",type:"bytes"},{name:"callGasLimit",type:"uint256"},{name:"verificationGasLimit",type:"uint256"},{name:"preVerificationGas",type:"uint256"},{name:"maxFeePerGas",type:"uint256"},{name:"maxPriorityFeePerGas",type:"uint256"},{name:"paymasterAndData",type:"bytes"},{name:"signature",type:"bytes"}],name:"userOp",type:"tuple"},{name:"userOpHash",type:"bytes32"},{name:"missingAccountFunds",type:"uint256"}],name:"validateUserOp",outputs:[{name:"validationData",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{stateMutability:"payable",type:"receive"}],b=[{inputs:[{name:"implementation_",type:"address"}],stateMutability:"payable",type:"constructor"},{inputs:[],name:"OwnerRequired",type:"error"},{inputs:[{name:"owners",type:"bytes[]"},{name:"nonce",type:"uint256"}],name:"createAccount",outputs:[{name:"account",type:"address"}],stateMutability:"payable",type:"function"},{inputs:[{name:"owners",type:"bytes[]"},{name:"nonce",type:"uint256"}],name:"getAddress",outputs:[{name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"implementation",outputs:[{name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"initCodeHash",outputs:[{name:"",type:"bytes32"}],stateMutability:"view",type:"function"}],y={invalidInput:-32e3,resourceNotFound:-32001,resourceUnavailable:-32002,transactionRejected:-32003,methodNotSupported:-32004,limitExceeded:-32005,parse:-32700,invalidRequest:-32600,methodNotFound:-32601,invalidParams:-32602,internal:-32603},g={userRejectedRequest:4001,unauthorized:4100,unsupportedMethod:4200,disconnected:4900,chainDisconnected:4901,unsupportedChain:4902},v={"-32700":{standard:"JSON RPC 2.0",message:"Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."},"-32600":{standard:"JSON RPC 2.0",message:"The JSON sent is not a valid Request object."},"-32601":{standard:"JSON RPC 2.0",message:"The method does not exist / is not available."},"-32602":{standard:"JSON RPC 2.0",message:"Invalid method parameter(s)."},"-32603":{standard:"JSON RPC 2.0",message:"Internal JSON-RPC error."},"-32000":{standard:"EIP-1474",message:"Invalid input."},"-32001":{standard:"EIP-1474",message:"Resource not found."},"-32002":{standard:"EIP-1474",message:"Resource unavailable."},"-32003":{standard:"EIP-1474",message:"Transaction rejected."},"-32004":{standard:"EIP-1474",message:"Method not supported."},"-32005":{standard:"EIP-1474",message:"Request limit exceeded."},4001:{standard:"EIP-1193",message:"User rejected the request."},4100:{standard:"EIP-1193",message:"The requested account and/or method has not been authorized by the user."},4200:{standard:"EIP-1193",message:"The requested method is not supported by this Ethereum provider."},4900:{standard:"EIP-1193",message:"The provider is disconnected from all chains."},4901:{standard:"EIP-1193",message:"The provider is disconnected from the specified chain."},4902:{standard:"EIP-3085",message:"Unrecognized chain ID."}},w="Unspecified error message.";function x(t,e=w){if(t&&Number.isInteger(t)){const e=t.toString();if(A(v,e))return v[e].message;if(k(t))return"Unspecified server error."}return e}function P(t,{shouldIncludeStack:e=!1}={}){const n={};if(t&&"object"==typeof t&&!Array.isArray(t)&&A(t,"code")&&function(t){if(!Number.isInteger(t))return!1;const e=t.toString();return!!v[e]||!!k(t)}(t.code)){const e=t;n.code=e.code,e.message&&"string"==typeof e.message?(n.message=e.message,A(e,"data")&&(n.data=e.data)):(n.message=x(n.code),n.data={originalError:I(t)})}else n.code=y.internal,n.message=E(t,"message")?t.message:w,n.data={originalError:I(t)};return e&&(n.stack=E(t,"stack")?t.stack:void 0),n}function k(t){return t>=-32099&&t<=-32e3}function I(t){return t&&"object"==typeof t&&!Array.isArray(t)?Object.assign({},t):t}function A(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function E(t,e){return"object"==typeof t&&null!==t&&e in t&&"string"==typeof t[e]}const O={parse:t=>T(y.parse,t),invalidRequest:t=>T(y.invalidRequest,t),invalidParams:t=>T(y.invalidParams,t),methodNotFound:t=>T(y.methodNotFound,t),internal:t=>T(y.internal,t),server:t=>{if(!t||"object"!=typeof t||Array.isArray(t))throw new Error("Ethereum RPC Server errors must provide single object argument.");const{code:e}=t;if(!Number.isInteger(e)||e>-32005||e<-32099)throw new Error('"code" must be an integer such that: -32099 <= code <= -32005');return T(e,t)},invalidInput:t=>T(y.invalidInput,t),resourceNotFound:t=>T(y.resourceNotFound,t),resourceUnavailable:t=>T(y.resourceUnavailable,t),transactionRejected:t=>T(y.transactionRejected,t),methodNotSupported:t=>T(y.methodNotSupported,t),limitExceeded:t=>T(y.limitExceeded,t)},S={userRejectedRequest:t=>C(g.userRejectedRequest,t),unauthorized:t=>C(g.unauthorized,t),unsupportedMethod:t=>C(g.unsupportedMethod,t),disconnected:t=>C(g.disconnected,t),chainDisconnected:t=>C(g.chainDisconnected,t),unsupportedChain:t=>C(g.unsupportedChain,t),custom:t=>{if(!t||"object"!=typeof t||Array.isArray(t))throw new Error("Ethereum Provider custom errors must provide single object argument.");const{code:e,message:n,data:r}=t;if(!n||"string"!=typeof n)throw new Error('"message" must be a nonempty string');return new j(e,n,r)}};function T(t,e){const[n,r]=B(e);return new N(t,n||x(t),r)}function C(t,e){const[n,r]=B(e);return new j(t,n||x(t),r)}function B(t){if(t){if("string"==typeof t)return[t];if("object"==typeof t&&!Array.isArray(t)){const{message:e,data:n}=t;if(e&&"string"!=typeof e)throw new Error("Must specify string message.");return[e||void 0,n]}}return[]}class N extends Error{constructor(t,e,n){if(!Number.isInteger(t))throw new Error('"code" must be an integer.');if(!e||"string"!=typeof e)throw new Error('"message" must be a nonempty string.');super(e),this.code=t,void 0!==n&&(this.data=n)}}class j extends N{constructor(t,e,n){if(!function(t){return Number.isInteger(t)&&t>=1e3&&t<=4999}(t))throw new Error('"code" must be an integer such that: 1000 <= code <= 4999');super(t,e,n)}}function U(t){return"object"==typeof t&&null!==t&&"code"in t&&"data"in t&&-32090===t.code&&"object"==typeof t.data&&null!==t.data&&"type"in t.data&&"INSUFFICIENT_FUNDS"===t.data.type}function M(t){return"object"==typeof t&&null!==t&&"details"in t}function R(t,e,n){if(null==t)throw null!=e?e:O.invalidParams({message:"value must be present",data:t})}function F(t,e){if(!Array.isArray(t))throw O.invalidParams({message:null!=e?e:"value must be an array",data:t})}const{checkCrossOriginOpenerPolicy:_,getCrossOriginOpenerPolicy:z}=(()=>{let t;return{getCrossOriginOpenerPolicy:()=>void 0===t?"undefined":t,checkCrossOriginOpenerPolicy:async()=>{if("undefined"!=typeof window)try{const e=`${window.location.origin}${window.location.pathname}`,n=await fetch(e,{method:"HEAD"});if(!n.ok)throw new Error(`HTTP error! status: ${n.status}`);const r=n.headers.get("Cross-Origin-Opener-Policy");t=null!=r?r:"null","same-origin"===t&&console.error("Base Account SDK requires the Cross-Origin-Opener-Policy header to not be set to 'same-origin'. This is to ensure that the SDK can communicate with the Base Account app.\n\nPlease see https://docs.base.org/smart-wallet/quickstart#cross-origin-opener-policy for more information.")}catch(e){console.error("Error checking Cross-Origin-Opener-Policy:",e.message),t="error"}else t="non-browser-env"}}})();function D(t){if("function"!=typeof t)throw new Error("toAccount is not a function")}let L=class t extends Error{constructor(e,n={}){const r=n.cause instanceof t?n.cause.details:n.cause?.message?n.cause.message:n.details,a=n.cause instanceof t&&n.cause.docsPath||n.docsPath;super([e||"An error occurred.","",...n.metaMessages?[...n.metaMessages,""]:[],...a?[`Docs: https://abitype.dev${a}`]:[],...r?[`Details: ${r}`]:[],"Version: abitype@1.1.0"].join("\n")),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=r,this.docsPath=a,this.metaMessages=n.metaMessages,this.shortMessage=e}};function G(t,e){const n=t.exec(e);return n?.groups}const q=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,H=/^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)?$/,V=/^\(.+?\).*?$/,K=/^tuple(?<array>(\[(\d*)\])*)$/;function W(t){let e=t.type;if(K.test(t.type)&&"components"in t){e="(";const n=t.components.length;for(let r=0;r<n;r++){e+=W(t.components[r]),r<n-1&&(e+=", ")}const r=G(K,t.type);return e+=`)${r?.array??""}`,W({...t,type:e})}return"indexed"in t&&t.indexed&&(e=`${e} indexed`),t.name?`${e} ${t.name}`:e}function Z(t){let e="";const n=t.length;for(let r=0;r<n;r++){e+=W(t[r]),r!==n-1&&(e+=", ")}return e}const J=/^error (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/;const Y=/^event (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/;const Q=/^function (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)(?: (?<scope>external|public{1}))?(?: (?<stateMutability>pure|view|nonpayable|payable{1}))?(?: returns\s?\((?<returns>.*?)\))?$/;const X=/^struct (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*) \{(?<properties>.*?)\}$/;function $(t){return X.test(t)}function tt(t){return G(X,t)}const et=/^constructor\((?<parameters>.*?)\)(?:\s(?<stateMutability>payable{1}))?$/;const nt=/^fallback\(\) external(?:\s(?<stateMutability>payable{1}))?$/;const rt=/^receive\(\) external payable$/;const at=new Set(["indexed"]),st=new Set(["calldata","memory","storage"]);let it=class extends L{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"})}},ot=class extends L{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"})}},ct=class extends L{constructor({param:t}){super("Invalid ABI parameter.",{details:t}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidParameterError"})}},ut=class extends L{constructor({param:t,name:e}){super("Invalid ABI parameter.",{details:t,metaMessages:[`"${e}" 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"})}},dt=class extends L{constructor({param:t,type:e,modifier:n}){super("Invalid ABI parameter.",{details:t,metaMessages:[`Modifier "${n}" not allowed${e?` in "${e}" type`:""}.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidModifierError"})}},lt=class extends L{constructor({param:t,type:e,modifier:n}){super("Invalid ABI parameter.",{details:t,metaMessages:[`Modifier "${n}" not allowed${e?` in "${e}" type`:""}.`,`Data location can only be specified for array, struct, or mapping types, but "${n}" was given.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidFunctionModifierError"})}},ft=class extends L{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"})}},pt=class extends L{constructor({signature:t,type:e}){super(`Invalid ${e} signature.`,{details:t}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidSignatureError"})}},mt=class extends L{constructor({signature:t}){super("Unknown signature.",{details:t}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownSignatureError"})}},ht=class extends L{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"})}},bt=class extends L{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"})}},yt=class extends L{constructor({current:t,depth:e}){super("Unbalanced parentheses.",{metaMessages:[`"${t.trim()}" has too many ${e>0?"opening":"closing"} parentheses.`],details:`Depth "${e}"`}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidParenthesisError"})}};const gt=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 vt(t,e={}){if(function(t){return Q.test(t)}(t))return function(t,e={}){const n=function(t){return G(Q,t)}(t);if(!n)throw new pt({signature:t,type:"function"});const r=It(n.parameters),a=[],s=r.length;for(let t=0;t<s;t++)a.push(kt(r[t],{modifiers:st,structs:e,type:"function"}));const i=[];if(n.returns){const t=It(n.returns),r=t.length;for(let n=0;n<r;n++)i.push(kt(t[n],{modifiers:st,structs:e,type:"function"}))}return{name:n.name,type:"function",stateMutability:n.stateMutability??"nonpayable",inputs:a,outputs:i}}(t,e);if(function(t){return Y.test(t)}(t))return function(t,e={}){const n=function(t){return G(Y,t)}(t);if(!n)throw new pt({signature:t,type:"event"});const r=It(n.parameters),a=[],s=r.length;for(let t=0;t<s;t++)a.push(kt(r[t],{modifiers:at,structs:e,type:"event"}));return{name:n.name,type:"event",inputs:a}}(t,e);if(function(t){return J.test(t)}(t))return function(t,e={}){const n=function(t){return G(J,t)}(t);if(!n)throw new pt({signature:t,type:"error"});const r=It(n.parameters),a=[],s=r.length;for(let t=0;t<s;t++)a.push(kt(r[t],{structs:e,type:"error"}));return{name:n.name,type:"error",inputs:a}}(t,e);if(function(t){return et.test(t)}(t))return function(t,e={}){const n=function(t){return G(et,t)}(t);if(!n)throw new pt({signature:t,type:"constructor"});const r=It(n.parameters),a=[],s=r.length;for(let t=0;t<s;t++)a.push(kt(r[t],{structs:e,type:"constructor"}));return{type:"constructor",stateMutability:n.stateMutability??"nonpayable",inputs:a}}(t,e);if(function(t){return nt.test(t)}(t))return function(t){const e=function(t){return G(nt,t)}(t);if(!e)throw new pt({signature:t,type:"fallback"});return{type:"fallback",stateMutability:e.stateMutability??"nonpayable"}}(t);if(function(t){return rt.test(t)}(t))return{type:"receive",stateMutability:"payable"};throw new mt({signature:t})}const wt=/^(?<type>[a-zA-Z$_][a-zA-Z0-9$_]*(?:\spayable)?)(?<array>(?:\[\d*?\])+?)?(?:\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\s(?<name>[a-zA-Z$_][a-zA-Z0-9$_]*))?$/,xt=/^\((?<type>.+?)\)(?<array>(?:\[\d*?\])+?)?(?:\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\s(?<name>[a-zA-Z$_][a-zA-Z0-9$_]*))?$/,Pt=/^u?int$/;function kt(t,e){const n=function(t,e,n){let r="";if(n)for(const t of Object.entries(n)){if(!t)continue;let e="";for(const n of t[1])e+=`[${n.type}${n.name?`:${n.name}`:""}]`;r+=`(${t[0]}{${e}})`}return e?`${e}:${t}${r}`:t}(t,e?.type,e?.structs);if(gt.has(n))return gt.get(n);const r=V.test(t),a=G(r?xt:wt,t);if(!a)throw new ct({param:t});if(a.name&&function(t){return"address"===t||"bool"===t||"function"===t||"string"===t||"tuple"===t||q.test(t)||H.test(t)||Et.test(t)}(a.name))throw new ut({param:t,name:a.name});const s=a.name?{name:a.name}:{},i="indexed"===a.modifier?{indexed:!0}:{},o=e?.structs??{};let c,u={};if(r){c="tuple";const t=It(a.type),e=[],n=t.length;for(let r=0;r<n;r++)e.push(kt(t[r],{structs:o}));u={components:e}}else if(a.type in o)c="tuple",u={components:o[a.type]};else if(Pt.test(a.type))c=`${a.type}256`;else if("address payable"===a.type)c="address";else if(c=a.type,"struct"!==e?.type&&!At(c))throw new ot({type:c});if(a.modifier){if(!e?.modifiers?.has?.(a.modifier))throw new dt({param:t,type:e?.type,modifier:a.modifier});if(st.has(a.modifier)&&!function(t,e){return e||"bytes"===t||"string"===t||"tuple"===t}(c,!!a.array))throw new lt({param:t,type:e?.type,modifier:a.modifier})}const d={type:`${c}${a.array??""}`,...s,...i,...u};return gt.set(n,d),d}function It(t,e=[],n="",r=0){const a=t.trim().length;for(let s=0;s<a;s++){const a=t[s],i=t.slice(s+1);switch(a){case",":return 0===r?It(i,[...e,n.trim()]):It(i,e,`${n}${a}`,r);case"(":return It(i,e,`${n}${a}`,r+1);case")":return It(i,e,`${n}${a}`,r-1);default:return It(i,e,`${n}${a}`,r)}}if(""===n)return e;if(0!==r)throw new yt({current:n,depth:r});return e.push(n.trim()),e}function At(t){return"address"===t||"bool"===t||"function"===t||"string"===t||q.test(t)||H.test(t)}const Et=/^(?: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)$/;const Ot=/^(?<type>[a-zA-Z$_][a-zA-Z0-9$_]*)(?<array>(?:\[\d*?\])+?)?$/;function St(t,e,n=new Set){const r=[],a=t.length;for(let s=0;s<a;s++){const a=t[s];if(V.test(a.type))r.push(a);else{const t=G(Ot,a.type);if(!t?.type)throw new ft({abiParameter:a});const{array:s,type:i}=t;if(i in e){if(n.has(i))throw new bt({type:i});r.push({...a,type:`tuple${s??""}`,components:St(e[i]??[],e,new Set([...n,i]))})}else{if(!At(i))throw new it({type:i});r.push(a)}}}return r}function Tt(t){const e=function(t){const e={},n=t.length;for(let r=0;r<n;r++){const n=t[r];if(!$(n))continue;const a=tt(n);if(!a)throw new pt({signature:n,type:"struct"});const s=a.properties.split(";"),i=[],o=s.length;for(let t=0;t<o;t++){const e=s[t].trim();if(!e)continue;const n=kt(e,{type:"struct"});i.push(n)}if(!i.length)throw new ht({signature:n});e[a.name]=i}const r={},a=Object.entries(e),s=a.length;for(let t=0;t<s;t++){const[n,s]=a[t];r[n]=St(s,e)}return r}(t),n=[],r=t.length;for(let a=0;a<r;a++){const r=t[a];$(r)||n.push(vt(r,e))}return n}function Ct(t,e,n){const r=t[e.name];if("function"==typeof r)return r;const a=t[n];return"function"==typeof a?a:n=>e(t,n)}function Bt(t,{includeName:e=!1}={}){if("function"!==t.type&&"event"!==t.type&&"error"!==t.type)throw new ue(t.type);return`${t.name}(${Nt(t.inputs,{includeName:e})})`}function Nt(t,{includeName:e=!1}={}){return t?t.map(t=>function(t,{includeName:e}){if(t.type.startsWith("tuple"))return`(${Nt(t.components,{includeName:e})})${t.type.slice(5)}`;return t.type+(e&&t.name?` ${t.name}`:"")}(t,{includeName:e})).join(e?", ":","):""}function jt(t,{strict:e=!0}={}){return!!t&&("string"==typeof t&&(e?/^0x[0-9a-fA-F]*$/.test(t):t.startsWith("0x")))}function Ut(t){return jt(t,{strict:!1})?Math.ceil((t.length-2)/2):t.length}const Mt="2.38.4";let Rt=({docsBaseUrl:t,docsPath:e="",docsSlug:n})=>e?`${t??"https://viem.sh"}${e}${n?`#${n}`:""}`:void 0,Ft=`viem@${Mt}`,_t=class t extends Error{constructor(e,n={}){const r=n.cause instanceof t?n.cause.details:n.cause?.message?n.cause.message:n.details,a=n.cause instanceof t&&n.cause.docsPath||n.docsPath,s=Rt?.({...n,docsPath:a});super([e||"An error occurred.","",...n.metaMessages?[...n.metaMessages,""]:[],...s?[`Docs: ${s}`]:[],...r?[`Details: ${r}`]:[],...Ft?[`Version: ${Ft}`]:[]].join("\n"),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=r,this.docsPath=a,this.metaMessages=n.metaMessages,this.name=n.name??this.name,this.shortMessage=e,this.version=Mt}walk(t){return zt(this,t)}};function zt(t,e){return e?.(t)?t:t&&"object"==typeof t&&"cause"in t&&void 0!==t.cause?zt(t.cause,e):e?null:t}class Dt extends _t{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("\n"),{docsPath:t,name:"AbiConstructorNotFoundError"})}}class Lt extends _t{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("\n"),{docsPath:t,name:"AbiConstructorParamsNotFoundError"})}}class Gt extends _t{constructor({data:t,params:e,size:n}){super([`Data size of ${n} bytes is too small for given parameters.`].join("\n"),{metaMessages:[`Params: (${Nt(e,{includeName:!0})})`,`Data: ${t} (${n} 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=e,this.size=n}}class qt extends _t{constructor(){super('Cannot decode zero data ("0x") with ABI parameters.',{name:"AbiDecodingZeroDataError"})}}class Ht extends _t{constructor({expectedLength:t,givenLength:e,type:n}){super([`ABI encoding array length mismatch for type ${n}.`,`Expected length: ${t}`,`Given length: ${e}`].join("\n"),{name:"AbiEncodingArrayLengthMismatchError"})}}class Vt extends _t{constructor({expectedSize:t,value:e}){super(`Size of bytes "${e}" (bytes${Ut(e)}) does not match expected size (bytes${t}).`,{name:"AbiEncodingBytesSizeMismatchError"})}}class Kt extends _t{constructor({expectedLength:t,givenLength:e}){super(["ABI encoding params/values length mismatch.",`Expected length (params): ${t}`,`Given length (values): ${e}`].join("\n"),{name:"AbiEncodingLengthMismatchError"})}}class Wt extends _t{constructor(t,{docsPath:e}){super([`Arguments (\`args\`) were provided to "${t}", but "${t}" on the ABI does not contain any parameters (\`inputs\`).`,"Cannot encode error result without knowing what the parameter types are.","Make sure you are using the correct ABI and that the inputs exist on it."].join("\n"),{docsPath:e,name:"AbiErrorInputsNotFoundError"})}}class Zt extends _t{constructor(t,{docsPath:e}={}){super([`Error ${t?`"${t}" `:""}not found on ABI.`,"Make sure you are using the correct ABI and that the error exists on it."].join("\n"),{docsPath:e,name:"AbiErrorNotFoundError"})}}class Jt extends _t{constructor(t,{docsPath:e}){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("\n"),{docsPath:e,name:"AbiErrorSignatureNotFoundError"}),Object.defineProperty(this,"signature",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.signature=t}}class Yt extends _t{constructor({docsPath:t}){super("Cannot extract event signature from empty topics.",{docsPath:t,name:"AbiEventSignatureEmptyTopicsError"})}}class Qt extends _t{constructor(t,{docsPath:e}){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("\n"),{docsPath:e,name:"AbiEventSignatureNotFoundError"})}}class Xt extends _t{constructor(t,{docsPath:e}={}){super([`Event ${t?`"${t}" `:""}not found on ABI.`,"Make sure you are using the correct ABI and that the event exists on it."].join("\n"),{docsPath:e,name:"AbiEventNotFoundError"})}}class $t extends _t{constructor(t,{docsPath:e}={}){super([`Function ${t?`"${t}" `:""}not found on ABI.`,"Make sure you are using the correct ABI and that the function exists on it."].join("\n"),{docsPath:e,name:"AbiFunctionNotFoundError"})}}class te extends _t{constructor(t,{docsPath:e}){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("\n"),{docsPath:e,name:"AbiFunctionOutputsNotFoundError"})}}class ee extends _t{constructor(t,{docsPath:e}){super([`Encoded function signature "${t}" not found on ABI.`,"Make sure you are using the correct ABI and that the function exists on it.",`You can look up the signature here: https://openchain.xyz/signatures?query=${t}.`].join("\n"),{docsPath:e,name:"AbiFunctionSignatureNotFoundError"})}}class ne extends _t{constructor(t,e){super("Found ambiguous types in overloaded ABI items.",{metaMessages:[`\`${t.type}\` in \`${Bt(t.abiItem)}\`, and`,`\`${e.type}\` in \`${Bt(e.abiItem)}\``,"","These types encode differently and cannot be distinguished at runtime.","Remove one of the ambiguous items in the ABI."],name:"AbiItemAmbiguityError"})}}let re=class extends _t{constructor({expectedSize:t,givenSize:e}){super(`Expected bytes${t}, got bytes${e}.`,{name:"BytesSizeMismatchError"})}};class ae extends _t{constructor({abiItem:t,data:e,params:n,size:r}){super([`Data size of ${r} bytes is too small for non-indexed event parameters.`].join("\n"),{metaMessages:[`Params: (${Nt(n,{includeName:!0})})`,`Data: ${e} (${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=e,this.params=n,this.size=r}}class se extends _t{constructor({abiItem:t,param:e}){super([`Expected a topic for indexed event parameter${e.name?` "${e.name}"`:""} on event "${Bt(t,{includeName:!0})}".`].join("\n"),{name:"DecodeLogTopicsMismatch"}),Object.defineProperty(this,"abiItem",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.abiItem=t}}class ie extends _t{constructor(t,{docsPath:e}){super([`Type "${t}" is not a valid encoding type.`,"Please provide a valid ABI type."].join("\n"),{docsPath:e,name:"InvalidAbiEncodingType"})}}class oe extends _t{constructor(t,{docsPath:e}){super([`Type "${t}" is not a valid decoding type.`,"Please provide a valid ABI type."].join("\n"),{docsPath:e,name:"InvalidAbiDecodingType"})}}let ce=class extends _t{constructor(t){super([`Value "${t}" is not a valid array.`].join("\n"),{name:"InvalidArrayError"})}};class ue extends _t{constructor(t){super([`"${t}" is not a valid definition type.`,'Valid types: "function", "event", "error"'].join("\n"),{name:"InvalidDefinitionTypeError"})}}class de extends _t{constructor(t){super(`Type "${t}" is not supported for packed encoding.`,{name:"UnsupportedPackedAbiType"})}}class le extends _t{constructor(t){super(`Filter type "${t}" is not supported.`,{name:"FilterTypeNotSupportedError"})}}let fe=class extends _t{constructor({offset:t,position:e,size:n}){super(`Slice ${"start"===e?"starting":"ending"} at offset "${t}" is out-of-bounds (size: ${n}).`,{name:"SliceOffsetOutOfBoundsError"})}},pe=class extends _t{constructor({size:t,targetSize:e,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (${t}) exceeds padding size (${e}).`,{name:"SizeExceedsPaddingSizeError"})}};class me extends _t{constructor({size:t,targetSize:e,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} is expected to be ${e} ${n} long, but is ${t} ${n} long.`,{name:"InvalidBytesLengthError"})}}function he(t,{dir:e,size:n=32}={}){return"string"==typeof t?be(t,{dir:e,size:n}):function(t,{dir:e,size:n=32}={}){if(null===n)return t;if(t.length>n)throw new pe({size:t.length,targetSize:n,type:"bytes"});const r=new Uint8Array(n);for(let a=0;a<n;a++){const s="right"===e;r[s?a:n-a-1]=t[s?a:t.length-a-1]}return r}(t,{dir:e,size:n})}function be(t,{dir:e,size:n=32}={}){if(null===n)return t;const r=t.replace("0x","");if(r.length>2*n)throw new pe({size:Math.ceil(r.length/2),targetSize:n,type:"hex"});return`0x${r["right"===e?"padEnd":"padStart"](2*n,"0")}`}let ye=class extends _t{constructor({max:t,min:e,signed:n,size:r,value:a}){super(`Number "${a}" is not in safe ${r?`${8*r}-bit ${n?"signed":"unsigned"} `:""}integer range ${t?`(${e} to ${t})`:`(above ${e})`}`,{name:"IntegerOutOfRangeError"})}},ge=class extends _t{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 ve extends _t{constructor(t){super(`Hex value "${t}" is not a valid boolean. The hex value must be "0x0" (false) or "0x1" (true).`,{name:"InvalidHexBooleanError"})}}let we=class extends _t{constructor({givenSize:t,maxSize:e}){super(`Size cannot exceed ${e} bytes. Given size: ${t} bytes.`,{name:"SizeOverflowError"})}};function xe(t,{dir:e="left"}={}){let n="string"==typeof t?t.replace("0x",""):t,r=0;for(let t=0;t<n.length-1&&"0"===n["left"===e?t:n.length-t-1].toString();t++)r++;return n="left"===e?n.slice(r):n.slice(0,n.length-r),"string"==typeof t?(1===n.length&&"right"===e&&(n=`${n}0`),`0x${n.length%2==1?`0${n}`:n}`):n}function Pe(t,{size:e}){if(Ut(t)>e)throw new we({givenSize:Ut(t),maxSize:e})}function ke(t,e={}){const{signed:n}=e;e.size&&Pe(t,{size:e.size});const r=BigInt(t);if(!n)return r;const a=(t.length-2)/2;return r<=(1n<<8n*BigInt(a)-1n)-1n?r:r-BigInt(`0x${"f".padStart(2*a,"f")}`)-1n}function Ie(t,e={}){return Number(ke(t,e))}function Ae(t,e={}){let n=Fe(t);return e.size&&(Pe(n,{size:e.size}),n=xe(n,{dir:"right"})),(new TextDecoder).decode(n)}const Ee=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Oe(t,e={}){return"number"==typeof t||"bigint"==typeof t?Ce(t,e):"string"==typeof t?Ne(t,e):"boolean"==typeof t?Se(t,e):Te(t,e)}function Se(t,e={}){const n=`0x${Number(t)}`;return"number"==typeof e.size?(Pe(n,{size:e.size}),he(n,{size:e.size})):n}function Te(t,e={}){let n="";for(let e=0;e<t.length;e++)n+=Ee[t[e]];const r=`0x${n}`;return"number"==typeof e.size?(Pe(r,{size:e.size}),he(r,{dir:"right",size:e.size})):r}function Ce(t,e={}){const{signed:n,size:r}=e,a=BigInt(t);let s;r?s=n?(1n<<8n*BigInt(r)-1n)-1n:2n**(8n*BigInt(r))-1n:"number"==typeof t&&(s=BigInt(Number.MAX_SAFE_INTEGER));const i="bigint"==typeof s&&n?-s-1n:0;if(s&&a>s||a<i){const e="bigint"==typeof t?"n":"";throw new ye({max:s?`${s}${e}`:void 0,min:`${i}${e}`,signed:n,size:r,value:`${t}${e}`})}const o=`0x${(n&&a<0?(1n<<BigInt(8*r))+BigInt(a):a).toString(16)}`;return r?he(o,{size:r}):o}const Be=new TextEncoder;function Ne(t,e={}){return Te(Be.encode(t),e)}const je=new TextEncoder;function Ue(t,e={}){return"number"==typeof t||"bigint"==typeof t?function(t,e){const n=Ce(t,e);return Fe(n)}(t,e):"boolean"==typeof t?function(t,e={}){const n=new Uint8Array(1);if(n[0]=Number(t),"number"==typeof e.size)return Pe(n,{size:e.size}),he(n,{size:e.size});return n}(t,e):jt(t)?Fe(t,e):_e(t,e)}const Me={zero:48,nine:57,A:65,F:70,a:97,f:102};function Re(t){return t>=Me.zero&&t<=Me.nine?t-Me.zero:t>=Me.A&&t<=Me.F?t-(Me.A-10):t>=Me.a&&t<=Me.f?t-(Me.a-10):void 0}function Fe(t,e={}){let n=t;e.size&&(Pe(n,{size:e.size}),n=he(n,{dir:"right",size:e.size}));let r=n.slice(2);r.length%2&&(r=`0${r}`);const a=r.length/2,s=new Uint8Array(a);for(let t=0,e=0;t<a;t++){const n=Re(r.charCodeAt(e++)),a=Re(r.charCodeAt(e++));if(void 0===n||void 0===a)throw new _t(`Invalid byte sequence ("${r[e-2]}${r[e-1]}" in "${r}").`);s[t]=16*n+a}return s}function _e(t,e={}){const n=je.encode(t);return"number"==typeof e.size?(Pe(n,{size:e.size}),he(n,{dir:"right",size:e.size})):n}const ze=BigInt(2**32-1),De=BigInt(32);function Le(t,e=!1){return e?{h:Number(t&ze),l:Number(t>>De&ze)}:{h:0|Number(t>>De&ze),l:0|Number(t&ze)}}function Ge(t,e=!1){const n=t.length;let r=new Uint32Array(n),a=new Uint32Array(n);for(let s=0;s<n;s++){const{h:n,l:i}=Le(t[s],e);[r[s],a[s]]=[n,i]}return[r,a]}const qe=(t,e,n)=>t>>>n,He=(t,e,n)=>t<<32-n|e>>>n,Ve=(t,e,n)=>t>>>n|e<<32-n,Ke=(t,e,n)=>t<<32-n|e>>>n,We=(t,e,n)=>t<<64-n|e>>>n-32,Ze=(t,e,n)=>t>>>n-32|e<<64-n;function Je(t,e,n,r){const a=(e>>>0)+(r>>>0);return{h:t+n+(a/2**32|0)|0,l:0|a}}const Ye=(t,e,n)=>(t>>>0)+(e>>>0)+(n>>>0),Qe=(t,e,n,r)=>e+n+r+(t/2**32|0)|0,Xe=(t,e,n,r)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0),$e=(t,e,n,r,a)=>e+n+r+a+(t/2**32|0)|0,tn=(t,e,n,r,a)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0)+(a>>>0),en=(t,e,n,r,a,s)=>e+n+r+a+s+(t/2**32|0)|0,nn="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0;function rn(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function an(t,...e){if(!
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).startaleAppSdk={})}(this,function(t){"use strict";const e="https://rpc.wallet.coinbase.com",n="@startale/app-sdk",r="1.2.0";function a(t,e){let n;try{n=t()}catch(t){return}const r={getItem:t=>{var e;const r=t=>null===t?null:JSON.parse(t,void 0),a=null!=(e=n.getItem(t))?e:null;return a instanceof Promise?a.then(r):r(a)},setItem:(t,e)=>n.setItem(t,JSON.stringify(e,void 0)),removeItem:t=>n.removeItem(t)};return r}const s=t=>e=>{try{const n=t(e);return n instanceof Promise?n:{then:t=>s(t)(n),catch(t){return this}}}catch(t){return{then(t){return this},catch:e=>s(e)(t)}}},i=(t,e)=>(n,r,i)=>{let o={storage:a(()=>localStorage),partialize:t=>t,version:0,merge:(t,e)=>({...e,...t}),...e},c=!1;const u=new Set,d=new Set;let l=o.storage;if(!l)return t((...t)=>{console.warn(`[zustand persist middleware] Unable to update item '${o.name}', the given storage is currently unavailable.`),n(...t)},r,i);const f=()=>{const t=o.partialize({...r()});return l.setItem(o.name,{state:t,version:o.version})},p=i.setState;i.setState=(t,e)=>{p(t,e),f()};const m=t((...t)=>{n(...t),f()},r,i);let h;i.getInitialState=()=>m;const b=()=>{var t,e;if(!l)return;c=!1,u.forEach(t=>{var e;return t(null!=(e=r())?e:m)});const a=(null==(e=o.onRehydrateStorage)?void 0:e.call(o,null!=(t=r())?t:m))||void 0;return s(l.getItem.bind(l))(o.name).then(t=>{if(t){if("number"!=typeof t.version||t.version===o.version)return[!1,t.state];if(o.migrate){const e=o.migrate(t.state,t.version);return e instanceof Promise?e.then(t=>[!0,t]):[!0,e]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}return[!1,void 0]}).then(t=>{var e;const[a,s]=t;if(h=o.merge(s,null!=(e=r())?e:m),n(h,!0),a)return f()}).then(()=>{null==a||a(h,void 0),h=r(),c=!0,d.forEach(t=>t(h))}).catch(t=>{null==a||a(void 0,t)})};return i.persist={setOptions:t=>{o={...o,...t},t.storage&&(l=t.storage)},clearStorage:()=>{null==l||l.removeItem(o.name)},getOptions:()=>o,rehydrate:()=>b(),hasHydrated:()=>c,onHydrate:t=>(u.add(t),()=>{u.delete(t)}),onFinishHydration:t=>(d.add(t),()=>{d.delete(t)})},o.skipHydration||b(),h||m},o=t=>{let e;const n=new Set,r=(t,r)=>{const a="function"==typeof t?t(e):t;if(!Object.is(a,e)){const t=e;e=(null!=r?r:"object"!=typeof a||null===a)?a:Object.assign({},e,a),n.forEach(n=>n(e,t))}},a=()=>e,s={setState:r,getState:a,getInitialState:()=>i,subscribe:t=>(n.add(t),()=>n.delete(t))},i=e=t(r,a,s);return s},c=t=>t?o(t):o,u=c(i((...t)=>Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},{chains:[]}),{keys:{}}),{account:{}}),{subAccount:void 0}),{spendPermissions:[]}),(()=>({config:{version:r}}))(...t)),{subAccountConfig:{}}),{userInfo:{}}),{name:"startale-app-sdk.store",storage:a(()=>localStorage),partialize:t=>({chains:t.chains,keys:t.keys,account:t.account,subAccount:t.subAccount,spendPermissions:t.spendPermissions,config:t.config,userInfo:t.userInfo})})),d={get:()=>u.getState().spendPermissions,set:t=>{u.setState({spendPermissions:t})},clear:()=>{u.setState({spendPermissions:[]})}},l={get:()=>u.getState().config,set:t=>{u.setState(e=>({config:Object.assign(Object.assign({},e.config),t)}))}},f={subAccounts:{get:()=>u.getState().subAccount,set:t=>{u.setState(e=>({subAccount:e.subAccount?Object.assign(Object.assign({},e.subAccount),t):Object.assign({address:t.address},t)}))},clear:()=>{u.setState({subAccount:void 0})}},subAccountsConfig:{get:()=>u.getState().subAccountConfig,set:t=>{u.setState(e=>({subAccountConfig:Object.assign(Object.assign({},e.subAccountConfig),t)}))},clear:()=>{u.setState({subAccountConfig:{}})}},spendPermissions:d,account:{get:()=>u.getState().account,set:t=>{u.setState(e=>({account:Object.assign(Object.assign({},e.account),t)}))},clear:()=>{u.setState({account:{}})}},chains:{get:()=>u.getState().chains,set:t=>{u.setState({chains:t})},clear:()=>{u.setState({chains:[]})}},keys:{get:t=>u.getState().keys[t],set:(t,e)=>{u.setState(n=>({keys:Object.assign(Object.assign({},n.keys),{[t]:e})}))},clear:()=>{u.setState({keys:{}})}},config:l,userInfo:{get:()=>u.getState().userInfo,set:t=>{u.setState(e=>({userInfo:t}))},clear:()=>{u.setState({userInfo:{}})}}},p=Object.assign(Object.assign({},u),f),m=()=>{var t,e,n;if("undefined"!=typeof window){const r=null!==(n=null!==(t=p.config.get().deviceId)&&void 0!==t?t:null===(e=window.crypto)||void 0===e?void 0:e.randomUUID())&&void 0!==n?n:"";if(window.ClientAnalytics){const{init:t,identify:e,PlatformName:n}=window.ClientAnalytics;t({isProd:!0,amplitudeApiKey:"c66737ad47ec354ced777935b0af822e",platform:n.web,projectName:"base_account_sdk",showDebugLogging:!1,version:"1.0.0",apiEndpoint:"https://cca-lite.coinbase.com"}),e({deviceId:r}),p.config.set({deviceId:r})}}},h=[{inputs:[],stateMutability:"nonpayable",type:"constructor"},{inputs:[{name:"owner",type:"bytes"}],name:"AlreadyOwner",type:"error"},{inputs:[],name:"Initialized",type:"error"},{inputs:[{name:"owner",type:"bytes"}],name:"InvalidEthereumAddressOwner",type:"error"},{inputs:[{name:"key",type:"uint256"}],name:"InvalidNonceKey",type:"error"},{inputs:[{name:"owner",type:"bytes"}],name:"InvalidOwnerBytesLength",type:"error"},{inputs:[],name:"LastOwner",type:"error"},{inputs:[{name:"index",type:"uint256"}],name:"NoOwnerAtIndex",type:"error"},{inputs:[{name:"ownersRemaining",type:"uint256"}],name:"NotLastOwner",type:"error"},{inputs:[{name:"selector",type:"bytes4"}],name:"SelectorNotAllowed",type:"error"},{inputs:[],name:"Unauthorized",type:"error"},{inputs:[],name:"UnauthorizedCallContext",type:"error"},{inputs:[],name:"UpgradeFailed",type:"error"},{inputs:[{name:"index",type:"uint256"},{name:"expectedOwner",type:"bytes"},{name:"actualOwner",type:"bytes"}],name:"WrongOwnerAtIndex",type:"error"},{anonymous:!1,inputs:[{indexed:!0,name:"index",type:"uint256"},{indexed:!1,name:"owner",type:"bytes"}],name:"AddOwner",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"index",type:"uint256"},{indexed:!1,name:"owner",type:"bytes"}],name:"RemoveOwner",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"implementation",type:"address"}],name:"Upgraded",type:"event"},{stateMutability:"payable",type:"fallback"},{inputs:[],name:"REPLAYABLE_NONCE_KEY",outputs:[{name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{name:"owner",type:"address"}],name:"addOwnerAddress",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{name:"x",type:"bytes32"},{name:"y",type:"bytes32"}],name:"addOwnerPublicKey",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{name:"functionSelector",type:"bytes4"}],name:"canSkipChainIdValidation",outputs:[{name:"",type:"bool"}],stateMutability:"pure",type:"function"},{inputs:[],name:"domainSeparator",outputs:[{name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"eip712Domain",outputs:[{name:"fields",type:"bytes1"},{name:"name",type:"string"},{name:"version",type:"string"},{name:"chainId",type:"uint256"},{name:"verifyingContract",type:"address"},{name:"salt",type:"bytes32"},{name:"extensions",type:"uint256[]"}],stateMutability:"view",type:"function"},{inputs:[],name:"entryPoint",outputs:[{name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{name:"target",type:"address"},{name:"value",type:"uint256"},{name:"data",type:"bytes"}],name:"execute",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{components:[{name:"target",type:"address"},{name:"value",type:"uint256"},{name:"data",type:"bytes"}],name:"calls",type:"tuple[]"}],name:"executeBatch",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{name:"calls",type:"bytes[]"}],name:"executeWithoutChainIdValidation",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{components:[{name:"sender",type:"address"},{name:"nonce",type:"uint256"},{name:"initCode",type:"bytes"},{name:"callData",type:"bytes"},{name:"callGasLimit",type:"uint256"},{name:"verificationGasLimit",type:"uint256"},{name:"preVerificationGas",type:"uint256"},{name:"maxFeePerGas",type:"uint256"},{name:"maxPriorityFeePerGas",type:"uint256"},{name:"paymasterAndData",type:"bytes"},{name:"signature",type:"bytes"}],name:"userOp",type:"tuple"}],name:"getUserOpHashWithoutChainId",outputs:[{name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[],name:"implementation",outputs:[{name:"$",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{name:"owners",type:"bytes[]"}],name:"initialize",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{name:"account",type:"address"}],name:"isOwnerAddress",outputs:[{name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{name:"account",type:"bytes"}],name:"isOwnerBytes",outputs:[{name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{name:"x",type:"bytes32"},{name:"y",type:"bytes32"}],name:"isOwnerPublicKey",outputs:[{name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{name:"hash",type:"bytes32"},{name:"signature",type:"bytes"}],name:"isValidSignature",outputs:[{name:"result",type:"bytes4"}],stateMutability:"view",type:"function"},{inputs:[],name:"nextOwnerIndex",outputs:[{name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{name:"index",type:"uint256"}],name:"ownerAtIndex",outputs:[{name:"",type:"bytes"}],stateMutability:"view",type:"function"},{inputs:[],name:"ownerCount",outputs:[{name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"proxiableUUID",outputs:[{name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{name:"index",type:"uint256"},{name:"owner",type:"bytes"}],name:"removeLastOwner",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{name:"index",type:"uint256"},{name:"owner",type:"bytes"}],name:"removeOwnerAtIndex",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"removedOwnersCount",outputs:[{name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{name:"hash",type:"bytes32"}],name:"replaySafeHash",outputs:[{name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{name:"newImplementation",type:"address"},{name:"data",type:"bytes"}],name:"upgradeToAndCall",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{components:[{name:"sender",type:"address"},{name:"nonce",type:"uint256"},{name:"initCode",type:"bytes"},{name:"callData",type:"bytes"},{name:"callGasLimit",type:"uint256"},{name:"verificationGasLimit",type:"uint256"},{name:"preVerificationGas",type:"uint256"},{name:"maxFeePerGas",type:"uint256"},{name:"maxPriorityFeePerGas",type:"uint256"},{name:"paymasterAndData",type:"bytes"},{name:"signature",type:"bytes"}],name:"userOp",type:"tuple"},{name:"userOpHash",type:"bytes32"},{name:"missingAccountFunds",type:"uint256"}],name:"validateUserOp",outputs:[{name:"validationData",type:"uint256"}],stateMutability:"nonpayable",type:"function"},{stateMutability:"payable",type:"receive"}],b=[{inputs:[{name:"implementation_",type:"address"}],stateMutability:"payable",type:"constructor"},{inputs:[],name:"OwnerRequired",type:"error"},{inputs:[{name:"owners",type:"bytes[]"},{name:"nonce",type:"uint256"}],name:"createAccount",outputs:[{name:"account",type:"address"}],stateMutability:"payable",type:"function"},{inputs:[{name:"owners",type:"bytes[]"},{name:"nonce",type:"uint256"}],name:"getAddress",outputs:[{name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"implementation",outputs:[{name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"initCodeHash",outputs:[{name:"",type:"bytes32"}],stateMutability:"view",type:"function"}],y={invalidInput:-32e3,resourceNotFound:-32001,resourceUnavailable:-32002,transactionRejected:-32003,methodNotSupported:-32004,limitExceeded:-32005,parse:-32700,invalidRequest:-32600,methodNotFound:-32601,invalidParams:-32602,internal:-32603},g={userRejectedRequest:4001,unauthorized:4100,unsupportedMethod:4200,disconnected:4900,chainDisconnected:4901,unsupportedChain:4902},v={"-32700":{standard:"JSON RPC 2.0",message:"Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."},"-32600":{standard:"JSON RPC 2.0",message:"The JSON sent is not a valid Request object."},"-32601":{standard:"JSON RPC 2.0",message:"The method does not exist / is not available."},"-32602":{standard:"JSON RPC 2.0",message:"Invalid method parameter(s)."},"-32603":{standard:"JSON RPC 2.0",message:"Internal JSON-RPC error."},"-32000":{standard:"EIP-1474",message:"Invalid input."},"-32001":{standard:"EIP-1474",message:"Resource not found."},"-32002":{standard:"EIP-1474",message:"Resource unavailable."},"-32003":{standard:"EIP-1474",message:"Transaction rejected."},"-32004":{standard:"EIP-1474",message:"Method not supported."},"-32005":{standard:"EIP-1474",message:"Request limit exceeded."},4001:{standard:"EIP-1193",message:"User rejected the request."},4100:{standard:"EIP-1193",message:"The requested account and/or method has not been authorized by the user."},4200:{standard:"EIP-1193",message:"The requested method is not supported by this Ethereum provider."},4900:{standard:"EIP-1193",message:"The provider is disconnected from all chains."},4901:{standard:"EIP-1193",message:"The provider is disconnected from the specified chain."},4902:{standard:"EIP-3085",message:"Unrecognized chain ID."}},w="Unspecified error message.";function x(t,e=w){if(t&&Number.isInteger(t)){const e=t.toString();if(A(v,e))return v[e].message;if(k(t))return"Unspecified server error."}return e}function P(t,{shouldIncludeStack:e=!1}={}){const n={};if(t&&"object"==typeof t&&!Array.isArray(t)&&A(t,"code")&&function(t){if(!Number.isInteger(t))return!1;const e=t.toString();return!!v[e]||!!k(t)}(t.code)){const e=t;n.code=e.code,e.message&&"string"==typeof e.message?(n.message=e.message,A(e,"data")&&(n.data=e.data)):(n.message=x(n.code),n.data={originalError:I(t)})}else n.code=y.internal,n.message=E(t,"message")?t.message:w,n.data={originalError:I(t)};return e&&(n.stack=E(t,"stack")?t.stack:void 0),n}function k(t){return t>=-32099&&t<=-32e3}function I(t){return t&&"object"==typeof t&&!Array.isArray(t)?Object.assign({},t):t}function A(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function E(t,e){return"object"==typeof t&&null!==t&&e in t&&"string"==typeof t[e]}const O={parse:t=>T(y.parse,t),invalidRequest:t=>T(y.invalidRequest,t),invalidParams:t=>T(y.invalidParams,t),methodNotFound:t=>T(y.methodNotFound,t),internal:t=>T(y.internal,t),server:t=>{if(!t||"object"!=typeof t||Array.isArray(t))throw new Error("Ethereum RPC Server errors must provide single object argument.");const{code:e}=t;if(!Number.isInteger(e)||e>-32005||e<-32099)throw new Error('"code" must be an integer such that: -32099 <= code <= -32005');return T(e,t)},invalidInput:t=>T(y.invalidInput,t),resourceNotFound:t=>T(y.resourceNotFound,t),resourceUnavailable:t=>T(y.resourceUnavailable,t),transactionRejected:t=>T(y.transactionRejected,t),methodNotSupported:t=>T(y.methodNotSupported,t),limitExceeded:t=>T(y.limitExceeded,t)},S={userRejectedRequest:t=>C(g.userRejectedRequest,t),unauthorized:t=>C(g.unauthorized,t),unsupportedMethod:t=>C(g.unsupportedMethod,t),disconnected:t=>C(g.disconnected,t),chainDisconnected:t=>C(g.chainDisconnected,t),unsupportedChain:t=>C(g.unsupportedChain,t),custom:t=>{if(!t||"object"!=typeof t||Array.isArray(t))throw new Error("Ethereum Provider custom errors must provide single object argument.");const{code:e,message:n,data:r}=t;if(!n||"string"!=typeof n)throw new Error('"message" must be a nonempty string');return new j(e,n,r)}};function T(t,e){const[n,r]=B(e);return new N(t,n||x(t),r)}function C(t,e){const[n,r]=B(e);return new j(t,n||x(t),r)}function B(t){if(t){if("string"==typeof t)return[t];if("object"==typeof t&&!Array.isArray(t)){const{message:e,data:n}=t;if(e&&"string"!=typeof e)throw new Error("Must specify string message.");return[e||void 0,n]}}return[]}class N extends Error{constructor(t,e,n){if(!Number.isInteger(t))throw new Error('"code" must be an integer.');if(!e||"string"!=typeof e)throw new Error('"message" must be a nonempty string.');super(e),this.code=t,void 0!==n&&(this.data=n)}}class j extends N{constructor(t,e,n){if(!function(t){return Number.isInteger(t)&&t>=1e3&&t<=4999}(t))throw new Error('"code" must be an integer such that: 1000 <= code <= 4999');super(t,e,n)}}function U(t){return"object"==typeof t&&null!==t&&"code"in t&&"data"in t&&-32090===t.code&&"object"==typeof t.data&&null!==t.data&&"type"in t.data&&"INSUFFICIENT_FUNDS"===t.data.type}function M(t){return"object"==typeof t&&null!==t&&"details"in t}function R(t,e,n){if(null==t)throw null!=e?e:O.invalidParams({message:"value must be present",data:t})}function F(t,e){if(!Array.isArray(t))throw O.invalidParams({message:null!=e?e:"value must be an array",data:t})}const{checkCrossOriginOpenerPolicy:_,getCrossOriginOpenerPolicy:z}=(()=>{let t;return{getCrossOriginOpenerPolicy:()=>void 0===t?"undefined":t,checkCrossOriginOpenerPolicy:async()=>{if("undefined"!=typeof window)try{const e=`${window.location.origin}${window.location.pathname}`,n=await fetch(e,{method:"HEAD"});if(!n.ok)throw new Error(`HTTP error! status: ${n.status}`);const r=n.headers.get("Cross-Origin-Opener-Policy");t=null!=r?r:"null","same-origin"===t&&console.error("Base Account SDK requires the Cross-Origin-Opener-Policy header to not be set to 'same-origin'. This is to ensure that the SDK can communicate with the Base Account app.\n\nPlease see https://docs.base.org/smart-wallet/quickstart#cross-origin-opener-policy for more information.")}catch(e){console.error("Error checking Cross-Origin-Opener-Policy:",e.message),t="error"}else t="non-browser-env"}}})();function D(t){if("function"!=typeof t)throw new Error("toAccount is not a function")}let L=class t extends Error{constructor(e,n={}){const r=n.cause instanceof t?n.cause.details:n.cause?.message?n.cause.message:n.details,a=n.cause instanceof t&&n.cause.docsPath||n.docsPath;super([e||"An error occurred.","",...n.metaMessages?[...n.metaMessages,""]:[],...a?[`Docs: https://abitype.dev${a}`]:[],...r?[`Details: ${r}`]:[],"Version: abitype@1.1.0"].join("\n")),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=r,this.docsPath=a,this.metaMessages=n.metaMessages,this.shortMessage=e}};function G(t,e){const n=t.exec(e);return n?.groups}const q=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,H=/^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)?$/,V=/^\(.+?\).*?$/,K=/^tuple(?<array>(\[(\d*)\])*)$/;function W(t){let e=t.type;if(K.test(t.type)&&"components"in t){e="(";const n=t.components.length;for(let r=0;r<n;r++){e+=W(t.components[r]),r<n-1&&(e+=", ")}const r=G(K,t.type);return e+=`)${r?.array??""}`,W({...t,type:e})}return"indexed"in t&&t.indexed&&(e=`${e} indexed`),t.name?`${e} ${t.name}`:e}function Z(t){let e="";const n=t.length;for(let r=0;r<n;r++){e+=W(t[r]),r!==n-1&&(e+=", ")}return e}const J=/^error (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/;const Y=/^event (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/;const Q=/^function (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)(?: (?<scope>external|public{1}))?(?: (?<stateMutability>pure|view|nonpayable|payable{1}))?(?: returns\s?\((?<returns>.*?)\))?$/;const X=/^struct (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*) \{(?<properties>.*?)\}$/;function $(t){return X.test(t)}function tt(t){return G(X,t)}const et=/^constructor\((?<parameters>.*?)\)(?:\s(?<stateMutability>payable{1}))?$/;const nt=/^fallback\(\) external(?:\s(?<stateMutability>payable{1}))?$/;const rt=/^receive\(\) external payable$/;const at=new Set(["indexed"]),st=new Set(["calldata","memory","storage"]);let it=class extends L{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"})}},ot=class extends L{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"})}},ct=class extends L{constructor({param:t}){super("Invalid ABI parameter.",{details:t}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidParameterError"})}},ut=class extends L{constructor({param:t,name:e}){super("Invalid ABI parameter.",{details:t,metaMessages:[`"${e}" 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"})}},dt=class extends L{constructor({param:t,type:e,modifier:n}){super("Invalid ABI parameter.",{details:t,metaMessages:[`Modifier "${n}" not allowed${e?` in "${e}" type`:""}.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidModifierError"})}},lt=class extends L{constructor({param:t,type:e,modifier:n}){super("Invalid ABI parameter.",{details:t,metaMessages:[`Modifier "${n}" not allowed${e?` in "${e}" type`:""}.`,`Data location can only be specified for array, struct, or mapping types, but "${n}" was given.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidFunctionModifierError"})}},ft=class extends L{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"})}},pt=class extends L{constructor({signature:t,type:e}){super(`Invalid ${e} signature.`,{details:t}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidSignatureError"})}},mt=class extends L{constructor({signature:t}){super("Unknown signature.",{details:t}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownSignatureError"})}},ht=class extends L{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"})}},bt=class extends L{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"})}},yt=class extends L{constructor({current:t,depth:e}){super("Unbalanced parentheses.",{metaMessages:[`"${t.trim()}" has too many ${e>0?"opening":"closing"} parentheses.`],details:`Depth "${e}"`}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidParenthesisError"})}};const gt=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 vt(t,e={}){if(function(t){return Q.test(t)}(t))return function(t,e={}){const n=function(t){return G(Q,t)}(t);if(!n)throw new pt({signature:t,type:"function"});const r=It(n.parameters),a=[],s=r.length;for(let t=0;t<s;t++)a.push(kt(r[t],{modifiers:st,structs:e,type:"function"}));const i=[];if(n.returns){const t=It(n.returns),r=t.length;for(let n=0;n<r;n++)i.push(kt(t[n],{modifiers:st,structs:e,type:"function"}))}return{name:n.name,type:"function",stateMutability:n.stateMutability??"nonpayable",inputs:a,outputs:i}}(t,e);if(function(t){return Y.test(t)}(t))return function(t,e={}){const n=function(t){return G(Y,t)}(t);if(!n)throw new pt({signature:t,type:"event"});const r=It(n.parameters),a=[],s=r.length;for(let t=0;t<s;t++)a.push(kt(r[t],{modifiers:at,structs:e,type:"event"}));return{name:n.name,type:"event",inputs:a}}(t,e);if(function(t){return J.test(t)}(t))return function(t,e={}){const n=function(t){return G(J,t)}(t);if(!n)throw new pt({signature:t,type:"error"});const r=It(n.parameters),a=[],s=r.length;for(let t=0;t<s;t++)a.push(kt(r[t],{structs:e,type:"error"}));return{name:n.name,type:"error",inputs:a}}(t,e);if(function(t){return et.test(t)}(t))return function(t,e={}){const n=function(t){return G(et,t)}(t);if(!n)throw new pt({signature:t,type:"constructor"});const r=It(n.parameters),a=[],s=r.length;for(let t=0;t<s;t++)a.push(kt(r[t],{structs:e,type:"constructor"}));return{type:"constructor",stateMutability:n.stateMutability??"nonpayable",inputs:a}}(t,e);if(function(t){return nt.test(t)}(t))return function(t){const e=function(t){return G(nt,t)}(t);if(!e)throw new pt({signature:t,type:"fallback"});return{type:"fallback",stateMutability:e.stateMutability??"nonpayable"}}(t);if(function(t){return rt.test(t)}(t))return{type:"receive",stateMutability:"payable"};throw new mt({signature:t})}const wt=/^(?<type>[a-zA-Z$_][a-zA-Z0-9$_]*(?:\spayable)?)(?<array>(?:\[\d*?\])+?)?(?:\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\s(?<name>[a-zA-Z$_][a-zA-Z0-9$_]*))?$/,xt=/^\((?<type>.+?)\)(?<array>(?:\[\d*?\])+?)?(?:\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\s(?<name>[a-zA-Z$_][a-zA-Z0-9$_]*))?$/,Pt=/^u?int$/;function kt(t,e){const n=function(t,e,n){let r="";if(n)for(const t of Object.entries(n)){if(!t)continue;let e="";for(const n of t[1])e+=`[${n.type}${n.name?`:${n.name}`:""}]`;r+=`(${t[0]}{${e}})`}return e?`${e}:${t}${r}`:t}(t,e?.type,e?.structs);if(gt.has(n))return gt.get(n);const r=V.test(t),a=G(r?xt:wt,t);if(!a)throw new ct({param:t});if(a.name&&function(t){return"address"===t||"bool"===t||"function"===t||"string"===t||"tuple"===t||q.test(t)||H.test(t)||Et.test(t)}(a.name))throw new ut({param:t,name:a.name});const s=a.name?{name:a.name}:{},i="indexed"===a.modifier?{indexed:!0}:{},o=e?.structs??{};let c,u={};if(r){c="tuple";const t=It(a.type),e=[],n=t.length;for(let r=0;r<n;r++)e.push(kt(t[r],{structs:o}));u={components:e}}else if(a.type in o)c="tuple",u={components:o[a.type]};else if(Pt.test(a.type))c=`${a.type}256`;else if("address payable"===a.type)c="address";else if(c=a.type,"struct"!==e?.type&&!At(c))throw new ot({type:c});if(a.modifier){if(!e?.modifiers?.has?.(a.modifier))throw new dt({param:t,type:e?.type,modifier:a.modifier});if(st.has(a.modifier)&&!function(t,e){return e||"bytes"===t||"string"===t||"tuple"===t}(c,!!a.array))throw new lt({param:t,type:e?.type,modifier:a.modifier})}const d={type:`${c}${a.array??""}`,...s,...i,...u};return gt.set(n,d),d}function It(t,e=[],n="",r=0){const a=t.trim().length;for(let s=0;s<a;s++){const a=t[s],i=t.slice(s+1);switch(a){case",":return 0===r?It(i,[...e,n.trim()]):It(i,e,`${n}${a}`,r);case"(":return It(i,e,`${n}${a}`,r+1);case")":return It(i,e,`${n}${a}`,r-1);default:return It(i,e,`${n}${a}`,r)}}if(""===n)return e;if(0!==r)throw new yt({current:n,depth:r});return e.push(n.trim()),e}function At(t){return"address"===t||"bool"===t||"function"===t||"string"===t||q.test(t)||H.test(t)}const Et=/^(?: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)$/;const Ot=/^(?<type>[a-zA-Z$_][a-zA-Z0-9$_]*)(?<array>(?:\[\d*?\])+?)?$/;function St(t,e,n=new Set){const r=[],a=t.length;for(let s=0;s<a;s++){const a=t[s];if(V.test(a.type))r.push(a);else{const t=G(Ot,a.type);if(!t?.type)throw new ft({abiParameter:a});const{array:s,type:i}=t;if(i in e){if(n.has(i))throw new bt({type:i});r.push({...a,type:`tuple${s??""}`,components:St(e[i]??[],e,new Set([...n,i]))})}else{if(!At(i))throw new it({type:i});r.push(a)}}}return r}function Tt(t){const e=function(t){const e={},n=t.length;for(let r=0;r<n;r++){const n=t[r];if(!$(n))continue;const a=tt(n);if(!a)throw new pt({signature:n,type:"struct"});const s=a.properties.split(";"),i=[],o=s.length;for(let t=0;t<o;t++){const e=s[t].trim();if(!e)continue;const n=kt(e,{type:"struct"});i.push(n)}if(!i.length)throw new ht({signature:n});e[a.name]=i}const r={},a=Object.entries(e),s=a.length;for(let t=0;t<s;t++){const[n,s]=a[t];r[n]=St(s,e)}return r}(t),n=[],r=t.length;for(let a=0;a<r;a++){const r=t[a];$(r)||n.push(vt(r,e))}return n}function Ct(t,e,n){const r=t[e.name];if("function"==typeof r)return r;const a=t[n];return"function"==typeof a?a:n=>e(t,n)}function Bt(t,{includeName:e=!1}={}){if("function"!==t.type&&"event"!==t.type&&"error"!==t.type)throw new ue(t.type);return`${t.name}(${Nt(t.inputs,{includeName:e})})`}function Nt(t,{includeName:e=!1}={}){return t?t.map(t=>function(t,{includeName:e}){if(t.type.startsWith("tuple"))return`(${Nt(t.components,{includeName:e})})${t.type.slice(5)}`;return t.type+(e&&t.name?` ${t.name}`:"")}(t,{includeName:e})).join(e?", ":","):""}function jt(t,{strict:e=!0}={}){return!!t&&("string"==typeof t&&(e?/^0x[0-9a-fA-F]*$/.test(t):t.startsWith("0x")))}function Ut(t){return jt(t,{strict:!1})?Math.ceil((t.length-2)/2):t.length}const Mt="2.38.4";let Rt=({docsBaseUrl:t,docsPath:e="",docsSlug:n})=>e?`${t??"https://viem.sh"}${e}${n?`#${n}`:""}`:void 0,Ft=`viem@${Mt}`,_t=class t extends Error{constructor(e,n={}){const r=n.cause instanceof t?n.cause.details:n.cause?.message?n.cause.message:n.details,a=n.cause instanceof t&&n.cause.docsPath||n.docsPath,s=Rt?.({...n,docsPath:a});super([e||"An error occurred.","",...n.metaMessages?[...n.metaMessages,""]:[],...s?[`Docs: ${s}`]:[],...r?[`Details: ${r}`]:[],...Ft?[`Version: ${Ft}`]:[]].join("\n"),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=r,this.docsPath=a,this.metaMessages=n.metaMessages,this.name=n.name??this.name,this.shortMessage=e,this.version=Mt}walk(t){return zt(this,t)}};function zt(t,e){return e?.(t)?t:t&&"object"==typeof t&&"cause"in t&&void 0!==t.cause?zt(t.cause,e):e?null:t}class Dt extends _t{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("\n"),{docsPath:t,name:"AbiConstructorNotFoundError"})}}class Lt extends _t{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("\n"),{docsPath:t,name:"AbiConstructorParamsNotFoundError"})}}class Gt extends _t{constructor({data:t,params:e,size:n}){super([`Data size of ${n} bytes is too small for given parameters.`].join("\n"),{metaMessages:[`Params: (${Nt(e,{includeName:!0})})`,`Data: ${t} (${n} 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=e,this.size=n}}class qt extends _t{constructor(){super('Cannot decode zero data ("0x") with ABI parameters.',{name:"AbiDecodingZeroDataError"})}}class Ht extends _t{constructor({expectedLength:t,givenLength:e,type:n}){super([`ABI encoding array length mismatch for type ${n}.`,`Expected length: ${t}`,`Given length: ${e}`].join("\n"),{name:"AbiEncodingArrayLengthMismatchError"})}}class Vt extends _t{constructor({expectedSize:t,value:e}){super(`Size of bytes "${e}" (bytes${Ut(e)}) does not match expected size (bytes${t}).`,{name:"AbiEncodingBytesSizeMismatchError"})}}class Kt extends _t{constructor({expectedLength:t,givenLength:e}){super(["ABI encoding params/values length mismatch.",`Expected length (params): ${t}`,`Given length (values): ${e}`].join("\n"),{name:"AbiEncodingLengthMismatchError"})}}class Wt extends _t{constructor(t,{docsPath:e}){super([`Arguments (\`args\`) were provided to "${t}", but "${t}" on the ABI does not contain any parameters (\`inputs\`).`,"Cannot encode error result without knowing what the parameter types are.","Make sure you are using the correct ABI and that the inputs exist on it."].join("\n"),{docsPath:e,name:"AbiErrorInputsNotFoundError"})}}class Zt extends _t{constructor(t,{docsPath:e}={}){super([`Error ${t?`"${t}" `:""}not found on ABI.`,"Make sure you are using the correct ABI and that the error exists on it."].join("\n"),{docsPath:e,name:"AbiErrorNotFoundError"})}}class Jt extends _t{constructor(t,{docsPath:e}){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("\n"),{docsPath:e,name:"AbiErrorSignatureNotFoundError"}),Object.defineProperty(this,"signature",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.signature=t}}class Yt extends _t{constructor({docsPath:t}){super("Cannot extract event signature from empty topics.",{docsPath:t,name:"AbiEventSignatureEmptyTopicsError"})}}class Qt extends _t{constructor(t,{docsPath:e}){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("\n"),{docsPath:e,name:"AbiEventSignatureNotFoundError"})}}class Xt extends _t{constructor(t,{docsPath:e}={}){super([`Event ${t?`"${t}" `:""}not found on ABI.`,"Make sure you are using the correct ABI and that the event exists on it."].join("\n"),{docsPath:e,name:"AbiEventNotFoundError"})}}class $t extends _t{constructor(t,{docsPath:e}={}){super([`Function ${t?`"${t}" `:""}not found on ABI.`,"Make sure you are using the correct ABI and that the function exists on it."].join("\n"),{docsPath:e,name:"AbiFunctionNotFoundError"})}}class te extends _t{constructor(t,{docsPath:e}){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("\n"),{docsPath:e,name:"AbiFunctionOutputsNotFoundError"})}}class ee extends _t{constructor(t,{docsPath:e}){super([`Encoded function signature "${t}" not found on ABI.`,"Make sure you are using the correct ABI and that the function exists on it.",`You can look up the signature here: https://openchain.xyz/signatures?query=${t}.`].join("\n"),{docsPath:e,name:"AbiFunctionSignatureNotFoundError"})}}class ne extends _t{constructor(t,e){super("Found ambiguous types in overloaded ABI items.",{metaMessages:[`\`${t.type}\` in \`${Bt(t.abiItem)}\`, and`,`\`${e.type}\` in \`${Bt(e.abiItem)}\``,"","These types encode differently and cannot be distinguished at runtime.","Remove one of the ambiguous items in the ABI."],name:"AbiItemAmbiguityError"})}}let re=class extends _t{constructor({expectedSize:t,givenSize:e}){super(`Expected bytes${t}, got bytes${e}.`,{name:"BytesSizeMismatchError"})}};class ae extends _t{constructor({abiItem:t,data:e,params:n,size:r}){super([`Data size of ${r} bytes is too small for non-indexed event parameters.`].join("\n"),{metaMessages:[`Params: (${Nt(n,{includeName:!0})})`,`Data: ${e} (${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=e,this.params=n,this.size=r}}class se extends _t{constructor({abiItem:t,param:e}){super([`Expected a topic for indexed event parameter${e.name?` "${e.name}"`:""} on event "${Bt(t,{includeName:!0})}".`].join("\n"),{name:"DecodeLogTopicsMismatch"}),Object.defineProperty(this,"abiItem",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.abiItem=t}}class ie extends _t{constructor(t,{docsPath:e}){super([`Type "${t}" is not a valid encoding type.`,"Please provide a valid ABI type."].join("\n"),{docsPath:e,name:"InvalidAbiEncodingType"})}}class oe extends _t{constructor(t,{docsPath:e}){super([`Type "${t}" is not a valid decoding type.`,"Please provide a valid ABI type."].join("\n"),{docsPath:e,name:"InvalidAbiDecodingType"})}}let ce=class extends _t{constructor(t){super([`Value "${t}" is not a valid array.`].join("\n"),{name:"InvalidArrayError"})}};class ue extends _t{constructor(t){super([`"${t}" is not a valid definition type.`,'Valid types: "function", "event", "error"'].join("\n"),{name:"InvalidDefinitionTypeError"})}}class de extends _t{constructor(t){super(`Type "${t}" is not supported for packed encoding.`,{name:"UnsupportedPackedAbiType"})}}class le extends _t{constructor(t){super(`Filter type "${t}" is not supported.`,{name:"FilterTypeNotSupportedError"})}}let fe=class extends _t{constructor({offset:t,position:e,size:n}){super(`Slice ${"start"===e?"starting":"ending"} at offset "${t}" is out-of-bounds (size: ${n}).`,{name:"SliceOffsetOutOfBoundsError"})}},pe=class extends _t{constructor({size:t,targetSize:e,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (${t}) exceeds padding size (${e}).`,{name:"SizeExceedsPaddingSizeError"})}};class me extends _t{constructor({size:t,targetSize:e,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} is expected to be ${e} ${n} long, but is ${t} ${n} long.`,{name:"InvalidBytesLengthError"})}}function he(t,{dir:e,size:n=32}={}){return"string"==typeof t?be(t,{dir:e,size:n}):function(t,{dir:e,size:n=32}={}){if(null===n)return t;if(t.length>n)throw new pe({size:t.length,targetSize:n,type:"bytes"});const r=new Uint8Array(n);for(let a=0;a<n;a++){const s="right"===e;r[s?a:n-a-1]=t[s?a:t.length-a-1]}return r}(t,{dir:e,size:n})}function be(t,{dir:e,size:n=32}={}){if(null===n)return t;const r=t.replace("0x","");if(r.length>2*n)throw new pe({size:Math.ceil(r.length/2),targetSize:n,type:"hex"});return`0x${r["right"===e?"padEnd":"padStart"](2*n,"0")}`}let ye=class extends _t{constructor({max:t,min:e,signed:n,size:r,value:a}){super(`Number "${a}" is not in safe ${r?`${8*r}-bit ${n?"signed":"unsigned"} `:""}integer range ${t?`(${e} to ${t})`:`(above ${e})`}`,{name:"IntegerOutOfRangeError"})}},ge=class extends _t{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 ve extends _t{constructor(t){super(`Hex value "${t}" is not a valid boolean. The hex value must be "0x0" (false) or "0x1" (true).`,{name:"InvalidHexBooleanError"})}}let we=class extends _t{constructor({givenSize:t,maxSize:e}){super(`Size cannot exceed ${e} bytes. Given size: ${t} bytes.`,{name:"SizeOverflowError"})}};function xe(t,{dir:e="left"}={}){let n="string"==typeof t?t.replace("0x",""):t,r=0;for(let t=0;t<n.length-1&&"0"===n["left"===e?t:n.length-t-1].toString();t++)r++;return n="left"===e?n.slice(r):n.slice(0,n.length-r),"string"==typeof t?(1===n.length&&"right"===e&&(n=`${n}0`),`0x${n.length%2==1?`0${n}`:n}`):n}function Pe(t,{size:e}){if(Ut(t)>e)throw new we({givenSize:Ut(t),maxSize:e})}function ke(t,e={}){const{signed:n}=e;e.size&&Pe(t,{size:e.size});const r=BigInt(t);if(!n)return r;const a=(t.length-2)/2;return r<=(1n<<8n*BigInt(a)-1n)-1n?r:r-BigInt(`0x${"f".padStart(2*a,"f")}`)-1n}function Ie(t,e={}){return Number(ke(t,e))}function Ae(t,e={}){let n=Fe(t);return e.size&&(Pe(n,{size:e.size}),n=xe(n,{dir:"right"})),(new TextDecoder).decode(n)}const Ee=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Oe(t,e={}){return"number"==typeof t||"bigint"==typeof t?Ce(t,e):"string"==typeof t?Ne(t,e):"boolean"==typeof t?Se(t,e):Te(t,e)}function Se(t,e={}){const n=`0x${Number(t)}`;return"number"==typeof e.size?(Pe(n,{size:e.size}),he(n,{size:e.size})):n}function Te(t,e={}){let n="";for(let e=0;e<t.length;e++)n+=Ee[t[e]];const r=`0x${n}`;return"number"==typeof e.size?(Pe(r,{size:e.size}),he(r,{dir:"right",size:e.size})):r}function Ce(t,e={}){const{signed:n,size:r}=e,a=BigInt(t);let s;r?s=n?(1n<<8n*BigInt(r)-1n)-1n:2n**(8n*BigInt(r))-1n:"number"==typeof t&&(s=BigInt(Number.MAX_SAFE_INTEGER));const i="bigint"==typeof s&&n?-s-1n:0;if(s&&a>s||a<i){const e="bigint"==typeof t?"n":"";throw new ye({max:s?`${s}${e}`:void 0,min:`${i}${e}`,signed:n,size:r,value:`${t}${e}`})}const o=`0x${(n&&a<0?(1n<<BigInt(8*r))+BigInt(a):a).toString(16)}`;return r?he(o,{size:r}):o}const Be=new TextEncoder;function Ne(t,e={}){return Te(Be.encode(t),e)}const je=new TextEncoder;function Ue(t,e={}){return"number"==typeof t||"bigint"==typeof t?function(t,e){const n=Ce(t,e);return Fe(n)}(t,e):"boolean"==typeof t?function(t,e={}){const n=new Uint8Array(1);if(n[0]=Number(t),"number"==typeof e.size)return Pe(n,{size:e.size}),he(n,{size:e.size});return n}(t,e):jt(t)?Fe(t,e):_e(t,e)}const Me={zero:48,nine:57,A:65,F:70,a:97,f:102};function Re(t){return t>=Me.zero&&t<=Me.nine?t-Me.zero:t>=Me.A&&t<=Me.F?t-(Me.A-10):t>=Me.a&&t<=Me.f?t-(Me.a-10):void 0}function Fe(t,e={}){let n=t;e.size&&(Pe(n,{size:e.size}),n=he(n,{dir:"right",size:e.size}));let r=n.slice(2);r.length%2&&(r=`0${r}`);const a=r.length/2,s=new Uint8Array(a);for(let t=0,e=0;t<a;t++){const n=Re(r.charCodeAt(e++)),a=Re(r.charCodeAt(e++));if(void 0===n||void 0===a)throw new _t(`Invalid byte sequence ("${r[e-2]}${r[e-1]}" in "${r}").`);s[t]=16*n+a}return s}function _e(t,e={}){const n=je.encode(t);return"number"==typeof e.size?(Pe(n,{size:e.size}),he(n,{dir:"right",size:e.size})):n}const ze=BigInt(2**32-1),De=BigInt(32);function Le(t,e=!1){return e?{h:Number(t&ze),l:Number(t>>De&ze)}:{h:0|Number(t>>De&ze),l:0|Number(t&ze)}}function Ge(t,e=!1){const n=t.length;let r=new Uint32Array(n),a=new Uint32Array(n);for(let s=0;s<n;s++){const{h:n,l:i}=Le(t[s],e);[r[s],a[s]]=[n,i]}return[r,a]}const qe=(t,e,n)=>t>>>n,He=(t,e,n)=>t<<32-n|e>>>n,Ve=(t,e,n)=>t>>>n|e<<32-n,Ke=(t,e,n)=>t<<32-n|e>>>n,We=(t,e,n)=>t<<64-n|e>>>n-32,Ze=(t,e,n)=>t>>>n-32|e<<64-n;function Je(t,e,n,r){const a=(e>>>0)+(r>>>0);return{h:t+n+(a/2**32|0)|0,l:0|a}}const Ye=(t,e,n)=>(t>>>0)+(e>>>0)+(n>>>0),Qe=(t,e,n,r)=>e+n+r+(t/2**32|0)|0,Xe=(t,e,n,r)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0),$e=(t,e,n,r,a)=>e+n+r+a+(t/2**32|0)|0,tn=(t,e,n,r,a)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0)+(a>>>0),en=(t,e,n,r,a,s)=>e+n+r+a+s+(t/2**32|0)|0,nn="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0;function rn(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function an(t,...e){if(!
|
|
2
2
|
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
3
3
|
function(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&"Uint8Array"===t.constructor.name}(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function sn(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function on(t,e){an(t);const n=e.outputLen;if(t.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function cn(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function un(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function dn(t,e){return t<<32-e|t>>>e}function ln(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}const fn=(()=>68===new Uint8Array(new Uint32Array([287454020]).buffer)[0])()?t=>t:function(t){for(let e=0;e<t.length;e++)t[e]=ln(t[e]);return t};function pn(t){return"string"==typeof t&&(t=function(t){if("string"!=typeof t)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(t))}(t)),an(t),t}class mn{}function hn(t){const e=e=>t().update(pn(e)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}function bn(t=32){if(nn&&"function"==typeof nn.getRandomValues)return nn.getRandomValues(new Uint8Array(t));if(nn&&"function"==typeof nn.randomBytes)return Uint8Array.from(nn.randomBytes(t));throw new Error("crypto.getRandomValues must be defined")}const yn=BigInt(0),gn=BigInt(1),vn=BigInt(2),wn=BigInt(7),xn=BigInt(256),Pn=BigInt(113),kn=[],In=[],An=[];for(let t=0,e=gn,n=1,r=0;t<24;t++){[n,r]=[r,(2*n+3*r)%5],kn.push(2*(5*r+n)),In.push((t+1)*(t+2)/2%64);let a=yn;for(let t=0;t<7;t++)e=(e<<gn^(e>>wn)*Pn)%xn,e&vn&&(a^=gn<<(gn<<BigInt(t))-gn);An.push(a)}const En=Ge(An,!0),On=En[0],Sn=En[1],Tn=(t,e,n)=>n>32?((t,e,n)=>e<<n-32|t>>>64-n)(t,e,n):((t,e,n)=>t<<n|e>>>32-n)(t,e,n),Cn=(t,e,n)=>n>32?((t,e,n)=>t<<n-32|e>>>64-n)(t,e,n):((t,e,n)=>e<<n|t>>>32-n)(t,e,n);class Bn extends mn{constructor(t,e,n,r=!1,a=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=t,this.suffix=e,this.outputLen=n,this.enableXOF=r,this.rounds=a,rn(n),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");var s;this.state=new Uint8Array(200),this.state32=(s=this.state,new Uint32Array(s.buffer,s.byteOffset,Math.floor(s.byteLength/4)))}clone(){return this._cloneInto()}keccak(){fn(this.state32),function(t,e=24){const n=new Uint32Array(10);for(let r=24-e;r<24;r++){for(let e=0;e<10;e++)n[e]=t[e]^t[e+10]^t[e+20]^t[e+30]^t[e+40];for(let e=0;e<10;e+=2){const r=(e+8)%10,a=(e+2)%10,s=n[a],i=n[a+1],o=Tn(s,i,1)^n[r],c=Cn(s,i,1)^n[r+1];for(let n=0;n<50;n+=10)t[e+n]^=o,t[e+n+1]^=c}let e=t[2],a=t[3];for(let n=0;n<24;n++){const r=In[n],s=Tn(e,a,r),i=Cn(e,a,r),o=kn[n];e=t[o],a=t[o+1],t[o]=s,t[o+1]=i}for(let e=0;e<50;e+=10){for(let r=0;r<10;r++)n[r]=t[e+r];for(let r=0;r<10;r++)t[e+r]^=~n[(r+2)%10]&n[(r+4)%10]}t[0]^=On[r],t[1]^=Sn[r]}cn(n)}(this.state32,this.rounds),fn(this.state32),this.posOut=0,this.pos=0}update(t){sn(this),an(t=pn(t));const{blockLen:e,state:n}=this,r=t.length;for(let a=0;a<r;){const s=Math.min(e-this.pos,r-a);for(let e=0;e<s;e++)n[this.pos++]^=t[a++];this.pos===e&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:e,pos:n,blockLen:r}=this;t[n]^=e,128&e&&n===r-1&&this.keccak(),t[r-1]^=128,this.keccak()}writeInto(t){sn(this,!1),an(t),this.finish();const e=this.state,{blockLen:n}=this;for(let r=0,a=t.length;r<a;){this.posOut>=n&&this.keccak();const s=Math.min(n-this.posOut,a-r);t.set(e.subarray(this.posOut,this.posOut+s),r),this.posOut+=s,r+=s}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return rn(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(on(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,cn(this.state)}_cloneInto(t){const{blockLen:e,suffix:n,outputLen:r,rounds:a,enableXOF:s}=this;return t||(t=new Bn(e,n,r,s,a)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=a,t.suffix=n,t.outputLen=r,t.enableXOF=s,t.destroyed=this.destroyed,t}}const Nn=(()=>{return t=1,e=136,n=32,hn(()=>new Bn(e,t,n));var t,e,n})();function jn(t,e){const n=e||"hex",r=Nn(jt(t,{strict:!1})?Ue(t):t);return"bytes"===n?r:Oe(r)}function Un(t){return jn(Ue(t))}const Mn=t=>{var e;return function(t){let e=!0,n="",r=0,a="",s=!1;for(let i=0;i<t.length;i++){const o=t[i];if(["(",")",","].includes(o)&&(e=!0),"("===o&&r++,")"===o&&r--,e)if(0!==r)" "!==o?(a+=o,n+=o):","!==t[i-1]&&","!==n&&",("!==n&&(n="",e=!1);else if(" "===o&&["event","function",""].includes(a))a="";else if(a+=o,")"===o){s=!0;break}}if(!s)throw new _t("Unable to normalize signature.");return a}("string"==typeof t?t:"function"===(e=t).type?`function ${e.name}(${Z(e.inputs)})${e.stateMutability&&"nonpayable"!==e.stateMutability?` ${e.stateMutability}`:""}${e.outputs?.length?` returns (${Z(e.outputs)})`:""}`:"event"===e.type?`event ${e.name}(${Z(e.inputs)})`:"error"===e.type?`error ${e.name}(${Z(e.inputs)})`:"constructor"===e.type?`constructor(${Z(e.inputs)})${"payable"===e.stateMutability?" payable":""}`:"fallback"===e.type?"fallback() external"+("payable"===e.stateMutability?" payable":""):"receive() external payable")};function Rn(t){return Un(Mn(t))}const Fn=Rn;let _n=class extends _t{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"})}},zn=class extends Map{constructor(t){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=t}get(t){const e=super.get(t);return super.has(t)&&void 0!==e&&(this.delete(t),super.set(t,e)),e}set(t,e){if(super.set(t,e),this.maxSize&&this.size>this.maxSize){const t=this.keys().next().value;t&&this.delete(t)}return this}};const Dn=new zn(8192);function Ln(t,e){if(Dn.has(`${t}.${e}`))return Dn.get(`${t}.${e}`);const n=t.substring(2).toLowerCase(),r=jn(_e(n),"bytes"),a=n.split("");for(let t=0;t<40;t+=2)r[t>>1]>>4>=8&&a[t]&&(a[t]=a[t].toUpperCase()),(15&r[t>>1])>=8&&a[t+1]&&(a[t+1]=a[t+1].toUpperCase());const s=`0x${a.join("")}`;return Dn.set(`${t}.${e}`,s),s}function Gn(t,e){if(!Vn(t,{strict:!1}))throw new _n({address:t});return Ln(t,e)}const qn=/^0x[a-fA-F0-9]{40}$/,Hn=new zn(8192);function Vn(t,e){const{strict:n=!0}=e??{},r=`${t}.${n}`;if(Hn.has(r))return Hn.get(r);const a=!(!qn.test(t)||t.toLowerCase()!==t&&n&&Ln(t)!==t);return Hn.set(r,a),a}function Kn(t){return"string"==typeof t[0]?Wn(t):function(t){let e=0;for(const n of t)e+=n.length;const n=new Uint8Array(e);let r=0;for(const e of t)n.set(e,r),r+=e.length;return n}(t)}function Wn(t){return`0x${t.reduce((t,e)=>t+e.replace("0x",""),"")}`}function Zn(t,e,n,{strict:r}={}){return jt(t,{strict:!1})?Xn(t,e,n,{strict:r}):Qn(t,e,n,{strict:r})}function Jn(t,e){if("number"==typeof e&&e>0&&e>Ut(t)-1)throw new fe({offset:e,position:"start",size:Ut(t)})}function Yn(t,e,n){if("number"==typeof e&&"number"==typeof n&&Ut(t)!==n-e)throw new fe({offset:n,position:"end",size:Ut(t)})}function Qn(t,e,n,{strict:r}={}){Jn(t,e);const a=t.slice(e,n);return r&&Yn(a,e,n),a}function Xn(t,e,n,{strict:r}={}){Jn(t,e);const a=`0x${t.replace("0x","").slice(2*(e??0),2*(n??t.length))}`;return r&&Yn(a,e,n),a}const $n=/^(.*)\[([0-9]*)\]$/,tr=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,er=/^(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 nr(t,e){if(t.length!==e.length)throw new Kt({expectedLength:t.length,givenLength:e.length});const n=function({params:t,values:e}){const n=[];for(let r=0;r<t.length;r++)n.push(rr({param:t[r],value:e[r]}));return n}({params:t,values:e}),r=ar(n);return 0===r.length?"0x":r}function rr({param:t,value:e}){const n=sr(t.type);if(n){const[r,a]=n;return function(t,{length:e,param:n}){const r=null===e;if(!Array.isArray(t))throw new ce(t);if(!r&&t.length!==e)throw new Ht({expectedLength:e,givenLength:t.length,type:`${n.type}[${e}]`});let a=!1;const s=[];for(let e=0;e<t.length;e++){const r=rr({param:n,value:t[e]});r.dynamic&&(a=!0),s.push(r)}if(r||a){const t=ar(s);if(r){const e=Ce(s.length,{size:32});return{dynamic:!0,encoded:s.length>0?Kn([e,t]):e}}if(a)return{dynamic:!0,encoded:t}}return{dynamic:!1,encoded:Kn(s.map(({encoded:t})=>t))}}(e,{length:r,param:{...t,type:a}})}if("tuple"===t.type)return function(t,{param:e}){let n=!1;const r=[];for(let a=0;a<e.components.length;a++){const s=e.components[a],i=rr({param:s,value:t[Array.isArray(t)?a:s.name]});r.push(i),i.dynamic&&(n=!0)}return{dynamic:n,encoded:n?ar(r):Kn(r.map(({encoded:t})=>t))}}(e,{param:t});if("address"===t.type)return function(t){if(!Vn(t))throw new _n({address:t});return{dynamic:!1,encoded:be(t.toLowerCase())}}(e);if("bool"===t.type)return function(t){if("boolean"!=typeof t)throw new _t(`Invalid boolean value: "${t}" (type: ${typeof t}). Expected: \`true\` or \`false\`.`);return{dynamic:!1,encoded:be(Se(t))}}(e);if(t.type.startsWith("uint")||t.type.startsWith("int")){const n=t.type.startsWith("int"),[,,r="256"]=er.exec(t.type)??[];return function(t,{signed:e,size:n=256}){if("number"==typeof n){const r=2n**(BigInt(n)-(e?1n:0n))-1n,a=e?-r-1n:0n;if(t>r||t<a)throw new ye({max:r.toString(),min:a.toString(),signed:e,size:n/8,value:t.toString()})}return{dynamic:!1,encoded:Ce(t,{size:32,signed:e})}}(e,{signed:n,size:Number(r)})}if(t.type.startsWith("bytes"))return function(t,{param:e}){const[,n]=e.type.split("bytes"),r=Ut(t);if(!n){let e=t;return r%32!=0&&(e=be(e,{dir:"right",size:32*Math.ceil((t.length-2)/2/32)})),{dynamic:!0,encoded:Kn([be(Ce(r,{size:32})),e])}}if(r!==Number.parseInt(n,10))throw new Vt({expectedSize:Number.parseInt(n,10),value:t});return{dynamic:!1,encoded:be(t,{dir:"right"})}}(e,{param:t});if("string"===t.type)return function(t){const e=Ne(t),n=Math.ceil(Ut(e)/32),r=[];for(let t=0;t<n;t++)r.push(be(Zn(e,32*t,32*(t+1)),{dir:"right"}));return{dynamic:!0,encoded:Kn([be(Ce(Ut(e),{size:32})),...r])}}(e);throw new ie(t.type,{docsPath:"/docs/contract/encodeAbiParameters"})}function ar(t){let e=0;for(let n=0;n<t.length;n++){const{dynamic:r,encoded:a}=t[n];e+=r?32:Ut(a)}const n=[],r=[];let a=0;for(let s=0;s<t.length;s++){const{dynamic:i,encoded:o}=t[s];i?(n.push(Ce(e+a,{size:32})),r.push(o),a+=Ut(o)):n.push(o)}return Kn([...n,...r])}function sr(t){const e=t.match(/^(.*)\[(\d+)?\]$/);return e?[e[2]?Number(e[2]):null,e[1]]:void 0}const ir=t=>Zn(Rn(t),0,4);function or(t){const{abi:e,args:n=[],name:r}=t,a=jt(r,{strict:!1}),s=e.filter(t=>a?"function"===t.type?ir(t)===r:"event"===t.type&&Fn(t)===r:"name"in t&&t.name===r);if(0===s.length)return;if(1===s.length)return s[0];let i;for(const t of s){if(!("inputs"in t))continue;if(!n||0===n.length){if(!t.inputs||0===t.inputs.length)return t;continue}if(!t.inputs)continue;if(0===t.inputs.length)continue;if(t.inputs.length!==n.length)continue;const e=n.every((e,n)=>{const r="inputs"in t&&t.inputs[n];return!!r&&cr(e,r)});if(e){if(i&&"inputs"in i&&i.inputs){const e=ur(t.inputs,i.inputs,n);if(e)throw new ne({abiItem:t,type:e[0]},{abiItem:i,type:e[1]})}i=t}}return i||s[0]}function cr(t,e){const n=typeof t,r=e.type;switch(r){case"address":return Vn(t,{strict:!1});case"bool":return"boolean"===n;case"function":case"string":return"string"===n;default:return"tuple"===r&&"components"in e?Object.values(e.components).every((e,n)=>cr(Object.values(t)[n],e)):/^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(r)?"number"===n||"bigint"===n:/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/.test(r)?"string"===n||t instanceof Uint8Array:!!/[a-z]+[1-9]{0,3}(\[[0-9]{0,}\])+$/.test(r)&&(Array.isArray(t)&&t.every(t=>cr(t,{...e,type:r.replace(/(\[[0-9]{0,}\])$/,"")})))}}function ur(t,e,n){for(const r in t){const a=t[r],s=e[r];if("tuple"===a.type&&"tuple"===s.type&&"components"in a&&"components"in s)return ur(a.components,s.components,n[r]);const i=[a.type,s.type];if((()=>!(!i.includes("address")||!i.includes("bytes20"))||(i.includes("address")&&i.includes("string")||!(!i.includes("address")||!i.includes("bytes")))&&Vn(n[r],{strict:!1}))())return i}}const dr="/docs/contract/encodeEventTopics";function lr(t){const{abi:e,eventName:n,args:r}=t;let a=e[0];if(n){const t=or({abi:e,name:n});if(!t)throw new Xt(n,{docsPath:dr});a=t}if("event"!==a.type)throw new Xt(void 0,{docsPath:dr});const s=Bt(a),i=Fn(s);let o=[];if(r&&"inputs"in a){const t=a.inputs?.filter(t=>"indexed"in t&&t.indexed),e=Array.isArray(r)?r:Object.values(r).length>0?t?.map(t=>r[t.name])??[]:[];e.length>0&&(o=t?.map((t,n)=>Array.isArray(e[n])?e[n].map((r,a)=>fr({param:t,value:e[n][a]})):void 0!==e[n]&&null!==e[n]?fr({param:t,value:e[n]}):null)??[])}return[i,...o]}function fr({param:t,value:e}){if("string"===t.type||"bytes"===t.type)return jn(Ue(e));if("tuple"===t.type||t.type.match(/^(.*)\[(\d+)?\]$/))throw new le(t.type);return nr([t],[e])}function pr(t,{method:e}){const n={};return"fallback"===t.transport.type&&t.transport.onResponse?.(({method:t,response:r,status:a,transport:s})=>{"success"===a&&e===t&&(n[r]=s.request)}),e=>n[e]||t.request}async function mr(t,e){const{address:n,abi:r,args:a,eventName:s,fromBlock:i,strict:o,toBlock:c}=e,u=pr(t,{method:"eth_newFilter"}),d=s?lr({abi:r,args:a,eventName:s}):void 0,l=await t.request({method:"eth_newFilter",params:[{address:n,fromBlock:"bigint"==typeof i?Ce(i):i,toBlock:"bigint"==typeof c?Ce(c):c,topics:d}]});return{abi:r,args:a,eventName:s,id:l,request:u(l),strict:Boolean(o),type:"event"}}function hr(t){return"string"==typeof t?{address:t,type:"json-rpc"}:t}const br="/docs/contract/encodeFunctionData";function yr(t){const{args:e}=t,{abi:n,functionName:r}=1===t.abi.length&&t.functionName?.startsWith("0x")?t:function(t){const{abi:e,args:n,functionName:r}=t;let a=e[0];if(r){const t=or({abi:e,args:n,name:r});if(!t)throw new $t(r,{docsPath:br});a=t}if("function"!==a.type)throw new $t(void 0,{docsPath:br});return{abi:[a],functionName:ir(Bt(a))}}(t),a=n[0];return Wn([r,("inputs"in a&&a.inputs?nr(a.inputs,e??[]):void 0)??"0x"])}const gr={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."},vr={inputs:[{name:"message",type:"string"}],name:"Error",type:"error"},wr={inputs:[{name:"reason",type:"uint256"}],name:"Panic",type:"error"};let xr=class extends _t{constructor({offset:t}){super(`Offset \`${t}\` cannot be negative.`,{name:"NegativeOffsetError"})}},Pr=class extends _t{constructor({length:t,position:e}){super(`Position \`${e}\` is out of bounds (\`0 < position < ${t}\`).`,{name:"PositionOutOfBoundsError"})}},kr=class extends _t{constructor({count:t,limit:e}){super(`Recursive read limit of \`${e}\` exceeded (recursive read count: \`${t}\`).`,{name:"RecursiveReadLimitExceededError"})}};const Ir={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 kr({count:this.recursiveReadCount+1,limit:this.recursiveReadLimit})},assertPosition(t){if(t<0||t>this.bytes.length-1)throw new Pr({length:this.bytes.length,position:t})},decrementPosition(t){if(t<0)throw new xr({offset:t});const e=this.position-t;this.assertPosition(e),this.position=e},getReadCount(t){return this.positionReadCount.get(t||this.position)||0},incrementPosition(t){if(t<0)throw new xr({offset:t});const e=this.position+t;this.assertPosition(e),this.position=e},inspectByte(t){const e=t??this.position;return this.assertPosition(e),this.bytes[e]},inspectBytes(t,e){const n=e??this.position;return this.assertPosition(n+t-1),this.bytes.subarray(n,n+t)},inspectUint8(t){const e=t??this.position;return this.assertPosition(e),this.bytes[e]},inspectUint16(t){const e=t??this.position;return this.assertPosition(e+1),this.dataView.getUint16(e)},inspectUint24(t){const e=t??this.position;return this.assertPosition(e+2),(this.dataView.getUint16(e)<<8)+this.dataView.getUint8(e+2)},inspectUint32(t){const e=t??this.position;return this.assertPosition(e+3),this.dataView.getUint32(e)},pushByte(t){this.assertPosition(this.position),this.bytes[this.position]=t,this.position++},pushBytes(t){this.assertPosition(this.position+t.length-1),this.bytes.set(t,this.position),this.position+=t.length},pushUint8(t){this.assertPosition(this.position),this.bytes[this.position]=t,this.position++},pushUint16(t){this.assertPosition(this.position+1),this.dataView.setUint16(this.position,t),this.position+=2},pushUint24(t){this.assertPosition(this.position+2),this.dataView.setUint16(this.position,t>>8),this.dataView.setUint8(this.position+2,255&t),this.position+=3},pushUint32(t){this.assertPosition(this.position+3),this.dataView.setUint32(this.position,t),this.position+=4},readByte(){this.assertReadLimit(),this._touch();const t=this.inspectByte();return this.position++,t},readBytes(t,e){this.assertReadLimit(),this._touch();const n=this.inspectBytes(t);return this.position+=e??t,n},readUint8(){this.assertReadLimit(),this._touch();const t=this.inspectUint8();return this.position+=1,t},readUint16(){this.assertReadLimit(),this._touch();const t=this.inspectUint16();return this.position+=2,t},readUint24(){this.assertReadLimit(),this._touch();const t=this.inspectUint24();return this.position+=3,t},readUint32(){this.assertReadLimit(),this._touch();const t=this.inspectUint32();return this.position+=4,t},get remaining(){return this.bytes.length-this.position},setPosition(t){const e=this.position;return this.assertPosition(t),this.position=t,()=>this.position=e},_touch(){if(this.recursiveReadLimit===Number.POSITIVE_INFINITY)return;const t=this.getReadCount();this.positionReadCount.set(this.position,t+1),t>0&&this.recursiveReadCount++}};function Ar(t,{recursiveReadLimit:e=8192}={}){const n=Object.create(Ir);return n.bytes=t,n.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength),n.positionReadCount=new Map,n.recursiveReadLimit=e,n}function Er(t,e={}){void 0!==e.size&&Pe(t,{size:e.size});return ke(Te(t,e),e)}function Or(t,e={}){let n=t;if(void 0!==e.size&&(Pe(n,{size:e.size}),n=xe(n)),n.length>1||n[0]>1)throw new ge(n);return Boolean(n[0])}function Sr(t,e={}){void 0!==e.size&&Pe(t,{size:e.size});return Ie(Te(t,e),e)}function Tr(t,e){const n="string"==typeof e?Fe(e):e,r=Ar(n);if(0===Ut(n)&&t.length>0)throw new qt;if(Ut(e)&&Ut(e)<32)throw new Gt({data:"string"==typeof e?e:Te(e),params:t,size:Ut(e)});let a=0;const s=[];for(let e=0;e<t.length;++e){const n=t[e];r.setPosition(a);const[i,o]=Cr(r,n,{staticPosition:0});a+=o,s.push(i)}return s}function Cr(t,e,{staticPosition:n}){const r=sr(e.type);if(r){const[a,s]=r;return function(t,e,{length:n,staticPosition:r}){if(!n){const n=r+Sr(t.readBytes(Nr)),a=n+Br;t.setPosition(n);const s=Sr(t.readBytes(Br)),i=jr(e);let o=0;const c=[];for(let n=0;n<s;++n){t.setPosition(a+(i?32*n:o));const[r,s]=Cr(t,e,{staticPosition:a});o+=s,c.push(r)}return t.setPosition(r+32),[c,32]}if(jr(e)){const a=r+Sr(t.readBytes(Nr)),s=[];for(let r=0;r<n;++r){t.setPosition(a+32*r);const[n]=Cr(t,e,{staticPosition:a});s.push(n)}return t.setPosition(r+32),[s,32]}let a=0;const s=[];for(let i=0;i<n;++i){const[n,i]=Cr(t,e,{staticPosition:r+a});a+=i,s.push(n)}return[s,a]}(t,{...e,type:s},{length:a,staticPosition:n})}if("tuple"===e.type)return function(t,e,{staticPosition:n}){const r=0===e.components.length||e.components.some(({name:t})=>!t),a=r?[]:{};let s=0;if(jr(e)){const i=n+Sr(t.readBytes(Nr));for(let n=0;n<e.components.length;++n){const o=e.components[n];t.setPosition(i+s);const[c,u]=Cr(t,o,{staticPosition:i});s+=u,a[r?n:o?.name]=c}return t.setPosition(n+32),[a,32]}for(let i=0;i<e.components.length;++i){const o=e.components[i],[c,u]=Cr(t,o,{staticPosition:n});a[r?i:o?.name]=c,s+=u}return[a,s]}(t,e,{staticPosition:n});if("address"===e.type)return function(t){const e=t.readBytes(32);return[Ln(Te(Qn(e,-20))),32]}(t);if("bool"===e.type)return function(t){return[Or(t.readBytes(32),{size:32}),32]}(t);if(e.type.startsWith("bytes"))return function(t,e,{staticPosition:n}){const[r,a]=e.type.split("bytes");if(!a){const e=Sr(t.readBytes(32));t.setPosition(n+e);const r=Sr(t.readBytes(32));if(0===r)return t.setPosition(n+32),["0x",32];const a=t.readBytes(r);return t.setPosition(n+32),[Te(a),32]}const s=Te(t.readBytes(Number.parseInt(a,10),32));return[s,32]}(t,e,{staticPosition:n});if(e.type.startsWith("uint")||e.type.startsWith("int"))return function(t,e){const n=e.type.startsWith("int"),r=Number.parseInt(e.type.split("int")[1]||"256",10),a=t.readBytes(32);return[r>48?Er(a,{signed:n}):Sr(a,{signed:n}),32]}(t,e);if("string"===e.type)return function(t,{staticPosition:e}){const n=Sr(t.readBytes(32)),r=e+n;t.setPosition(r);const a=Sr(t.readBytes(32));if(0===a)return t.setPosition(e+32),["",32];const s=t.readBytes(a,32),i=function(t,e={}){let n=t;return void 0!==e.size&&(Pe(n,{size:e.size}),n=xe(n,{dir:"right"})),(new TextDecoder).decode(n)}(xe(s));return t.setPosition(e+32),[i,32]}(t,{staticPosition:n});throw new oe(e.type,{docsPath:"/docs/contract/decodeAbiParameters"})}const Br=32,Nr=32;function jr(t){const{type:e}=t;if("string"===e)return!0;if("bytes"===e)return!0;if(e.endsWith("[]"))return!0;if("tuple"===e)return t.components?.some(jr);const n=sr(t.type);return!(!n||!jr({...t,type:n[1]}))}function Ur(t){const{abi:e,data:n}=t,r=Zn(n,0,4);if("0x"===r)throw new qt;const a=[...e||[],vr,wr].find(t=>"error"===t.type&&r===ir(Bt(t)));if(!a)throw new Jt(r,{docsPath:"/docs/contract/decodeErrorResult"});return{abiItem:a,args:"inputs"in a&&a.inputs&&a.inputs.length>0?Tr(a.inputs,Zn(n,4)):void 0,errorName:a.name}}const Mr=(t,e,n)=>JSON.stringify(t,(t,e)=>"bigint"==typeof e?e.toString():e,n);function Rr({abiItem:t,args:e,includeFunctionName:n=!0,includeName:r=!1}){if("name"in t&&"inputs"in t&&t.inputs)return`${n?t.name:""}(${t.inputs.map((t,n)=>`${r&&t.name?`${t.name}: `:""}${"object"==typeof e[n]?Mr(e[n]):e[n]}`).join(", ")})`}const Fr={gwei:9,wei:18},_r={ether:-9,wei:9};function zr(t,e){let n=t.toString();const r=n.startsWith("-");r&&(n=n.slice(1)),n=n.padStart(e,"0");let[a,s]=[n.slice(0,n.length-e),n.slice(n.length-e)];return s=s.replace(/(0+)$/,""),`${r?"-":""}${a||"0"}${s?`.${s}`:""}`}function Dr(t,e="wei"){return zr(t,Fr[e])}function Lr(t,e="wei"){return zr(t,_r[e])}class Gr extends _t{constructor({address:t}){super(`State for account "${t}" is set multiple times.`,{name:"AccountStateConflictError"})}}class qr extends _t{constructor(){super("state and stateDiff are set on the same account.",{name:"StateAssignmentConflictError"})}}function Hr(t){return t.reduce((t,{slot:e,value:n})=>`${t} ${e}: ${n}\n`,"")}function Vr(t){const e=Object.entries(t).map(([t,e])=>void 0===e||!1===e?null:[t,e]).filter(Boolean),n=e.reduce((t,[e])=>Math.max(t,e.length),0);return e.map(([t,e])=>` ${`${t}:`.padEnd(n+1)} ${e}`).join("\n")}class Kr extends _t{constructor(){super(["Cannot specify both a `gasPrice` and a `maxFeePerGas`/`maxPriorityFeePerGas`.","Use `maxFeePerGas`/`maxPriorityFeePerGas` for EIP-1559 compatible networks, and `gasPrice` for others."].join("\n"),{name:"FeeConflictError"})}}class Wr extends _t{constructor({v:t}){super(`Invalid \`v\` value "${t}". Expected 27 or 28.`,{name:"InvalidLegacyVError"})}}class Zr extends _t{constructor({transaction:t}){super("Cannot infer a transaction type from provided transaction.",{metaMessages:["Provided Transaction:","{",Vr(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 Jr extends _t{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 Yr extends _t{constructor({blockHash:t,blockNumber:e,blockTag:n,hash:r,index:a}){let s="Transaction";n&&void 0!==a&&(s=`Transaction at block time "${n}" at index "${a}"`),t&&void 0!==a&&(s=`Transaction at block hash "${t}" at index "${a}"`),e&&void 0!==a&&(s=`Transaction at block number "${e}" at index "${a}"`),r&&(s=`Transaction with hash "${r}"`),super(`${s} could not be found.`,{name:"TransactionNotFoundError"})}}class Qr extends _t{constructor({hash:t}){super(`Transaction receipt with hash "${t}" could not be found. The Transaction may not be processed on a block yet.`,{name:"TransactionReceiptNotFoundError"})}}class Xr extends _t{constructor({receipt:t}){super(`Transaction with hash "${t.transactionHash}" reverted.`,{metaMessages:['The receipt marked the transaction as "reverted". This could mean that the function on the contract you are trying to call threw an error.'," ","You can attempt to extract the revert reason by:","- calling the `simulateContract` or `simulateCalls` Action with the `abi` and `functionName` of the contract","- using the `call` Action with raw `data`"],name:"TransactionReceiptRevertedError"}),Object.defineProperty(this,"receipt",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.receipt=t}}class $r extends _t{constructor({hash:t}){super(`Timed out while waiting for transaction with hash "${t}" to be confirmed.`,{name:"WaitForTransactionReceiptTimeoutError"})}}class ta extends _t{constructor(t,{account:e,docsPath:n,chain:r,data:a,gas:s,gasPrice:i,maxFeePerGas:o,maxPriorityFeePerGas:c,nonce:u,to:d,value:l,stateOverride:f}){const p=e?hr(e):void 0;let m=Vr({from:p?.address,to:d,value:void 0!==l&&`${Dr(l)} ${r?.nativeCurrency?.symbol||"ETH"}`,data:a,gas:s,gasPrice:void 0!==i&&`${Lr(i)} gwei`,maxFeePerGas:void 0!==o&&`${Lr(o)} gwei`,maxPriorityFeePerGas:void 0!==c&&`${Lr(c)} gwei`,nonce:u});f&&(m+=`\n${function(t){return t.reduce((t,{address:e,...n})=>{let r=`${t} ${e}:\n`;return n.nonce&&(r+=` nonce: ${n.nonce}\n`),n.balance&&(r+=` balance: ${n.balance}\n`),n.code&&(r+=` code: ${n.code}\n`),n.state&&(r+=" state:\n",r+=Hr(n.state)),n.stateDiff&&(r+=" stateDiff:\n",r+=Hr(n.stateDiff)),r}," State Override:\n").slice(0,-1)}(f)}`),super(t.shortMessage,{cause:t,docsPath:n,metaMessages:[...t.metaMessages?[...t.metaMessages," "]:[],"Raw Call Arguments:",m].filter(Boolean),name:"CallExecutionError"}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.cause=t}}class ea extends _t{constructor(t,{abi:e,args:n,contractAddress:r,docsPath:a,functionName:s,sender:i}){const o=or({abi:e,args:n,name:s}),c=o?Rr({abiItem:o,args:n,includeFunctionName:!1,includeName:!1}):void 0,u=Vr({address:r&&r,function:o?Bt(o,{includeName:!0}):void 0,args:c&&"()"!==c&&`${[...Array(s?.length??0).keys()].map(()=>" ").join("")}${c}`,sender:i});super(t.shortMessage||`An unknown error occurred while executing the contract function "${s}".`,{cause:t,docsPath:a,metaMessages:[...t.metaMessages?[...t.metaMessages," "]:[],u&&"Contract Call:",u].filter(Boolean),name:"ContractFunctionExecutionError"}),Object.defineProperty(this,"abi",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"args",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"contractAddress",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"formattedArgs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"functionName",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"sender",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.abi=e,this.args=n,this.cause=t,this.contractAddress=r,this.functionName=s,this.sender=i}}class na extends _t{constructor({abi:t,data:e,functionName:n,message:r}){let a,s,i,o,c;if(e&&"0x"!==e)try{s=Ur({abi:t,data:e});const{abiItem:n,errorName:r,args:a}=s;if("Error"===r)o=a[0];else if("Panic"===r){const[t]=a;o=gr[t]}else{const t=n?Bt(n,{includeName:!0}):void 0,e=n&&a?Rr({abiItem:n,args:a,includeFunctionName:!1,includeName:!1}):void 0;i=[t?`Error: ${t}`:"",e&&"()"!==e?` ${[...Array(r?.length??0).keys()].map(()=>" ").join("")}${e}`:""]}}catch(t){a=t}else r&&(o=r);a instanceof Jt&&(c=a.signature,i=[`Unable to decode signature "${c}" as it was not found on the provided 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=${c}.`]),super(o&&"execution reverted"!==o||c?[`The contract function "${n}" reverted with the following ${c?"signature":"reason"}:`,o||c].join("\n"):`The contract function "${n}" reverted.`,{cause:a,metaMessages:i,name:"ContractFunctionRevertedError"}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"raw",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"reason",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"signature",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.data=s,this.raw=e,this.reason=o,this.signature=c}}class ra extends _t{constructor({functionName:t}){super(`The contract function "${t}" returned no data ("0x").`,{metaMessages:["This could be due to any of the following:",` - The contract does not have the function "${t}",`," - The parameters passed to the contract function may be invalid, or"," - The address is not a contract."],name:"ContractFunctionZeroDataError"})}}class aa extends _t{constructor({factory:t}){super("Deployment for counterfactual contract call failed"+(t?` for factory "${t}".`:""),{metaMessages:["Please ensure:","- The `factory` is a valid contract deployment factory (ie. Create2 Factory, ERC-4337 Factory, etc).","- The `factoryData` is a valid encoded function call for contract deployment function on the factory."],name:"CounterfactualDeploymentFailedError"})}}class sa extends _t{constructor({data:t,message:e}){super(e||"",{name:"RawContractError"}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:3}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.data=t}}class ia extends _t{constructor({body:t,cause:e,details:n,headers:r,status:a,url:s}){super("HTTP request failed.",{cause:e,details:n,metaMessages:[a&&`Status: ${a}`,`URL: ${s}`,t&&`Request body: ${Mr(t)}`].filter(Boolean),name:"HttpRequestError"}),Object.defineProperty(this,"body",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"headers",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"status",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"url",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.body=t,this.headers=r,this.status=a,this.url=s}}class oa extends _t{constructor({body:t,error:e,url:n}){super("RPC Request failed.",{cause:e,details:e.message,metaMessages:[`URL: ${n}`,`Request body: ${Mr(t)}`],name:"RpcRequestError"}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.code=e.code,this.data=e.data}}class ca extends _t{constructor({body:t,url:e}){super("The request took too long to respond.",{details:"The request timed out.",metaMessages:[`URL: ${e}`,`Request body: ${Mr(t)}`],name:"TimeoutError"})}}class ua extends _t{constructor(t,{code:e,docsPath:n,metaMessages:r,name:a,shortMessage:s}){super(s,{cause:t,docsPath:n,metaMessages:r||t?.metaMessages,name:a||"RpcError"}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name=a||t.name,this.code=t instanceof oa?t.code:e??-1}}class da extends ua{constructor(t,e){super(t,e),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.data=e.data}}class la extends ua{constructor(t){super(t,{code:la.code,name:"ParseRpcError",shortMessage:"Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."})}}Object.defineProperty(la,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32700});class fa extends ua{constructor(t){super(t,{code:fa.code,name:"InvalidRequestRpcError",shortMessage:"JSON is not a valid request object."})}}Object.defineProperty(fa,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32600});class pa extends ua{constructor(t,{method:e}={}){super(t,{code:pa.code,name:"MethodNotFoundRpcError",shortMessage:`The method${e?` "${e}"`:""} does not exist / is not available.`})}}Object.defineProperty(pa,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32601});class ma extends ua{constructor(t){super(t,{code:ma.code,name:"InvalidParamsRpcError",shortMessage:["Invalid parameters were provided to the RPC method.","Double check you have provided the correct parameters."].join("\n")})}}Object.defineProperty(ma,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32602});class ha extends ua{constructor(t){super(t,{code:ha.code,name:"InternalRpcError",shortMessage:"An internal error was received."})}}Object.defineProperty(ha,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32603});class ba extends ua{constructor(t){super(t,{code:ba.code,name:"InvalidInputRpcError",shortMessage:["Missing or invalid parameters.","Double check you have provided the correct parameters."].join("\n")})}}Object.defineProperty(ba,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32e3});class ya extends ua{constructor(t){super(t,{code:ya.code,name:"ResourceNotFoundRpcError",shortMessage:"Requested resource not found."}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ResourceNotFoundRpcError"})}}Object.defineProperty(ya,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32001});class ga extends ua{constructor(t){super(t,{code:ga.code,name:"ResourceUnavailableRpcError",shortMessage:"Requested resource not available."})}}Object.defineProperty(ga,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32002});class va extends ua{constructor(t){super(t,{code:va.code,name:"TransactionRejectedRpcError",shortMessage:"Transaction creation failed."})}}Object.defineProperty(va,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32003});class wa extends ua{constructor(t,{method:e}={}){super(t,{code:wa.code,name:"MethodNotSupportedRpcError",shortMessage:`Method${e?` "${e}"`:""} is not supported.`})}}Object.defineProperty(wa,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32004});class xa extends ua{constructor(t){super(t,{code:xa.code,name:"LimitExceededRpcError",shortMessage:"Request exceeds defined limit."})}}Object.defineProperty(xa,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32005});class Pa extends ua{constructor(t){super(t,{code:Pa.code,name:"JsonRpcVersionUnsupportedError",shortMessage:"Version of JSON-RPC protocol is not supported."})}}Object.defineProperty(Pa,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32006});class ka extends da{constructor(t){super(t,{code:ka.code,name:"UserRejectedRequestError",shortMessage:"User rejected the request."})}}Object.defineProperty(ka,"code",{enumerable:!0,configurable:!0,writable:!0,value:4001});class Ia extends da{constructor(t){super(t,{code:Ia.code,name:"UnauthorizedProviderError",shortMessage:"The requested method and/or account has not been authorized by the user."})}}Object.defineProperty(Ia,"code",{enumerable:!0,configurable:!0,writable:!0,value:4100});class Aa extends da{constructor(t,{method:e}={}){super(t,{code:Aa.code,name:"UnsupportedProviderMethodError",shortMessage:`The Provider does not support the requested method${e?` " ${e}"`:""}.`})}}Object.defineProperty(Aa,"code",{enumerable:!0,configurable:!0,writable:!0,value:4200});class Ea extends da{constructor(t){super(t,{code:Ea.code,name:"ProviderDisconnectedError",shortMessage:"The Provider is disconnected from all chains."})}}Object.defineProperty(Ea,"code",{enumerable:!0,configurable:!0,writable:!0,value:4900});class Oa extends da{constructor(t){super(t,{code:Oa.code,name:"ChainDisconnectedError",shortMessage:"The Provider is not connected to the requested chain."})}}Object.defineProperty(Oa,"code",{enumerable:!0,configurable:!0,writable:!0,value:4901});class Sa extends da{constructor(t){super(t,{code:Sa.code,name:"SwitchChainError",shortMessage:"An error occurred when attempting to switch chain."})}}Object.defineProperty(Sa,"code",{enumerable:!0,configurable:!0,writable:!0,value:4902});class Ta extends da{constructor(t){super(t,{code:Ta.code,name:"UnsupportedNonOptionalCapabilityError",shortMessage:"This Wallet does not support a capability that was not marked as optional."})}}Object.defineProperty(Ta,"code",{enumerable:!0,configurable:!0,writable:!0,value:5700});class Ca extends da{constructor(t){super(t,{code:Ca.code,name:"UnsupportedChainIdError",shortMessage:"This Wallet does not support the requested chain ID."})}}Object.defineProperty(Ca,"code",{enumerable:!0,configurable:!0,writable:!0,value:5710});class Ba extends da{constructor(t){super(t,{code:Ba.code,name:"DuplicateIdError",shortMessage:"There is already a bundle submitted with this ID."})}}Object.defineProperty(Ba,"code",{enumerable:!0,configurable:!0,writable:!0,value:5720});class Na extends da{constructor(t){super(t,{code:Na.code,name:"UnknownBundleIdError",shortMessage:"This bundle id is unknown / has not been submitted"})}}Object.defineProperty(Na,"code",{enumerable:!0,configurable:!0,writable:!0,value:5730});class ja extends da{constructor(t){super(t,{code:ja.code,name:"BundleTooLargeError",shortMessage:"The call bundle is too large for the Wallet to process."})}}Object.defineProperty(ja,"code",{enumerable:!0,configurable:!0,writable:!0,value:5740});class Ua extends da{constructor(t){super(t,{code:Ua.code,name:"AtomicReadyWalletRejectedUpgradeError",shortMessage:"The Wallet can support atomicity after an upgrade, but the user rejected the upgrade."})}}Object.defineProperty(Ua,"code",{enumerable:!0,configurable:!0,writable:!0,value:5750});class Ma extends da{constructor(t){super(t,{code:Ma.code,name:"AtomicityNotSupportedError",shortMessage:"The wallet does not support atomic execution but the request requires it."})}}Object.defineProperty(Ma,"code",{enumerable:!0,configurable:!0,writable:!0,value:5760});class Ra extends ua{constructor(t){super(t,{name:"UnknownRpcError",shortMessage:"An unknown RPC error occurred."})}}const Fa=3;function _a(t,{abi:e,address:n,args:r,docsPath:a,functionName:s,sender:i}){const o=t instanceof sa?t:t instanceof _t?t.walk(t=>"data"in t)||t.walk():{},{code:c,data:u,details:d,message:l,shortMessage:f}=o,p=t instanceof qt?new ra({functionName:s}):[Fa,ha.code].includes(c)&&(u||d||l||f)?new na({abi:e,data:"object"==typeof u?u.data:u,functionName:s,message:o instanceof oa?d:f??l}):t;return new ea(p,{abi:e,args:r,contractAddress:n,docsPath:a,functionName:s,sender:i})}function za(t){if(0===t||1===t)return t;if(27===t)return 0;if(28===t)return 1;throw new Error("Invalid yParityOrV value")}async function Da({hash:t,signature:e}){return n=await async function({hash:t,signature:e}){const n=jt(t)?t:Oe(t),{secp256k1:r}=await Promise.resolve().then(function(){return ep}),a=(()=>{if("object"==typeof e&&"r"in e&&"s"in e){const{r:t,s:n,v:a,yParity:s}=e,i=za(Number(s??a));return new r.Signature(ke(t),ke(n)).addRecoveryBit(i)}const t=jt(e)?e:Oe(e);if(65!==Ut(t))throw new Error("invalid signature length");const n=za(Ie(`0x${t.slice(130)}`));return r.Signature.fromCompact(t.substring(2,130)).addRecoveryBit(n)})();return`0x${a.recoverPublicKey(n.substring(2)).toHex(!1)}`}({hash:t,signature:e}),Ln(`0x${jn(`0x${n.substring(4)}`).substring(26)}`);var n}function La(t,e="hex"){const n=Ga(t),r=Ar(new Uint8Array(n.length));return n.encode(r),"hex"===e?Te(r.bytes):r.bytes}function Ga(t){return Array.isArray(t)?function(t){const e=t.reduce((t,e)=>t+e.length,0),n=qa(e);return{length:e<=55?1+e:1+n+e,encode(r){e<=55?r.pushByte(192+e):(r.pushByte(247+n),1===n?r.pushUint8(e):2===n?r.pushUint16(e):3===n?r.pushUint24(e):r.pushUint32(e));for(const{encode:e}of t)e(r)}}}(t.map(t=>Ga(t))):function(t){const e="string"==typeof t?Fe(t):t,n=qa(e.length),r=1===e.length&&e[0]<128?1:e.length<=55?1+e.length:1+n+e.length;return{length:r,encode(t){1===e.length&&e[0]<128?t.pushBytes(e):e.length<=55?(t.pushByte(128+e.length),t.pushBytes(e)):(t.pushByte(183+n),1===n?t.pushUint8(e.length):2===n?t.pushUint16(e.length):3===n?t.pushUint24(e.length):t.pushUint32(e.length),t.pushBytes(e))}}}(t)}function qa(t){if(t<256)return 1;if(t<65536)return 2;if(t<2**24)return 3;if(t<2**32)return 4;throw new _t("Length is too large.")}function Ha(t){const{chainId:e,nonce:n,to:r}=t,a=t.contractAddress??t.address,s=jn(Wn(["0x05",La([e?Ce(e):"0x",a,n?Ce(n):"0x"])]));return"bytes"===r?Fe(s):s}async function Va(t){const{authorization:e,signature:n}=t;return Da({hash:Ha(e),signature:n??e})}class Ka extends _t{constructor(t,{account:e,docsPath:n,chain:r,data:a,gas:s,gasPrice:i,maxFeePerGas:o,maxPriorityFeePerGas:c,nonce:u,to:d,value:l}){const f=Vr({from:e?.address,to:d,value:void 0!==l&&`${Dr(l)} ${r?.nativeCurrency?.symbol||"ETH"}`,data:a,gas:s,gasPrice:void 0!==i&&`${Lr(i)} gwei`,maxFeePerGas:void 0!==o&&`${Lr(o)} gwei`,maxPriorityFeePerGas:void 0!==c&&`${Lr(c)} gwei`,nonce:u});super(t.shortMessage,{cause:t,docsPath:n,metaMessages:[...t.metaMessages?[...t.metaMessages," "]:[],"Estimate Gas Arguments:",f].filter(Boolean),name:"EstimateGasExecutionError"}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.cause=t}}let Wa=class extends _t{constructor({cause:t,message:e}={}){const n=e?.replace("execution reverted: ","")?.replace("execution reverted","");super(`Execution reverted ${n?`with reason: ${n}`:"for an unknown reason"}.`,{cause:t,name:"ExecutionRevertedError"})}};Object.defineProperty(Wa,"code",{enumerable:!0,configurable:!0,writable:!0,value:3}),Object.defineProperty(Wa,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/execution reverted/});class Za extends _t{constructor({cause:t,maxFeePerGas:e}={}){super(`The fee cap (\`maxFeePerGas\`${e?` = ${Lr(e)} gwei`:""}) cannot be higher than the maximum allowed value (2^256-1).`,{cause:t,name:"FeeCapTooHighError"})}}Object.defineProperty(Za,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max fee per gas higher than 2\^256-1|fee cap higher than 2\^256-1/});class Ja extends _t{constructor({cause:t,maxFeePerGas:e}={}){super(`The fee cap (\`maxFeePerGas\`${e?` = ${Lr(e)}`:""} gwei) cannot be lower than the block base fee.`,{cause:t,name:"FeeCapTooLowError"})}}Object.defineProperty(Ja,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max fee per gas less than block base fee|fee cap less than block base fee|transaction is outdated/});class Ya extends _t{constructor({cause:t,nonce:e}={}){super(`Nonce provided for the transaction ${e?`(${e}) `:""}is higher than the next one expected.`,{cause:t,name:"NonceTooHighError"})}}Object.defineProperty(Ya,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too high/});class Qa extends _t{constructor({cause:t,nonce:e}={}){super([`Nonce provided for the transaction ${e?`(${e}) `:""}is lower than the current nonce of the account.`,"Try increasing the nonce or find the latest nonce with `getTransactionCount`."].join("\n"),{cause:t,name:"NonceTooLowError"})}}Object.defineProperty(Qa,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too low|transaction already imported|already known/});class Xa extends _t{constructor({cause:t,nonce:e}={}){super(`Nonce provided for the transaction ${e?`(${e}) `:""}exceeds the maximum allowed nonce.`,{cause:t,name:"NonceMaxValueError"})}}Object.defineProperty(Xa,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce has max value/});class $a extends _t{constructor({cause:t}={}){super(["The total cost (gas * gas fee + value) of executing this transaction exceeds the balance of the account."].join("\n"),{cause:t,metaMessages:["This error could arise when the account does not have enough funds to:"," - pay for the total gas fee,"," - pay for the value to send."," ","The cost of the transaction is calculated as `gas * gas fee + value`, where:"," - `gas` is the amount of gas needed for transaction to execute,"," - `gas fee` is the gas fee,"," - `value` is the amount of ether to send to the recipient."],name:"InsufficientFundsError"})}}Object.defineProperty($a,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/insufficient funds|exceeds transaction sender account balance/});class ts extends _t{constructor({cause:t,gas:e}={}){super(`The amount of gas ${e?`(${e}) `:""}provided for the transaction exceeds the limit allowed for the block.`,{cause:t,name:"IntrinsicGasTooHighError"})}}Object.defineProperty(ts,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too high|gas limit reached/});class es extends _t{constructor({cause:t,gas:e}={}){super(`The amount of gas ${e?`(${e}) `:""}provided for the transaction is too low.`,{cause:t,name:"IntrinsicGasTooLowError"})}}Object.defineProperty(es,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too low/});class ns extends _t{constructor({cause:t}){super("The transaction type is not supported for this chain.",{cause:t,name:"TransactionTypeNotSupportedError"})}}Object.defineProperty(ns,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/transaction type not valid/});class rs extends _t{constructor({cause:t,maxPriorityFeePerGas:e,maxFeePerGas:n}={}){super([`The provided tip (\`maxPriorityFeePerGas\`${e?` = ${Lr(e)} gwei`:""}) cannot be higher than the fee cap (\`maxFeePerGas\`${n?` = ${Lr(n)} gwei`:""}).`].join("\n"),{cause:t,name:"TipAboveFeeCapError"})}}Object.defineProperty(rs,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max priority fee per gas higher than max fee per gas|tip higher than fee cap/});class as extends _t{constructor({cause:t}){super(`An error occurred while executing: ${t?.shortMessage}`,{cause:t,name:"UnknownNodeError"})}}function ss(t,e){const n=(t.details||"").toLowerCase(),r=t instanceof _t?t.walk(t=>t?.code===Wa.code):t;return r instanceof _t?new Wa({cause:t,message:r.details}):Wa.nodeMessage.test(n)?new Wa({cause:t,message:t.details}):Za.nodeMessage.test(n)?new Za({cause:t,maxFeePerGas:e?.maxFeePerGas}):Ja.nodeMessage.test(n)?new Ja({cause:t,maxFeePerGas:e?.maxFeePerGas}):Ya.nodeMessage.test(n)?new Ya({cause:t,nonce:e?.nonce}):Qa.nodeMessage.test(n)?new Qa({cause:t,nonce:e?.nonce}):Xa.nodeMessage.test(n)?new Xa({cause:t,nonce:e?.nonce}):$a.nodeMessage.test(n)?new $a({cause:t}):ts.nodeMessage.test(n)?new ts({cause:t,gas:e?.gas}):es.nodeMessage.test(n)?new es({cause:t,gas:e?.gas}):ns.nodeMessage.test(n)?new ns({cause:t}):rs.nodeMessage.test(n)?new rs({cause:t,maxFeePerGas:e?.maxFeePerGas,maxPriorityFeePerGas:e?.maxPriorityFeePerGas}):new as({cause:t})}function is(t,{format:e}){if(!e)return{};const n={};return function e(r){const a=Object.keys(r);for(const s of a)s in t&&(n[s]=t[s]),r[s]&&"object"==typeof r[s]&&!Array.isArray(r[s])&&e(r[s])}(e(t||{})),n}function os(t,e){return({exclude:n,format:r})=>({exclude:n,format:(t,a)=>{const s=e(t,a);if(n)for(const t of n)delete s[t];return{...s,...r(t,a)}},type:t})}const cs={legacy:"0x0",eip2930:"0x1",eip1559:"0x2",eip4844:"0x3",eip7702:"0x4"};function us(t,e){const n={};return void 0!==t.authorizationList&&(n.authorizationList=t.authorizationList.map(t=>({address:t.address,r:t.r?Ce(BigInt(t.r)):t.r,s:t.s?Ce(BigInt(t.s)):t.s,chainId:Ce(t.chainId),nonce:Ce(t.nonce),...void 0!==t.yParity?{yParity:Ce(t.yParity)}:{},...void 0!==t.v&&void 0===t.yParity?{v:Ce(t.v)}:{}}))),void 0!==t.accessList&&(n.accessList=t.accessList),void 0!==t.blobVersionedHashes&&(n.blobVersionedHashes=t.blobVersionedHashes),void 0!==t.blobs&&("string"!=typeof t.blobs[0]?n.blobs=t.blobs.map(t=>Te(t)):n.blobs=t.blobs),void 0!==t.data&&(n.data=t.data),t.account&&(n.from=t.account.address),void 0!==t.from&&(n.from=t.from),void 0!==t.gas&&(n.gas=Ce(t.gas)),void 0!==t.gasPrice&&(n.gasPrice=Ce(t.gasPrice)),void 0!==t.maxFeePerBlobGas&&(n.maxFeePerBlobGas=Ce(t.maxFeePerBlobGas)),void 0!==t.maxFeePerGas&&(n.maxFeePerGas=Ce(t.maxFeePerGas)),void 0!==t.maxPriorityFeePerGas&&(n.maxPriorityFeePerGas=Ce(t.maxPriorityFeePerGas)),void 0!==t.nonce&&(n.nonce=Ce(t.nonce)),void 0!==t.to&&(n.to=t.to),void 0!==t.type&&(n.type=cs[t.type]),void 0!==t.value&&(n.value=Ce(t.value)),n}function ds(t){if(t&&0!==t.length)return t.reduce((t,{slot:e,value:n})=>{if(66!==e.length)throw new me({size:e.length,targetSize:66,type:"hex"});if(66!==n.length)throw new me({size:n.length,targetSize:66,type:"hex"});return t[e]=n,t},{})}function ls(t){const{balance:e,nonce:n,state:r,stateDiff:a,code:s}=t,i={};if(void 0!==s&&(i.code=s),void 0!==e&&(i.balance=Ce(e)),void 0!==n&&(i.nonce=Ce(n)),void 0!==r&&(i.state=ds(r)),void 0!==a){if(i.state)throw new qr;i.stateDiff=ds(a)}return i}function fs(t){if(!t)return;const e={};for(const{address:n,...r}of t){if(!Vn(n,{strict:!1}))throw new _n({address:n});if(e[n])throw new Gr({address:n});e[n]=ls(r)}return e}const ps=2n**256n-1n;function ms(t){const{account:e,gasPrice:n,maxFeePerGas:r,maxPriorityFeePerGas:a,to:s}=t,i=e?hr(e):void 0;if(i&&!Vn(i.address))throw new _n({address:i.address});if(s&&!Vn(s))throw new _n({address:s});if(void 0!==n&&(void 0!==r||void 0!==a))throw new Kr;if(r&&r>ps)throw new Za({maxFeePerGas:r});if(a&&r&&a>r)throw new rs({maxFeePerGas:r,maxPriorityFeePerGas:a})}class hs extends _t{constructor(){super("`baseFeeMultiplier` must be greater than 1.",{name:"BaseFeeScalarError"})}}class bs extends _t{constructor(){super("Chain does not support EIP-1559 fees.",{name:"Eip1559FeesNotSupportedError"})}}class ys extends _t{constructor({maxPriorityFeePerGas:t}){super(`\`maxFeePerGas\` cannot be less than the \`maxPriorityFeePerGas\` (${Lr(t)} gwei).`,{name:"MaxFeePerGasTooLowError"})}}class gs extends _t{constructor({blockHash:t,blockNumber:e}){let n="Block";t&&(n=`Block at hash "${t}"`),e&&(n=`Block at number "${e}"`),super(`${n} could not be found.`,{name:"BlockNotFoundError"})}}const vs={"0x0":"legacy","0x1":"eip2930","0x2":"eip1559","0x3":"eip4844","0x4":"eip7702"};function ws(t,e){const n={...t,blockHash:t.blockHash?t.blockHash:null,blockNumber:t.blockNumber?BigInt(t.blockNumber):null,chainId:t.chainId?Ie(t.chainId):void 0,gas:t.gas?BigInt(t.gas):void 0,gasPrice:t.gasPrice?BigInt(t.gasPrice):void 0,maxFeePerBlobGas:t.maxFeePerBlobGas?BigInt(t.maxFeePerBlobGas):void 0,maxFeePerGas:t.maxFeePerGas?BigInt(t.maxFeePerGas):void 0,maxPriorityFeePerGas:t.maxPriorityFeePerGas?BigInt(t.maxPriorityFeePerGas):void 0,nonce:t.nonce?Ie(t.nonce):void 0,to:t.to?t.to:null,transactionIndex:t.transactionIndex?Number(t.transactionIndex):null,type:t.type?vs[t.type]:void 0,typeHex:t.type?t.type:void 0,value:t.value?BigInt(t.value):void 0,v:t.v?BigInt(t.v):void 0};return t.authorizationList&&(n.authorizationList=t.authorizationList.map(t=>({address:t.address,chainId:Number(t.chainId),nonce:Number(t.nonce),r:t.r,s:t.s,yParity:Number(t.yParity)}))),n.yParity=(()=>{if(t.yParity)return Number(t.yParity);if("bigint"==typeof n.v){if(0n===n.v||27n===n.v)return 0;if(1n===n.v||28n===n.v)return 1;if(n.v>=35n)return n.v%2n==0n?1:0}})(),"legacy"===n.type&&(delete n.accessList,delete n.maxFeePerBlobGas,delete n.maxFeePerGas,delete n.maxPriorityFeePerGas,delete n.yParity),"eip2930"===n.type&&(delete n.maxFeePerBlobGas,delete n.maxFeePerGas,delete n.maxPriorityFeePerGas),"eip1559"===n.type&&delete n.maxFeePerBlobGas,n}const xs=os("transaction",ws);function Ps(t,e){const n=(t.transactions??[]).map(t=>"string"==typeof t?t:ws(t));return{...t,baseFeePerGas:t.baseFeePerGas?BigInt(t.baseFeePerGas):null,blobGasUsed:t.blobGasUsed?BigInt(t.blobGasUsed):void 0,difficulty:t.difficulty?BigInt(t.difficulty):void 0,excessBlobGas:t.excessBlobGas?BigInt(t.excessBlobGas):void 0,gasLimit:t.gasLimit?BigInt(t.gasLimit):void 0,gasUsed:t.gasUsed?BigInt(t.gasUsed):void 0,hash:t.hash?t.hash:null,logsBloom:t.logsBloom?t.logsBloom:null,nonce:t.nonce?t.nonce:null,number:t.number?BigInt(t.number):null,size:t.size?BigInt(t.size):void 0,timestamp:t.timestamp?BigInt(t.timestamp):void 0,transactions:n,totalDifficulty:t.totalDifficulty?BigInt(t.totalDifficulty):null}}const ks=os("block",Ps);async function Is(t,{blockHash:e,blockNumber:n,blockTag:r=t.experimental_blockTag??"latest",includeTransactions:a}={}){const s=a??!1,i=void 0!==n?Ce(n):void 0;let o=null;if(o=e?await t.request({method:"eth_getBlockByHash",params:[e,s]},{dedupe:!0}):await t.request({method:"eth_getBlockByNumber",params:[i||r,s]},{dedupe:Boolean(i)}),!o)throw new gs({blockHash:e,blockNumber:n});return(t.chain?.formatters?.block?.format||Ps)(o,"getBlock")}async function As(t){const e=await t.request({method:"eth_gasPrice"});return BigInt(e)}async function Es(t,e){const{block:n,chain:r=t.chain,request:a}=e||{};try{const e=r?.fees?.maxPriorityFeePerGas??r?.fees?.defaultPriorityFee;if("function"==typeof e){const r=n||await Ct(t,Is,"getBlock")({}),s=await e({block:r,client:t,request:a});if(null===s)throw new Error;return s}if(void 0!==e)return e;return ke(await t.request({method:"eth_maxPriorityFeePerGas"}))}catch{const[e,r]=await Promise.all([n?Promise.resolve(n):Ct(t,Is,"getBlock")({}),Ct(t,As,"getGasPrice")({})]);if("bigint"!=typeof e.baseFeePerGas)throw new bs;const a=r-e.baseFeePerGas;return a<0n?0n:a}}async function Os(t,e){return Ss(t,e)}async function Ss(t,e){const{block:n,chain:r=t.chain,request:a,type:s="eip1559"}=e||{},i=await(async()=>"function"==typeof r?.fees?.baseFeeMultiplier?r.fees.baseFeeMultiplier({block:n,client:t,request:a}):r?.fees?.baseFeeMultiplier??1.2)();if(i<1)throw new hs;const o=10**(i.toString().split(".")[1]?.length??0),c=t=>t*BigInt(Math.ceil(i*o))/BigInt(o),u=n||await Ct(t,Is,"getBlock")({});if("function"==typeof r?.fees?.estimateFeesPerGas){const e=await r.fees.estimateFeesPerGas({block:n,client:t,multiply:c,request:a,type:s});if(null!==e)return e}if("eip1559"===s){if("bigint"!=typeof u.baseFeePerGas)throw new bs;const e="bigint"==typeof a?.maxPriorityFeePerGas?a.maxPriorityFeePerGas:await Es(t,{block:u,chain:r,request:a}),n=c(u.baseFeePerGas);return{maxFeePerGas:a?.maxFeePerGas??n+e,maxPriorityFeePerGas:e}}return{gasPrice:a?.gasPrice??c(await Ct(t,As,"getGasPrice")({}))}}async function Ts(t,{address:e,blockTag:n="latest",blockNumber:r}){return Ie(await t.request({method:"eth_getTransactionCount",params:[e,"bigint"==typeof r?Ce(r):n]},{dedupe:Boolean(r)}))}function Cs(t){const{kzg:e}=t,n=t.to??("string"==typeof t.blobs[0]?"hex":"bytes"),r="string"==typeof t.blobs[0]?t.blobs.map(t=>Fe(t)):t.blobs,a=[];for(const t of r)a.push(Uint8Array.from(e.blobToKzgCommitment(t)));return"bytes"===n?a:a.map(t=>Te(t))}function Bs(t){const{kzg:e}=t,n=t.to??("string"==typeof t.blobs[0]?"hex":"bytes"),r="string"==typeof t.blobs[0]?t.blobs.map(t=>Fe(t)):t.blobs,a="string"==typeof t.commitments[0]?t.commitments.map(t=>Fe(t)):t.commitments,s=[];for(let t=0;t<r.length;t++){const n=r[t],i=a[t];s.push(Uint8Array.from(e.computeBlobKzgProof(n,i)))}return"bytes"===n?s:s.map(t=>Te(t))}function Ns(t,e,n){return t&e^~t&n}function js(t,e,n){return t&e^t&n^e&n}class Us extends mn{constructor(t,e,n,r){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=r,this.buffer=new Uint8Array(t),this.view=un(this.buffer)}update(t){sn(this),an(t=pn(t));const{view:e,buffer:n,blockLen:r}=this,a=t.length;for(let s=0;s<a;){const i=Math.min(r-this.pos,a-s);if(i===r){const e=un(t);for(;r<=a-s;s+=r)this.process(e,s);continue}n.set(t.subarray(s,s+i),this.pos),this.pos+=i,s+=i,this.pos===r&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){sn(this),on(t,this),this.finished=!0;const{buffer:e,view:n,blockLen:r,isLE:a}=this;let{pos:s}=this;e[s++]=128,cn(this.buffer.subarray(s)),this.padOffset>r-s&&(this.process(n,0),s=0);for(let t=s;t<r;t++)e[t]=0;!function(t,e,n,r){if("function"==typeof t.setBigUint64)return t.setBigUint64(e,n,r);const a=BigInt(32),s=BigInt(4294967295),i=Number(n>>a&s),o=Number(n&s),c=r?4:0,u=r?0:4;t.setUint32(e+c,i,r),t.setUint32(e+u,o,r)}(n,r-8,BigInt(8*this.length),a),this.process(n,0);const i=un(t),o=this.outputLen;if(o%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=o/4,u=this.get();if(c>u.length)throw new Error("_sha2: outputLen bigger than state");for(let t=0;t<c;t++)i.setUint32(4*t,u[t],a)}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const n=t.slice(0,e);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:e,buffer:n,length:r,finished:a,destroyed:s,pos:i}=this;return t.destroyed=s,t.finished=a,t.length=r,t.pos=i,r%e&&t.buffer.set(n),t}clone(){return this._cloneInto()}}const Ms=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Rs=Uint32Array.from([3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]),Fs=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),_s=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),zs=new Uint32Array(64);class Ds extends Us{constructor(t=32){super(64,t,8,!1),this.A=0|Ms[0],this.B=0|Ms[1],this.C=0|Ms[2],this.D=0|Ms[3],this.E=0|Ms[4],this.F=0|Ms[5],this.G=0|Ms[6],this.H=0|Ms[7]}get(){const{A:t,B:e,C:n,D:r,E:a,F:s,G:i,H:o}=this;return[t,e,n,r,a,s,i,o]}set(t,e,n,r,a,s,i,o){this.A=0|t,this.B=0|e,this.C=0|n,this.D=0|r,this.E=0|a,this.F=0|s,this.G=0|i,this.H=0|o}process(t,e){for(let n=0;n<16;n++,e+=4)zs[n]=t.getUint32(e,!1);for(let t=16;t<64;t++){const e=zs[t-15],n=zs[t-2],r=dn(e,7)^dn(e,18)^e>>>3,a=dn(n,17)^dn(n,19)^n>>>10;zs[t]=a+zs[t-7]+r+zs[t-16]|0}let{A:n,B:r,C:a,D:s,E:i,F:o,G:c,H:u}=this;for(let t=0;t<64;t++){const e=u+(dn(i,6)^dn(i,11)^dn(i,25))+Ns(i,o,c)+_s[t]+zs[t]|0,d=(dn(n,2)^dn(n,13)^dn(n,22))+js(n,r,a)|0;u=c,c=o,o=i,i=s+e|0,s=a,a=r,r=n,n=e+d|0}n=n+this.A|0,r=r+this.B|0,a=a+this.C|0,s=s+this.D|0,i=i+this.E|0,o=o+this.F|0,c=c+this.G|0,u=u+this.H|0,this.set(n,r,a,s,i,o,c,u)}roundClean(){cn(zs)}destroy(){this.set(0,0,0,0,0,0,0,0),cn(this.buffer)}}const Ls=(()=>Ge(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))))(),Gs=(()=>Ls[0])(),qs=(()=>Ls[1])(),Hs=new Uint32Array(80),Vs=new Uint32Array(80);class Ks extends Us{constructor(t=64){super(128,t,16,!1),this.Ah=0|Fs[0],this.Al=0|Fs[1],this.Bh=0|Fs[2],this.Bl=0|Fs[3],this.Ch=0|Fs[4],this.Cl=0|Fs[5],this.Dh=0|Fs[6],this.Dl=0|Fs[7],this.Eh=0|Fs[8],this.El=0|Fs[9],this.Fh=0|Fs[10],this.Fl=0|Fs[11],this.Gh=0|Fs[12],this.Gl=0|Fs[13],this.Hh=0|Fs[14],this.Hl=0|Fs[15]}get(){const{Ah:t,Al:e,Bh:n,Bl:r,Ch:a,Cl:s,Dh:i,Dl:o,Eh:c,El:u,Fh:d,Fl:l,Gh:f,Gl:p,Hh:m,Hl:h}=this;return[t,e,n,r,a,s,i,o,c,u,d,l,f,p,m,h]}set(t,e,n,r,a,s,i,o,c,u,d,l,f,p,m,h){this.Ah=0|t,this.Al=0|e,this.Bh=0|n,this.Bl=0|r,this.Ch=0|a,this.Cl=0|s,this.Dh=0|i,this.Dl=0|o,this.Eh=0|c,this.El=0|u,this.Fh=0|d,this.Fl=0|l,this.Gh=0|f,this.Gl=0|p,this.Hh=0|m,this.Hl=0|h}process(t,e){for(let n=0;n<16;n++,e+=4)Hs[n]=t.getUint32(e),Vs[n]=t.getUint32(e+=4);for(let t=16;t<80;t++){const e=0|Hs[t-15],n=0|Vs[t-15],r=Ve(e,n,1)^Ve(e,n,8)^qe(e,0,7),a=Ke(e,n,1)^Ke(e,n,8)^He(e,n,7),s=0|Hs[t-2],i=0|Vs[t-2],o=Ve(s,i,19)^We(s,i,61)^qe(s,0,6),c=Ke(s,i,19)^Ze(s,i,61)^He(s,i,6),u=Xe(a,c,Vs[t-7],Vs[t-16]),d=$e(u,r,o,Hs[t-7],Hs[t-16]);Hs[t]=0|d,Vs[t]=0|u}let{Ah:n,Al:r,Bh:a,Bl:s,Ch:i,Cl:o,Dh:c,Dl:u,Eh:d,El:l,Fh:f,Fl:p,Gh:m,Gl:h,Hh:b,Hl:y}=this;for(let t=0;t<80;t++){const e=Ve(d,l,14)^Ve(d,l,18)^We(d,l,41),g=Ke(d,l,14)^Ke(d,l,18)^Ze(d,l,41),v=d&f^~d&m,w=tn(y,g,l&p^~l&h,qs[t],Vs[t]),x=en(w,b,e,v,Gs[t],Hs[t]),P=0|w,k=Ve(n,r,28)^We(n,r,34)^We(n,r,39),I=Ke(n,r,28)^Ze(n,r,34)^Ze(n,r,39),A=n&a^n&i^a&i,E=r&s^r&o^s&o;b=0|m,y=0|h,m=0|f,h=0|p,f=0|d,p=0|l,({h:d,l:l}=Je(0|c,0|u,0|x,0|P)),c=0|i,u=0|o,i=0|a,o=0|s,a=0|n,s=0|r;const O=Ye(P,I,E);n=Qe(O,x,k,A),r=0|O}({h:n,l:r}=Je(0|this.Ah,0|this.Al,0|n,0|r)),({h:a,l:s}=Je(0|this.Bh,0|this.Bl,0|a,0|s)),({h:i,l:o}=Je(0|this.Ch,0|this.Cl,0|i,0|o)),({h:c,l:u}=Je(0|this.Dh,0|this.Dl,0|c,0|u)),({h:d,l:l}=Je(0|this.Eh,0|this.El,0|d,0|l)),({h:f,l:p}=Je(0|this.Fh,0|this.Fl,0|f,0|p)),({h:m,l:h}=Je(0|this.Gh,0|this.Gl,0|m,0|h)),({h:b,l:y}=Je(0|this.Hh,0|this.Hl,0|b,0|y)),this.set(n,r,a,s,i,o,c,u,d,l,f,p,m,h,b,y)}roundClean(){cn(Hs,Vs)}destroy(){cn(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class Ws extends Ks{constructor(){super(48),this.Ah=0|Rs[0],this.Al=0|Rs[1],this.Bh=0|Rs[2],this.Bl=0|Rs[3],this.Ch=0|Rs[4],this.Cl=0|Rs[5],this.Dh=0|Rs[6],this.Dl=0|Rs[7],this.Eh=0|Rs[8],this.El=0|Rs[9],this.Fh=0|Rs[10],this.Fl=0|Rs[11],this.Gh=0|Rs[12],this.Gl=0|Rs[13],this.Hh=0|Rs[14],this.Hl=0|Rs[15]}}const Zs=hn(()=>new Ds),Js=hn(()=>new Ks),Ys=hn(()=>new Ws),Qs=Zs;function Xs(t){const{commitment:e,version:n=1}=t,r=t.to??("string"==typeof e?"hex":"bytes"),a=Qs(jt(s=e,{strict:!1})?Ue(s):s);var s;return a.set([n],0),"bytes"===r?a:Te(a)}function $s(t){const{commitments:e,version:n}=t,r=t.to??("string"==typeof e[0]?"hex":"bytes"),a=[];for(const t of e)a.push(Xs({commitment:t,to:r,version:n}));return a}const ti=4096,ei=131072,ni=761855;class ri extends _t{constructor({maxSize:t,size:e}){super("Blob size is too large.",{metaMessages:[`Max: ${t} bytes`,`Given: ${e} bytes`],name:"BlobSizeTooLargeError"})}}class ai extends _t{constructor(){super("Blob data must not be empty.",{name:"EmptyBlobError"})}}class si extends _t{constructor({hash:t,size:e}){super(`Versioned hash "${t}" size is invalid.`,{metaMessages:["Expected: 32",`Received: ${e}`],name:"InvalidVersionedHashSizeError"})}}class ii extends _t{constructor({hash:t,version:e}){super(`Versioned hash "${t}" version is invalid.`,{metaMessages:["Expected: 1",`Received: ${e}`],name:"InvalidVersionedHashVersionError"})}}function oi(t){const{data:e,kzg:n,to:r}=t,a=t.blobs??function(t){const e=t.to??("string"==typeof t.data?"hex":"bytes"),n="string"==typeof t.data?Fe(t.data):t.data,r=Ut(n);if(!r)throw new ai;if(r>ni)throw new ri({maxSize:ni,size:r});const a=[];let s=!0,i=0;for(;s;){const t=Ar(new Uint8Array(ei));let e=0;for(;e<ti;){const r=n.slice(i,i+31);if(t.pushByte(0),t.pushBytes(r),r.length<31){t.pushByte(128),s=!1;break}e++,i+=31}a.push(t)}return"bytes"===e?a.map(t=>t.bytes):a.map(t=>Te(t.bytes))}({data:e,to:r}),s=t.commitments??Cs({blobs:a,kzg:n,to:r}),i=t.proofs??Bs({blobs:a,commitments:s,kzg:n,to:r}),o=[];for(let t=0;t<a.length;t++)o.push({blob:a[t],commitment:s[t],proof:i[t]});return o}function ci(t){if(t.type)return t.type;if(void 0!==t.authorizationList)return"eip7702";if(void 0!==t.blobs||void 0!==t.blobVersionedHashes||void 0!==t.maxFeePerBlobGas||void 0!==t.sidecars)return"eip4844";if(void 0!==t.maxFeePerGas||void 0!==t.maxPriorityFeePerGas)return"eip1559";if(void 0!==t.gasPrice)return void 0!==t.accessList?"eip2930":"legacy";throw new Zr({transaction:t})}async function ui(t){return Ie(await t.request({method:"eth_chainId"},{dedupe:!0}))}const di=["blobVersionedHashes","chainId","fees","gas","nonce","type"],li=new Map;async function fi(t,e){const{account:n=t.account,blobs:r,chain:a,gas:s,kzg:i,nonce:o,nonceManager:c,parameters:u=di,type:d}=e,l=n?hr(n):n,f={...e,...l?{from:l?.address}:{}};let p,m;async function h(){return p||(p=await Ct(t,Is,"getBlock")({blockTag:"latest"}),p)}async function b(){if(m)return m;if(a)return a.id;if(void 0!==e.chainId)return e.chainId;const n=await Ct(t,ui,"getChainId")({});return m=n,m}if(u.includes("nonce")&&void 0===o&&l)if(c){const e=await b();f.nonce=await c.consume({address:l.address,chainId:e,client:t})}else f.nonce=await Ct(t,Ts,"getTransactionCount")({address:l.address,blockTag:"pending"});if((u.includes("blobVersionedHashes")||u.includes("sidecars"))&&r&&i){const t=Cs({blobs:r,kzg:i});if(u.includes("blobVersionedHashes")){const e=$s({commitments:t,to:"hex"});f.blobVersionedHashes=e}if(u.includes("sidecars")){const e=oi({blobs:r,commitments:t,proofs:Bs({blobs:r,commitments:t,kzg:i}),to:"hex"});f.sidecars=e}}if(u.includes("chainId")&&(f.chainId=await b()),(u.includes("fees")||u.includes("type"))&&void 0===d)try{f.type=ci(f)}catch{let e=li.get(t.uid);if(void 0===e){const n=await h();e="bigint"==typeof n?.baseFeePerGas,li.set(t.uid,e)}f.type=e?"eip1559":"legacy"}if(u.includes("fees"))if("legacy"!==f.type&&"eip2930"!==f.type){if(void 0===f.maxFeePerGas||void 0===f.maxPriorityFeePerGas){const n=await h(),{maxFeePerGas:r,maxPriorityFeePerGas:s}=await Ss(t,{block:n,chain:a,request:f});if(void 0===e.maxPriorityFeePerGas&&e.maxFeePerGas&&e.maxFeePerGas<s)throw new ys({maxPriorityFeePerGas:s});f.maxPriorityFeePerGas=s,f.maxFeePerGas=r}}else{if(void 0!==e.maxFeePerGas||void 0!==e.maxPriorityFeePerGas)throw new bs;if(void 0===e.gasPrice){const e=await h(),{gasPrice:n}=await Ss(t,{block:e,chain:a,request:f,type:"legacy"});f.gasPrice=n}}return u.includes("gas")&&void 0===s&&(f.gas=await Ct(t,pi,"estimateGas")({...f,account:l,prepare:"local"===l?.type?[]:["blobVersionedHashes"]})),ms(f),delete f.parameters,f}async function pi(t,e){const{account:n=t.account,prepare:r=!0}=e,a=n?hr(n):void 0,s=Array.isArray(r)?r:"local"!==a?.type?["blobVersionedHashes"]:void 0;try{const{accessList:n,authorizationList:i,blobs:o,blobVersionedHashes:c,blockNumber:u,blockTag:d,data:l,gas:f,gasPrice:p,maxFeePerBlobGas:m,maxFeePerGas:h,maxPriorityFeePerGas:b,nonce:y,value:g,stateOverride:v,...w}=r?await fi(t,{...e,parameters:s}):e,x=("bigint"==typeof u?Ce(u):void 0)||d,P=fs(v),k=await(async()=>w.to?w.to:i&&i.length>0?await Va({authorization:i[0]}).catch(()=>{throw new _t("`to` is required. Could not infer from `authorizationList`")}):void 0)();ms(e);const I=t.chain?.formatters?.transactionRequest?.format,A=(I||us)({...is(w,{format:I}),account:a,accessList:n,authorizationList:i,blobs:o,blobVersionedHashes:c,data:l,gas:f,gasPrice:p,maxFeePerBlobGas:m,maxFeePerGas:h,maxPriorityFeePerGas:b,nonce:y,to:k,value:g},"estimateGas");return BigInt(await t.request({method:"eth_estimateGas",params:P?[A,x??t.experimental_blockTag??"latest",P]:x?[A,x]:[A]}))}catch(n){throw function(t,{docsPath:e,...n}){const r=(()=>{const e=ss(t,n);return e instanceof as?t:e})();return new Ka(r,{docsPath:e,...n})}(n,{...e,account:a,chain:t.chain})}}function mi(t,e){if(!Vn(t,{strict:!1}))throw new _n({address:t});if(!Vn(e,{strict:!1}))throw new _n({address:e});return t.toLowerCase()===e.toLowerCase()}const hi="/docs/contract/decodeEventLog";function bi(t){const{abi:e,data:n,strict:r,topics:a}=t,s=r??!0,[i,...o]=a;if(!i)throw new Yt({docsPath:hi});const c=e.find(t=>"event"===t.type&&i===Fn(Bt(t)));if(!c||!("name"in c)||"event"!==c.type)throw new Qt(i,{docsPath:hi});const{name:u,inputs:d}=c,l=d?.some(t=>!("name"in t&&t.name)),f=l?[]:{},p=d.map((t,e)=>[t,e]).filter(([t])=>"indexed"in t&&t.indexed);for(let t=0;t<p.length;t++){const[e,n]=p[t],r=o[t];if(!r)throw new se({abiItem:c,param:e});f[l?n:e.name||n]=yi({param:e,value:r})}const m=d.filter(t=>!("indexed"in t&&t.indexed));if(m.length>0)if(n&&"0x"!==n)try{const t=Tr(m,n);if(t)if(l)for(let e=0;e<d.length;e++)f[e]=f[e]??t.shift();else for(let e=0;e<m.length;e++)f[m[e].name]=t[e]}catch(t){if(s){if(t instanceof Gt||t instanceof Pr)throw new ae({abiItem:c,data:n,params:m,size:Ut(n)});throw t}}else if(s)throw new ae({abiItem:c,data:"0x",params:m,size:0});return{eventName:u,args:Object.values(f).length>0?f:void 0}}function yi({param:t,value:e}){if("string"===t.type||"bytes"===t.type||"tuple"===t.type||t.type.match(/^(.*)\[(\d+)?\]$/))return e;return(Tr([t],e)||[])[0]}function gi(t){const{abi:e,args:n,logs:r,strict:a=!0}=t,s=(()=>{if(t.eventName)return Array.isArray(t.eventName)?t.eventName:[t.eventName]})();return r.map(t=>{try{const r=e.find(e=>"event"===e.type&&t.topics[0]===Fn(e));if(!r)return null;const i=bi({...t,abi:[r],strict:a});return s&&!s.includes(i.eventName)?null:function(t){const{args:e,inputs:n,matchArgs:r}=t;if(!r)return!0;if(!e)return!1;function a(t,e,n){try{return"address"===t.type?mi(e,n):"string"===t.type||"bytes"===t.type?jn(Ue(e))===n:e===n}catch{return!1}}if(Array.isArray(e)&&Array.isArray(r))return r.every((t,r)=>{if(null==t)return!0;const s=n[r];if(!s)return!1;return(Array.isArray(t)?t:[t]).some(t=>a(s,t,e[r]))});return"object"==typeof e&&!Array.isArray(e)&&"object"==typeof r&&!Array.isArray(r)&&Object.entries(r).every(([t,r])=>{if(null==r)return!0;const s=n.find(e=>e.name===t);if(!s)return!1;return(Array.isArray(r)?r:[r]).some(n=>a(s,n,e[t]))})}({args:i.args,inputs:r.inputs,matchArgs:n})?{...i,...t}:null}catch(e){let n,r;if(e instanceof Qt)return null;if(e instanceof ae||e instanceof se){if(a)return null;n=e.abiItem.name,r=e.abiItem.inputs?.some(t=>!("name"in t&&t.name))}return{...t,args:r?[]:{},eventName:n}}}).filter(Boolean)}function vi(t,{args:e,eventName:n}={}){return{...t,blockHash:t.blockHash?t.blockHash:null,blockNumber:t.blockNumber?BigInt(t.blockNumber):null,logIndex:t.logIndex?Number(t.logIndex):null,transactionHash:t.transactionHash?t.transactionHash:null,transactionIndex:t.transactionIndex?Number(t.transactionIndex):null,...n?{args:e,eventName:n}:{}}}async function wi(t,{address:e,blockHash:n,fromBlock:r,toBlock:a,event:s,events:i,args:o,strict:c}={}){const u=c??!1,d=i??(s?[s]:void 0);let l,f=[];if(d){const t=d.flatMap(t=>lr({abi:[t],eventName:t.name,args:i?void 0:o}));f=[t],s&&(f=f[0])}l=n?await t.request({method:"eth_getLogs",params:[{address:e,topics:f,blockHash:n}]}):await t.request({method:"eth_getLogs",params:[{address:e,topics:f,fromBlock:"bigint"==typeof r?Ce(r):r,toBlock:"bigint"==typeof a?Ce(a):a}]});const p=l.map(t=>vi(t));return d?gi({abi:d,args:o,logs:p,strict:u}):p}async function xi(t,e){const{abi:n,address:r,args:a,blockHash:s,eventName:i,fromBlock:o,toBlock:c,strict:u}=e,d=i?or({abi:n,name:i}):void 0,l=d?void 0:n.filter(t=>"event"===t.type);return Ct(t,wi,"getLogs")({address:r,args:a,blockHash:s,event:d,events:l,fromBlock:o,toBlock:c,strict:u})}const Pi="/docs/contract/decodeFunctionResult";function ki(t){const{abi:e,args:n,functionName:r,data:a}=t;let s=e[0];if(r){const t=or({abi:e,args:n,name:r});if(!t)throw new $t(r,{docsPath:Pi});s=t}if("function"!==s.type)throw new $t(void 0,{docsPath:Pi});if(!s.outputs)throw new te(s.name,{docsPath:Pi});const i=Tr(s.outputs,a);return i&&i.length>1?i:i&&1===i.length?i[0]:void 0}
|
|
4
4
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Ii=BigInt(0),Ai=BigInt(1);function Ei(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&"Uint8Array"===t.constructor.name}function Oi(t){if(!Ei(t))throw new Error("Uint8Array expected")}function Si(t,e){if("boolean"!=typeof e)throw new Error(t+" boolean expected, got "+e)}function Ti(t){const e=t.toString(16);return 1&e.length?"0"+e:e}function Ci(t){if("string"!=typeof t)throw new Error("hex string expected, got "+typeof t);return""===t?Ii:BigInt("0x"+t)}const Bi="function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex,Ni=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function ji(t){if(Oi(t),Bi)return t.toHex();let e="";for(let n=0;n<t.length;n++)e+=Ni[t[n]];return e}const Ui=48,Mi=57,Ri=65,Fi=70,_i=97,zi=102;function Di(t){return t>=Ui&&t<=Mi?t-Ui:t>=Ri&&t<=Fi?t-(Ri-10):t>=_i&&t<=zi?t-(_i-10):void 0}function Li(t){if("string"!=typeof t)throw new Error("hex string expected, got "+typeof t);if(Bi)return Uint8Array.fromHex(t);const e=t.length,n=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const r=new Uint8Array(n);for(let e=0,a=0;e<n;e++,a+=2){const n=Di(t.charCodeAt(a)),s=Di(t.charCodeAt(a+1));if(void 0===n||void 0===s){const e=t[a]+t[a+1];throw new Error('hex string expected, got non-hex character "'+e+'" at index '+a)}r[e]=16*n+s}return r}function Gi(t){return Ci(ji(t))}function qi(t){return Oi(t),Ci(ji(Uint8Array.from(t).reverse()))}function Hi(t,e){return Li(t.toString(16).padStart(2*e,"0"))}function Vi(t,e){return Hi(t,e).reverse()}function Ki(t,e,n){let r;if("string"==typeof e)try{r=Li(e)}catch(e){throw new Error(t+" must be hex string or Uint8Array, cause: "+e)}else{if(!Ei(e))throw new Error(t+" must be hex string or Uint8Array");r=Uint8Array.from(e)}const a=r.length;if("number"==typeof n&&a!==n)throw new Error(t+" of length "+n+" expected, got "+a);return r}function Wi(...t){let e=0;for(let n=0;n<t.length;n++){const r=t[n];Oi(r),e+=r.length}const n=new Uint8Array(e);for(let e=0,r=0;e<t.length;e++){const a=t[e];n.set(a,r),r+=a.length}return n}const Zi=t=>"bigint"==typeof t&&Ii<=t;function Ji(t,e,n){return Zi(t)&&Zi(e)&&Zi(n)&&e<=t&&t<n}function Yi(t,e,n,r){if(!Ji(e,n,r))throw new Error("expected valid "+t+": "+n+" <= n < "+r+", got "+e)}const Qi=t=>(Ai<<BigInt(t))-Ai,Xi=t=>new Uint8Array(t),$i=t=>Uint8Array.from(t);const to={bigint:t=>"bigint"==typeof t,function:t=>"function"==typeof t,boolean:t=>"boolean"==typeof t,string:t=>"string"==typeof t,stringOrUint8Array:t=>"string"==typeof t||Ei(t),isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>"function"==typeof t&&Number.isSafeInteger(t.outputLen)};function eo(t,e,n={}){const r=(e,n,r)=>{const a=to[n];if("function"!=typeof a)throw new Error("invalid validator function");const s=t[e];if(!(r&&void 0===s||a(s,t)))throw new Error("param "+String(e)+" is invalid. Expected "+n+", got "+s)};for(const[t,n]of Object.entries(e))r(t,n,!1);for(const[t,e]of Object.entries(n))r(t,e,!0);return t}function no(t){const e=new WeakMap;return(n,...r)=>{const a=e.get(n);if(void 0!==a)return a;const s=t(n,...r);return e.set(n,s),s}}let ro=class t extends Error{constructor(e,n={}){const r=(()=>{if(n.cause instanceof t){if(n.cause.details)return n.cause.details;if(n.cause.shortMessage)return n.cause.shortMessage}return n.cause&&"details"in n.cause&&"string"==typeof n.cause.details?n.cause.details:n.cause?.message?n.cause.message:n.details})(),a=n.cause instanceof t&&n.cause.docsPath||n.docsPath,s=`${n.docsOrigin??"https://oxlib.sh"}${a??""}`,i=[e||"An error occurred.",...n.metaMessages?["",...n.metaMessages]:[],...r||a||n.version?["",r?`Details: ${r}`:void 0,a?`See: ${s}`:void 0,n.version?`Version: ${n.version}`:void 0]:[]].filter(t=>"string"==typeof t).join("\n");super(i,n.cause?{cause:n.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docs",{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,"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,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.cause=n.cause,this.details=r,this.docs=s,this.docsPath=a,this.shortMessage=e,this.version=n.version??"ox@0.1.1"}walk(t){return ao(this,t)}};function ao(t,e){return e?.(t)?t:t&&"object"==typeof t&&"cause"in t&&t.cause?ao(t.cause,e):e?null:t}function so(t,e){if(Io(t)>e)throw new Uo({givenSize:Io(t),maxSize:e})}const io=48,oo=57,co=65,uo=70,lo=97,fo=102;function po(t){return t>=io&&t<=oo?t-io:t>=co&&t<=uo?t-(co-10):t>=lo&&t<=fo?t-(lo-10):void 0}function mo(t,e={}){const{dir:n="left"}=e;let r=t,a=0;for(let t=0;t<r.length-1&&"0"===r["left"===n?t:r.length-t-1].toString();t++)a++;return r="left"===n?r.slice(a):r.slice(0,r.length-a),r}function ho(t,e){if(Zo(t)>e)throw new ec({givenSize:Zo(t),maxSize:e})}function bo(t,e={}){const{dir:n,size:r=32}=e;if(0===r)return t;const a=t.replace("0x","");if(a.length>2*r)throw new rc({size:Math.ceil(a.length/2),targetSize:r,type:"Hex"});return`0x${a["right"===n?"padEnd":"padStart"](2*r,"0")}`}function yo(t,e,n){return JSON.stringify(t,(t,e)=>"bigint"==typeof e?e.toString()+"#__bigint":e,n)}const go=new TextDecoder,vo=new TextEncoder;function wo(t){return t instanceof Uint8Array?t:"string"==typeof t?Po(t):xo(t)}function xo(t){return t instanceof Uint8Array?t:new Uint8Array(t)}function Po(t,e={}){const{size:n}=e;let r=t;n&&(ho(t,n),r=Ko(t,n));let a=r.slice(2);a.length%2&&(a=`0${a}`);const s=a.length/2,i=new Uint8Array(s);for(let t=0,e=0;t<s;t++){const n=po(a.charCodeAt(e++)),r=po(a.charCodeAt(e++));if(void 0===n||void 0===r)throw new ro(`Invalid byte sequence ("${a[e-2]}${a[e-1]}" in "${a}").`);i[t]=n<<4|r}return i}function ko(t,e={}){const{size:n}=e,r=vo.encode(t);return"number"==typeof n?(so(r,n),function(t,e){return function(t,e={}){const{dir:n,size:r=32}=e;if(0===r)return t;if(t.length>r)throw new Ro({size:t.length,targetSize:r,type:"Bytes"});const a=new Uint8Array(r);for(let e=0;e<r;e++){const s="right"===n;a[s?e:r-e-1]=t[s?e:t.length-e-1]}return a}(t,{dir:"right",size:e})}(r,n)):r}function Io(t){return t.length}function Ao(t,e,n,r={}){const{strict:a}=r;!function(t,e){if("number"==typeof e&&e>0&&e>Io(t)-1)throw new Mo({offset:e,position:"start",size:Io(t)})}(t,e);const s=t.slice(e,n);return a&&function(t,e,n){if("number"==typeof e&&"number"==typeof n&&Io(t)!==n-e)throw new Mo({offset:n,position:"end",size:Io(t)})}(s,e,n),s}function Eo(t,e={}){const{size:n}=e;void 0!==n&&so(t,n);return Jo(Go(t,e),e)}function Oo(t,e={}){const{size:n}=e;let r=t;if(void 0!==n&&(so(r,n),r=Co(r)),r.length>1||r[0]>1)throw new No(r);return Boolean(r[0])}function So(t,e={}){const{size:n}=e;void 0!==n&&so(t,n);return Yo(Go(t,e),e)}function To(t,e={}){const{size:n}=e;let r=t;return void 0!==n&&(so(r,n),r=mo(r,{dir:"right"})),go.decode(r)}function Co(t){return mo(t,{dir:"left"})}function Bo(t){try{return function(t){if(!(t instanceof Uint8Array)){if(!t)throw new jo(t);if("object"!=typeof t)throw new jo(t);if(!("BYTES_PER_ELEMENT"in t))throw new jo(t);if(1!==t.BYTES_PER_ELEMENT||"Uint8Array"!==t.constructor.name)throw new jo(t)}}(t),!0}catch{return!1}}class No extends ro{constructor(t){super(`Bytes value \`${t}\` is not a valid boolean.`,{metaMessages:["The bytes array must contain a single byte of either a `0` or `1` value."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.InvalidBytesBooleanError"})}}class jo extends ro{constructor(t){super(`Value \`${"object"==typeof t?yo(t):t}\` of type \`${typeof t}\` is an invalid Bytes value.`,{metaMessages:["Bytes values must be of type `Bytes`."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.InvalidBytesTypeError"})}}let Uo=class extends ro{constructor({givenSize:t,maxSize:e}){super(`Size cannot exceed \`${e}\` bytes. Given size: \`${t}\` bytes.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.SizeOverflowError"})}},Mo=class extends ro{constructor({offset:t,position:e,size:n}){super(`Slice ${"start"===e?"starting":"ending"} at offset \`${t}\` is out-of-bounds (size: \`${n}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.SliceOffsetOutOfBoundsError"})}},Ro=class extends ro{constructor({size:t,targetSize:e,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (\`${t}\`) exceeds padding size (\`${e}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.SizeExceedsPaddingSizeError"})}};const Fo=new TextEncoder,_o=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function zo(...t){return`0x${t.reduce((t,e)=>t+e.replace("0x",""),"")}`}function Do(t){return t instanceof Uint8Array?Go(t):Array.isArray(t)?Go(new Uint8Array(t)):t}function Lo(t,e={}){const n=`0x${Number(t)}`;return"number"==typeof e.size?(ho(n,e.size),Vo(n,e.size)):n}function Go(t,e={}){let n="";for(let e=0;e<t.length;e++)n+=_o[t[e]];const r=`0x${n}`;return"number"==typeof e.size?(ho(r,e.size),Ko(r,e.size)):r}function qo(t,e={}){const{signed:n,size:r}=e,a=BigInt(t);let s;r?s=n?(1n<<8n*BigInt(r)-1n)-1n:2n**(8n*BigInt(r))-1n:"number"==typeof t&&(s=BigInt(Number.MAX_SAFE_INTEGER));const i="bigint"==typeof s&&n?-s-1n:0;if(s&&a>s||a<i){const e="bigint"==typeof t?"n":"";throw new Xo({max:s?`${s}${e}`:void 0,min:`${i}${e}`,signed:n,size:r,value:`${t}${e}`})}const o=`0x${(n&&a<0?BigInt.asUintN(8*r,BigInt(a)):a).toString(16)}`;return r?Vo(o,r):o}function Ho(t,e={}){return Go(Fo.encode(t),e)}function Vo(t,e){return bo(t,{dir:"left",size:e})}function Ko(t,e){return bo(t,{dir:"right",size:e})}function Wo(t,e,n,r={}){const{strict:a}=r;!function(t,e){if("number"==typeof e&&e>0&&e>Zo(t)-1)throw new nc({offset:e,position:"start",size:Zo(t)})}(t,e);const s=`0x${t.replace("0x","").slice(2*(e??0),2*(n??t.length))}`;return a&&function(t,e,n){if("number"==typeof e&&"number"==typeof n&&Zo(t)!==n-e)throw new nc({offset:n,position:"end",size:Zo(t)})}(s,e,n),s}function Zo(t){return Math.ceil((t.length-2)/2)}function Jo(t,e={}){const{signed:n}=e;e.size&&ho(t,e.size);const r=BigInt(t);if(!n)return r;const a=(t.length-2)/2,s=(1n<<8n*BigInt(a))-1n;return r<=s>>1n?r:r-s-1n}function Yo(t,e={}){const{signed:n,size:r}=e;return Number(n||r?Jo(t,e):t)}function Qo(t,e={}){const{strict:n=!1}=e;try{return function(t,e={}){const{strict:n=!1}=e;if(!t)throw new $o(t);if("string"!=typeof t)throw new $o(t);if(n&&!/^0x[0-9a-fA-F]*$/.test(t))throw new tc(t);if(!t.startsWith("0x"))throw new tc(t)}(t,{strict:n}),!0}catch{return!1}}class Xo extends ro{constructor({max:t,min:e,signed:n,size:r,value:a}){super(`Number \`${a}\` is not in safe${r?` ${8*r}-bit`:""}${n?" signed":" unsigned"} integer range ${t?`(\`${e}\` to \`${t}\`)`:`(above \`${e}\`)`}`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.IntegerOutOfRangeError"})}}class $o extends ro{constructor(t){super(`Value \`${"object"==typeof t?yo(t):t}\` of type \`${typeof t}\` is an invalid hex type.`,{metaMessages:['Hex types must be represented as `"0x${string}"`.']}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.InvalidHexTypeError"})}}class tc extends ro{constructor(t){super(`Value \`${t}\` is an invalid hex value.`,{metaMessages:['Hex values must start with `"0x"` and contain only hexadecimal characters (0-9, a-f, A-F).']}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.InvalidHexValueError"})}}class ec extends ro{constructor({givenSize:t,maxSize:e}){super(`Size cannot exceed \`${e}\` bytes. Given size: \`${t}\` bytes.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SizeOverflowError"})}}class nc extends ro{constructor({offset:t,position:e,size:n}){super(`Slice ${"start"===e?"starting":"ending"} at offset \`${t}\` is out-of-bounds (size: \`${n}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SliceOffsetOutOfBoundsError"})}}class rc extends ro{constructor({size:t,targetSize:e,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (\`${t}\`) exceeds padding size (\`${e}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SizeExceedsPaddingSizeError"})}}function ac(t){return{address:t.address,amount:qo(t.amount),index:qo(t.index),validatorIndex:qo(t.validatorIndex)}}function sc(t){return{..."bigint"==typeof t.baseFeePerGas&&{baseFeePerGas:qo(t.baseFeePerGas)},..."bigint"==typeof t.blobBaseFee&&{blobBaseFee:qo(t.blobBaseFee)},..."string"==typeof t.feeRecipient&&{feeRecipient:t.feeRecipient},..."bigint"==typeof t.gasLimit&&{gasLimit:qo(t.gasLimit)},..."bigint"==typeof t.number&&{number:qo(t.number)},..."bigint"==typeof t.prevRandao&&{prevRandao:qo(t.prevRandao)},..."bigint"==typeof t.time&&{time:qo(t.time)},...t.withdrawals&&{withdrawals:t.withdrawals.map(ac)}}}const ic=[{inputs:[{components:[{name:"target",type:"address"},{name:"allowFailure",type:"bool"},{name:"callData",type:"bytes"}],name:"calls",type:"tuple[]"}],name:"aggregate3",outputs:[{components:[{name:"success",type:"bool"},{name:"returnData",type:"bytes"}],name:"returnData",type:"tuple[]"}],stateMutability:"view",type:"function"},{inputs:[],name:"getCurrentBlockTimestamp",outputs:[{internalType:"uint256",name:"timestamp",type:"uint256"}],stateMutability:"view",type:"function"}],oc=[{name:"query",type:"function",stateMutability:"view",inputs:[{type:"tuple[]",name:"queries",components:[{type:"address",name:"sender"},{type:"string[]",name:"urls"},{type:"bytes",name:"data"}]}],outputs:[{type:"bool[]",name:"failures"},{type:"bytes[]",name:"responses"}]},{name:"HttpError",type:"error",inputs:[{type:"uint16",name:"status"},{type:"string",name:"message"}]}],cc=[{inputs:[{name:"dns",type:"bytes"}],name:"DNSDecodingFailed",type:"error"},{inputs:[{name:"ens",type:"string"}],name:"DNSEncodingFailed",type:"error"},{inputs:[],name:"EmptyAddress",type:"error"},{inputs:[{name:"status",type:"uint16"},{name:"message",type:"string"}],name:"HttpError",type:"error"},{inputs:[],name:"InvalidBatchGatewayResponse",type:"error"},{inputs:[{name:"errorData",type:"bytes"}],name:"ResolverError",type:"error"},{inputs:[{name:"name",type:"bytes"},{name:"resolver",type:"address"}],name:"ResolverNotContract",type:"error"},{inputs:[{name:"name",type:"bytes"}],name:"ResolverNotFound",type:"error"},{inputs:[{name:"primary",type:"string"},{name:"primaryAddress",type:"bytes"}],name:"ReverseAddressMismatch",type:"error"},{inputs:[{internalType:"bytes4",name:"selector",type:"bytes4"}],name:"UnsupportedResolverProfile",type:"error"}],uc=[...cc,{name:"resolveWithGateways",type:"function",stateMutability:"view",inputs:[{name:"name",type:"bytes"},{name:"data",type:"bytes"},{name:"gateways",type:"string[]"}],outputs:[{name:"",type:"bytes"},{name:"address",type:"address"}]}],dc=[...cc,{name:"reverseWithGateways",type:"function",stateMutability:"view",inputs:[{type:"bytes",name:"reverseName"},{type:"uint256",name:"coinType"},{type:"string[]",name:"gateways"}],outputs:[{type:"string",name:"resolvedName"},{type:"address",name:"resolver"},{type:"address",name:"reverseResolver"}]}],lc=[{name:"text",type:"function",stateMutability:"view",inputs:[{name:"name",type:"bytes32"},{name:"key",type:"string"}],outputs:[{name:"",type:"string"}]}],fc=[{name:"addr",type:"function",stateMutability:"view",inputs:[{name:"name",type:"bytes32"}],outputs:[{name:"",type:"address"}]},{name:"addr",type:"function",stateMutability:"view",inputs:[{name:"name",type:"bytes32"},{name:"coinType",type:"uint256"}],outputs:[{name:"",type:"bytes"}]}],pc=[{name:"isValidSignature",type:"function",stateMutability:"view",inputs:[{name:"hash",type:"bytes32"},{name:"signature",type:"bytes"}],outputs:[{name:"",type:"bytes4"}]}],mc=[{inputs:[{name:"_signer",type:"address"},{name:"_hash",type:"bytes32"},{name:"_signature",type:"bytes"}],stateMutability:"nonpayable",type:"constructor"},{inputs:[{name:"_signer",type:"address"},{name:"_hash",type:"bytes32"},{name:"_signature",type:"bytes"}],outputs:[{type:"bool"}],stateMutability:"nonpayable",type:"function",name:"isValidSig"}],hc="0x82ad56cb",bc="0x608060405234801561001057600080fd5b5060405161018e38038061018e83398101604081905261002f91610124565b6000808351602085016000f59050803b61004857600080fd5b6000808351602085016000855af16040513d6000823e81610067573d81fd5b3d81f35b634e487b7160e01b600052604160045260246000fd5b600082601f83011261009257600080fd5b81516001600160401b038111156100ab576100ab61006b565b604051601f8201601f19908116603f011681016001600160401b03811182821017156100d9576100d961006b565b6040528181528382016020018510156100f157600080fd5b60005b82811015610110576020818601810151838301820152016100f4565b506000918101602001919091529392505050565b6000806040838503121561013757600080fd5b82516001600160401b0381111561014d57600080fd5b61015985828601610081565b602085015190935090506001600160401b0381111561017757600080fd5b61018385828601610081565b915050925092905056fe",yc="0x608060405234801561001057600080fd5b506040516102c03803806102c083398101604081905261002f916101e6565b836001600160a01b03163b6000036100e457600080836001600160a01b03168360405161005c9190610270565b6000604051808303816000865af19150503d8060008114610099576040519150601f19603f3d011682016040523d82523d6000602084013e61009e565b606091505b50915091508115806100b857506001600160a01b0386163b155b156100e1578060405163101bb98d60e01b81526004016100d8919061028c565b60405180910390fd5b50505b6000808451602086016000885af16040513d6000823e81610103573d81fd5b3d81f35b80516001600160a01b038116811461011e57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b8381101561015457818101518382015260200161013c565b50506000910152565b600082601f83011261016e57600080fd5b81516001600160401b0381111561018757610187610123565b604051601f8201601f19908116603f011681016001600160401b03811182821017156101b5576101b5610123565b6040528181528382016020018510156101cd57600080fd5b6101de826020830160208701610139565b949350505050565b600080600080608085870312156101fc57600080fd5b61020585610107565b60208601519094506001600160401b0381111561022157600080fd5b61022d8782880161015d565b93505061023c60408601610107565b60608601519092506001600160401b0381111561025857600080fd5b6102648782880161015d565b91505092959194509250565b60008251610282818460208701610139565b9190910192915050565b60208152600082518060208401526102ab816040850160208701610139565b601f01601f1916919091016040019291505056fe",gc="0x608060405234801561001057600080fd5b5060405161069438038061069483398101604081905261002f9161051e565b600061003c848484610048565b9050806000526001601ff35b60007f64926492649264926492649264926492649264926492649264926492649264926100748361040c565b036101e7576000606080848060200190518101906100929190610577565b60405192955090935091506000906001600160a01b038516906100b69085906105dd565b6000604051808303816000865af19150503d80600081146100f3576040519150601f19603f3d011682016040523d82523d6000602084013e6100f8565b606091505b50509050876001600160a01b03163b60000361016057806101605760405162461bcd60e51b815260206004820152601e60248201527f5369676e617475726556616c696461746f723a206465706c6f796d656e74000060448201526064015b60405180910390fd5b604051630b135d3f60e11b808252906001600160a01b038a1690631626ba7e90610190908b9087906004016105f9565b602060405180830381865afa1580156101ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101d19190610633565b6001600160e01b03191614945050505050610405565b6001600160a01b0384163b1561027a57604051630b135d3f60e11b808252906001600160a01b03861690631626ba7e9061022790879087906004016105f9565b602060405180830381865afa158015610244573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102689190610633565b6001600160e01b031916149050610405565b81516041146102df5760405162461bcd60e51b815260206004820152603a602482015260008051602061067483398151915260448201527f3a20696e76616c6964207369676e6174757265206c656e6774680000000000006064820152608401610157565b6102e7610425565b5060208201516040808401518451859392600091859190811061030c5761030c61065d565b016020015160f81c9050601b811480159061032b57508060ff16601c14155b1561038c5760405162461bcd60e51b815260206004820152603b602482015260008051602061067483398151915260448201527f3a20696e76616c6964207369676e617475726520762076616c756500000000006064820152608401610157565b60408051600081526020810180835289905260ff83169181019190915260608101849052608081018390526001600160a01b0389169060019060a0016020604051602081039080840390855afa1580156103ea573d6000803e3d6000fd5b505050602060405103516001600160a01b0316149450505050505b9392505050565b600060208251101561041d57600080fd5b508051015190565b60405180606001604052806003906020820280368337509192915050565b6001600160a01b038116811461045857600080fd5b50565b634e487b7160e01b600052604160045260246000fd5b60005b8381101561048c578181015183820152602001610474565b50506000910152565b600082601f8301126104a657600080fd5b81516001600160401b038111156104bf576104bf61045b565b604051601f8201601f19908116603f011681016001600160401b03811182821017156104ed576104ed61045b565b60405281815283820160200185101561050557600080fd5b610516826020830160208701610471565b949350505050565b60008060006060848603121561053357600080fd5b835161053e81610443565b6020850151604086015191945092506001600160401b0381111561056157600080fd5b61056d86828701610495565b9150509250925092565b60008060006060848603121561058c57600080fd5b835161059781610443565b60208501519093506001600160401b038111156105b357600080fd5b6105bf86828701610495565b604086015190935090506001600160401b0381111561056157600080fd5b600082516105ef818460208701610471565b9190910192915050565b828152604060208201526000825180604084015261061e816060850160208701610471565b601f01601f1916919091016060019392505050565b60006020828403121561064557600080fd5b81516001600160e01b03198116811461040557600080fd5b634e487b7160e01b600052603260045260246000fdfe5369676e617475726556616c696461746f72237265636f7665725369676e6572",vc="0x608060405234801561001057600080fd5b506115b9806100206000396000f3fe6080604052600436106100f35760003560e01c80634d2301cc1161008a578063a8b0574e11610059578063a8b0574e14610325578063bce38bd714610350578063c3077fa914610380578063ee82ac5e146103b2576100f3565b80634d2301cc1461026257806372425d9d1461029f57806382ad56cb146102ca57806386d516e8146102fa576100f3565b80633408e470116100c65780633408e470146101af578063399542e9146101da5780633e64a6961461020c57806342cbb15c14610237576100f3565b80630f28c97d146100f8578063174dea7114610123578063252dba421461015357806327e86d6e14610184575b600080fd5b34801561010457600080fd5b5061010d6103ef565b60405161011a9190610c0a565b60405180910390f35b61013d60048036038101906101389190610c94565b6103f7565b60405161014a9190610e94565b60405180910390f35b61016d60048036038101906101689190610f0c565b610615565b60405161017b92919061101b565b60405180910390f35b34801561019057600080fd5b506101996107ab565b6040516101a69190611064565b60405180910390f35b3480156101bb57600080fd5b506101c46107b7565b6040516101d19190610c0a565b60405180910390f35b6101f460048036038101906101ef91906110ab565b6107bf565b6040516102039392919061110b565b60405180910390f35b34801561021857600080fd5b506102216107e1565b60405161022e9190610c0a565b60405180910390f35b34801561024357600080fd5b5061024c6107e9565b6040516102599190610c0a565b60405180910390f35b34801561026e57600080fd5b50610289600480360381019061028491906111a7565b6107f1565b6040516102969190610c0a565b60405180910390f35b3480156102ab57600080fd5b506102b4610812565b6040516102c19190610c0a565b60405180910390f35b6102e460048036038101906102df919061122a565b61081a565b6040516102f19190610e94565b60405180910390f35b34801561030657600080fd5b5061030f6109e4565b60405161031c9190610c0a565b60405180910390f35b34801561033157600080fd5b5061033a6109ec565b6040516103479190611286565b60405180910390f35b61036a600480360381019061036591906110ab565b6109f4565b6040516103779190610e94565b60405180910390f35b61039a60048036038101906103959190610f0c565b610ba6565b6040516103a99392919061110b565b60405180910390f35b3480156103be57600080fd5b506103d960048036038101906103d491906112cd565b610bca565b6040516103e69190611064565b60405180910390f35b600042905090565b60606000808484905090508067ffffffffffffffff81111561041c5761041b6112fa565b5b60405190808252806020026020018201604052801561045557816020015b610442610bd5565b81526020019060019003908161043a5790505b5092503660005b828110156105c957600085828151811061047957610478611329565b5b6020026020010151905087878381811061049657610495611329565b5b90506020028101906104a89190611367565b925060008360400135905080860195508360000160208101906104cb91906111a7565b73ffffffffffffffffffffffffffffffffffffffff16818580606001906104f2919061138f565b604051610500929190611431565b60006040518083038185875af1925050503d806000811461053d576040519150601f19603f3d011682016040523d82523d6000602084013e610542565b606091505b5083600001846020018290528215151515815250505081516020850135176105bc577f08c379a000000000000000000000000000000000000000000000000000000000600052602060045260176024527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060445260846000fd5b826001019250505061045c565b5082341461060c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610603906114a7565b60405180910390fd5b50505092915050565b6000606043915060008484905090508067ffffffffffffffff81111561063e5761063d6112fa565b5b60405190808252806020026020018201604052801561067157816020015b606081526020019060019003908161065c5790505b5091503660005b828110156107a157600087878381811061069557610694611329565b5b90506020028101906106a791906114c7565b92508260000160208101906106bc91906111a7565b73ffffffffffffffffffffffffffffffffffffffff168380602001906106e2919061138f565b6040516106f0929190611431565b6000604051808303816000865af19150503d806000811461072d576040519150601f19603f3d011682016040523d82523d6000602084013e610732565b606091505b5086848151811061074657610745611329565b5b60200260200101819052819250505080610795576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161078c9061153b565b60405180910390fd5b81600101915050610678565b5050509250929050565b60006001430340905090565b600046905090565b6000806060439250434091506107d68686866109f4565b905093509350939050565b600048905090565b600043905090565b60008173ffffffffffffffffffffffffffffffffffffffff16319050919050565b600044905090565b606060008383905090508067ffffffffffffffff81111561083e5761083d6112fa565b5b60405190808252806020026020018201604052801561087757816020015b610864610bd5565b81526020019060019003908161085c5790505b5091503660005b828110156109db57600084828151811061089b5761089a611329565b5b602002602001015190508686838181106108b8576108b7611329565b5b90506020028101906108ca919061155b565b92508260000160208101906108df91906111a7565b73ffffffffffffffffffffffffffffffffffffffff16838060400190610905919061138f565b604051610913929190611431565b6000604051808303816000865af19150503d8060008114610950576040519150601f19603f3d011682016040523d82523d6000602084013e610955565b606091505b5082600001836020018290528215151515815250505080516020840135176109cf577f08c379a000000000000000000000000000000000000000000000000000000000600052602060045260176024527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060445260646000fd5b8160010191505061087e565b50505092915050565b600045905090565b600041905090565b606060008383905090508067ffffffffffffffff811115610a1857610a176112fa565b5b604051908082528060200260200182016040528015610a5157816020015b610a3e610bd5565b815260200190600190039081610a365790505b5091503660005b82811015610b9c576000848281518110610a7557610a74611329565b5b60200260200101519050868683818110610a9257610a91611329565b5b9050602002810190610aa491906114c7565b9250826000016020810190610ab991906111a7565b73ffffffffffffffffffffffffffffffffffffffff16838060200190610adf919061138f565b604051610aed929190611431565b6000604051808303816000865af19150503d8060008114610b2a576040519150601f19603f3d011682016040523d82523d6000602084013e610b2f565b606091505b508260000183602001829052821515151581525050508715610b90578060000151610b8f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b869061153b565b60405180910390fd5b5b81600101915050610a58565b5050509392505050565b6000806060610bb7600186866107bf565b8093508194508295505050509250925092565b600081409050919050565b6040518060400160405280600015158152602001606081525090565b6000819050919050565b610c0481610bf1565b82525050565b6000602082019050610c1f6000830184610bfb565b92915050565b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b60008083601f840112610c5457610c53610c2f565b5b8235905067ffffffffffffffff811115610c7157610c70610c34565b5b602083019150836020820283011115610c8d57610c8c610c39565b5b9250929050565b60008060208385031215610cab57610caa610c25565b5b600083013567ffffffffffffffff811115610cc957610cc8610c2a565b5b610cd585828601610c3e565b92509250509250929050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b60008115159050919050565b610d2281610d0d565b82525050565b600081519050919050565b600082825260208201905092915050565b60005b83811015610d62578082015181840152602081019050610d47565b83811115610d71576000848401525b50505050565b6000601f19601f8301169050919050565b6000610d9382610d28565b610d9d8185610d33565b9350610dad818560208601610d44565b610db681610d77565b840191505092915050565b6000604083016000830151610dd96000860182610d19565b5060208301518482036020860152610df18282610d88565b9150508091505092915050565b6000610e0a8383610dc1565b905092915050565b6000602082019050919050565b6000610e2a82610ce1565b610e348185610cec565b935083602082028501610e4685610cfd565b8060005b85811015610e825784840389528151610e638582610dfe565b9450610e6e83610e12565b925060208a01995050600181019050610e4a565b50829750879550505050505092915050565b60006020820190508181036000830152610eae8184610e1f565b905092915050565b60008083601f840112610ecc57610ecb610c2f565b5b8235905067ffffffffffffffff811115610ee957610ee8610c34565b5b602083019150836020820283011115610f0557610f04610c39565b5b9250929050565b60008060208385031215610f2357610f22610c25565b5b600083013567ffffffffffffffff811115610f4157610f40610c2a565b5b610f4d85828601610eb6565b92509250509250929050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b6000610f918383610d88565b905092915050565b6000602082019050919050565b6000610fb182610f59565b610fbb8185610f64565b935083602082028501610fcd85610f75565b8060005b858110156110095784840389528151610fea8582610f85565b9450610ff583610f99565b925060208a01995050600181019050610fd1565b50829750879550505050505092915050565b60006040820190506110306000830185610bfb565b81810360208301526110428184610fa6565b90509392505050565b6000819050919050565b61105e8161104b565b82525050565b60006020820190506110796000830184611055565b92915050565b61108881610d0d565b811461109357600080fd5b50565b6000813590506110a58161107f565b92915050565b6000806000604084860312156110c4576110c3610c25565b5b60006110d286828701611096565b935050602084013567ffffffffffffffff8111156110f3576110f2610c2a565b5b6110ff86828701610eb6565b92509250509250925092565b60006060820190506111206000830186610bfb565b61112d6020830185611055565b818103604083015261113f8184610e1f565b9050949350505050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061117482611149565b9050919050565b61118481611169565b811461118f57600080fd5b50565b6000813590506111a18161117b565b92915050565b6000602082840312156111bd576111bc610c25565b5b60006111cb84828501611192565b91505092915050565b60008083601f8401126111ea576111e9610c2f565b5b8235905067ffffffffffffffff81111561120757611206610c34565b5b60208301915083602082028301111561122357611222610c39565b5b9250929050565b6000806020838503121561124157611240610c25565b5b600083013567ffffffffffffffff81111561125f5761125e610c2a565b5b61126b858286016111d4565b92509250509250929050565b61128081611169565b82525050565b600060208201905061129b6000830184611277565b92915050565b6112aa81610bf1565b81146112b557600080fd5b50565b6000813590506112c7816112a1565b92915050565b6000602082840312156112e3576112e2610c25565b5b60006112f1848285016112b8565b91505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600080fd5b600080fd5b600080fd5b60008235600160800383360303811261138357611382611358565b5b80830191505092915050565b600080833560016020038436030381126113ac576113ab611358565b5b80840192508235915067ffffffffffffffff8211156113ce576113cd61135d565b5b6020830192506001820236038313156113ea576113e9611362565b5b509250929050565b600081905092915050565b82818337600083830152505050565b600061141883856113f2565b93506114258385846113fd565b82840190509392505050565b600061143e82848661140c565b91508190509392505050565b600082825260208201905092915050565b7f4d756c746963616c6c333a2076616c7565206d69736d61746368000000000000600082015250565b6000611491601a8361144a565b915061149c8261145b565b602082019050919050565b600060208201905081810360008301526114c081611484565b9050919050565b6000823560016040038336030381126114e3576114e2611358565b5b80830191505092915050565b7f4d756c746963616c6c333a2063616c6c206661696c6564000000000000000000600082015250565b600061152560178361144a565b9150611530826114ef565b602082019050919050565b6000602082019050818103600083015261155481611518565b9050919050565b60008235600160600383360303811261157757611576611358565b5b8083019150509291505056fea264697066735822122020c1bc9aacf8e4a6507193432a895a8e77094f45a1395583f07b24e860ef06cd64736f6c634300080c0033";class wc extends _t{constructor({blockNumber:t,chain:e,contract:n}){super(`Chain "${e.name}" does not support contract "${n.name}".`,{metaMessages:["This could be due to any of the following:",...t&&n.blockCreated&&n.blockCreated>t?[`- The contract "${n.name}" was not deployed until block ${n.blockCreated} (current block ${t}).`]:[`- The chain does not have the contract "${n.name}" configured.`]],name:"ChainDoesNotSupportContract"})}}class xc extends _t{constructor(){super("No chain was provided to the Client.",{name:"ClientChainNotConfiguredError"})}}class Pc extends _t{constructor({chainId:t}){super("number"==typeof t?`Chain ID "${t}" is invalid.`:"Chain ID is invalid.",{name:"InvalidChainIdError"})}}const kc="/docs/contract/encodeDeployData";function Ic(t){const{abi:e,args:n,bytecode:r}=t;if(!n||0===n.length)return r;const a=e.find(t=>"type"in t&&"constructor"===t.type);if(!a)throw new Dt({docsPath:kc});if(!("inputs"in a))throw new Lt({docsPath:kc});if(!a.inputs||0===a.inputs.length)throw new Lt({docsPath:kc});return Wn([r,nr(a.inputs,n)])}function Ac({blockNumber:t,chain:e,contract:n}){const r=e?.contracts?.[n];if(!r)throw new wc({chain:e,contract:{name:n}});if(t&&r.blockCreated&&r.blockCreated>t)throw new wc({blockNumber:t,chain:e,contract:{name:n,blockCreated:r.blockCreated}});return r.address}function Ec(t,{docsPath:e,...n}){const r=(()=>{const e=ss(t,n);return e instanceof as?t:e})();return new ta(r,{docsPath:e,...n})}function Oc(){let t=()=>{},e=()=>{};return{promise:new Promise((n,r)=>{t=n,e=r}),resolve:t,reject:e}}const Sc=new Map;function Tc({fn:t,id:e,shouldSplitBatch:n,wait:r=0,sort:a}){const s=async()=>{const e=o();i();const n=e.map(({args:t})=>t);0!==n.length&&t(n).then(t=>{a&&Array.isArray(t)&&t.sort(a);for(let n=0;n<e.length;n++){const{resolve:r}=e[n];r?.([t[n],t])}}).catch(t=>{for(let n=0;n<e.length;n++){const{reject:r}=e[n];r?.(t)}})},i=()=>Sc.delete(e),o=()=>Sc.get(e)||[],c=t=>Sc.set(e,[...o(),t]);return{flush:i,async schedule(t){const{promise:e,resolve:a,reject:i}=Oc(),u=n?.([...o().map(({args:t})=>t),t]);u&&s();return o().length>0?(c({args:t,resolve:a,reject:i}),e):(c({args:t,resolve:a,reject:i}),setTimeout(s,r),e)}}}async function Cc(t,e){const{account:n=t.account,authorizationList:r,batch:a=Boolean(t.batch?.multicall),blockNumber:s,blockTag:i=t.experimental_blockTag??"latest",accessList:o,blobs:c,blockOverrides:u,code:d,data:l,factory:f,factoryData:p,gas:m,gasPrice:h,maxFeePerBlobGas:b,maxFeePerGas:y,maxPriorityFeePerGas:g,nonce:v,to:w,value:x,stateOverride:P,...k}=e,I=n?hr(n):void 0;if(d&&(f||p))throw new _t("Cannot provide both `code` & `factory`/`factoryData` as parameters.");if(d&&w)throw new _t("Cannot provide both `code` & `to` as parameters.");const A=d&&l,E=f&&p&&w&&l,O=A||E,S=A?Bc({code:d,data:l}):E?function(t){const{data:e,factory:n,factoryData:r,to:a}=t;return Ic({abi:Tt(["constructor(address, bytes, address, bytes)"]),bytecode:yc,args:[a,e,n,r]})}({data:l,factory:f,factoryData:p,to:w}):l;try{ms(e);const n=("bigint"==typeof s?Ce(s):void 0)||i,d=u?sc(u):void 0,l=fs(P),f=t.chain?.formatters?.transactionRequest?.format,p=(f||us)({...is(k,{format:f}),accessList:o,account:I,authorizationList:r,blobs:c,data:S,gas:m,gasPrice:h,maxFeePerBlobGas:b,maxFeePerGas:y,maxPriorityFeePerGas:g,nonce:v,to:O?void 0:w,value:x},"call");if(a&&function({request:t}){const{data:e,to:n,...r}=t;return!!e&&(!e.startsWith(hc)&&(!!n&&!(Object.values(r).filter(t=>void 0!==t).length>0)))}({request:p})&&!l&&!d)try{return await async function(t,e){const{batchSize:n=1024,deployless:r=!1,wait:a=0}="object"==typeof t.batch?.multicall?t.batch.multicall:{},{blockNumber:s,blockTag:i=t.experimental_blockTag??"latest",data:o,to:c}=e,u=(()=>{if(r)return null;if(e.multicallAddress)return e.multicallAddress;if(t.chain)return Ac({blockNumber:s,chain:t.chain,contract:"multicall3"});throw new xc})(),d="bigint"==typeof s?Ce(s):void 0,l=d||i,{schedule:f}=Tc({id:`${t.uid}.${l}`,wait:a,shouldSplitBatch(t){const e=t.reduce((t,{data:e})=>t+(e.length-2),0);return e>2*n},fn:async e=>{const n=e.map(t=>({allowFailure:!0,callData:t.data,target:t.to})),r=yr({abi:ic,args:[n],functionName:"aggregate3"}),a=await t.request({method:"eth_call",params:[{...null===u?{data:Bc({code:vc,data:r})}:{to:u,data:r}},l]});return ki({abi:ic,args:[n],functionName:"aggregate3",data:a||"0x"})}}),[{returnData:p,success:m}]=await f({data:o,to:c});if(!m)throw new sa({data:p});return"0x"===p?{data:void 0}:{data:p}}(t,{...p,blockNumber:s,blockTag:i})}catch(t){if(!(t instanceof xc||t instanceof wc))throw t}const A=(()=>{const t=[p,n];return l&&d?[...t,l,d]:l?[...t,l]:d?[...t,{},d]:t})(),E=await t.request({method:"eth_call",params:A});return"0x"===E?{data:void 0}:{data:E}}catch(n){const r=function(t){if(!(t instanceof _t))return;const e=t.walk();return"object"==typeof e?.data?e.data?.data:e.data}(n),{offchainLookup:a,offchainLookupSignature:s}=await Promise.resolve().then(function(){return Yu});if(!1!==t.ccipRead&&r?.slice(0,10)===s&&w)return{data:await a(t,{data:r,to:w})};if(O&&"0x101bb98d"===r?.slice(0,10))throw new aa({factory:f});throw Ec(n,{...e,account:I,chain:t.chain})}}function Bc(t){const{code:e,data:n}=t;return Ic({abi:Tt(["constructor(bytes, bytes)"]),bytecode:bc,args:[e,n]})}async function Nc(t,e){const{abi:n,address:r,args:a,functionName:s,...i}=e,o=yr({abi:n,args:a,functionName:s});try{const{data:e}=await Ct(t,Cc,"call")({...i,data:o,to:r});return ki({abi:n,args:a,functionName:s,data:e||"0x"})}catch(t){throw _a(t,{abi:n,address:r,args:a,docsPath:"/docs/contract/readContract",functionName:s})}}const jc=new Map,Uc=new Map;let Mc=0;function Rc(t,e,n){const r=++Mc,a=()=>jc.get(t)||[],s=()=>{const e=a();if(!e.some(t=>t.id===r))return;const n=Uc.get(t);if(1===e.length&&n){const t=n();t instanceof Promise&&t.catch(()=>{})}(()=>{const e=a();jc.set(t,e.filter(t=>t.id!==r))})()},i=a();if(jc.set(t,[...i,{id:r,fns:e}]),i&&i.length>0)return s;const o={};for(const t in e)o[t]=(...e)=>{const n=a();if(0!==n.length)for(const r of n)r.fns[t]?.(...e)};const c=n(o);return"function"==typeof c&&Uc.set(t,c),s}async function Fc(t){return new Promise(e=>setTimeout(e,t))}function _c(t,{emitOnBegin:e,initialWaitTime:n,interval:r}){let a=!0;const s=()=>a=!1;return(async()=>{let i;e&&(i=await t({unpoll:s}));const o=await(n?.(i))??r;await Fc(o);const c=async()=>{a&&(await t({unpoll:s}),await Fc(r),c())};c()})(),s}const zc=new Map,Dc=new Map;async function Lc(t,{cacheKey:e,cacheTime:n=Number.POSITIVE_INFINITY}){const r=function(t){const e=(t,e)=>({clear:()=>e.delete(t),get:()=>e.get(t),set:n=>e.set(t,n)}),n=e(t,zc),r=e(t,Dc);return{clear:()=>{n.clear(),r.clear()},promise:n,response:r}}(e),a=r.response.get();if(a&&n>0){if(Date.now()-a.created.getTime()<n)return a.data}let s=r.promise.get();s||(s=t(),r.promise.set(s));try{const t=await s;return r.response.set({created:new Date,data:t}),t}finally{r.promise.clear()}}async function Gc(t,{cacheTime:e=t.cacheTime}={}){const n=await Lc(()=>t.request({method:"eth_blockNumber"}),{cacheKey:(r=t.uid,`blockNumber.${r}`),cacheTime:e});var r;return BigInt(n)}async function qc(t,{filter:e}){const n="strict"in e&&e.strict,r=await e.request({method:"eth_getFilterChanges",params:[e.id]});if("string"==typeof r[0])return r;const a=r.map(t=>vi(t));return"abi"in e&&e.abi?gi({abi:e.abi,logs:a,strict:n}):a}async function Hc(t,{filter:e}){return e.request({method:"eth_uninstallFilter",params:[e.id]})}class Vc extends _t{constructor({docsPath:t}={}){super(["Could not find an Account to execute with this Action.","Please provide an Account with the `account` argument on the Action, or by supplying an `account` to the Client."].join("\n"),{docsPath:t,docsSlug:"account",name:"AccountNotFoundError"})}}class Kc extends _t{constructor(t){super(`Call bundle failed with status: ${t.statusCode}`,{name:"BundleFailedError"}),Object.defineProperty(this,"result",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.result=t}}function Wc(t,{delay:e=100,retryCount:n=2,shouldRetry:r=()=>!0}={}){return new Promise((a,s)=>{const i=async({count:o=0}={})=>{try{const e=await t();a(e)}catch(t){if(o<n&&await r({count:o,error:t}))return(async({error:t})=>{const n="function"==typeof e?e({count:o,error:t}):e;n&&await Fc(n),i({count:o+1})})({error:t});s(t)}};i()})}const Zc={"0x0":"reverted","0x1":"success"};function Jc(t,e){const n={...t,blockNumber:t.blockNumber?BigInt(t.blockNumber):null,contractAddress:t.contractAddress?t.contractAddress:null,cumulativeGasUsed:t.cumulativeGasUsed?BigInt(t.cumulativeGasUsed):null,effectiveGasPrice:t.effectiveGasPrice?BigInt(t.effectiveGasPrice):null,gasUsed:t.gasUsed?BigInt(t.gasUsed):null,logs:t.logs?t.logs.map(t=>vi(t)):null,to:t.to?t.to:null,transactionIndex:t.transactionIndex?Ie(t.transactionIndex):null,status:t.status?Zc[t.status]:null,type:t.type?vs[t.type]||t.type:null};return t.blobGasPrice&&(n.blobGasPrice=BigInt(t.blobGasPrice)),t.blobGasUsed&&(n.blobGasUsed=BigInt(t.blobGasUsed)),n}const Yc=os("transactionReceipt",Jc),Qc=Ce(0,{size:32});async function Xc(t,e){const{atomic:n=!1,chainId:r,receipts:a,version:s="2.0.0",...i}=await async function(e){if(e.endsWith("0x5792579257925792579257925792579257925792579257925792579257925792".slice(2))){const n=xe(Xn(e,-64,-32)),r=Xn(e,0,-64).slice(2).match(/.{1,64}/g),a=await Promise.all(r.map(e=>Qc.slice(2)!==e?t.request({method:"eth_getTransactionReceipt",params:[`0x${e}`]},{dedupe:!0}):void 0)),s=a.some(t=>null===t)?100:a.every(t=>"0x1"===t?.status)?200:a.every(t=>"0x0"===t?.status)?500:600;return{atomic:!1,chainId:Ie(n),receipts:a.filter(Boolean),status:s,version:"2.0.0"}}return t.request({method:"wallet_getCallsStatus",params:[e]})}(e.id),[o,c]=(()=>{const t=i.status;return t>=100&&t<200?["pending",t]:t>=200&&t<300?["success",t]:t>=300&&t<700?["failure",t]:"CONFIRMED"===t?["success",200]:"PENDING"===t?["pending",100]:[void 0,t]})();return{...i,atomic:n,chainId:r?Ie(r):void 0,receipts:a?.map(t=>({...t,blockNumber:ke(t.blockNumber),gasUsed:ke(t.gasUsed),status:Zc[t.status]}))??[],statusCode:c,status:o,version:s}}async function $c(t,e){const{id:n,pollingInterval:r=t.pollingInterval,status:a=({statusCode:t})=>200===t||t>=300,retryCount:s=4,retryDelay:i=({count:t})=>200*(1<<t),timeout:o=6e4,throwOnFailure:c=!1}=e,u=Mr(["waitForCallsStatus",t.uid,n]),{promise:d,resolve:l,reject:f}=Oc();let p;const m=Rc(u,{resolve:l,reject:f},e=>{const o=_c(async()=>{const r=t=>{clearTimeout(p),o(),t(),m()};try{const o=await Wc(async()=>{const e=await Ct(t,Xc,"getCallsStatus")({id:n});if(c&&"failure"===e.status)throw new Kc(e);return e},{retryCount:s,delay:i});if(!a(o))return;r(()=>e.resolve(o))}catch(t){r(()=>e.reject(t))}},{interval:r,emitOnBegin:!0});return o});return p=o?setTimeout(()=>{m(),clearTimeout(p),f(new tu({id:n}))},o):void 0,await d}class tu extends _t{constructor({id:t}){super(`Timed out while waiting for call bundle with id "${t}" to be confirmed.`,{name:"WaitForCallsStatusTimeoutError"})}}let eu,nu=256;function ru(t=11){if(!eu||nu+t>512){eu="",nu=0;for(let t=0;t<256;t++)eu+=(256+256*Math.random()|0).toString(16).substring(1)}return eu.substring(nu,nu+++t)}function au(t){const{batch:e,chain:n,ccipRead:r,key:a="base",name:s="Base Client",type:i="base"}=t,o=t.experimental_blockTag??("number"==typeof n?.experimental_preconfirmationTime?"pending":void 0),c=n?.blockTime??12e3,u=Math.min(Math.max(Math.floor(c/2),500),4e3),d=t.pollingInterval??u,l=t.cacheTime??d,f=t.account?hr(t.account):void 0,{config:p,request:m,value:h}=t.transport({chain:n,pollingInterval:d}),b={account:f,batch:e,cacheTime:l,ccipRead:r,chain:n,key:a,name:s,pollingInterval:d,request:m,transport:{...p,...h},type:i,uid:ru(),...o?{experimental_blockTag:o}:{}};return Object.assign(b,{extend:function t(e){return n=>{const r=n(e);for(const t in b)delete r[t];const a={...e,...r};return Object.assign(a,{extend:t(a)})}}(b)})}function su(t){if(!(t instanceof _t))return!1;const e=t.walk(t=>t instanceof na);return e instanceof na&&("HttpError"===e.data?.errorName||("ResolverError"===e.data?.errorName||("ResolverNotContract"===e.data?.errorName||("ResolverNotFound"===e.data?.errorName||("ReverseAddressMismatch"===e.data?.errorName||"UnsupportedResolverProfile"===e.data?.errorName)))))}function iu(t){const{abi:e,data:n}=t,r=Zn(n,0,4),a=e.find(t=>"function"===t.type&&r===ir(Bt(t)));if(!a)throw new ee(r,{docsPath:"/docs/contract/decodeFunctionData"});return{functionName:a.name,args:"inputs"in a&&a.inputs&&a.inputs.length>0?Tr(a.inputs,Zn(n,4)):void 0}}const ou="/docs/contract/encodeErrorResult";function cu(t){const{abi:e,errorName:n,args:r}=t;let a=e[0];if(n){const t=or({abi:e,args:r,name:n});if(!t)throw new Zt(n,{docsPath:ou});a=t}if("error"!==a.type)throw new Zt(void 0,{docsPath:ou});const s=Bt(a),i=ir(s);let o="0x";if(r&&r.length>0){if(!a.inputs)throw new Wt(a.name,{docsPath:ou});o=nr(a.inputs,r)}return Wn([i,o])}const uu="/docs/contract/encodeFunctionResult";const du="x-batch-gateway:true";async function lu(t){const{data:e,ccipRequest:n}=t,{args:[r]}=iu({abi:oc,data:e}),a=[],s=[];return await Promise.all(r.map(async(t,e)=>{try{s[e]=t.urls.includes(du)?await lu({data:t.data,ccipRequest:n}):await n(t),a[e]=!1}catch(t){a[e]=!0,s[e]="HttpRequestError"===(r=t).name&&r.status?cu({abi:oc,errorName:"HttpError",args:[r.status,r.shortMessage]}):cu({abi:[vr],errorName:"Error",args:["shortMessage"in r?r.shortMessage:r.message]})}var r})),function(t){const{abi:e,functionName:n,result:r}=t;let a=e[0];if(n){const t=or({abi:e,name:n});if(!t)throw new $t(n,{docsPath:uu});a=t}if("function"!==a.type)throw new $t(void 0,{docsPath:uu});if(!a.outputs)throw new te(a.name,{docsPath:uu});const s=(()=>{if(0===a.outputs.length)return[];if(1===a.outputs.length)return[r];if(Array.isArray(r))return r;throw new ce(r)})();return nr(a.outputs,s)}({abi:oc,functionName:"query",result:[a,s]})}function fu(t){if(66!==t.length)return null;if(0!==t.indexOf("["))return null;if(65!==t.indexOf("]"))return null;const e=`0x${t.slice(1,65)}`;return jt(e)?e:null}function pu(t){let e=new Uint8Array(32).fill(0);if(!t)return Te(e);const n=t.split(".");for(let t=n.length-1;t>=0;t-=1){const r=fu(n[t]),a=r?Ue(r):jn(_e(n[t]),"bytes");e=jn(Kn([e,a]),"bytes")}return Te(e)}function mu(t){return`[${t.slice(2)}]`}function hu(t){const e=new Uint8Array(32).fill(0);return t?fu(t)||jn(_e(t)):Te(e)}function bu(t){const e=t.replace(/^\.|\.$/gm,"");if(0===e.length)return new Uint8Array(1);const n=new Uint8Array(_e(e).byteLength+2);let r=0;const a=e.split(".");for(let t=0;t<a.length;t++){let e=_e(a[t]);e.byteLength>255&&(e=_e(mu(hu(a[t])))),n[r]=e.length,n.set(e,r+1),r+=e.length+1}return n.byteLength!==r+1?n.slice(0,r+1):n}class yu extends _t{constructor({data:t}){super("Unable to extract image from metadata. The metadata may be malformed or invalid.",{metaMessages:["- Metadata must be a JSON object with at least an `image`, `image_url` or `image_data` property.","",`Provided data: ${JSON.stringify(t)}`],name:"EnsAvatarInvalidMetadataError"})}}class gu extends _t{constructor({reason:t}){super(`ENS NFT avatar URI is invalid. ${t}`,{name:"EnsAvatarInvalidNftUriError"})}}class vu extends _t{constructor({uri:t}){super(`Unable to resolve ENS avatar URI "${t}". The URI may be malformed, invalid, or does not respond with a valid image.`,{name:"EnsAvatarUriResolutionError"})}}class wu extends _t{constructor({namespace:t}){super(`ENS NFT avatar namespace "${t}" is not supported. Must be "erc721" or "erc1155".`,{name:"EnsAvatarUnsupportedNamespaceError"})}}const xu=/(?<protocol>https?:\/\/[^/]*|ipfs:\/|ipns:\/|ar:\/)?(?<root>\/)?(?<subpath>ipfs\/|ipns\/)?(?<target>[\w\-.]+)(?<subtarget>\/.*)?/,Pu=/^(Qm[1-9A-HJ-NP-Za-km-z]{44,}|b[A-Za-z2-7]{58,}|B[A-Z2-7]{58,}|z[1-9A-HJ-NP-Za-km-z]{48,}|F[0-9A-F]{50,})(\/(?<target>[\w\-.]+))?(?<subtarget>\/.*)?$/,ku=/^data:([a-zA-Z\-/+]*);base64,([^"].*)/,Iu=/^data:([a-zA-Z\-/+]*)?(;[a-zA-Z0-9].*?)?(,)/;function Au(t,e){return t?t.endsWith("/")?t.slice(0,-1):t:e}function Eu({uri:t,gatewayUrls:e}){const n=ku.test(t);if(n)return{uri:t,isOnChain:!0,isEncoded:n};const r=Au(e?.ipfs,"https://ipfs.io"),a=Au(e?.arweave,"https://arweave.net"),s=t.match(xu),{protocol:i,subpath:o,target:c,subtarget:u=""}=s?.groups||{},d="ipns:/"===i||"ipns/"===o,l="ipfs:/"===i||"ipfs/"===o||Pu.test(t);if(t.startsWith("http")&&!d&&!l){let n=t;return e?.arweave&&(n=t.replace(/https:\/\/arweave.net/g,e?.arweave)),{uri:n,isOnChain:!1,isEncoded:!1}}if((d||l)&&c)return{uri:`${r}/${d?"ipns":"ipfs"}/${c}${u}`,isOnChain:!1,isEncoded:!1};if("ar:/"===i&&c)return{uri:`${a}/${c}${u||""}`,isOnChain:!1,isEncoded:!1};let f=t.replace(Iu,"");if(f.startsWith("<svg")&&(f=`data:image/svg+xml;base64,${btoa(f)}`),f.startsWith("data:")||f.startsWith("{"))return{uri:f,isOnChain:!0,isEncoded:!1};throw new vu({uri:t})}function Ou(t){if("object"!=typeof t||!("image"in t)&&!("image_url"in t)&&!("image_data"in t))throw new yu({data:t});return t.image||t.image_url||t.image_data}async function Su({gatewayUrls:t,uri:e}){const{uri:n,isOnChain:r}=Eu({uri:e,gatewayUrls:t});if(r)return n;const a=await async function(t){try{const e=await fetch(t,{method:"HEAD"});if(200===e.status){const t=e.headers.get("content-type");return t?.startsWith("image/")}return!1}catch(e){return("object"!=typeof e||void 0===e.response)&&!!Object.hasOwn(globalThis,"Image")&&new Promise(e=>{const n=new Image;n.onload=()=>{e(!0)},n.onerror=()=>{e(!1)},n.src=t})}}(n);if(a)return n;throw new vu({uri:e})}async function Tu(t,{gatewayUrls:e,record:n}){return/eip155:/i.test(n)?async function(t,{gatewayUrls:e,record:n}){const r=function(t){let e=t;e.startsWith("did:nft:")&&(e=e.replace("did:nft:","").replace(/_/g,"/"));const[n,r,a]=e.split("/"),[s,i]=n.split(":"),[o,c]=r.split(":");if(!s||"eip155"!==s.toLowerCase())throw new gu({reason:"Only EIP-155 supported"});if(!i)throw new gu({reason:"Chain ID not found"});if(!c)throw new gu({reason:"Contract address not found"});if(!a)throw new gu({reason:"Token ID not found"});if(!o)throw new gu({reason:"ERC namespace not found"});return{chainID:Number.parseInt(i,10),namespace:o.toLowerCase(),contractAddress:c,tokenID:a}}(n),a=await async function(t,{nft:e}){if("erc721"===e.namespace)return Nc(t,{address:e.contractAddress,abi:[{name:"tokenURI",type:"function",stateMutability:"view",inputs:[{name:"tokenId",type:"uint256"}],outputs:[{name:"",type:"string"}]}],functionName:"tokenURI",args:[BigInt(e.tokenID)]});if("erc1155"===e.namespace)return Nc(t,{address:e.contractAddress,abi:[{name:"uri",type:"function",stateMutability:"view",inputs:[{name:"_id",type:"uint256"}],outputs:[{name:"",type:"string"}]}],functionName:"uri",args:[BigInt(e.tokenID)]});throw new wu({namespace:e.namespace})}(t,{nft:r}),{uri:s,isOnChain:i,isEncoded:o}=Eu({uri:a,gatewayUrls:e});if(i&&(s.includes("data:application/json;base64,")||s.startsWith("{"))){const t=o?atob(s.replace("data:application/json;base64,","")):s;return Su({uri:Ou(JSON.parse(t)),gatewayUrls:e})}let c=r.tokenID;"erc1155"===r.namespace&&(c=c.replace("0x","").padStart(64,"0"));return async function({gatewayUrls:t,uri:e}){try{const n=await fetch(e).then(t=>t.json());return await Su({gatewayUrls:t,uri:Ou(n)})}catch{throw new vu({uri:e})}}({gatewayUrls:e,uri:s.replace(/(?:0x)?{id}/,c)})}(t,{gatewayUrls:e,record:n}):Su({uri:n,gatewayUrls:e})}async function Cu(t,e){const{blockNumber:n,blockTag:r,key:a,name:s,gatewayUrls:i,strict:o}=e,{chain:c}=t,u=(()=>{if(e.universalResolverAddress)return e.universalResolverAddress;if(!c)throw new Error("client chain not configured. universalResolverAddress is required.");return Ac({blockNumber:n,chain:c,contract:"ensUniversalResolver"})})(),d=c?.ensTlds;if(d&&!d.some(t=>s.endsWith(t)))return null;try{const e={address:u,abi:uc,args:[Oe(bu(s)),yr({abi:lc,functionName:"text",args:[pu(s),a]}),i??[du]],functionName:"resolveWithGateways",blockNumber:n,blockTag:r},o=Ct(t,Nc,"readContract"),c=await o(e);if("0x"===c[0])return null;const d=ki({abi:lc,functionName:"text",data:c[0]});return""===d?null:d}catch(t){if(o)throw t;if(su(t))return null;throw t}}async function Bu(t,e){const{account:n=t.account,blockNumber:r,blockTag:a="latest",blobs:s,data:i,gas:o,gasPrice:c,maxFeePerBlobGas:u,maxFeePerGas:d,maxPriorityFeePerGas:l,to:f,value:p,...m}=e,h=n?hr(n):void 0;try{ms(e);const n=("bigint"==typeof r?Ce(r):void 0)||a,b=t.chain?.formatters?.transactionRequest?.format,y=(b||us)({...is(m,{format:b}),account:h,blobs:s,data:i,gas:o,gasPrice:c,maxFeePerBlobGas:u,maxFeePerGas:d,maxPriorityFeePerGas:l,to:f,value:p},"createAccessList"),g=await t.request({method:"eth_createAccessList",params:[y,n]});return{accessList:g.accessList,gasUsed:BigInt(g.gasUsed)}}catch(n){throw Ec(n,{...e,account:h,chain:t.chain})}}async function Nu(t,{address:e,args:n,event:r,events:a,fromBlock:s,strict:i,toBlock:o}={}){const c=a??(r?[r]:void 0),u=pr(t,{method:"eth_newFilter"});let d=[];if(c){const t=c.flatMap(t=>lr({abi:[t],eventName:t.name,args:n}));d=[t],r&&(d=d[0])}const l=await t.request({method:"eth_newFilter",params:[{address:e,fromBlock:"bigint"==typeof s?Ce(s):s,toBlock:"bigint"==typeof o?Ce(o):o,...d.length?{topics:d}:{}}]});return{abi:c,args:n,eventName:r?r.name:void 0,fromBlock:s,id:l,request:u(l),strict:Boolean(i),toBlock:o,type:"event"}}async function ju(t){const e=pr(t,{method:"eth_newPendingTransactionFilter"}),n=await t.request({method:"eth_newPendingTransactionFilter"});return{id:n,request:e(n),type:"transaction"}}async function Uu(t,{address:e,blockNumber:n,blockTag:r="latest"}){const a=void 0!==n?Ce(n):void 0,s=await t.request({method:"eth_getCode",params:[e,a||r]},{dedupe:Boolean(a)});if("0x"!==s)return s}class Mu extends _t{constructor({address:t}){super(`No EIP-712 domain found on contract "${t}".`,{metaMessages:["Ensure that:",`- The contract is deployed at the address "${t}".`,"- `eip712Domain()` function exists on the contract.","- `eip712Domain()` function matches signature to ERC-5267 specification."],name:"Eip712DomainNotFoundError"})}}const Ru=[{inputs:[],name:"eip712Domain",outputs:[{name:"fields",type:"bytes1"},{name:"name",type:"string"},{name:"version",type:"string"},{name:"chainId",type:"uint256"},{name:"verifyingContract",type:"address"},{name:"salt",type:"bytes32"},{name:"extensions",type:"uint256[]"}],stateMutability:"view",type:"function"}];async function Fu(t,{blockCount:e,blockNumber:n,blockTag:r="latest",rewardPercentiles:a}){const s="bigint"==typeof n?Ce(n):void 0;return function(t){return{baseFeePerGas:t.baseFeePerGas.map(t=>BigInt(t)),gasUsedRatio:t.gasUsedRatio,oldestBlock:BigInt(t.oldestBlock),reward:t.reward?.map(t=>t.map(t=>BigInt(t)))}}(await t.request({method:"eth_feeHistory",params:[Ce(e),s||r,a]},{dedupe:Boolean(s)}))}function _u(t,e,n=!1){if("address"===t){const t=e;if(!Vn(t))throw new _n({address:t});return he(t.toLowerCase(),{size:n?32:null})}if("string"===t)return Ne(e);if("bytes"===t)return e;if("bool"===t)return he(Se(e),{size:n?32:1});const r=t.match(er);if(r){const[t,a,s="256"]=r,i=Number.parseInt(s,10)/8;return Ce(e,{size:n?32:i,signed:"int"===a})}const a=t.match(tr);if(a){const[t,r]=a;if(Number.parseInt(r,10)!==(e.length-2)/2)throw new re({expectedSize:Number.parseInt(r,10),givenSize:(e.length-2)/2});return he(e,{dir:"right",size:n?32:null})}const s=t.match($n);if(s&&Array.isArray(e)){const[t,n]=s,r=[];for(let t=0;t<e.length;t++)r.push(_u(n,e[t],!0));return 0===r.length?"0x":Wn(r)}throw new de(t)}function zu(t){const{chainId:e,maxPriorityFeePerGas:n,maxFeePerGas:r,to:a}=t;if(e<=0)throw new Pc({chainId:e});if(a&&!Vn(a))throw new _n({address:a});if(r&&r>ps)throw new Za({maxFeePerGas:r});if(n&&r&&n>r)throw new rs({maxFeePerGas:r,maxPriorityFeePerGas:n})}function Du(t){if(!t||0===t.length)return[];const e=[];for(let n=0;n<t.length;n++){const{address:r,storageKeys:a}=t[n];for(let t=0;t<a.length;t++)if(a[t].length-2!=64)throw new Jr({storageKey:a[t]});if(!Vn(r,{strict:!1}))throw new _n({address:r});e.push([r,a])}return e}function Lu(t,e){const n=ci(t);return"eip1559"===n?function(t,e){const{chainId:n,gas:r,nonce:a,to:s,value:i,maxFeePerGas:o,maxPriorityFeePerGas:c,accessList:u,data:d}=t;zu(t);const l=Du(u),f=[Ce(n),a?Ce(a):"0x",c?Ce(c):"0x",o?Ce(o):"0x",r?Ce(r):"0x",s??"0x",i?Ce(i):"0x",d??"0x",l,...Gu(t,e)];return Wn(["0x02",La(f)])}(t,e):"eip2930"===n?function(t,e){const{chainId:n,gas:r,data:a,nonce:s,to:i,value:o,accessList:c,gasPrice:u}=t;!function(t){const{chainId:e,maxPriorityFeePerGas:n,gasPrice:r,maxFeePerGas:a,to:s}=t;if(e<=0)throw new Pc({chainId:e});if(s&&!Vn(s))throw new _n({address:s});if(n||a)throw new _t("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid EIP-2930 Transaction attribute.");if(r&&r>ps)throw new Za({maxFeePerGas:r})}(t);const d=Du(c),l=[Ce(n),s?Ce(s):"0x",u?Ce(u):"0x",r?Ce(r):"0x",i??"0x",o?Ce(o):"0x",a??"0x",d,...Gu(t,e)];return Wn(["0x01",La(l)])}(t,e):"eip4844"===n?function(t,e){const{chainId:n,gas:r,nonce:a,to:s,value:i,maxFeePerBlobGas:o,maxFeePerGas:c,maxPriorityFeePerGas:u,accessList:d,data:l}=t;!function(t){const{blobVersionedHashes:e}=t;if(e){if(0===e.length)throw new ai;for(const t of e){const e=Ut(t),n=Ie(Zn(t,0,1));if(32!==e)throw new si({hash:t,size:e});if(1!==n)throw new ii({hash:t,version:n})}}zu(t)}(t);let f=t.blobVersionedHashes,p=t.sidecars;if(t.blobs&&(void 0===f||void 0===p)){const e="string"==typeof t.blobs[0]?t.blobs:t.blobs.map(t=>Te(t)),n=t.kzg,r=Cs({blobs:e,kzg:n});if(void 0===f&&(f=$s({commitments:r})),void 0===p){p=oi({blobs:e,commitments:r,proofs:Bs({blobs:e,commitments:r,kzg:n})})}}const m=Du(d),h=[Ce(n),a?Ce(a):"0x",u?Ce(u):"0x",c?Ce(c):"0x",r?Ce(r):"0x",s??"0x",i?Ce(i):"0x",l??"0x",m,o?Ce(o):"0x",f??[],...Gu(t,e)],b=[],y=[],g=[];if(p)for(let t=0;t<p.length;t++){const{blob:e,commitment:n,proof:r}=p[t];b.push(e),y.push(n),g.push(r)}return Wn(["0x03",La(p?[h,b,y,g]:h)])}(t,e):"eip7702"===n?function(t,e){const{authorizationList:n,chainId:r,gas:a,nonce:s,to:i,value:o,maxFeePerGas:c,maxPriorityFeePerGas:u,accessList:d,data:l}=t;!function(t){const{authorizationList:e}=t;if(e)for(const t of e){const{chainId:e}=t,n=t.address;if(!Vn(n))throw new _n({address:n});if(e<0)throw new Pc({chainId:e})}zu(t)}(t);const f=Du(d),p=function(t){if(!t||0===t.length)return[];const e=[];for(const n of t){const{chainId:t,nonce:r,...a}=n,s=n.address;e.push([t?Oe(t):"0x",s,r?Oe(r):"0x",...Gu({},a)])}return e}(n);return Wn(["0x04",La([Ce(r),s?Ce(s):"0x",u?Ce(u):"0x",c?Ce(c):"0x",a?Ce(a):"0x",i??"0x",o?Ce(o):"0x",l??"0x",f,p,...Gu(t,e)])])}(t,e):function(t,e){const{chainId:n=0,gas:r,data:a,nonce:s,to:i,value:o,gasPrice:c}=t;!function(t){const{chainId:e,maxPriorityFeePerGas:n,gasPrice:r,maxFeePerGas:a,to:s}=t;if(s&&!Vn(s))throw new _n({address:s});if(void 0!==e&&e<=0)throw new Pc({chainId:e});if(n||a)throw new _t("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid Legacy Transaction attribute.");if(r&&r>ps)throw new Za({maxFeePerGas:r})}(t);let u=[s?Ce(s):"0x",c?Ce(c):"0x",r?Ce(r):"0x",i??"0x",o?Ce(o):"0x",a??"0x"];if(e){const t=(()=>{if(e.v>=35n){return(e.v-35n)/2n>0?e.v:27n+(35n===e.v?0n:1n)}if(n>0)return BigInt(2*n)+BigInt(35n+e.v-27n);const t=27n+(27n===e.v?0n:1n);if(e.v!==t)throw new Wr({v:e.v});return t})(),r=xe(e.r),a=xe(e.s);u=[...u,Ce(t),"0x00"===r?"0x":r,"0x00"===a?"0x":a]}else n>0&&(u=[...u,Ce(n),"0x","0x"]);return La(u)}(t,e)}function Gu(t,e){const n=e??t,{v:r,yParity:a}=n;if(void 0===n.r)return[];if(void 0===n.s)return[];if(void 0===r&&void 0===a)return[];const s=xe(n.r),i=xe(n.s);return["number"==typeof a?a?Ce(1):"0x":0n===r?"0x":1n===r?Ce(1):27n===r?"0x":Ce(1),"0x00"===s?"0x":s,"0x00"===i?"0x":i]}const qu=new zn(8192);function Hu(t,e={}){return async(n,r={})=>{const{dedupe:a=!1,methods:s,retryDelay:i=150,retryCount:o=3,uid:c}={...e,...r},{method:u}=n;if(s?.exclude?.includes(u))throw new wa(new Error("method not supported"),{method:u});if(s?.include&&!s.include.includes(u))throw new wa(new Error("method not supported"),{method:u});return function(t,{enabled:e=!0,id:n}){if(!e||!n)return t();if(qu.get(n))return qu.get(n);const r=t().finally(()=>qu.delete(n));return qu.set(n,r),r}(()=>Wc(async()=>{try{return await t(n)}catch(t){const e=t;switch(e.code){case la.code:throw new la(e);case fa.code:throw new fa(e);case pa.code:throw new pa(e,{method:n.method});case ma.code:throw new ma(e);case ha.code:throw new ha(e);case ba.code:throw new ba(e);case ya.code:throw new ya(e);case ga.code:throw new ga(e);case va.code:throw new va(e);case wa.code:throw new wa(e,{method:n.method});case xa.code:throw new xa(e);case Pa.code:throw new Pa(e);case ka.code:throw new ka(e);case Ia.code:throw new Ia(e);case Aa.code:throw new Aa(e);case Ea.code:throw new Ea(e);case Oa.code:throw new Oa(e);case Sa.code:throw new Sa(e);case Ta.code:throw new Ta(e);case Ca.code:throw new Ca(e);case Ba.code:throw new Ba(e);case Na.code:throw new Na(e);case ja.code:throw new ja(e);case Ua.code:throw new Ua(e);case Ma.code:throw new Ma(e);case 5e3:throw new ka(e);default:if(t instanceof _t)throw t;throw new Ra(e)}}},{delay:({count:t,error:e})=>{if(e&&e instanceof ia){const t=e?.headers?.get("Retry-After");if(t?.match(/\d/))return 1e3*Number.parseInt(t,10)}return(1<<t)*i},retryCount:o,shouldRetry:({error:t})=>function(t){if("code"in t&&"number"==typeof t.code)return-1===t.code||(t.code===xa.code||t.code===ha.code);if(t instanceof ia&&t.status)return 403===t.status||(408===t.status||(413===t.status||(429===t.status||(500===t.status||(502===t.status||(503===t.status||504===t.status))))));return!0}(t)}),{enabled:a,id:a?Ne(`${c}.${Mr(n)}`):void 0})}}class Vu extends _t{constructor({callbackSelector:t,cause:e,data:n,extraData:r,sender:a,urls:s}){super(e.shortMessage||"An error occurred while fetching for an offchain result.",{cause:e,metaMessages:[...e.metaMessages||[],e.metaMessages?.length?"":[],"Offchain Gateway Call:",s&&[" Gateway URL(s):",...s.map(t=>` ${t}`)],` Sender: ${a}`,` Data: ${n}`,` Callback selector: ${t}`,` Extra data: ${r}`].flat(),name:"OffchainLookupError"})}}class Ku extends _t{constructor({result:t,url:e}){super("Offchain gateway response is malformed. Response data must be a hex value.",{metaMessages:[`Gateway URL: ${e}`,`Response: ${Mr(t)}`],name:"OffchainLookupResponseMalformedError"})}}class Wu extends _t{constructor({sender:t,to:e}){super("Reverted sender address does not match target contract address (`to`).",{metaMessages:[`Contract address: ${e}`,`OffchainLookup sender address: ${t}`],name:"OffchainLookupSenderMismatchError"})}}const Zu={name:"OffchainLookup",type:"error",inputs:[{name:"sender",type:"address"},{name:"urls",type:"string[]"},{name:"callData",type:"bytes"},{name:"callbackFunction",type:"bytes4"},{name:"extraData",type:"bytes"}]};async function Ju({data:t,sender:e,urls:n}){let r=new Error("An unknown error occurred.");for(let a=0;a<n.length;a++){const s=n[a],i=s.includes("{data}")?"GET":"POST",o="POST"===i?{data:t,sender:e}:void 0,c="POST"===i?{"Content-Type":"application/json"}:{};try{const n=await fetch(s.replace("{sender}",e.toLowerCase()).replace("{data}",t),{body:JSON.stringify(o),headers:c,method:i});let a;if(a=n.headers.get("Content-Type")?.startsWith("application/json")?(await n.json()).data:await n.text(),!n.ok){r=new ia({body:o,details:a?.error?Mr(a.error):n.statusText,headers:n.headers,status:n.status,url:s});continue}if(!jt(a)){r=new Ku({result:a,url:s});continue}return a}catch(t){r=new ia({body:o,details:t.message,url:s})}}throw r}var Yu=Object.freeze({__proto__:null,ccipRequest:Ju,offchainLookup:async function(t,{blockNumber:e,blockTag:n,data:r,to:a}){const{args:s}=Ur({data:r,abi:[Zu]}),[i,o,c,u,d]=s,{ccipRead:l}=t,f=l&&"function"==typeof l?.request?l.request:Ju;try{if(!mi(a,i))throw new Wu({sender:i,to:a});const r=o.includes(du)?await lu({data:c,ccipRequest:f}):await f({data:c,sender:i,urls:o}),{data:s}=await Cc(t,{blockNumber:e,blockTag:n,data:Kn([u,nr([{type:"bytes"},{type:"bytes"}],[r,d])]),to:a});return s}catch(t){throw new Vu({callbackSelector:u,cause:t,data:r,extraData:d,sender:i,urls:o})}},offchainLookupAbiItem:Zu,offchainLookupSignature:"0x556f1830"});function Qu(t){return{formatters:void 0,fees:void 0,serializers:void 0,...t}}function Xu(t){const{source:e}=t,n=new Map,r=new zn(8192),a=new Map,s=({address:t,chainId:e})=>`${t}.${e}`;return{async consume({address:t,chainId:n,client:a}){const i=s({address:t,chainId:n}),o=this.get({address:t,chainId:n,client:a});this.increment({address:t,chainId:n});const c=await o;return await e.set({address:t,chainId:n},c),r.set(i,c),c},async increment({address:t,chainId:e}){const r=s({address:t,chainId:e}),a=n.get(r)??0;n.set(r,a+1)},async get({address:t,chainId:i,client:o}){const c=s({address:t,chainId:i});let u=a.get(c);u||(u=(async()=>{try{const n=await e.get({address:t,chainId:i,client:o}),a=r.get(c)??0;return a>0&&n<=a?a+1:(r.delete(c),n)}finally{this.reset({address:t,chainId:i})}})(),a.set(c,u));return(n.get(c)??0)+await u},reset({address:t,chainId:e}){const r=s({address:t,chainId:e});n.delete(r),a.delete(r)}}}function $u(){return{current:0,take(){return this.current++},reset(){this.current=0}}}const td=$u();function ed(t,e={}){return{async request(n){const{body:r,fetchFn:a=e.fetchFn??fetch,onRequest:s=e.onRequest,onResponse:i=e.onResponse,timeout:o=e.timeout??1e4}=n,c={...e.fetchOptions??{},...n.fetchOptions??{}},{headers:u,method:d,signal:l}=c;try{const e=await function(t,{errorInstance:e=new Error("timed out"),timeout:n,signal:r}){return new Promise((a,s)=>{(async()=>{let i;try{const e=new AbortController;n>0&&(i=setTimeout(()=>{r&&e.abort()},n)),a(await t({signal:e?.signal||null}))}catch(t){"AbortError"===t?.name&&s(e),s(t)}finally{clearTimeout(i)}})()})}(async({signal:e})=>{const n={...c,body:Array.isArray(r)?Mr(r.map(t=>({jsonrpc:"2.0",id:t.id??td.take(),...t}))):Mr({jsonrpc:"2.0",id:r.id??td.take(),...r}),headers:{"Content-Type":"application/json",...u},method:d||"POST",signal:l||(o>0?e:null)},i=new Request(t,n),f=await(s?.(i,n))??{...n,url:t};return await a(f.url??t,f)},{errorInstance:new ca({body:r,url:t}),timeout:o,signal:!0});let n;if(i&&await i(e),e.headers.get("Content-Type")?.startsWith("application/json"))n=await e.json();else{n=await e.text();try{n=JSON.parse(n||"{}")}catch(t){if(e.ok)throw t;n={error:n}}}if(!e.ok)throw new ia({body:r,details:Mr(n.error)||e.statusText,headers:e.headers,status:e.status,url:t});return n}catch(e){if(e instanceof ia)throw e;if(e instanceof ca)throw e;throw new ia({body:r,cause:e,url:t})}}}}function nd(t,e){return jn(function(t){const e="string"==typeof t?Ne(t):"string"==typeof t.raw?t.raw:Te(t.raw);return Kn([Ne(`Ethereum Signed Message:\n${Ut(e)}`),e])}(t),e)}class rd extends _t{constructor({domain:t}){super(`Invalid domain "${Mr(t)}".`,{metaMessages:["Must be a valid EIP-712 domain."]})}}class ad extends _t{constructor({primaryType:t,types:e}){super(`Invalid primary type \`${t}\` must be one of \`${JSON.stringify(Object.keys(e))}\`.`,{docsPath:"/api/glossary/Errors#typeddatainvalidprimarytypeerror",metaMessages:["Check that the primary type is a key in `types`."]})}}class sd extends _t{constructor({type:t}){super(`Struct type "${t}" is invalid.`,{metaMessages:["Struct type must not be a Solidity type."],name:"InvalidStructTypeError"})}}function id({domain:t}){return["string"==typeof t?.name&&{name:"name",type:"string"},t?.version&&{name:"version",type:"string"},("number"==typeof t?.chainId||"bigint"==typeof t?.chainId)&&{name:"chainId",type:"uint256"},t?.verifyingContract&&{name:"verifyingContract",type:"address"},t?.salt&&{name:"salt",type:"bytes32"}].filter(Boolean)}function od(t){if("address"===t||"bool"===t||"string"===t||t.startsWith("bytes")||t.startsWith("uint")||t.startsWith("int"))throw new sd({type:t})}function cd(t){const{domain:e={},message:n,primaryType:r}=t,a={EIP712Domain:id({domain:e}),...t.types};!function(t){const{domain:e,message:n,primaryType:r,types:a}=t,s=(t,e)=>{for(const n of t){const{name:t,type:r}=n,i=e[t],o=r.match(er);if(o&&("number"==typeof i||"bigint"==typeof i)){const[t,e,n]=o;Ce(i,{signed:"int"===e,size:Number.parseInt(n,10)/8})}if("address"===r&&"string"==typeof i&&!Vn(i))throw new _n({address:i});const c=r.match(tr);if(c){const[t,e]=c;if(e&&Ut(i)!==Number.parseInt(e,10))throw new re({expectedSize:Number.parseInt(e,10),givenSize:Ut(i)})}const u=a[r];u&&(od(r),s(u,i))}};if(a.EIP712Domain&&e){if("object"!=typeof e)throw new rd({domain:e});s(a.EIP712Domain,e)}if("EIP712Domain"!==r){if(!a[r])throw new ad({primaryType:r,types:a});s(a[r],n)}}({domain:e,message:n,primaryType:r,types:a});const s=["0x1901"];return e&&s.push(function({domain:t,types:e}){return ud({data:t,primaryType:"EIP712Domain",types:e})}({domain:e,types:a})),"EIP712Domain"!==r&&s.push(ud({data:n,primaryType:r,types:a})),jn(Kn(s))}function ud({data:t,primaryType:e,types:n}){return jn(dd({data:t,primaryType:e,types:n}))}function dd({data:t,primaryType:e,types:n}){const r=[{type:"bytes32"}],a=[ld({primaryType:e,types:n})];for(const s of n[e]){const[e,i]=pd({types:n,name:s.name,type:s.type,value:t[s.name]});r.push(e),a.push(i)}return nr(r,a)}function ld({primaryType:t,types:e}){const n=Oe(function({primaryType:t,types:e}){let n="";const r=fd({primaryType:t,types:e});r.delete(t);const a=[t,...Array.from(r).sort()];for(const t of a)n+=`${t}(${e[t].map(({name:t,type:e})=>`${e} ${t}`).join(",")})`;return n}({primaryType:t,types:e}));return jn(n)}function fd({primaryType:t,types:e},n=new Set){const r=t.match(/^\w*/u),a=r?.[0];if(n.has(a)||void 0===e[a])return n;n.add(a);for(const t of e[a])fd({primaryType:t.type,types:e},n);return n}function pd({types:t,name:e,type:n,value:r}){if(void 0!==t[n])return[{type:"bytes32"},jn(dd({data:r,primaryType:n,types:t}))];if("bytes"===n){return[{type:"bytes32"},jn(r=`0x${(r.length%2?"0":"")+r.slice(2)}`)]}if("string"===n)return[{type:"bytes32"},jn(Oe(r))];if(n.lastIndexOf("]")===n.length-1){const a=n.slice(0,n.lastIndexOf("[")),s=r.map(n=>pd({name:e,type:a,types:t,value:n}));return[{type:"bytes32"},jn(nr(s.map(([t])=>t),s.map(([,t])=>t)))]}return[{type:n},r]}class md extends Error{constructor(t,e={}){const n=e.cause instanceof md?e.cause.details:e.cause?.message?e.cause.message:e.details,r=e.cause instanceof md&&e.cause.docsPath||e.docsPath;super([t||"An error occurred.","",...e.metaMessages?[...e.metaMessages,""]:[],...r?[`Docs: https://abitype.dev${r}`]:[],...n?[`Details: ${n}`]:[],"Version: abitype@1.1.1"].join("\n")),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"}),e.cause&&(this.cause=e.cause),this.details=n,this.docsPath=r,this.metaMessages=e.metaMessages,this.shortMessage=t}}function hd(t,e){const n=t.exec(e);return n?.groups}const bd=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,yd=/^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)?$/,gd=/^\(.+?\).*?$/,vd=/^tuple(?<array>(\[(\d*)\])*)$/;function wd(t){let e=t.type;if(vd.test(t.type)&&"components"in t){e="(";const n=t.components.length;for(let r=0;r<n;r++){e+=wd(t.components[r]),r<n-1&&(e+=", ")}const r=hd(vd,t.type);return e+=`)${r?.array??""}`,wd({...t,type:e})}return"indexed"in t&&t.indexed&&(e=`${e} indexed`),t.name?`${e} ${t.name}`:e}function xd(t){let e="";const n=t.length;for(let r=0;r<n;r++){e+=wd(t[r]),r!==n-1&&(e+=", ")}return e}function Pd(t){return"function"===t.type?`function ${t.name}(${xd(t.inputs)})${t.stateMutability&&"nonpayable"!==t.stateMutability?` ${t.stateMutability}`:""}${t.outputs?.length?` returns (${xd(t.outputs)})`:""}`:"event"===t.type?`event ${t.name}(${xd(t.inputs)})`:"error"===t.type?`error ${t.name}(${xd(t.inputs)})`:"constructor"===t.type?`constructor(${xd(t.inputs)})${"payable"===t.stateMutability?" payable":""}`:"fallback"===t.type?"fallback() external"+("payable"===t.stateMutability?" payable":""):"receive() external payable"}const kd=/^error (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/;const Id=/^event (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/;const Ad=/^function (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)(?: (?<scope>external|public{1}))?(?: (?<stateMutability>pure|view|nonpayable|payable{1}))?(?: returns\s?\((?<returns>.*?)\))?$/;const Ed=/^struct (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*) \{(?<properties>.*?)\}$/;function Od(t){return Ed.test(t)}function Sd(t){return hd(Ed,t)}const Td=/^constructor\((?<parameters>.*?)\)(?:\s(?<stateMutability>payable{1}))?$/;const Cd=/^fallback\(\) external(?:\s(?<stateMutability>payable{1}))?$/;const Bd=/^receive\(\) external payable$/;const Nd=new Set(["memory","indexed","storage","calldata"]),jd=new Set(["indexed"]),Ud=new Set(["calldata","memory","storage"]);class Md extends md{constructor({signature:t}){super("Failed to parse ABI item.",{details:`parseAbiItem(${JSON.stringify(t,null,2)})`,docsPath:"/api/human#parseabiitem-1"}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidAbiItemError"})}}class Rd extends md{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 Fd extends md{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 _d extends md{constructor({params:t}){super("Failed to parse ABI parameters.",{details:`parseAbiParameters(${JSON.stringify(t,null,2)})`,docsPath:"/api/human#parseabiparameters-1"}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidAbiParametersError"})}}class zd extends md{constructor({param:t}){super("Invalid ABI parameter.",{details:t}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidParameterError"})}}class Dd extends md{constructor({param:t,name:e}){super("Invalid ABI parameter.",{details:t,metaMessages:[`"${e}" 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 Ld extends md{constructor({param:t,type:e,modifier:n}){super("Invalid ABI parameter.",{details:t,metaMessages:[`Modifier "${n}" not allowed${e?` in "${e}" type`:""}.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidModifierError"})}}class Gd extends md{constructor({param:t,type:e,modifier:n}){super("Invalid ABI parameter.",{details:t,metaMessages:[`Modifier "${n}" not allowed${e?` in "${e}" type`:""}.`,`Data location can only be specified for array, struct, or mapping types, but "${n}" was given.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidFunctionModifierError"})}}class qd extends md{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 Hd extends md{constructor({signature:t,type:e}){super(`Invalid ${e} signature.`,{details:t}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidSignatureError"})}}class Vd extends md{constructor({signature:t}){super("Unknown signature.",{details:t}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownSignatureError"})}}class Kd extends md{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 Wd extends md{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 Zd extends md{constructor({current:t,depth:e}){super("Unbalanced parentheses.",{metaMessages:[`"${t.trim()}" has too many ${e>0?"opening":"closing"} parentheses.`],details:`Depth "${e}"`}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidParenthesisError"})}}const Jd=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 Yd(t,e={}){if(function(t){return Ad.test(t)}(t))return function(t,e={}){const n=function(t){return hd(Ad,t)}(t);if(!n)throw new Hd({signature:t,type:"function"});const r=el(n.parameters),a=[],s=r.length;for(let t=0;t<s;t++)a.push(tl(r[t],{modifiers:Ud,structs:e,type:"function"}));const i=[];if(n.returns){const t=el(n.returns),r=t.length;for(let n=0;n<r;n++)i.push(tl(t[n],{modifiers:Ud,structs:e,type:"function"}))}return{name:n.name,type:"function",stateMutability:n.stateMutability??"nonpayable",inputs:a,outputs:i}}(t,e);if(function(t){return Id.test(t)}(t))return function(t,e={}){const n=function(t){return hd(Id,t)}(t);if(!n)throw new Hd({signature:t,type:"event"});const r=el(n.parameters),a=[],s=r.length;for(let t=0;t<s;t++)a.push(tl(r[t],{modifiers:jd,structs:e,type:"event"}));return{name:n.name,type:"event",inputs:a}}(t,e);if(function(t){return kd.test(t)}(t))return function(t,e={}){const n=function(t){return hd(kd,t)}(t);if(!n)throw new Hd({signature:t,type:"error"});const r=el(n.parameters),a=[],s=r.length;for(let t=0;t<s;t++)a.push(tl(r[t],{structs:e,type:"error"}));return{name:n.name,type:"error",inputs:a}}(t,e);if(function(t){return Td.test(t)}(t))return function(t,e={}){const n=function(t){return hd(Td,t)}(t);if(!n)throw new Hd({signature:t,type:"constructor"});const r=el(n.parameters),a=[],s=r.length;for(let t=0;t<s;t++)a.push(tl(r[t],{structs:e,type:"constructor"}));return{type:"constructor",stateMutability:n.stateMutability??"nonpayable",inputs:a}}(t,e);if(function(t){return Cd.test(t)}(t))return function(t){const e=function(t){return hd(Cd,t)}(t);if(!e)throw new Hd({signature:t,type:"fallback"});return{type:"fallback",stateMutability:e.stateMutability??"nonpayable"}}(t);if(function(t){return Bd.test(t)}(t))return{type:"receive",stateMutability:"payable"};throw new Vd({signature:t})}const Qd=/^(?<type>[a-zA-Z$_][a-zA-Z0-9$_]*(?:\spayable)?)(?<array>(?:\[\d*?\])+?)?(?:\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\s(?<name>[a-zA-Z$_][a-zA-Z0-9$_]*))?$/,Xd=/^\((?<type>.+?)\)(?<array>(?:\[\d*?\])+?)?(?:\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\s(?<name>[a-zA-Z$_][a-zA-Z0-9$_]*))?$/,$d=/^u?int$/;function tl(t,e){const n=function(t,e,n){let r="";if(n)for(const t of Object.entries(n)){if(!t)continue;let e="";for(const n of t[1])e+=`[${n.type}${n.name?`:${n.name}`:""}]`;r+=`(${t[0]}{${e}})`}return e?`${e}:${t}${r}`:t}(t,e?.type,e?.structs);if(Jd.has(n))return Jd.get(n);const r=gd.test(t),a=hd(r?Xd:Qd,t);if(!a)throw new zd({param:t});if(a.name&&function(t){return"address"===t||"bool"===t||"function"===t||"string"===t||"tuple"===t||bd.test(t)||yd.test(t)||rl.test(t)}(a.name))throw new Dd({param:t,name:a.name});const s=a.name?{name:a.name}:{},i="indexed"===a.modifier?{indexed:!0}:{},o=e?.structs??{};let c,u={};if(r){c="tuple";const t=el(a.type),e=[],n=t.length;for(let r=0;r<n;r++)e.push(tl(t[r],{structs:o}));u={components:e}}else if(a.type in o)c="tuple",u={components:o[a.type]};else if($d.test(a.type))c=`${a.type}256`;else if("address payable"===a.type)c="address";else if(c=a.type,"struct"!==e?.type&&!nl(c))throw new Fd({type:c});if(a.modifier){if(!e?.modifiers?.has?.(a.modifier))throw new Ld({param:t,type:e?.type,modifier:a.modifier});if(Ud.has(a.modifier)&&!function(t,e){return e||"bytes"===t||"string"===t||"tuple"===t}(c,!!a.array))throw new Gd({param:t,type:e?.type,modifier:a.modifier})}const d={type:`${c}${a.array??""}`,...s,...i,...u};return Jd.set(n,d),d}function el(t,e=[],n="",r=0){const a=t.trim().length;for(let s=0;s<a;s++){const a=t[s],i=t.slice(s+1);switch(a){case",":return 0===r?el(i,[...e,n.trim()]):el(i,e,`${n}${a}`,r);case"(":return el(i,e,`${n}${a}`,r+1);case")":return el(i,e,`${n}${a}`,r-1);default:return el(i,e,`${n}${a}`,r)}}if(""===n)return e;if(0!==r)throw new Zd({current:n,depth:r});return e.push(n.trim()),e}function nl(t){return"address"===t||"bool"===t||"function"===t||"string"===t||bd.test(t)||yd.test(t)}const rl=/^(?: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 al(t){const e={},n=t.length;for(let r=0;r<n;r++){const n=t[r];if(!Od(n))continue;const a=Sd(n);if(!a)throw new Hd({signature:n,type:"struct"});const s=a.properties.split(";"),i=[],o=s.length;for(let t=0;t<o;t++){const e=s[t].trim();if(!e)continue;const n=tl(e,{type:"struct"});i.push(n)}if(!i.length)throw new Kd({signature:n});e[a.name]=i}const r={},a=Object.entries(e),s=a.length;for(let t=0;t<s;t++){const[n,s]=a[t];r[n]=il(s,e)}return r}const sl=/^(?<type>[a-zA-Z$_][a-zA-Z0-9$_]*)(?<array>(?:\[\d*?\])+?)?$/;function il(t,e,n=new Set){const r=[],a=t.length;for(let s=0;s<a;s++){const a=t[s];if(gd.test(a.type))r.push(a);else{const t=hd(sl,a.type);if(!t?.type)throw new qd({abiParameter:a});const{array:s,type:i}=t;if(i in e){if(n.has(i))throw new Wd({type:i});r.push({...a,type:`tuple${s??""}`,components:il(e[i]??[],e,new Set([...n,i]))})}else{if(!nl(i))throw new Rd({type:i});r.push(a)}}}return r}function ol(t){let e;if("string"==typeof t)e=Yd(t);else{const n=al(t),r=t.length;for(let a=0;a<r;a++){const r=t[a];if(!Od(r)){e=Yd(r,n);break}}}if(!e)throw new Md({signature:t});return e}function cl(t){const e=[];if("string"==typeof t){const n=el(t),r=n.length;for(let t=0;t<r;t++)e.push(tl(n[t],{modifiers:Nd}))}else{const n=al(t),r=t.length;for(let a=0;a<r;a++){const r=t[a];if(Od(r))continue;const s=el(r),i=s.length;for(let t=0;t<i;t++)e.push(tl(s[t],{modifiers:Nd,structs:n}))}}if(0===e.length)throw new _d({params:t});return e}class ul extends Map{constructor(t){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=t}get(t){const e=super.get(t);return super.has(t)&&void 0!==e&&(this.delete(t),super.set(t,e)),e}set(t,e){if(super.set(t,e),this.maxSize&&this.size>this.maxSize){const t=this.keys().next().value;t&&this.delete(t)}return this}}const dl={checksum:new ul(8192)}.checksum;function ll(t,e={}){const{as:n=("string"==typeof t?"Hex":"Bytes")}=e,r=Nn(wo(t));return"Bytes"===n?r:Go(r)}function fl(t,e={}){const{as:n=("string"==typeof t?"Hex":"Bytes")}=e,r=Qs(wo(t));return"Bytes"===n?r:Go(r)}function pl(t,e={}){const{compressed:n}=e,{prefix:r,x:a,y:s}=t;if(!1===n||"bigint"==typeof a&&"bigint"==typeof s){if(4!==r)throw new gl({prefix:r,cause:new wl})}else{if(!0!==n&&("bigint"!=typeof a||void 0!==s))throw new yl({publicKey:t});if(3!==r&&2!==r)throw new gl({prefix:r,cause:new vl})}}function ml(t){const e=(()=>{if(Qo(t))return hl(t);if(Bo(t))return function(t){return hl(Go(t))}(t);const{prefix:e,x:n,y:r}=t;return"bigint"==typeof n&&"bigint"==typeof r?{prefix:e??4,x:n,y:r}:{prefix:e,x:n}})();return pl(e),e}function hl(t){if(132!==t.length&&130!==t.length&&68!==t.length)throw new xl({publicKey:t});if(130===t.length){return{prefix:4,x:BigInt(Wo(t,0,32)),y:BigInt(Wo(t,32,64))}}if(132===t.length){return{prefix:Number(Wo(t,0,1)),x:BigInt(Wo(t,1,33)),y:BigInt(Wo(t,33,65))}}return{prefix:Number(Wo(t,0,1)),x:BigInt(Wo(t,1,33))}}function bl(t,e={}){pl(t);const{prefix:n,x:r,y:a}=t,{includePrefix:s=!0}=e;return zo(s?qo(n,{size:1}):"0x",qo(r,{size:32}),"bigint"==typeof a?qo(a,{size:32}):"0x")}class yl extends ro{constructor({publicKey:t}){super(`Value \`${yo(t)}\` is not a valid public key.`,{metaMessages:["Public key must contain:","- an `x` and `prefix` value (compressed)","- an `x`, `y`, and `prefix` value (uncompressed)"]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"PublicKey.InvalidError"})}}class gl extends ro{constructor({prefix:t,cause:e}){super(`Prefix "${t}" is invalid.`,{cause:e}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"PublicKey.InvalidPrefixError"})}}class vl extends ro{constructor(){super("Prefix must be 2 or 3 for compressed public keys."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"PublicKey.InvalidCompressedPrefixError"})}}class wl extends ro{constructor(){super("Prefix must be 4 for uncompressed public keys."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"PublicKey.InvalidUncompressedPrefixError"})}}let xl=class extends ro{constructor({publicKey:t}){super(`Value \`${t}\` is an invalid public key size.`,{metaMessages:["Expected: 33 bytes (compressed + prefix), 64 bytes (uncompressed) or 65 bytes (uncompressed + prefix).",`Received ${Zo(Do(t))} bytes.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"PublicKey.InvalidSerializedSizeError"})}};const Pl=/^0x[a-fA-F0-9]{40}$/;function kl(t,e={}){const{strict:n=!0}=e;if(!Pl.test(t))throw new El({address:t,cause:new Ol});if(n){if(t.toLowerCase()===t)return;if(Il(t)!==t)throw new El({address:t,cause:new Sl})}}function Il(t){if(dl.has(t))return dl.get(t);kl(t,{strict:!1});const e=t.substring(2).toLowerCase(),n=ll(ko(e),{as:"Bytes"}),r=e.split("");for(let t=0;t<40;t+=2)n[t>>1]>>4>=8&&r[t]&&(r[t]=r[t].toUpperCase()),(15&n[t>>1])>=8&&r[t+1]&&(r[t+1]=r[t+1].toUpperCase());const a=`0x${r.join("")}`;return dl.set(t,a),a}function Al(t,e={}){const{strict:n=!0}=e??{};try{return kl(t,{strict:n}),!0}catch{return!1}}class El extends ro{constructor({address:t,cause:e}){super(`Address "${t}" is invalid.`,{cause:e}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidAddressError"})}}class Ol extends ro{constructor(){super("Address is not a 20 byte (40 hexadecimal character) value."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidInputError"})}}class Sl extends ro{constructor(){super("Address does not match its checksum counterpart."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidChecksumError"})}}const Tl=/^(.*)\[([0-9]*)\]$/,Cl=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,Bl=/^(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)?$/,Nl=2n**256n-1n;function jl(t,e,n){const{checksumAddress:r,staticPosition:a}=n,s=_l(e.type);if(s){const[n,i]=s;return function(t,e,n){const{checksumAddress:r,length:a,staticPosition:s}=n;if(!a){const n=s+So(t.readBytes(Ml)),a=n+Ul;t.setPosition(n);const i=So(t.readBytes(Ul)),o=zl(e);let c=0;const u=[];for(let n=0;n<i;++n){t.setPosition(a+(o?32*n:c));const[s,i]=jl(t,e,{checksumAddress:r,staticPosition:a});c+=i,u.push(s)}return t.setPosition(s+32),[u,32]}if(zl(e)){const n=s+So(t.readBytes(Ml)),i=[];for(let s=0;s<a;++s){t.setPosition(n+32*s);const[a]=jl(t,e,{checksumAddress:r,staticPosition:n});i.push(a)}return t.setPosition(s+32),[i,32]}let i=0;const o=[];for(let n=0;n<a;++n){const[n,a]=jl(t,e,{checksumAddress:r,staticPosition:s+i});i+=a,o.push(n)}return[o,i]}(t,{...e,type:i},{checksumAddress:r,length:n,staticPosition:a})}if("tuple"===e.type)return function(t,e,n){const{checksumAddress:r,staticPosition:a}=n,s=0===e.components.length||e.components.some(({name:t})=>!t),i=s?[]:{};let o=0;if(zl(e)){const n=a+So(t.readBytes(Ml));for(let a=0;a<e.components.length;++a){const c=e.components[a];t.setPosition(n+o);const[u,d]=jl(t,c,{checksumAddress:r,staticPosition:n});o+=d,i[s?a:c?.name]=u}return t.setPosition(a+32),[i,32]}for(let n=0;n<e.components.length;++n){const c=e.components[n],[u,d]=jl(t,c,{checksumAddress:r,staticPosition:a});i[s?n:c?.name]=u,o+=d}return[i,o]}(t,e,{checksumAddress:r,staticPosition:a});if("address"===e.type)return function(t,e={}){const{checksum:n=!1}=e,r=t.readBytes(32),a=t=>n?Il(t):t;return[a(Go(Ao(r,-20))),32]}(t,{checksum:r});if("bool"===e.type)return function(t){return[Oo(t.readBytes(32),{size:32}),32]}(t);if(e.type.startsWith("bytes"))return function(t,e,{staticPosition:n}){const[r,a]=e.type.split("bytes");if(!a){const e=So(t.readBytes(32));t.setPosition(n+e);const r=So(t.readBytes(32));if(0===r)return t.setPosition(n+32),["0x",32];const a=t.readBytes(r);return t.setPosition(n+32),[Go(a),32]}const s=Go(t.readBytes(Number.parseInt(a,10),32));return[s,32]}(t,e,{staticPosition:a});if(e.type.startsWith("uint")||e.type.startsWith("int"))return function(t,e){const n=e.type.startsWith("int"),r=Number.parseInt(e.type.split("int")[1]||"256",10),a=t.readBytes(32);return[r>48?Eo(a,{signed:n}):So(a,{signed:n}),32]}(t,e);if("string"===e.type)return function(t,{staticPosition:e}){const n=So(t.readBytes(32)),r=e+n;t.setPosition(r);const a=So(t.readBytes(32));if(0===a)return t.setPosition(e+32),["",32];const s=t.readBytes(a,32),i=To(Co(s));return t.setPosition(e+32),[i,32]}(t,{staticPosition:a});throw new tf(e.type)}const Ul=32,Ml=32;function Rl({checksumAddress:t=!1,parameter:e,value:n}){const r=e,a=_l(r.type);if(a){const[e,s]=a;return function(t,e){const{checksumAddress:n,length:r,parameter:a}=e,s=null===r;if(!Array.isArray(t))throw new $l(t);if(!s&&t.length!==r)throw new Yl({expectedLength:r,givenLength:t.length,type:`${a.type}[${r}]`});let i=!1;const o=[];for(let e=0;e<t.length;e++){const r=Rl({checksumAddress:n,parameter:a,value:t[e]});r.dynamic&&(i=!0),o.push(r)}if(s||i){const t=Fl(o);if(s){const e=qo(o.length,{size:32});return{dynamic:!0,encoded:o.length>0?zo(e,t):e}}if(i)return{dynamic:!0,encoded:t}}return{dynamic:!1,encoded:zo(...o.map(({encoded:t})=>t))}}(n,{checksumAddress:t,length:e,parameter:{...r,type:s}})}if("tuple"===r.type)return function(t,e){const{checksumAddress:n,parameter:r}=e;let a=!1;const s=[];for(let e=0;e<r.components.length;e++){const i=r.components[e],o=Rl({checksumAddress:n,parameter:i,value:t[Array.isArray(t)?e:i.name]});s.push(o),o.dynamic&&(a=!0)}return{dynamic:a,encoded:a?Fl(s):zo(...s.map(({encoded:t})=>t))}}(n,{checksumAddress:t,parameter:r});if("address"===r.type)return function(t,e){const{checksum:n=!1}=e;return kl(t,{strict:n}),{dynamic:!1,encoded:Vo(t.toLowerCase())}}(n,{checksum:t});if("bool"===r.type)return function(t){if("boolean"!=typeof t)throw new ro(`Invalid boolean value: "${t}" (type: ${typeof t}). Expected: \`true\` or \`false\`.`);return{dynamic:!1,encoded:Vo(Lo(t))}}(n);if(r.type.startsWith("uint")||r.type.startsWith("int")){const t=r.type.startsWith("int"),[,,e="256"]=Bl.exec(r.type)??[];return function(t,{signed:e,size:n}){if("number"==typeof n){const r=2n**(BigInt(n)-(e?1n:0n))-1n,a=e?-r-1n:0n;if(t>r||t<a)throw new Xo({max:r.toString(),min:a.toString(),signed:e,size:n/8,value:t.toString()})}return{dynamic:!1,encoded:qo(t,{size:32,signed:e})}}(n,{signed:t,size:Number(e)})}if(r.type.startsWith("bytes"))return function(t,{type:e}){const[,n]=e.split("bytes"),r=Zo(t);if(!n){let e=t;return r%32!=0&&(e=Ko(e,32*Math.ceil((t.length-2)/2/32))),{dynamic:!0,encoded:zo(Vo(qo(r,{size:32})),e)}}if(r!==Number.parseInt(n,10))throw new Ql({expectedSize:Number.parseInt(n,10),value:t});return{dynamic:!1,encoded:Ko(t)}}(n,{type:r.type});if("string"===r.type)return function(t){const e=Ho(t),n=Math.ceil(Zo(e)/32),r=[];for(let t=0;t<n;t++)r.push(Ko(Wo(e,32*t,32*(t+1))));return{dynamic:!0,encoded:zo(Ko(qo(Zo(e),{size:32})),...r)}}(n);throw new tf(r.type)}function Fl(t){let e=0;for(let n=0;n<t.length;n++){const{dynamic:r,encoded:a}=t[n];e+=r?32:Zo(a)}const n=[],r=[];let a=0;for(let s=0;s<t.length;s++){const{dynamic:i,encoded:o}=t[s];i?(n.push(qo(e+a,{size:32})),r.push(o),a+=Zo(o)):n.push(o)}return zo(...n,...r)}function _l(t){const e=t.match(/^(.*)\[(\d+)?\]$/);return e?[e[2]?Number(e[2]):null,e[1]]:void 0}function zl(t){const{type:e}=t;if("string"===e)return!0;if("bytes"===e)return!0;if(e.endsWith("[]"))return!0;if("tuple"===e)return t.components?.some(zl);const n=_l(t.type);return!(!n||!zl({...t,type:n[1]}))}const Dl={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 ql({count:this.recursiveReadCount+1,limit:this.recursiveReadLimit})},assertPosition(t){if(t<0||t>this.bytes.length-1)throw new Gl({length:this.bytes.length,position:t})},decrementPosition(t){if(t<0)throw new Ll({offset:t});const e=this.position-t;this.assertPosition(e),this.position=e},getReadCount(t){return this.positionReadCount.get(t||this.position)||0},incrementPosition(t){if(t<0)throw new Ll({offset:t});const e=this.position+t;this.assertPosition(e),this.position=e},inspectByte(t){const e=t??this.position;return this.assertPosition(e),this.bytes[e]},inspectBytes(t,e){const n=e??this.position;return this.assertPosition(n+t-1),this.bytes.subarray(n,n+t)},inspectUint8(t){const e=t??this.position;return this.assertPosition(e),this.bytes[e]},inspectUint16(t){const e=t??this.position;return this.assertPosition(e+1),this.dataView.getUint16(e)},inspectUint24(t){const e=t??this.position;return this.assertPosition(e+2),(this.dataView.getUint16(e)<<8)+this.dataView.getUint8(e+2)},inspectUint32(t){const e=t??this.position;return this.assertPosition(e+3),this.dataView.getUint32(e)},pushByte(t){this.assertPosition(this.position),this.bytes[this.position]=t,this.position++},pushBytes(t){this.assertPosition(this.position+t.length-1),this.bytes.set(t,this.position),this.position+=t.length},pushUint8(t){this.assertPosition(this.position),this.bytes[this.position]=t,this.position++},pushUint16(t){this.assertPosition(this.position+1),this.dataView.setUint16(this.position,t),this.position+=2},pushUint24(t){this.assertPosition(this.position+2),this.dataView.setUint16(this.position,t>>8),this.dataView.setUint8(this.position+2,255&t),this.position+=3},pushUint32(t){this.assertPosition(this.position+3),this.dataView.setUint32(this.position,t),this.position+=4},readByte(){this.assertReadLimit(),this._touch();const t=this.inspectByte();return this.position++,t},readBytes(t,e){this.assertReadLimit(),this._touch();const n=this.inspectBytes(t);return this.position+=e??t,n},readUint8(){this.assertReadLimit(),this._touch();const t=this.inspectUint8();return this.position+=1,t},readUint16(){this.assertReadLimit(),this._touch();const t=this.inspectUint16();return this.position+=2,t},readUint24(){this.assertReadLimit(),this._touch();const t=this.inspectUint24();return this.position+=3,t},readUint32(){this.assertReadLimit(),this._touch();const t=this.inspectUint32();return this.position+=4,t},get remaining(){return this.bytes.length-this.position},setPosition(t){const e=this.position;return this.assertPosition(t),this.position=t,()=>this.position=e},_touch(){if(this.recursiveReadLimit===Number.POSITIVE_INFINITY)return;const t=this.getReadCount();this.positionReadCount.set(this.position,t+1),t>0&&this.recursiveReadCount++}};class Ll extends ro{constructor({offset:t}){super(`Offset \`${t}\` cannot be negative.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Cursor.NegativeOffsetError"})}}class Gl extends ro{constructor({length:t,position:e}){super(`Position \`${e}\` is out of bounds (\`0 < position < ${t}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Cursor.PositionOutOfBoundsError"})}}class ql extends ro{constructor({count:t,limit:e}){super(`Recursive read limit of \`${e}\` exceeded (recursive read count: \`${t}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Cursor.RecursiveReadLimitExceededError"})}}function Hl(t,e,n={}){const{as:r="Array",checksumAddress:a=!1}=n,s="string"==typeof e?Po(e):e,i=function(t,{recursiveReadLimit:e=8192}={}){const n=Object.create(Dl);return n.bytes=t,n.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength),n.positionReadCount=new Map,n.recursiveReadLimit=e,n}(s);if(0===Io(s)&&t.length>0)throw new Jl;if(Io(s)&&Io(s)<32)throw new Zl({data:"string"==typeof e?e:Go(e),parameters:t,size:Io(s)});let o=0;const c="Array"===r?[]:{};for(let e=0;e<t.length;++e){const n=t[e];i.setPosition(o);const[s,u]=jl(i,n,{checksumAddress:a,staticPosition:0});o+=u,"Array"===r?c.push(s):c[n.name??e]=s}return c}function Vl(t,e,n){const{checksumAddress:r=!1}={};if(t.length!==e.length)throw new Xl({expectedLength:t.length,givenLength:e.length});const a=function({checksumAddress:t,parameters:e,values:n}){const r=[];for(let a=0;a<e.length;a++)r.push(Rl({checksumAddress:t,parameter:e[a],value:n[a]}));return r}({checksumAddress:r,parameters:t,values:e}),s=Fl(a);return 0===s.length?"0x":s}function Kl(t,e){if(t.length!==e.length)throw new Xl({expectedLength:t.length,givenLength:e.length});const n=[];for(let r=0;r<t.length;r++){const a=t[r],s=e[r];n.push(Kl.encode(a,s))}return zo(...n)}function Wl(t){return Array.isArray(t)&&"string"==typeof t[0]||"string"==typeof t?cl(t):t}!function(t){t.encode=function t(e,n,r=!1){if("address"===e){const t=n;return kl(t),Vo(t.toLowerCase(),r?32:0)}if("string"===e)return Ho(n);if("bytes"===e)return n;if("bool"===e)return Vo(Lo(n),r?32:1);const a=e.match(Bl);if(a){const[t,e,s="256"]=a,i=Number.parseInt(s,10)/8;return qo(n,{size:r?32:i,signed:"int"===e})}const s=e.match(Cl);if(s){const[t,e]=s;if(Number.parseInt(e,10)!==(n.length-2)/2)throw new Ql({expectedSize:Number.parseInt(e,10),value:n});return Ko(n,r?32:0)}const i=e.match(Tl);if(i&&Array.isArray(n)){const[e,r]=i,a=[];for(let e=0;e<n.length;e++)a.push(t(r,n[e],!0));return 0===a.length?"0x":zo(...a)}throw new tf(e)}}(Kl||(Kl={}));class Zl extends ro{constructor({data:t,parameters:e,size:n}){super(`Data size of ${n} bytes is too small for given parameters.`,{metaMessages:[`Params: (${xd(e)})`,`Data: ${t} (${n} bytes)`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.DataSizeTooSmallError"})}}class Jl extends ro{constructor(){super('Cannot decode zero data ("0x") with ABI parameters.'),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.ZeroDataError"})}}class Yl extends ro{constructor({expectedLength:t,givenLength:e,type:n}){super(`Array length mismatch for type \`${n}\`. Expected: \`${t}\`. Given: \`${e}\`.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.ArrayLengthMismatchError"})}}class Ql extends ro{constructor({expectedSize:t,value:e}){super(`Size of bytes "${e}" (bytes${Zo(e)}) does not match expected size (bytes${t}).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.BytesSizeMismatchError"})}}class Xl extends ro{constructor({expectedLength:t,givenLength:e}){super(["ABI encoding parameters/values length mismatch.",`Expected length (parameters): ${t}`,`Given length (values): ${e}`].join("\n")),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.LengthMismatchError"})}}class $l extends ro{constructor(t){super(`Value \`${t}\` is not a valid array.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.InvalidArrayError"})}}class tf extends ro{constructor(t){super(`Type \`${t}\` is not a valid ABI Type.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.InvalidTypeError"})}}class ef extends mn{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,function(t){if("function"!=typeof t||"function"!=typeof t.create)throw new Error("Hash should be wrapped by utils.createHasher");rn(t.outputLen),rn(t.blockLen)}(t);const n=pn(e);if(this.iHash=t.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const r=this.blockLen,a=new Uint8Array(r);a.set(n.length>r?t.create().update(n).digest():n);for(let t=0;t<a.length;t++)a[t]^=54;this.iHash.update(a),this.oHash=t.create();for(let t=0;t<a.length;t++)a[t]^=106;this.oHash.update(a),cn(a)}update(t){return sn(this),this.iHash.update(t),this}digestInto(t){sn(this),an(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));const{oHash:e,iHash:n,finished:r,destroyed:a,blockLen:s,outputLen:i}=this;return t.finished=r,t.destroyed=a,t.blockLen=s,t.outputLen=i,t.oHash=e._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const nf=(t,e,n)=>new ef(t,e).update(n).digest();nf.create=(t,e)=>new ef(t,e);
|
|
@@ -77,11 +77,11 @@ export type Preference = {
|
|
|
77
77
|
* @default undefined
|
|
78
78
|
*/
|
|
79
79
|
authType?: 'google' | 'line' | 'apple';
|
|
80
|
-
/** EOA
|
|
81
|
-
* @description When set to true,
|
|
82
|
-
* @default false
|
|
80
|
+
/** Require EOA wallet linking
|
|
81
|
+
* @description When set to true, the user will be required to link an EOA wallet. Other authentication methods remain available.
|
|
82
|
+
* @default false
|
|
83
83
|
*/
|
|
84
|
-
|
|
84
|
+
eoaRequired?: boolean;
|
|
85
85
|
} & Record<string, unknown>;
|
|
86
86
|
export type SubAccountOptions = {
|
|
87
87
|
enableAutoSubAccounts?: boolean;
|