superstack-wallet-sdk 0.4.2 → 0.4.5
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/esm/src/hooks.js +1 -1
- package/dist/esm/src/hooks.js.map +1 -1
- package/dist/esm/src/storage.js +1 -1
- package/dist/esm/src/storage.js.map +1 -1
- package/dist/esm/src/types.js.map +1 -1
- package/dist/esm/types/client.d.ts +1 -1
- package/dist/esm/types/hooks.d.ts +1 -1
- package/dist/esm/types/types.d.ts +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -3
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var e=require("axios"),t=require("@solana/web3.js"),n=require("bs58"),r=require("uuid"),o=require("react"),s=require("lucide-react"),a=require("qs");function i(e){return e&&e.__esModule?e:{default:e}}function c(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach(function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}}),t.default=e,Object.freeze(t)}var u,l,d,f=i(e),h=i(n),p=i(o),m=c(a);function g(e){return"version"in e}"undefined"!=typeof globalThis&&void 0===globalThis.globalThis&&(globalThis.global=globalThis),exports.Network=void 0,(u=exports.Network||(exports.Network={})).Solana="Solana",u.Ethereum="Ethereum",exports.WalletType=void 0,(l=exports.WalletType||(exports.WalletType={})).Phantom="Phantom",l.Embedded="Embedded",exports.SocialType=void 0,(d=exports.SocialType||(exports.SocialType={})).Email="Email",d.Google="Google",d.Twitter="Twitter",d.Phantom="Phantom",d.Phone="Phone",d.Okx="Okx";const b="embedded_wallet_state",y="clique_wallet_type";class w{static saveAccessToken(e,t){const n={accessToken:e,social:t,lastConnected:Date.now()};localStorage.setItem(b,JSON.stringify(n))}static saveWalletType(e){localStorage.setItem(y,e)}static getWalletType(){return localStorage.getItem(y)}static getAccessToken(){try{const e=localStorage.getItem(b);if(!e)return null;const t=JSON.parse(e);return Date.now()-t.lastConnected<6048e5?t.accessToken:(this.clear(),null)}catch(e){return null}}static getSocial(){try{const e=localStorage.getItem(b);if(!e)return null;return JSON.parse(e).social}catch(e){return null}}static clear(){localStorage.removeItem(b),localStorage.removeItem(y)}}function v(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var x={exports:{}};!function(e){var t=Object.prototype.hasOwnProperty,n="~";function r(){}function o(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function s(e,t,r,s,a){if("function"!=typeof r)throw new TypeError("The listener must be a function");var i=new o(r,s||e,a),c=n?n+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],i]:e._events[c].push(i):(e._events[c]=i,e._eventsCount++),e}function a(e,t){0===--e._eventsCount?e._events=new r:delete e._events[t]}function i(){this._events=new r,this._eventsCount=0}Object.create&&(r.prototype=Object.create(null),(new r).__proto__||(n=!1)),i.prototype.eventNames=function(){var e,r,o=[];if(0===this._eventsCount)return o;for(r in e=this._events)t.call(e,r)&&o.push(n?r.slice(1):r);return Object.getOwnPropertySymbols?o.concat(Object.getOwnPropertySymbols(e)):o},i.prototype.listeners=function(e){var t=n?n+e:e,r=this._events[t];if(!r)return[];if(r.fn)return[r.fn];for(var o=0,s=r.length,a=new Array(s);o<s;o++)a[o]=r[o].fn;return a},i.prototype.listenerCount=function(e){var t=n?n+e:e,r=this._events[t];return r?r.fn?1:r.length:0},i.prototype.emit=function(e,t,r,o,s,a){var i=n?n+e:e;if(!this._events[i])return!1;var c,u,l=this._events[i],d=arguments.length;if(l.fn){switch(l.once&&this.removeListener(e,l.fn,void 0,!0),d){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,t),!0;case 3:return l.fn.call(l.context,t,r),!0;case 4:return l.fn.call(l.context,t,r,o),!0;case 5:return l.fn.call(l.context,t,r,o,s),!0;case 6:return l.fn.call(l.context,t,r,o,s,a),!0}for(u=1,c=new Array(d-1);u<d;u++)c[u-1]=arguments[u];l.fn.apply(l.context,c)}else{var f,h=l.length;for(u=0;u<h;u++)switch(l[u].once&&this.removeListener(e,l[u].fn,void 0,!0),d){case 1:l[u].fn.call(l[u].context);break;case 2:l[u].fn.call(l[u].context,t);break;case 3:l[u].fn.call(l[u].context,t,r);break;case 4:l[u].fn.call(l[u].context,t,r,o);break;default:if(!c)for(f=1,c=new Array(d-1);f<d;f++)c[f-1]=arguments[f];l[u].fn.apply(l[u].context,c)}}return!0},i.prototype.on=function(e,t,n){return s(this,e,t,n,!1)},i.prototype.once=function(e,t,n){return s(this,e,t,n,!0)},i.prototype.removeListener=function(e,t,r,o){var s=n?n+e:e;if(!this._events[s])return this;if(!t)return a(this,s),this;var i=this._events[s];if(i.fn)i.fn!==t||o&&!i.once||r&&i.context!==r||a(this,s);else{for(var c=0,u=[],l=i.length;c<l;c++)(i[c].fn!==t||o&&!i[c].once||r&&i[c].context!==r)&&u.push(i[c]);u.length?this._events[s]=1===u.length?u[0]:u:a(this,s)}return this},i.prototype.removeAllListeners=function(e){var t;return e?(t=n?n+e:e,this._events[t]&&a(this,t)):(this._events=new r,this._eventsCount=0),this},i.prototype.off=i.prototype.removeListener,i.prototype.addListener=i.prototype.on,i.prefixed=n,i.EventEmitter=i,e.exports=i}(x);var E,P=v(x.exports);class k extends Error{constructor(e,t){super(e),this.error=t}}class A extends k{constructor(){super(...arguments),this.name="WalletNotReadyError"}}class I extends k{constructor(){super(...arguments),this.name="WalletConnectionError"}}class N extends k{constructor(){super(...arguments),this.name="WalletDisconnectedError"}}class S extends k{constructor(){super(...arguments),this.name="WalletDisconnectionError"}}class T extends k{constructor(){super(...arguments),this.name="WalletAccountError"}}class $ extends k{constructor(){super(...arguments),this.name="WalletPublicKeyError"}}class B extends k{constructor(){super(...arguments),this.name="WalletNotConnectedError"}}class C extends k{constructor(){super(...arguments),this.name="WalletSendTransactionError"}}class O extends k{constructor(){super(...arguments),this.name="WalletSignTransactionError"}}class R extends k{constructor(){super(...arguments),this.name="WalletSignMessageError"}}!function(e){e.Installed="Installed",e.NotDetected="NotDetected",e.Loadable="Loadable",e.Unsupported="Unsupported"}(E||(E={}));class z extends P{get connected(){return!!this.publicKey}async autoConnect(){await this.connect()}async prepareTransaction(e,t,n={}){const r=this.publicKey;if(!r)throw new B;return e.feePayer=e.feePayer||r,e.recentBlockhash=e.recentBlockhash||(await t.getLatestBlockhash({commitment:n.preflightCommitment,minContextSlot:n.minContextSlot})).blockhash,e}}function M(e){return"version"in e}class _ extends z{async sendTransaction(e,t,n={}){let r=!0;try{if(M(e)){if(!this.supportedTransactionVersions)throw new C("Sending versioned transactions isn't supported by this wallet");if(!this.supportedTransactionVersions.has(e.version))throw new C(`Sending transaction version ${e.version} isn't supported by this wallet`);try{const r=(e=await this.signTransaction(e)).serialize();return await t.sendRawTransaction(r,n)}catch(e){if(e instanceof O)throw r=!1,e;throw new C(e?.message,e)}}else try{const{signers:r,...o}=n;e=await this.prepareTransaction(e,t,o),r?.length&&e.partialSign(...r);const s=(e=await this.signTransaction(e)).serialize();return await t.sendRawTransaction(s,o)}catch(e){if(e instanceof O)throw r=!1,e;throw new C(e?.message,e)}}catch(e){throw r&&this.emit("error",e),e}}async signAllTransactions(e){for(const t of e)if(M(t)){if(!this.supportedTransactionVersions)throw new O("Signing versioned transactions isn't supported by this wallet");if(!this.supportedTransactionVersions.has(t.version))throw new O(`Signing transaction version ${t.version} isn't supported by this wallet`)}const t=[];for(const n of e)t.push(await this.signTransaction(n));return t}}class F extends _{}class j extends F{constructor(e={}){super(),this.name="Phantom",this.url="https://phantom.app",this.icon="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMDgiIGhlaWdodD0iMTA4IiB2aWV3Qm94PSIwIDAgMTA4IDEwOCIgZmlsbD0ibm9uZSI+CjxyZWN0IHdpZHRoPSIxMDgiIGhlaWdodD0iMTA4IiByeD0iMjYiIGZpbGw9IiNBQjlGRjIiLz4KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik00Ni41MjY3IDY5LjkyMjlDNDIuMDA1NCA3Ni44NTA5IDM0LjQyOTIgODUuNjE4MiAyNC4zNDggODUuNjE4MkMxOS41ODI0IDg1LjYxODIgMTUgODMuNjU2MyAxNSA3NS4xMzQyQzE1IDUzLjQzMDUgNDQuNjMyNiAxOS44MzI3IDcyLjEyNjggMTkuODMyN0M4Ny43NjggMTkuODMyNyA5NCAzMC42ODQ2IDk0IDQzLjAwNzlDOTQgNTguODI1OCA4My43MzU1IDc2LjkxMjIgNzMuNTMyMSA3Ni45MTIyQzcwLjI5MzkgNzYuOTEyMiA2OC43MDUzIDc1LjEzNDIgNjguNzA1MyA3Mi4zMTRDNjguNzA1MyA3MS41NzgzIDY4LjgyNzUgNzAuNzgxMiA2OS4wNzE5IDY5LjkyMjlDNjUuNTg5MyA3NS44Njk5IDU4Ljg2ODUgODEuMzg3OCA1Mi41NzU0IDgxLjM4NzhDNDcuOTkzIDgxLjM4NzggNDUuNjcxMyA3OC41MDYzIDQ1LjY3MTMgNzQuNDU5OEM0NS42NzEzIDcyLjk4ODQgNDUuOTc2OCA3MS40NTU2IDQ2LjUyNjcgNjkuOTIyOVpNODMuNjc2MSA0Mi41Nzk0QzgzLjY3NjEgNDYuMTcwNCA4MS41NTc1IDQ3Ljk2NTggNzkuMTg3NSA0Ny45NjU4Qzc2Ljc4MTYgNDcuOTY1OCA3NC42OTg5IDQ2LjE3MDQgNzQuNjk4OSA0Mi41Nzk0Qzc0LjY5ODkgMzguOTg4NSA3Ni43ODE2IDM3LjE5MzEgNzkuMTg3NSAzNy4xOTMxQzgxLjU1NzUgMzcuMTkzMSA4My42NzYxIDM4Ljk4ODUgODMuNjc2MSA0Mi41Nzk0Wk03MC4yMTAzIDQyLjU3OTVDNzAuMjEwMyA0Ni4xNzA0IDY4LjA5MTYgNDcuOTY1OCA2NS43MjE2IDQ3Ljk2NThDNjMuMzE1NyA0Ny45NjU4IDYxLjIzMyA0Ni4xNzA0IDYxLjIzMyA0Mi41Nzk1QzYxLjIzMyAzOC45ODg1IDYzLjMxNTcgMzcuMTkzMSA2NS43MjE2IDM3LjE5MzFDNjguMDkxNiAzNy4xOTMxIDcwLjIxMDMgMzguOTg4NSA3MC4yMTAzIDQyLjU3OTVaIiBmaWxsPSIjRkZGREY4Ii8+Cjwvc3ZnPg==",this.supportedTransactionVersions=new Set(["legacy",0]),this._readyState="undefined"==typeof window||"undefined"==typeof document?E.Unsupported:E.NotDetected,this._disconnected=()=>{const e=this._wallet;e&&(e.off("disconnect",this._disconnected),e.off("accountChanged",this._accountChanged),this._wallet=null,this._publicKey=null,this.emit("error",new N),this.emit("disconnect"))},this._accountChanged=e=>{const n=this._publicKey;if(n){try{e=new t.PublicKey(e.toBytes())}catch(e){return void this.emit("error",new $(null==e?void 0:e.message,e))}n.equals(e)||(this._publicKey=e,this.emit("connect",e))}},this._connecting=!1,this._wallet=null,this._publicKey=null,this._readyState!==E.Unsupported&&(function(){if(!navigator)return!1;const e=navigator.userAgent.toLowerCase(),t=e.includes("iphone")||e.includes("ipad"),n=e.includes("safari");return t&&n}()?(this._readyState=E.Loadable,this.emit("readyStateChange",this._readyState)):function(e){if("undefined"==typeof window||"undefined"==typeof document)return;const t=[];function n(){if(e())for(const e of t)e()}const r=setInterval(n,1e3);t.push(()=>clearInterval(r)),"loading"===document.readyState&&(document.addEventListener("DOMContentLoaded",n,{once:!0}),t.push(()=>document.removeEventListener("DOMContentLoaded",n))),"complete"!==document.readyState&&(window.addEventListener("load",n,{once:!0}),t.push(()=>window.removeEventListener("load",n))),n()}(()=>{var e,t,n;return!(!(null===(t=null===(e=window.phantom)||void 0===e?void 0:e.solana)||void 0===t?void 0:t.isPhantom)&&!(null===(n=window.solana)||void 0===n?void 0:n.isPhantom))&&(this._readyState=E.Installed,this.emit("readyStateChange",this._readyState),!0)}))}get publicKey(){return this._publicKey}get connecting(){return this._connecting}get readyState(){return this._readyState}async autoConnect(){this.readyState===E.Installed&&await this.connect()}async connect(){var e;try{if(this.connected||this.connecting)return;if(this.readyState===E.Loadable){const e=encodeURIComponent(window.location.href),t=encodeURIComponent(window.location.origin);return void(window.location.href=`https://phantom.app/ul/browse/${e}?ref=${t}`)}if(this.readyState!==E.Installed)throw new A;this._connecting=!0;const n=(null===(e=window.phantom)||void 0===e?void 0:e.solana)||window.solana;if(!n.isConnected)try{await n.connect()}catch(e){throw new I(null==e?void 0:e.message,e)}if(!n.publicKey)throw new T;let r;try{r=new t.PublicKey(n.publicKey.toBytes())}catch(e){throw new $(null==e?void 0:e.message,e)}n.on("disconnect",this._disconnected),n.on("accountChanged",this._accountChanged),this._wallet=n,this._publicKey=r,this.emit("connect",r)}catch(e){throw this.emit("error",e),e}finally{this._connecting=!1}}async disconnect(){const e=this._wallet;if(e){e.off("disconnect",this._disconnected),e.off("accountChanged",this._accountChanged),this._wallet=null,this._publicKey=null;try{await e.disconnect()}catch(e){this.emit("error",new S(null==e?void 0:e.message,e))}}this.emit("disconnect")}async sendTransaction(e,t,n={}){try{const r=this._wallet;if(!r)throw new B;try{const{signers:o,...s}=n;M(e)?(null==o?void 0:o.length)&&e.sign(o):(e=await this.prepareTransaction(e,t,s),(null==o?void 0:o.length)&&e.partialSign(...o)),s.preflightCommitment=s.preflightCommitment||t.commitment;const{signature:a}=await r.signAndSendTransaction(e,s);return a}catch(e){if(e instanceof k)throw e;throw new C(null==e?void 0:e.message,e)}}catch(e){throw this.emit("error",e),e}}async signTransaction(e){try{const t=this._wallet;if(!t)throw new B;try{return await t.signTransaction(e)||e}catch(e){throw new O(null==e?void 0:e.message,e)}}catch(e){throw this.emit("error",e),e}}async signAllTransactions(e){try{const t=this._wallet;if(!t)throw new B;try{return await t.signAllTransactions(e)||e}catch(e){throw new O(null==e?void 0:e.message,e)}}catch(e){throw this.emit("error",e),e}}async signMessage(e){try{const t=this._wallet;if(!t)throw new B;try{const{signature:n}=await t.signMessage(e);return n}catch(e){throw new R(null==e?void 0:e.message,e)}}catch(e){throw this.emit("error",e),e}}}let L=class e extends Error{constructor(t,n={}){const r=n.cause instanceof e?n.cause.details:n.cause?.message?n.cause.message:n.details,o=n.cause instanceof e&&n.cause.docsPath||n.docsPath;super([t||"An error occurred.","",...n.metaMessages?[...n.metaMessages,""]:[],...o?[`Docs: https://abitype.dev${o}`]:[],...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=o,this.metaMessages=n.metaMessages,this.shortMessage=t}};function U(e,t){const n=e.exec(t);return n?.groups}const D=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,G=/^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)?$/,q=/^\(.+?\).*?$/,V=/^tuple(?<array>(\[(\d*)\])*)$/;function W(e){let t=e.type;if(V.test(e.type)&&"components"in e){t="(";const n=e.components.length;for(let r=0;r<n;r++){t+=W(e.components[r]),r<n-1&&(t+=", ")}const r=U(V,e.type);return t+=`)${r?.array??""}`,W({...e,type:t})}return"indexed"in e&&e.indexed&&(t=`${t} indexed`),e.name?`${t} ${e.name}`:t}function H(e){let t="";const n=e.length;for(let r=0;r<n;r++){t+=W(e[r]),r!==n-1&&(t+=", ")}return t}function Y(e){return"function"===e.type?`function ${e.name}(${H(e.inputs)})${e.stateMutability&&"nonpayable"!==e.stateMutability?` ${e.stateMutability}`:""}${e.outputs?.length?` returns (${H(e.outputs)})`:""}`:"event"===e.type?`event ${e.name}(${H(e.inputs)})`:"error"===e.type?`error ${e.name}(${H(e.inputs)})`:"constructor"===e.type?`constructor(${H(e.inputs)})${"payable"===e.stateMutability?" payable":""}`:"fallback"===e.type?"fallback() external"+("payable"===e.stateMutability?" payable":""):"receive() external payable"}const Z=/^error (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/;const K=/^event (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/;const J=/^function (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)(?: (?<scope>external|public{1}))?(?: (?<stateMutability>pure|view|nonpayable|payable{1}))?(?: returns\s?\((?<returns>.*?)\))?$/;const Q=/^struct (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*) \{(?<properties>.*?)\}$/;function X(e){return Q.test(e)}function ee(e){return U(Q,e)}const te=/^constructor\((?<parameters>.*?)\)(?:\s(?<stateMutability>payable{1}))?$/;const ne=/^fallback\(\) external(?:\s(?<stateMutability>payable{1}))?$/;const re=/^receive\(\) external payable$/;const oe=new Set(["memory","indexed","storage","calldata"]),se=new Set(["indexed"]),ae=new Set(["calldata","memory","storage"]);class ie extends L{constructor({signature:e}){super("Failed to parse ABI item.",{details:`parseAbiItem(${JSON.stringify(e,null,2)})`,docsPath:"/api/human#parseabiitem-1"}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidAbiItemError"})}}class ce extends L{constructor({type:e}){super("Unknown type.",{metaMessages:[`Type "${e}" 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 ue extends L{constructor({type:e}){super("Unknown type.",{metaMessages:[`Type "${e}" is not a valid ABI type.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownSolidityTypeError"})}}class le extends L{constructor({params:e}){super("Failed to parse ABI parameters.",{details:`parseAbiParameters(${JSON.stringify(e,null,2)})`,docsPath:"/api/human#parseabiparameters-1"}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidAbiParametersError"})}}class de extends L{constructor({param:e}){super("Invalid ABI parameter.",{details:e}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidParameterError"})}}class fe extends L{constructor({param:e,name:t}){super("Invalid ABI parameter.",{details:e,metaMessages:[`"${t}" 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 he extends L{constructor({param:e,type:t,modifier:n}){super("Invalid ABI parameter.",{details:e,metaMessages:[`Modifier "${n}" not allowed${t?` in "${t}" type`:""}.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidModifierError"})}}class pe extends L{constructor({param:e,type:t,modifier:n}){super("Invalid ABI parameter.",{details:e,metaMessages:[`Modifier "${n}" not allowed${t?` in "${t}" 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 me extends L{constructor({abiParameter:e}){super("Invalid ABI parameter.",{details:JSON.stringify(e,null,2),metaMessages:["ABI parameter type is invalid."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidAbiTypeParameterError"})}}class ge extends L{constructor({signature:e,type:t}){super(`Invalid ${t} signature.`,{details:e}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidSignatureError"})}}class be extends L{constructor({signature:e}){super("Unknown signature.",{details:e}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownSignatureError"})}}class ye extends L{constructor({signature:e}){super("Invalid struct signature.",{details:e,metaMessages:["No properties exist."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidStructSignatureError"})}}class we extends L{constructor({type:e}){super("Circular reference detected.",{metaMessages:[`Struct "${e}" is a circular reference.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"CircularReferenceError"})}}class ve extends L{constructor({current:e,depth:t}){super("Unbalanced parentheses.",{metaMessages:[`"${e.trim()}" has too many ${t>0?"opening":"closing"} parentheses.`],details:`Depth "${t}"`}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidParenthesisError"})}}const xe=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 Ee(e,t={}){if(function(e){return J.test(e)}(e))return function(e,t={}){const n=function(e){return U(J,e)}(e);if(!n)throw new ge({signature:e,type:"function"});const r=Ne(n.parameters),o=[],s=r.length;for(let e=0;e<s;e++)o.push(Ie(r[e],{modifiers:ae,structs:t,type:"function"}));const a=[];if(n.returns){const e=Ne(n.returns),r=e.length;for(let n=0;n<r;n++)a.push(Ie(e[n],{modifiers:ae,structs:t,type:"function"}))}return{name:n.name,type:"function",stateMutability:n.stateMutability??"nonpayable",inputs:o,outputs:a}}(e,t);if(function(e){return K.test(e)}(e))return function(e,t={}){const n=function(e){return U(K,e)}(e);if(!n)throw new ge({signature:e,type:"event"});const r=Ne(n.parameters),o=[],s=r.length;for(let e=0;e<s;e++)o.push(Ie(r[e],{modifiers:se,structs:t,type:"event"}));return{name:n.name,type:"event",inputs:o}}(e,t);if(function(e){return Z.test(e)}(e))return function(e,t={}){const n=function(e){return U(Z,e)}(e);if(!n)throw new ge({signature:e,type:"error"});const r=Ne(n.parameters),o=[],s=r.length;for(let e=0;e<s;e++)o.push(Ie(r[e],{structs:t,type:"error"}));return{name:n.name,type:"error",inputs:o}}(e,t);if(function(e){return te.test(e)}(e))return function(e,t={}){const n=function(e){return U(te,e)}(e);if(!n)throw new ge({signature:e,type:"constructor"});const r=Ne(n.parameters),o=[],s=r.length;for(let e=0;e<s;e++)o.push(Ie(r[e],{structs:t,type:"constructor"}));return{type:"constructor",stateMutability:n.stateMutability??"nonpayable",inputs:o}}(e,t);if(function(e){return ne.test(e)}(e))return function(e){const t=function(e){return U(ne,e)}(e);if(!t)throw new ge({signature:e,type:"fallback"});return{type:"fallback",stateMutability:t.stateMutability??"nonpayable"}}(e);if(function(e){return re.test(e)}(e))return{type:"receive",stateMutability:"payable"};throw new be({signature:e})}const Pe=/^(?<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$_]*))?$/,ke=/^\((?<type>.+?)\)(?<array>(?:\[\d*?\])+?)?(?:\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\s(?<name>[a-zA-Z$_][a-zA-Z0-9$_]*))?$/,Ae=/^u?int$/;function Ie(e,t){const n=function(e,t,n){let r="";if(n)for(const e of Object.entries(n)){if(!e)continue;let t="";for(const n of e[1])t+=`[${n.type}${n.name?`:${n.name}`:""}]`;r+=`(${e[0]}{${t}})`}return t?`${t}:${e}${r}`:e}(e,t?.type,t?.structs);if(xe.has(n))return xe.get(n);const r=q.test(e),o=U(r?ke:Pe,e);if(!o)throw new de({param:e});if(o.name&&function(e){return"address"===e||"bool"===e||"function"===e||"string"===e||"tuple"===e||D.test(e)||G.test(e)||Te.test(e)}(o.name))throw new fe({param:e,name:o.name});const s=o.name?{name:o.name}:{},a="indexed"===o.modifier?{indexed:!0}:{},i=t?.structs??{};let c,u={};if(r){c="tuple";const e=Ne(o.type),t=[],n=e.length;for(let r=0;r<n;r++)t.push(Ie(e[r],{structs:i}));u={components:t}}else if(o.type in i)c="tuple",u={components:i[o.type]};else if(Ae.test(o.type))c=`${o.type}256`;else if("address payable"===o.type)c="address";else if(c=o.type,"struct"!==t?.type&&!Se(c))throw new ue({type:c});if(o.modifier){if(!t?.modifiers?.has?.(o.modifier))throw new he({param:e,type:t?.type,modifier:o.modifier});if(ae.has(o.modifier)&&!function(e,t){return t||"bytes"===e||"string"===e||"tuple"===e}(c,!!o.array))throw new pe({param:e,type:t?.type,modifier:o.modifier})}const l={type:`${c}${o.array??""}`,...s,...a,...u};return xe.set(n,l),l}function Ne(e,t=[],n="",r=0){const o=e.trim().length;for(let s=0;s<o;s++){const o=e[s],a=e.slice(s+1);switch(o){case",":return 0===r?Ne(a,[...t,n.trim()]):Ne(a,t,`${n}${o}`,r);case"(":return Ne(a,t,`${n}${o}`,r+1);case")":return Ne(a,t,`${n}${o}`,r-1);default:return Ne(a,t,`${n}${o}`,r)}}if(""===n)return t;if(0!==r)throw new ve({current:n,depth:r});return t.push(n.trim()),t}function Se(e){return"address"===e||"bool"===e||"function"===e||"string"===e||D.test(e)||G.test(e)}const Te=/^(?: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 $e(e){const t={},n=e.length;for(let r=0;r<n;r++){const n=e[r];if(!X(n))continue;const o=ee(n);if(!o)throw new ge({signature:n,type:"struct"});const s=o.properties.split(";"),a=[],i=s.length;for(let e=0;e<i;e++){const t=s[e].trim();if(!t)continue;const n=Ie(t,{type:"struct"});a.push(n)}if(!a.length)throw new ye({signature:n});t[o.name]=a}const r={},o=Object.entries(t),s=o.length;for(let e=0;e<s;e++){const[n,s]=o[e];r[n]=Ce(s,t)}return r}const Be=/^(?<type>[a-zA-Z$_][a-zA-Z0-9$_]*)(?<array>(?:\[\d*?\])+?)?$/;function Ce(e,t,n=new Set){const r=[],o=e.length;for(let s=0;s<o;s++){const o=e[s];if(q.test(o.type))r.push(o);else{const e=U(Be,o.type);if(!e?.type)throw new me({abiParameter:o});const{array:s,type:a}=e;if(a in t){if(n.has(a))throw new we({type:a});r.push({...o,type:`tuple${s??""}`,components:Ce(t[a]??[],t,new Set([...n,a]))})}else{if(!Se(a))throw new ce({type:a});r.push(o)}}}return r}function Oe(e){const t=$e(e),n=[],r=e.length;for(let o=0;o<r;o++){const r=e[o];X(r)||n.push(Ee(r,t))}return n}function Re(e){let t;if("string"==typeof e)t=Ee(e);else{const n=$e(e),r=e.length;for(let o=0;o<r;o++){const r=e[o];if(!X(r)){t=Ee(r,n);break}}}if(!t)throw new ie({signature:e});return t}function ze(e){const t=[];if("string"==typeof e){const n=Ne(e),r=n.length;for(let e=0;e<r;e++)t.push(Ie(n[e],{modifiers:oe}))}else{const n=$e(e),r=e.length;for(let o=0;o<r;o++){const r=e[o];if(X(r))continue;const s=Ne(r),a=s.length;for(let e=0;e<a;e++)t.push(Ie(s[e],{modifiers:oe,structs:n}))}}if(0===t.length)throw new le({params:e});return t}function Me(e,t,n){const r=e[t.name];if("function"==typeof r)return r;const o=e[n];return"function"==typeof o?o:n=>t(e,n)}function _e(e,{includeName:t=!1}={}){if("function"!==e.type&&"event"!==e.type&&"error"!==e.type)throw new mt(e.type);return`${e.name}(${Fe(e.inputs,{includeName:t})})`}function Fe(e,{includeName:t=!1}={}){return e?e.map(e=>function(e,{includeName:t}){if(e.type.startsWith("tuple"))return`(${Fe(e.components,{includeName:t})})${e.type.slice(5)}`;return e.type+(t&&e.name?` ${e.name}`:"")}(e,{includeName:t})).join(t?", ":","):""}function je(e,{strict:t=!0}={}){return!!e&&("string"==typeof e&&(t?/^0x[0-9a-fA-F]*$/.test(e):e.startsWith("0x")))}function Le(e){return je(e,{strict:!1})?Math.ceil((e.length-2)/2):e.length}const Ue="2.37.8";let De=({docsBaseUrl:e,docsPath:t="",docsSlug:n})=>t?`${e??"https://viem.sh"}${t}${n?`#${n}`:""}`:void 0,Ge=`viem@${Ue}`,qe=class e extends Error{constructor(t,n={}){const r=n.cause instanceof e?n.cause.details:n.cause?.message?n.cause.message:n.details,o=n.cause instanceof e&&n.cause.docsPath||n.docsPath,s=De?.({...n,docsPath:o});super([t||"An error occurred.","",...n.metaMessages?[...n.metaMessages,""]:[],...s?[`Docs: ${s}`]:[],...r?[`Details: ${r}`]:[],...Ge?[`Version: ${Ge}`]:[]].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=o,this.metaMessages=n.metaMessages,this.name=n.name??this.name,this.shortMessage=t,this.version=Ue}walk(e){return Ve(this,e)}};function Ve(e,t){return t?.(e)?e:e&&"object"==typeof e&&"cause"in e&&void 0!==e.cause?Ve(e.cause,t):t?null:e}class We extends qe{constructor({docsPath:e}){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:e,name:"AbiConstructorNotFoundError"})}}class He extends qe{constructor({docsPath:e}){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:e,name:"AbiConstructorParamsNotFoundError"})}}class Ye extends qe{constructor({data:e,params:t,size:n}){super([`Data size of ${n} bytes is too small for given parameters.`].join("\n"),{metaMessages:[`Params: (${Fe(t,{includeName:!0})})`,`Data: ${e} (${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=e,this.params=t,this.size=n}}class Ze extends qe{constructor(){super('Cannot decode zero data ("0x") with ABI parameters.',{name:"AbiDecodingZeroDataError"})}}class Ke extends qe{constructor({expectedLength:e,givenLength:t,type:n}){super([`ABI encoding array length mismatch for type ${n}.`,`Expected length: ${e}`,`Given length: ${t}`].join("\n"),{name:"AbiEncodingArrayLengthMismatchError"})}}class Je extends qe{constructor({expectedSize:e,value:t}){super(`Size of bytes "${t}" (bytes${Le(t)}) does not match expected size (bytes${e}).`,{name:"AbiEncodingBytesSizeMismatchError"})}}class Qe extends qe{constructor({expectedLength:e,givenLength:t}){super(["ABI encoding params/values length mismatch.",`Expected length (params): ${e}`,`Given length (values): ${t}`].join("\n"),{name:"AbiEncodingLengthMismatchError"})}}class Xe extends qe{constructor(e,{docsPath:t}){super([`Arguments (\`args\`) were provided to "${e}", but "${e}" 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:t,name:"AbiErrorInputsNotFoundError"})}}class et extends qe{constructor(e,{docsPath:t}={}){super([`Error ${e?`"${e}" `:""}not found on ABI.`,"Make sure you are using the correct ABI and that the error exists on it."].join("\n"),{docsPath:t,name:"AbiErrorNotFoundError"})}}class tt extends qe{constructor(e,{docsPath:t}){super([`Encoded error signature "${e}" 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=${e}.`].join("\n"),{docsPath:t,name:"AbiErrorSignatureNotFoundError"}),Object.defineProperty(this,"signature",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.signature=e}}class nt extends qe{constructor({docsPath:e}){super("Cannot extract event signature from empty topics.",{docsPath:e,name:"AbiEventSignatureEmptyTopicsError"})}}class rt extends qe{constructor(e,{docsPath:t}){super([`Encoded event signature "${e}" 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=${e}.`].join("\n"),{docsPath:t,name:"AbiEventSignatureNotFoundError"})}}class ot extends qe{constructor(e,{docsPath:t}={}){super([`Event ${e?`"${e}" `:""}not found on ABI.`,"Make sure you are using the correct ABI and that the event exists on it."].join("\n"),{docsPath:t,name:"AbiEventNotFoundError"})}}class st extends qe{constructor(e,{docsPath:t}={}){super([`Function ${e?`"${e}" `:""}not found on ABI.`,"Make sure you are using the correct ABI and that the function exists on it."].join("\n"),{docsPath:t,name:"AbiFunctionNotFoundError"})}}class at extends qe{constructor(e,{docsPath:t}){super([`Function "${e}" 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:t,name:"AbiFunctionOutputsNotFoundError"})}}class it extends qe{constructor(e,{docsPath:t}){super([`Encoded function signature "${e}" 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=${e}.`].join("\n"),{docsPath:t,name:"AbiFunctionSignatureNotFoundError"})}}class ct extends qe{constructor(e,t){super("Found ambiguous types in overloaded ABI items.",{metaMessages:[`\`${e.type}\` in \`${_e(e.abiItem)}\`, and`,`\`${t.type}\` in \`${_e(t.abiItem)}\``,"","These types encode differently and cannot be distinguished at runtime.","Remove one of the ambiguous items in the ABI."],name:"AbiItemAmbiguityError"})}}let ut=class extends qe{constructor({expectedSize:e,givenSize:t}){super(`Expected bytes${e}, got bytes${t}.`,{name:"BytesSizeMismatchError"})}};class lt extends qe{constructor({abiItem:e,data:t,params:n,size:r}){super([`Data size of ${r} bytes is too small for non-indexed event parameters.`].join("\n"),{metaMessages:[`Params: (${Fe(n,{includeName:!0})})`,`Data: ${t} (${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=e,this.data=t,this.params=n,this.size=r}}class dt extends qe{constructor({abiItem:e,param:t}){super([`Expected a topic for indexed event parameter${t.name?` "${t.name}"`:""} on event "${_e(e,{includeName:!0})}".`].join("\n"),{name:"DecodeLogTopicsMismatch"}),Object.defineProperty(this,"abiItem",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.abiItem=e}}class ft extends qe{constructor(e,{docsPath:t}){super([`Type "${e}" is not a valid encoding type.`,"Please provide a valid ABI type."].join("\n"),{docsPath:t,name:"InvalidAbiEncodingType"})}}class ht extends qe{constructor(e,{docsPath:t}){super([`Type "${e}" is not a valid decoding type.`,"Please provide a valid ABI type."].join("\n"),{docsPath:t,name:"InvalidAbiDecodingType"})}}let pt=class extends qe{constructor(e){super([`Value "${e}" is not a valid array.`].join("\n"),{name:"InvalidArrayError"})}};class mt extends qe{constructor(e){super([`"${e}" is not a valid definition type.`,'Valid types: "function", "event", "error"'].join("\n"),{name:"InvalidDefinitionTypeError"})}}class gt extends qe{constructor(e){super(`Filter type "${e}" is not supported.`,{name:"FilterTypeNotSupportedError"})}}let bt=class extends qe{constructor({offset:e,position:t,size:n}){super(`Slice ${"start"===t?"starting":"ending"} at offset "${e}" is out-of-bounds (size: ${n}).`,{name:"SliceOffsetOutOfBoundsError"})}},yt=class extends qe{constructor({size:e,targetSize:t,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (${e}) exceeds padding size (${t}).`,{name:"SizeExceedsPaddingSizeError"})}};class wt extends qe{constructor({size:e,targetSize:t,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} is expected to be ${t} ${n} long, but is ${e} ${n} long.`,{name:"InvalidBytesLengthError"})}}function vt(e,{dir:t,size:n=32}={}){return"string"==typeof e?xt(e,{dir:t,size:n}):function(e,{dir:t,size:n=32}={}){if(null===n)return e;if(e.length>n)throw new yt({size:e.length,targetSize:n,type:"bytes"});const r=new Uint8Array(n);for(let o=0;o<n;o++){const s="right"===t;r[s?o:n-o-1]=e[s?o:e.length-o-1]}return r}(e,{dir:t,size:n})}function xt(e,{dir:t,size:n=32}={}){if(null===n)return e;const r=e.replace("0x","");if(r.length>2*n)throw new yt({size:Math.ceil(r.length/2),targetSize:n,type:"hex"});return`0x${r["right"===t?"padEnd":"padStart"](2*n,"0")}`}let Et=class extends qe{constructor({max:e,min:t,signed:n,size:r,value:o}){super(`Number "${o}" is not in safe ${r?`${8*r}-bit ${n?"signed":"unsigned"} `:""}integer range ${e?`(${t} to ${e})`:`(above ${t})`}`,{name:"IntegerOutOfRangeError"})}},Pt=class extends qe{constructor(e){super(`Bytes value "${e}" is not a valid boolean. The bytes array must contain a single byte of either a 0 or 1 value.`,{name:"InvalidBytesBooleanError"})}};class kt extends qe{constructor(e){super(`Hex value "${e}" is not a valid boolean. The hex value must be "0x0" (false) or "0x1" (true).`,{name:"InvalidHexBooleanError"})}}let At=class extends qe{constructor({givenSize:e,maxSize:t}){super(`Size cannot exceed ${t} bytes. Given size: ${e} bytes.`,{name:"SizeOverflowError"})}};function It(e,{dir:t="left"}={}){let n="string"==typeof e?e.replace("0x",""):e,r=0;for(let e=0;e<n.length-1&&"0"===n["left"===t?e:n.length-e-1].toString();e++)r++;return n="left"===t?n.slice(r):n.slice(0,n.length-r),"string"==typeof e?(1===n.length&&"right"===t&&(n=`${n}0`),`0x${n.length%2==1?`0${n}`:n}`):n}function Nt(e,{size:t}){if(Le(e)>t)throw new At({givenSize:Le(e),maxSize:t})}function St(e,t={}){const{signed:n}=t;t.size&&Nt(e,{size:t.size});const r=BigInt(e);if(!n)return r;const o=(e.length-2)/2;return r<=(1n<<8n*BigInt(o)-1n)-1n?r:r-BigInt(`0x${"f".padStart(2*o,"f")}`)-1n}function Tt(e,t={}){return Number(St(e,t))}const $t=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Bt(e,t={}){return"number"==typeof e||"bigint"==typeof e?Rt(e,t):"string"==typeof e?Mt(e,t):"boolean"==typeof e?Ct(e,t):Ot(e,t)}function Ct(e,t={}){const n=`0x${Number(e)}`;return"number"==typeof t.size?(Nt(n,{size:t.size}),vt(n,{size:t.size})):n}function Ot(e,t={}){let n="";for(let t=0;t<e.length;t++)n+=$t[e[t]];const r=`0x${n}`;return"number"==typeof t.size?(Nt(r,{size:t.size}),vt(r,{dir:"right",size:t.size})):r}function Rt(e,t={}){const{signed:n,size:r}=t,o=BigInt(e);let s;r?s=n?(1n<<8n*BigInt(r)-1n)-1n:2n**(8n*BigInt(r))-1n:"number"==typeof e&&(s=BigInt(Number.MAX_SAFE_INTEGER));const a="bigint"==typeof s&&n?-s-1n:0;if(s&&o>s||o<a){const t="bigint"==typeof e?"n":"";throw new Et({max:s?`${s}${t}`:void 0,min:`${a}${t}`,signed:n,size:r,value:`${e}${t}`})}const i=`0x${(n&&o<0?(1n<<BigInt(8*r))+BigInt(o):o).toString(16)}`;return r?vt(i,{size:r}):i}const zt=new TextEncoder;function Mt(e,t={}){return Ot(zt.encode(e),t)}const _t=new TextEncoder;function Ft(e,t={}){return"number"==typeof e||"bigint"==typeof e?function(e,t){const n=Rt(e,t);return Ut(n)}(e,t):"boolean"==typeof e?function(e,t={}){const n=new Uint8Array(1);if(n[0]=Number(e),"number"==typeof t.size)return Nt(n,{size:t.size}),vt(n,{size:t.size});return n}(e,t):je(e)?Ut(e,t):Dt(e,t)}const jt={zero:48,nine:57,A:65,F:70,a:97,f:102};function Lt(e){return e>=jt.zero&&e<=jt.nine?e-jt.zero:e>=jt.A&&e<=jt.F?e-(jt.A-10):e>=jt.a&&e<=jt.f?e-(jt.a-10):void 0}function Ut(e,t={}){let n=e;t.size&&(Nt(n,{size:t.size}),n=vt(n,{dir:"right",size:t.size}));let r=n.slice(2);r.length%2&&(r=`0${r}`);const o=r.length/2,s=new Uint8Array(o);for(let e=0,t=0;e<o;e++){const n=Lt(r.charCodeAt(t++)),o=Lt(r.charCodeAt(t++));if(void 0===n||void 0===o)throw new qe(`Invalid byte sequence ("${r[t-2]}${r[t-1]}" in "${r}").`);s[e]=16*n+o}return s}function Dt(e,t={}){const n=_t.encode(e);return"number"==typeof t.size?(Nt(n,{size:t.size}),vt(n,{dir:"right",size:t.size})):n}const Gt=BigInt(2**32-1),qt=BigInt(32);function Vt(e,t=!1){return t?{h:Number(e&Gt),l:Number(e>>qt&Gt)}:{h:0|Number(e>>qt&Gt),l:0|Number(e&Gt)}}const Wt="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0;function Ht(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function Yt(e,...t){if(!((n=e)instanceof Uint8Array||ArrayBuffer.isView(n)&&"Uint8Array"===n.constructor.name))throw new Error("Uint8Array expected");
|
|
1
|
+
"use strict";var e=require("axios"),t=require("@solana/web3.js"),n=require("bs58"),r=require("uuid"),o=require("react"),s=require("lucide-react"),a=require("qs");function i(e){return e&&e.__esModule?e:{default:e}}function c(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach(function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}}),t.default=e,Object.freeze(t)}var u,l,d,f=i(e),h=i(n),p=i(o),m=c(a);function g(e){return"version"in e}"undefined"!=typeof globalThis&&void 0===globalThis.globalThis&&(globalThis.global=globalThis),exports.Network=void 0,(u=exports.Network||(exports.Network={})).Solana="Solana",u.Ethereum="Ethereum",exports.WalletType=void 0,(l=exports.WalletType||(exports.WalletType={})).Phantom="Phantom",l.Embedded="Embedded",exports.SocialType=void 0,(d=exports.SocialType||(exports.SocialType={})).Email="Email",d.Google="Google",d.Twitter="Twitter",d.Phantom="Phantom",d.Phone="Phone",d.Okx="Okx";const b="embedded_wallet_state",y="superstack_wallet_type";class w{static saveAccessToken(e,t){const n={accessToken:e,social:t,lastConnected:Date.now()};localStorage.setItem(b,JSON.stringify(n))}static saveWalletType(e){localStorage.setItem(y,e)}static getWalletType(){return localStorage.getItem(y)}static getAccessToken(){try{const e=localStorage.getItem(b);if(!e)return null;const t=JSON.parse(e);return Date.now()-t.lastConnected<6048e5?t.accessToken:(this.clear(),null)}catch(e){return null}}static getSocial(){try{const e=localStorage.getItem(b);if(!e)return null;return JSON.parse(e).social}catch(e){return null}}static clear(){localStorage.removeItem(b),localStorage.removeItem(y)}}function v(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var x={exports:{}};!function(e){var t=Object.prototype.hasOwnProperty,n="~";function r(){}function o(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function s(e,t,r,s,a){if("function"!=typeof r)throw new TypeError("The listener must be a function");var i=new o(r,s||e,a),c=n?n+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],i]:e._events[c].push(i):(e._events[c]=i,e._eventsCount++),e}function a(e,t){0===--e._eventsCount?e._events=new r:delete e._events[t]}function i(){this._events=new r,this._eventsCount=0}Object.create&&(r.prototype=Object.create(null),(new r).__proto__||(n=!1)),i.prototype.eventNames=function(){var e,r,o=[];if(0===this._eventsCount)return o;for(r in e=this._events)t.call(e,r)&&o.push(n?r.slice(1):r);return Object.getOwnPropertySymbols?o.concat(Object.getOwnPropertySymbols(e)):o},i.prototype.listeners=function(e){var t=n?n+e:e,r=this._events[t];if(!r)return[];if(r.fn)return[r.fn];for(var o=0,s=r.length,a=new Array(s);o<s;o++)a[o]=r[o].fn;return a},i.prototype.listenerCount=function(e){var t=n?n+e:e,r=this._events[t];return r?r.fn?1:r.length:0},i.prototype.emit=function(e,t,r,o,s,a){var i=n?n+e:e;if(!this._events[i])return!1;var c,u,l=this._events[i],d=arguments.length;if(l.fn){switch(l.once&&this.removeListener(e,l.fn,void 0,!0),d){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,t),!0;case 3:return l.fn.call(l.context,t,r),!0;case 4:return l.fn.call(l.context,t,r,o),!0;case 5:return l.fn.call(l.context,t,r,o,s),!0;case 6:return l.fn.call(l.context,t,r,o,s,a),!0}for(u=1,c=new Array(d-1);u<d;u++)c[u-1]=arguments[u];l.fn.apply(l.context,c)}else{var f,h=l.length;for(u=0;u<h;u++)switch(l[u].once&&this.removeListener(e,l[u].fn,void 0,!0),d){case 1:l[u].fn.call(l[u].context);break;case 2:l[u].fn.call(l[u].context,t);break;case 3:l[u].fn.call(l[u].context,t,r);break;case 4:l[u].fn.call(l[u].context,t,r,o);break;default:if(!c)for(f=1,c=new Array(d-1);f<d;f++)c[f-1]=arguments[f];l[u].fn.apply(l[u].context,c)}}return!0},i.prototype.on=function(e,t,n){return s(this,e,t,n,!1)},i.prototype.once=function(e,t,n){return s(this,e,t,n,!0)},i.prototype.removeListener=function(e,t,r,o){var s=n?n+e:e;if(!this._events[s])return this;if(!t)return a(this,s),this;var i=this._events[s];if(i.fn)i.fn!==t||o&&!i.once||r&&i.context!==r||a(this,s);else{for(var c=0,u=[],l=i.length;c<l;c++)(i[c].fn!==t||o&&!i[c].once||r&&i[c].context!==r)&&u.push(i[c]);u.length?this._events[s]=1===u.length?u[0]:u:a(this,s)}return this},i.prototype.removeAllListeners=function(e){var t;return e?(t=n?n+e:e,this._events[t]&&a(this,t)):(this._events=new r,this._eventsCount=0),this},i.prototype.off=i.prototype.removeListener,i.prototype.addListener=i.prototype.on,i.prefixed=n,i.EventEmitter=i,e.exports=i}(x);var E,P=v(x.exports);class k extends Error{constructor(e,t){super(e),this.error=t}}class A extends k{constructor(){super(...arguments),this.name="WalletNotReadyError"}}class I extends k{constructor(){super(...arguments),this.name="WalletConnectionError"}}class N extends k{constructor(){super(...arguments),this.name="WalletDisconnectedError"}}class S extends k{constructor(){super(...arguments),this.name="WalletDisconnectionError"}}class T extends k{constructor(){super(...arguments),this.name="WalletAccountError"}}class $ extends k{constructor(){super(...arguments),this.name="WalletPublicKeyError"}}class B extends k{constructor(){super(...arguments),this.name="WalletNotConnectedError"}}class C extends k{constructor(){super(...arguments),this.name="WalletSendTransactionError"}}class O extends k{constructor(){super(...arguments),this.name="WalletSignTransactionError"}}class R extends k{constructor(){super(...arguments),this.name="WalletSignMessageError"}}!function(e){e.Installed="Installed",e.NotDetected="NotDetected",e.Loadable="Loadable",e.Unsupported="Unsupported"}(E||(E={}));class z extends P{get connected(){return!!this.publicKey}async autoConnect(){await this.connect()}async prepareTransaction(e,t,n={}){const r=this.publicKey;if(!r)throw new B;return e.feePayer=e.feePayer||r,e.recentBlockhash=e.recentBlockhash||(await t.getLatestBlockhash({commitment:n.preflightCommitment,minContextSlot:n.minContextSlot})).blockhash,e}}function M(e){return"version"in e}class _ extends z{async sendTransaction(e,t,n={}){let r=!0;try{if(M(e)){if(!this.supportedTransactionVersions)throw new C("Sending versioned transactions isn't supported by this wallet");if(!this.supportedTransactionVersions.has(e.version))throw new C(`Sending transaction version ${e.version} isn't supported by this wallet`);try{const r=(e=await this.signTransaction(e)).serialize();return await t.sendRawTransaction(r,n)}catch(e){if(e instanceof O)throw r=!1,e;throw new C(e?.message,e)}}else try{const{signers:r,...o}=n;e=await this.prepareTransaction(e,t,o),r?.length&&e.partialSign(...r);const s=(e=await this.signTransaction(e)).serialize();return await t.sendRawTransaction(s,o)}catch(e){if(e instanceof O)throw r=!1,e;throw new C(e?.message,e)}}catch(e){throw r&&this.emit("error",e),e}}async signAllTransactions(e){for(const t of e)if(M(t)){if(!this.supportedTransactionVersions)throw new O("Signing versioned transactions isn't supported by this wallet");if(!this.supportedTransactionVersions.has(t.version))throw new O(`Signing transaction version ${t.version} isn't supported by this wallet`)}const t=[];for(const n of e)t.push(await this.signTransaction(n));return t}}class F extends _{}class j extends F{constructor(e={}){super(),this.name="Phantom",this.url="https://phantom.app",this.icon="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMDgiIGhlaWdodD0iMTA4IiB2aWV3Qm94PSIwIDAgMTA4IDEwOCIgZmlsbD0ibm9uZSI+CjxyZWN0IHdpZHRoPSIxMDgiIGhlaWdodD0iMTA4IiByeD0iMjYiIGZpbGw9IiNBQjlGRjIiLz4KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik00Ni41MjY3IDY5LjkyMjlDNDIuMDA1NCA3Ni44NTA5IDM0LjQyOTIgODUuNjE4MiAyNC4zNDggODUuNjE4MkMxOS41ODI0IDg1LjYxODIgMTUgODMuNjU2MyAxNSA3NS4xMzQyQzE1IDUzLjQzMDUgNDQuNjMyNiAxOS44MzI3IDcyLjEyNjggMTkuODMyN0M4Ny43NjggMTkuODMyNyA5NCAzMC42ODQ2IDk0IDQzLjAwNzlDOTQgNTguODI1OCA4My43MzU1IDc2LjkxMjIgNzMuNTMyMSA3Ni45MTIyQzcwLjI5MzkgNzYuOTEyMiA2OC43MDUzIDc1LjEzNDIgNjguNzA1MyA3Mi4zMTRDNjguNzA1MyA3MS41NzgzIDY4LjgyNzUgNzAuNzgxMiA2OS4wNzE5IDY5LjkyMjlDNjUuNTg5MyA3NS44Njk5IDU4Ljg2ODUgODEuMzg3OCA1Mi41NzU0IDgxLjM4NzhDNDcuOTkzIDgxLjM4NzggNDUuNjcxMyA3OC41MDYzIDQ1LjY3MTMgNzQuNDU5OEM0NS42NzEzIDcyLjk4ODQgNDUuOTc2OCA3MS40NTU2IDQ2LjUyNjcgNjkuOTIyOVpNODMuNjc2MSA0Mi41Nzk0QzgzLjY3NjEgNDYuMTcwNCA4MS41NTc1IDQ3Ljk2NTggNzkuMTg3NSA0Ny45NjU4Qzc2Ljc4MTYgNDcuOTY1OCA3NC42OTg5IDQ2LjE3MDQgNzQuNjk4OSA0Mi41Nzk0Qzc0LjY5ODkgMzguOTg4NSA3Ni43ODE2IDM3LjE5MzEgNzkuMTg3NSAzNy4xOTMxQzgxLjU1NzUgMzcuMTkzMSA4My42NzYxIDM4Ljk4ODUgODMuNjc2MSA0Mi41Nzk0Wk03MC4yMTAzIDQyLjU3OTVDNzAuMjEwMyA0Ni4xNzA0IDY4LjA5MTYgNDcuOTY1OCA2NS43MjE2IDQ3Ljk2NThDNjMuMzE1NyA0Ny45NjU4IDYxLjIzMyA0Ni4xNzA0IDYxLjIzMyA0Mi41Nzk1QzYxLjIzMyAzOC45ODg1IDYzLjMxNTcgMzcuMTkzMSA2NS43MjE2IDM3LjE5MzFDNjguMDkxNiAzNy4xOTMxIDcwLjIxMDMgMzguOTg4NSA3MC4yMTAzIDQyLjU3OTVaIiBmaWxsPSIjRkZGREY4Ii8+Cjwvc3ZnPg==",this.supportedTransactionVersions=new Set(["legacy",0]),this._readyState="undefined"==typeof window||"undefined"==typeof document?E.Unsupported:E.NotDetected,this._disconnected=()=>{const e=this._wallet;e&&(e.off("disconnect",this._disconnected),e.off("accountChanged",this._accountChanged),this._wallet=null,this._publicKey=null,this.emit("error",new N),this.emit("disconnect"))},this._accountChanged=e=>{const n=this._publicKey;if(n){try{e=new t.PublicKey(e.toBytes())}catch(e){return void this.emit("error",new $(null==e?void 0:e.message,e))}n.equals(e)||(this._publicKey=e,this.emit("connect",e))}},this._connecting=!1,this._wallet=null,this._publicKey=null,this._readyState!==E.Unsupported&&(function(){if(!navigator)return!1;const e=navigator.userAgent.toLowerCase(),t=e.includes("iphone")||e.includes("ipad"),n=e.includes("safari");return t&&n}()?(this._readyState=E.Loadable,this.emit("readyStateChange",this._readyState)):function(e){if("undefined"==typeof window||"undefined"==typeof document)return;const t=[];function n(){if(e())for(const e of t)e()}const r=setInterval(n,1e3);t.push(()=>clearInterval(r)),"loading"===document.readyState&&(document.addEventListener("DOMContentLoaded",n,{once:!0}),t.push(()=>document.removeEventListener("DOMContentLoaded",n))),"complete"!==document.readyState&&(window.addEventListener("load",n,{once:!0}),t.push(()=>window.removeEventListener("load",n))),n()}(()=>{var e,t,n;return!(!(null===(t=null===(e=window.phantom)||void 0===e?void 0:e.solana)||void 0===t?void 0:t.isPhantom)&&!(null===(n=window.solana)||void 0===n?void 0:n.isPhantom))&&(this._readyState=E.Installed,this.emit("readyStateChange",this._readyState),!0)}))}get publicKey(){return this._publicKey}get connecting(){return this._connecting}get readyState(){return this._readyState}async autoConnect(){this.readyState===E.Installed&&await this.connect()}async connect(){var e;try{if(this.connected||this.connecting)return;if(this.readyState===E.Loadable){const e=encodeURIComponent(window.location.href),t=encodeURIComponent(window.location.origin);return void(window.location.href=`https://phantom.app/ul/browse/${e}?ref=${t}`)}if(this.readyState!==E.Installed)throw new A;this._connecting=!0;const n=(null===(e=window.phantom)||void 0===e?void 0:e.solana)||window.solana;if(!n.isConnected)try{await n.connect()}catch(e){throw new I(null==e?void 0:e.message,e)}if(!n.publicKey)throw new T;let r;try{r=new t.PublicKey(n.publicKey.toBytes())}catch(e){throw new $(null==e?void 0:e.message,e)}n.on("disconnect",this._disconnected),n.on("accountChanged",this._accountChanged),this._wallet=n,this._publicKey=r,this.emit("connect",r)}catch(e){throw this.emit("error",e),e}finally{this._connecting=!1}}async disconnect(){const e=this._wallet;if(e){e.off("disconnect",this._disconnected),e.off("accountChanged",this._accountChanged),this._wallet=null,this._publicKey=null;try{await e.disconnect()}catch(e){this.emit("error",new S(null==e?void 0:e.message,e))}}this.emit("disconnect")}async sendTransaction(e,t,n={}){try{const r=this._wallet;if(!r)throw new B;try{const{signers:o,...s}=n;M(e)?(null==o?void 0:o.length)&&e.sign(o):(e=await this.prepareTransaction(e,t,s),(null==o?void 0:o.length)&&e.partialSign(...o)),s.preflightCommitment=s.preflightCommitment||t.commitment;const{signature:a}=await r.signAndSendTransaction(e,s);return a}catch(e){if(e instanceof k)throw e;throw new C(null==e?void 0:e.message,e)}}catch(e){throw this.emit("error",e),e}}async signTransaction(e){try{const t=this._wallet;if(!t)throw new B;try{return await t.signTransaction(e)||e}catch(e){throw new O(null==e?void 0:e.message,e)}}catch(e){throw this.emit("error",e),e}}async signAllTransactions(e){try{const t=this._wallet;if(!t)throw new B;try{return await t.signAllTransactions(e)||e}catch(e){throw new O(null==e?void 0:e.message,e)}}catch(e){throw this.emit("error",e),e}}async signMessage(e){try{const t=this._wallet;if(!t)throw new B;try{const{signature:n}=await t.signMessage(e);return n}catch(e){throw new R(null==e?void 0:e.message,e)}}catch(e){throw this.emit("error",e),e}}}let L=class e extends Error{constructor(t,n={}){const r=n.cause instanceof e?n.cause.details:n.cause?.message?n.cause.message:n.details,o=n.cause instanceof e&&n.cause.docsPath||n.docsPath;super([t||"An error occurred.","",...n.metaMessages?[...n.metaMessages,""]:[],...o?[`Docs: https://abitype.dev${o}`]:[],...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=o,this.metaMessages=n.metaMessages,this.shortMessage=t}};function U(e,t){const n=e.exec(t);return n?.groups}const D=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,G=/^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)?$/,q=/^\(.+?\).*?$/,V=/^tuple(?<array>(\[(\d*)\])*)$/;function W(e){let t=e.type;if(V.test(e.type)&&"components"in e){t="(";const n=e.components.length;for(let r=0;r<n;r++){t+=W(e.components[r]),r<n-1&&(t+=", ")}const r=U(V,e.type);return t+=`)${r?.array??""}`,W({...e,type:t})}return"indexed"in e&&e.indexed&&(t=`${t} indexed`),e.name?`${t} ${e.name}`:t}function H(e){let t="";const n=e.length;for(let r=0;r<n;r++){t+=W(e[r]),r!==n-1&&(t+=", ")}return t}function Y(e){return"function"===e.type?`function ${e.name}(${H(e.inputs)})${e.stateMutability&&"nonpayable"!==e.stateMutability?` ${e.stateMutability}`:""}${e.outputs?.length?` returns (${H(e.outputs)})`:""}`:"event"===e.type?`event ${e.name}(${H(e.inputs)})`:"error"===e.type?`error ${e.name}(${H(e.inputs)})`:"constructor"===e.type?`constructor(${H(e.inputs)})${"payable"===e.stateMutability?" payable":""}`:"fallback"===e.type?"fallback() external"+("payable"===e.stateMutability?" payable":""):"receive() external payable"}const Z=/^error (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/;const K=/^event (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/;const J=/^function (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)(?: (?<scope>external|public{1}))?(?: (?<stateMutability>pure|view|nonpayable|payable{1}))?(?: returns\s?\((?<returns>.*?)\))?$/;const Q=/^struct (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*) \{(?<properties>.*?)\}$/;function X(e){return Q.test(e)}function ee(e){return U(Q,e)}const te=/^constructor\((?<parameters>.*?)\)(?:\s(?<stateMutability>payable{1}))?$/;const ne=/^fallback\(\) external(?:\s(?<stateMutability>payable{1}))?$/;const re=/^receive\(\) external payable$/;const oe=new Set(["memory","indexed","storage","calldata"]),se=new Set(["indexed"]),ae=new Set(["calldata","memory","storage"]);class ie extends L{constructor({signature:e}){super("Failed to parse ABI item.",{details:`parseAbiItem(${JSON.stringify(e,null,2)})`,docsPath:"/api/human#parseabiitem-1"}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidAbiItemError"})}}class ce extends L{constructor({type:e}){super("Unknown type.",{metaMessages:[`Type "${e}" 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 ue extends L{constructor({type:e}){super("Unknown type.",{metaMessages:[`Type "${e}" is not a valid ABI type.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownSolidityTypeError"})}}class le extends L{constructor({params:e}){super("Failed to parse ABI parameters.",{details:`parseAbiParameters(${JSON.stringify(e,null,2)})`,docsPath:"/api/human#parseabiparameters-1"}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidAbiParametersError"})}}class de extends L{constructor({param:e}){super("Invalid ABI parameter.",{details:e}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidParameterError"})}}class fe extends L{constructor({param:e,name:t}){super("Invalid ABI parameter.",{details:e,metaMessages:[`"${t}" 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 he extends L{constructor({param:e,type:t,modifier:n}){super("Invalid ABI parameter.",{details:e,metaMessages:[`Modifier "${n}" not allowed${t?` in "${t}" type`:""}.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidModifierError"})}}class pe extends L{constructor({param:e,type:t,modifier:n}){super("Invalid ABI parameter.",{details:e,metaMessages:[`Modifier "${n}" not allowed${t?` in "${t}" 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 me extends L{constructor({abiParameter:e}){super("Invalid ABI parameter.",{details:JSON.stringify(e,null,2),metaMessages:["ABI parameter type is invalid."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidAbiTypeParameterError"})}}class ge extends L{constructor({signature:e,type:t}){super(`Invalid ${t} signature.`,{details:e}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidSignatureError"})}}class be extends L{constructor({signature:e}){super("Unknown signature.",{details:e}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownSignatureError"})}}class ye extends L{constructor({signature:e}){super("Invalid struct signature.",{details:e,metaMessages:["No properties exist."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidStructSignatureError"})}}class we extends L{constructor({type:e}){super("Circular reference detected.",{metaMessages:[`Struct "${e}" is a circular reference.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"CircularReferenceError"})}}class ve extends L{constructor({current:e,depth:t}){super("Unbalanced parentheses.",{metaMessages:[`"${e.trim()}" has too many ${t>0?"opening":"closing"} parentheses.`],details:`Depth "${t}"`}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidParenthesisError"})}}const xe=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 Ee(e,t={}){if(function(e){return J.test(e)}(e))return function(e,t={}){const n=function(e){return U(J,e)}(e);if(!n)throw new ge({signature:e,type:"function"});const r=Ne(n.parameters),o=[],s=r.length;for(let e=0;e<s;e++)o.push(Ie(r[e],{modifiers:ae,structs:t,type:"function"}));const a=[];if(n.returns){const e=Ne(n.returns),r=e.length;for(let n=0;n<r;n++)a.push(Ie(e[n],{modifiers:ae,structs:t,type:"function"}))}return{name:n.name,type:"function",stateMutability:n.stateMutability??"nonpayable",inputs:o,outputs:a}}(e,t);if(function(e){return K.test(e)}(e))return function(e,t={}){const n=function(e){return U(K,e)}(e);if(!n)throw new ge({signature:e,type:"event"});const r=Ne(n.parameters),o=[],s=r.length;for(let e=0;e<s;e++)o.push(Ie(r[e],{modifiers:se,structs:t,type:"event"}));return{name:n.name,type:"event",inputs:o}}(e,t);if(function(e){return Z.test(e)}(e))return function(e,t={}){const n=function(e){return U(Z,e)}(e);if(!n)throw new ge({signature:e,type:"error"});const r=Ne(n.parameters),o=[],s=r.length;for(let e=0;e<s;e++)o.push(Ie(r[e],{structs:t,type:"error"}));return{name:n.name,type:"error",inputs:o}}(e,t);if(function(e){return te.test(e)}(e))return function(e,t={}){const n=function(e){return U(te,e)}(e);if(!n)throw new ge({signature:e,type:"constructor"});const r=Ne(n.parameters),o=[],s=r.length;for(let e=0;e<s;e++)o.push(Ie(r[e],{structs:t,type:"constructor"}));return{type:"constructor",stateMutability:n.stateMutability??"nonpayable",inputs:o}}(e,t);if(function(e){return ne.test(e)}(e))return function(e){const t=function(e){return U(ne,e)}(e);if(!t)throw new ge({signature:e,type:"fallback"});return{type:"fallback",stateMutability:t.stateMutability??"nonpayable"}}(e);if(function(e){return re.test(e)}(e))return{type:"receive",stateMutability:"payable"};throw new be({signature:e})}const Pe=/^(?<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$_]*))?$/,ke=/^\((?<type>.+?)\)(?<array>(?:\[\d*?\])+?)?(?:\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\s(?<name>[a-zA-Z$_][a-zA-Z0-9$_]*))?$/,Ae=/^u?int$/;function Ie(e,t){const n=function(e,t,n){let r="";if(n)for(const e of Object.entries(n)){if(!e)continue;let t="";for(const n of e[1])t+=`[${n.type}${n.name?`:${n.name}`:""}]`;r+=`(${e[0]}{${t}})`}return t?`${t}:${e}${r}`:e}(e,t?.type,t?.structs);if(xe.has(n))return xe.get(n);const r=q.test(e),o=U(r?ke:Pe,e);if(!o)throw new de({param:e});if(o.name&&function(e){return"address"===e||"bool"===e||"function"===e||"string"===e||"tuple"===e||D.test(e)||G.test(e)||Te.test(e)}(o.name))throw new fe({param:e,name:o.name});const s=o.name?{name:o.name}:{},a="indexed"===o.modifier?{indexed:!0}:{},i=t?.structs??{};let c,u={};if(r){c="tuple";const e=Ne(o.type),t=[],n=e.length;for(let r=0;r<n;r++)t.push(Ie(e[r],{structs:i}));u={components:t}}else if(o.type in i)c="tuple",u={components:i[o.type]};else if(Ae.test(o.type))c=`${o.type}256`;else if("address payable"===o.type)c="address";else if(c=o.type,"struct"!==t?.type&&!Se(c))throw new ue({type:c});if(o.modifier){if(!t?.modifiers?.has?.(o.modifier))throw new he({param:e,type:t?.type,modifier:o.modifier});if(ae.has(o.modifier)&&!function(e,t){return t||"bytes"===e||"string"===e||"tuple"===e}(c,!!o.array))throw new pe({param:e,type:t?.type,modifier:o.modifier})}const l={type:`${c}${o.array??""}`,...s,...a,...u};return xe.set(n,l),l}function Ne(e,t=[],n="",r=0){const o=e.trim().length;for(let s=0;s<o;s++){const o=e[s],a=e.slice(s+1);switch(o){case",":return 0===r?Ne(a,[...t,n.trim()]):Ne(a,t,`${n}${o}`,r);case"(":return Ne(a,t,`${n}${o}`,r+1);case")":return Ne(a,t,`${n}${o}`,r-1);default:return Ne(a,t,`${n}${o}`,r)}}if(""===n)return t;if(0!==r)throw new ve({current:n,depth:r});return t.push(n.trim()),t}function Se(e){return"address"===e||"bool"===e||"function"===e||"string"===e||D.test(e)||G.test(e)}const Te=/^(?: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 $e(e){const t={},n=e.length;for(let r=0;r<n;r++){const n=e[r];if(!X(n))continue;const o=ee(n);if(!o)throw new ge({signature:n,type:"struct"});const s=o.properties.split(";"),a=[],i=s.length;for(let e=0;e<i;e++){const t=s[e].trim();if(!t)continue;const n=Ie(t,{type:"struct"});a.push(n)}if(!a.length)throw new ye({signature:n});t[o.name]=a}const r={},o=Object.entries(t),s=o.length;for(let e=0;e<s;e++){const[n,s]=o[e];r[n]=Ce(s,t)}return r}const Be=/^(?<type>[a-zA-Z$_][a-zA-Z0-9$_]*)(?<array>(?:\[\d*?\])+?)?$/;function Ce(e,t,n=new Set){const r=[],o=e.length;for(let s=0;s<o;s++){const o=e[s];if(q.test(o.type))r.push(o);else{const e=U(Be,o.type);if(!e?.type)throw new me({abiParameter:o});const{array:s,type:a}=e;if(a in t){if(n.has(a))throw new we({type:a});r.push({...o,type:`tuple${s??""}`,components:Ce(t[a]??[],t,new Set([...n,a]))})}else{if(!Se(a))throw new ce({type:a});r.push(o)}}}return r}function Oe(e){const t=$e(e),n=[],r=e.length;for(let o=0;o<r;o++){const r=e[o];X(r)||n.push(Ee(r,t))}return n}function Re(e){let t;if("string"==typeof e)t=Ee(e);else{const n=$e(e),r=e.length;for(let o=0;o<r;o++){const r=e[o];if(!X(r)){t=Ee(r,n);break}}}if(!t)throw new ie({signature:e});return t}function ze(e){const t=[];if("string"==typeof e){const n=Ne(e),r=n.length;for(let e=0;e<r;e++)t.push(Ie(n[e],{modifiers:oe}))}else{const n=$e(e),r=e.length;for(let o=0;o<r;o++){const r=e[o];if(X(r))continue;const s=Ne(r),a=s.length;for(let e=0;e<a;e++)t.push(Ie(s[e],{modifiers:oe,structs:n}))}}if(0===t.length)throw new le({params:e});return t}function Me(e,t,n){const r=e[t.name];if("function"==typeof r)return r;const o=e[n];return"function"==typeof o?o:n=>t(e,n)}function _e(e,{includeName:t=!1}={}){if("function"!==e.type&&"event"!==e.type&&"error"!==e.type)throw new mt(e.type);return`${e.name}(${Fe(e.inputs,{includeName:t})})`}function Fe(e,{includeName:t=!1}={}){return e?e.map(e=>function(e,{includeName:t}){if(e.type.startsWith("tuple"))return`(${Fe(e.components,{includeName:t})})${e.type.slice(5)}`;return e.type+(t&&e.name?` ${e.name}`:"")}(e,{includeName:t})).join(t?", ":","):""}function je(e,{strict:t=!0}={}){return!!e&&("string"==typeof e&&(t?/^0x[0-9a-fA-F]*$/.test(e):e.startsWith("0x")))}function Le(e){return je(e,{strict:!1})?Math.ceil((e.length-2)/2):e.length}const Ue="2.37.8";let De=({docsBaseUrl:e,docsPath:t="",docsSlug:n})=>t?`${e??"https://viem.sh"}${t}${n?`#${n}`:""}`:void 0,Ge=`viem@${Ue}`,qe=class e extends Error{constructor(t,n={}){const r=n.cause instanceof e?n.cause.details:n.cause?.message?n.cause.message:n.details,o=n.cause instanceof e&&n.cause.docsPath||n.docsPath,s=De?.({...n,docsPath:o});super([t||"An error occurred.","",...n.metaMessages?[...n.metaMessages,""]:[],...s?[`Docs: ${s}`]:[],...r?[`Details: ${r}`]:[],...Ge?[`Version: ${Ge}`]:[]].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=o,this.metaMessages=n.metaMessages,this.name=n.name??this.name,this.shortMessage=t,this.version=Ue}walk(e){return Ve(this,e)}};function Ve(e,t){return t?.(e)?e:e&&"object"==typeof e&&"cause"in e&&void 0!==e.cause?Ve(e.cause,t):t?null:e}class We extends qe{constructor({docsPath:e}){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:e,name:"AbiConstructorNotFoundError"})}}class He extends qe{constructor({docsPath:e}){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:e,name:"AbiConstructorParamsNotFoundError"})}}class Ye extends qe{constructor({data:e,params:t,size:n}){super([`Data size of ${n} bytes is too small for given parameters.`].join("\n"),{metaMessages:[`Params: (${Fe(t,{includeName:!0})})`,`Data: ${e} (${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=e,this.params=t,this.size=n}}class Ze extends qe{constructor(){super('Cannot decode zero data ("0x") with ABI parameters.',{name:"AbiDecodingZeroDataError"})}}class Ke extends qe{constructor({expectedLength:e,givenLength:t,type:n}){super([`ABI encoding array length mismatch for type ${n}.`,`Expected length: ${e}`,`Given length: ${t}`].join("\n"),{name:"AbiEncodingArrayLengthMismatchError"})}}class Je extends qe{constructor({expectedSize:e,value:t}){super(`Size of bytes "${t}" (bytes${Le(t)}) does not match expected size (bytes${e}).`,{name:"AbiEncodingBytesSizeMismatchError"})}}class Qe extends qe{constructor({expectedLength:e,givenLength:t}){super(["ABI encoding params/values length mismatch.",`Expected length (params): ${e}`,`Given length (values): ${t}`].join("\n"),{name:"AbiEncodingLengthMismatchError"})}}class Xe extends qe{constructor(e,{docsPath:t}){super([`Arguments (\`args\`) were provided to "${e}", but "${e}" 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:t,name:"AbiErrorInputsNotFoundError"})}}class et extends qe{constructor(e,{docsPath:t}={}){super([`Error ${e?`"${e}" `:""}not found on ABI.`,"Make sure you are using the correct ABI and that the error exists on it."].join("\n"),{docsPath:t,name:"AbiErrorNotFoundError"})}}class tt extends qe{constructor(e,{docsPath:t}){super([`Encoded error signature "${e}" 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=${e}.`].join("\n"),{docsPath:t,name:"AbiErrorSignatureNotFoundError"}),Object.defineProperty(this,"signature",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.signature=e}}class nt extends qe{constructor({docsPath:e}){super("Cannot extract event signature from empty topics.",{docsPath:e,name:"AbiEventSignatureEmptyTopicsError"})}}class rt extends qe{constructor(e,{docsPath:t}){super([`Encoded event signature "${e}" 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=${e}.`].join("\n"),{docsPath:t,name:"AbiEventSignatureNotFoundError"})}}class ot extends qe{constructor(e,{docsPath:t}={}){super([`Event ${e?`"${e}" `:""}not found on ABI.`,"Make sure you are using the correct ABI and that the event exists on it."].join("\n"),{docsPath:t,name:"AbiEventNotFoundError"})}}class st extends qe{constructor(e,{docsPath:t}={}){super([`Function ${e?`"${e}" `:""}not found on ABI.`,"Make sure you are using the correct ABI and that the function exists on it."].join("\n"),{docsPath:t,name:"AbiFunctionNotFoundError"})}}class at extends qe{constructor(e,{docsPath:t}){super([`Function "${e}" 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:t,name:"AbiFunctionOutputsNotFoundError"})}}class it extends qe{constructor(e,{docsPath:t}){super([`Encoded function signature "${e}" 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=${e}.`].join("\n"),{docsPath:t,name:"AbiFunctionSignatureNotFoundError"})}}class ct extends qe{constructor(e,t){super("Found ambiguous types in overloaded ABI items.",{metaMessages:[`\`${e.type}\` in \`${_e(e.abiItem)}\`, and`,`\`${t.type}\` in \`${_e(t.abiItem)}\``,"","These types encode differently and cannot be distinguished at runtime.","Remove one of the ambiguous items in the ABI."],name:"AbiItemAmbiguityError"})}}let ut=class extends qe{constructor({expectedSize:e,givenSize:t}){super(`Expected bytes${e}, got bytes${t}.`,{name:"BytesSizeMismatchError"})}};class lt extends qe{constructor({abiItem:e,data:t,params:n,size:r}){super([`Data size of ${r} bytes is too small for non-indexed event parameters.`].join("\n"),{metaMessages:[`Params: (${Fe(n,{includeName:!0})})`,`Data: ${t} (${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=e,this.data=t,this.params=n,this.size=r}}class dt extends qe{constructor({abiItem:e,param:t}){super([`Expected a topic for indexed event parameter${t.name?` "${t.name}"`:""} on event "${_e(e,{includeName:!0})}".`].join("\n"),{name:"DecodeLogTopicsMismatch"}),Object.defineProperty(this,"abiItem",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.abiItem=e}}class ft extends qe{constructor(e,{docsPath:t}){super([`Type "${e}" is not a valid encoding type.`,"Please provide a valid ABI type."].join("\n"),{docsPath:t,name:"InvalidAbiEncodingType"})}}class ht extends qe{constructor(e,{docsPath:t}){super([`Type "${e}" is not a valid decoding type.`,"Please provide a valid ABI type."].join("\n"),{docsPath:t,name:"InvalidAbiDecodingType"})}}let pt=class extends qe{constructor(e){super([`Value "${e}" is not a valid array.`].join("\n"),{name:"InvalidArrayError"})}};class mt extends qe{constructor(e){super([`"${e}" is not a valid definition type.`,'Valid types: "function", "event", "error"'].join("\n"),{name:"InvalidDefinitionTypeError"})}}class gt extends qe{constructor(e){super(`Filter type "${e}" is not supported.`,{name:"FilterTypeNotSupportedError"})}}let bt=class extends qe{constructor({offset:e,position:t,size:n}){super(`Slice ${"start"===t?"starting":"ending"} at offset "${e}" is out-of-bounds (size: ${n}).`,{name:"SliceOffsetOutOfBoundsError"})}},yt=class extends qe{constructor({size:e,targetSize:t,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (${e}) exceeds padding size (${t}).`,{name:"SizeExceedsPaddingSizeError"})}};class wt extends qe{constructor({size:e,targetSize:t,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} is expected to be ${t} ${n} long, but is ${e} ${n} long.`,{name:"InvalidBytesLengthError"})}}function vt(e,{dir:t,size:n=32}={}){return"string"==typeof e?xt(e,{dir:t,size:n}):function(e,{dir:t,size:n=32}={}){if(null===n)return e;if(e.length>n)throw new yt({size:e.length,targetSize:n,type:"bytes"});const r=new Uint8Array(n);for(let o=0;o<n;o++){const s="right"===t;r[s?o:n-o-1]=e[s?o:e.length-o-1]}return r}(e,{dir:t,size:n})}function xt(e,{dir:t,size:n=32}={}){if(null===n)return e;const r=e.replace("0x","");if(r.length>2*n)throw new yt({size:Math.ceil(r.length/2),targetSize:n,type:"hex"});return`0x${r["right"===t?"padEnd":"padStart"](2*n,"0")}`}let Et=class extends qe{constructor({max:e,min:t,signed:n,size:r,value:o}){super(`Number "${o}" is not in safe ${r?`${8*r}-bit ${n?"signed":"unsigned"} `:""}integer range ${e?`(${t} to ${e})`:`(above ${t})`}`,{name:"IntegerOutOfRangeError"})}},Pt=class extends qe{constructor(e){super(`Bytes value "${e}" is not a valid boolean. The bytes array must contain a single byte of either a 0 or 1 value.`,{name:"InvalidBytesBooleanError"})}};class kt extends qe{constructor(e){super(`Hex value "${e}" is not a valid boolean. The hex value must be "0x0" (false) or "0x1" (true).`,{name:"InvalidHexBooleanError"})}}let At=class extends qe{constructor({givenSize:e,maxSize:t}){super(`Size cannot exceed ${t} bytes. Given size: ${e} bytes.`,{name:"SizeOverflowError"})}};function It(e,{dir:t="left"}={}){let n="string"==typeof e?e.replace("0x",""):e,r=0;for(let e=0;e<n.length-1&&"0"===n["left"===t?e:n.length-e-1].toString();e++)r++;return n="left"===t?n.slice(r):n.slice(0,n.length-r),"string"==typeof e?(1===n.length&&"right"===t&&(n=`${n}0`),`0x${n.length%2==1?`0${n}`:n}`):n}function Nt(e,{size:t}){if(Le(e)>t)throw new At({givenSize:Le(e),maxSize:t})}function St(e,t={}){const{signed:n}=t;t.size&&Nt(e,{size:t.size});const r=BigInt(e);if(!n)return r;const o=(e.length-2)/2;return r<=(1n<<8n*BigInt(o)-1n)-1n?r:r-BigInt(`0x${"f".padStart(2*o,"f")}`)-1n}function Tt(e,t={}){return Number(St(e,t))}const $t=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Bt(e,t={}){return"number"==typeof e||"bigint"==typeof e?Rt(e,t):"string"==typeof e?Mt(e,t):"boolean"==typeof e?Ct(e,t):Ot(e,t)}function Ct(e,t={}){const n=`0x${Number(e)}`;return"number"==typeof t.size?(Nt(n,{size:t.size}),vt(n,{size:t.size})):n}function Ot(e,t={}){let n="";for(let t=0;t<e.length;t++)n+=$t[e[t]];const r=`0x${n}`;return"number"==typeof t.size?(Nt(r,{size:t.size}),vt(r,{dir:"right",size:t.size})):r}function Rt(e,t={}){const{signed:n,size:r}=t,o=BigInt(e);let s;r?s=n?(1n<<8n*BigInt(r)-1n)-1n:2n**(8n*BigInt(r))-1n:"number"==typeof e&&(s=BigInt(Number.MAX_SAFE_INTEGER));const a="bigint"==typeof s&&n?-s-1n:0;if(s&&o>s||o<a){const t="bigint"==typeof e?"n":"";throw new Et({max:s?`${s}${t}`:void 0,min:`${a}${t}`,signed:n,size:r,value:`${e}${t}`})}const i=`0x${(n&&o<0?(1n<<BigInt(8*r))+BigInt(o):o).toString(16)}`;return r?vt(i,{size:r}):i}const zt=new TextEncoder;function Mt(e,t={}){return Ot(zt.encode(e),t)}const _t=new TextEncoder;function Ft(e,t={}){return"number"==typeof e||"bigint"==typeof e?function(e,t){const n=Rt(e,t);return Ut(n)}(e,t):"boolean"==typeof e?function(e,t={}){const n=new Uint8Array(1);if(n[0]=Number(e),"number"==typeof t.size)return Nt(n,{size:t.size}),vt(n,{size:t.size});return n}(e,t):je(e)?Ut(e,t):Dt(e,t)}const jt={zero:48,nine:57,A:65,F:70,a:97,f:102};function Lt(e){return e>=jt.zero&&e<=jt.nine?e-jt.zero:e>=jt.A&&e<=jt.F?e-(jt.A-10):e>=jt.a&&e<=jt.f?e-(jt.a-10):void 0}function Ut(e,t={}){let n=e;t.size&&(Nt(n,{size:t.size}),n=vt(n,{dir:"right",size:t.size}));let r=n.slice(2);r.length%2&&(r=`0${r}`);const o=r.length/2,s=new Uint8Array(o);for(let e=0,t=0;e<o;e++){const n=Lt(r.charCodeAt(t++)),o=Lt(r.charCodeAt(t++));if(void 0===n||void 0===o)throw new qe(`Invalid byte sequence ("${r[t-2]}${r[t-1]}" in "${r}").`);s[e]=16*n+o}return s}function Dt(e,t={}){const n=_t.encode(e);return"number"==typeof t.size?(Nt(n,{size:t.size}),vt(n,{dir:"right",size:t.size})):n}const Gt=BigInt(2**32-1),qt=BigInt(32);function Vt(e,t=!1){return t?{h:Number(e&Gt),l:Number(e>>qt&Gt)}:{h:0|Number(e>>qt&Gt),l:0|Number(e&Gt)}}const Wt="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0;function Ht(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function Yt(e,...t){if(!((n=e)instanceof Uint8Array||ArrayBuffer.isView(n)&&"Uint8Array"===n.constructor.name))throw new Error("Uint8Array expected");
|
|
2
2
|
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
3
3
|
var n;if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function Zt(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Kt(e,t){Yt(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function Jt(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Qt(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Xt(e,t){return e<<32-t|e>>>t}function en(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}const tn=(()=>68===new Uint8Array(new Uint32Array([287454020]).buffer)[0])()?e=>e:function(e){for(let t=0;t<e.length;t++)e[t]=en(e[t]);return e};function nn(e){return"string"==typeof e&&(e=function(e){if("string"!=typeof e)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(e))}(e)),Yt(e),e}class rn{}function on(e){const t=t=>e().update(nn(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function sn(e=32){if(Wt&&"function"==typeof Wt.getRandomValues)return Wt.getRandomValues(new Uint8Array(e));if(Wt&&"function"==typeof Wt.randomBytes)return Uint8Array.from(Wt.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}const an=BigInt(0),cn=BigInt(1),un=BigInt(2),ln=BigInt(7),dn=BigInt(256),fn=BigInt(113),hn=[],pn=[],mn=[];for(let e=0,t=cn,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],hn.push(2*(5*r+n)),pn.push((e+1)*(e+2)/2%64);let o=an;for(let e=0;e<7;e++)t=(t<<cn^(t>>ln)*fn)%dn,t&un&&(o^=cn<<(cn<<BigInt(e))-cn);mn.push(o)}const gn=function(e,t=!1){const n=e.length;let r=new Uint32Array(n),o=new Uint32Array(n);for(let s=0;s<n;s++){const{h:n,l:a}=Vt(e[s],t);[r[s],o[s]]=[n,a]}return[r,o]}(mn,!0),bn=gn[0],yn=gn[1],wn=(e,t,n)=>n>32?((e,t,n)=>t<<n-32|e>>>64-n)(e,t,n):((e,t,n)=>e<<n|t>>>32-n)(e,t,n),vn=(e,t,n)=>n>32?((e,t,n)=>e<<n-32|t>>>64-n)(e,t,n):((e,t,n)=>t<<n|e>>>32-n)(e,t,n);class xn extends rn{constructor(e,t,n,r=!1,o=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=e,this.suffix=t,this.outputLen=n,this.enableXOF=r,this.rounds=o,Ht(n),!(0<e&&e<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(){tn(this.state32),function(e,t=24){const n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let t=0;t<10;t++)n[t]=e[t]^e[t+10]^e[t+20]^e[t+30]^e[t+40];for(let t=0;t<10;t+=2){const r=(t+8)%10,o=(t+2)%10,s=n[o],a=n[o+1],i=wn(s,a,1)^n[r],c=vn(s,a,1)^n[r+1];for(let n=0;n<50;n+=10)e[t+n]^=i,e[t+n+1]^=c}let t=e[2],o=e[3];for(let n=0;n<24;n++){const r=pn[n],s=wn(t,o,r),a=vn(t,o,r),i=hn[n];t=e[i],o=e[i+1],e[i]=s,e[i+1]=a}for(let t=0;t<50;t+=10){for(let r=0;r<10;r++)n[r]=e[t+r];for(let r=0;r<10;r++)e[t+r]^=~n[(r+2)%10]&n[(r+4)%10]}e[0]^=bn[r],e[1]^=yn[r]}Jt(n)}(this.state32,this.rounds),tn(this.state32),this.posOut=0,this.pos=0}update(e){Zt(this),Yt(e=nn(e));const{blockLen:t,state:n}=this,r=e.length;for(let o=0;o<r;){const s=Math.min(t-this.pos,r-o);for(let t=0;t<s;t++)n[this.pos++]^=e[o++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:n,blockLen:r}=this;e[n]^=t,128&t&&n===r-1&&this.keccak(),e[r-1]^=128,this.keccak()}writeInto(e){Zt(this,!1),Yt(e),this.finish();const t=this.state,{blockLen:n}=this;for(let r=0,o=e.length;r<o;){this.posOut>=n&&this.keccak();const s=Math.min(n-this.posOut,o-r);e.set(t.subarray(this.posOut,this.posOut+s),r),this.posOut+=s,r+=s}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return Ht(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(Kt(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,Jt(this.state)}_cloneInto(e){const{blockLen:t,suffix:n,outputLen:r,rounds:o,enableXOF:s}=this;return e||(e=new xn(t,n,r,s,o)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=o,e.suffix=n,e.outputLen=r,e.enableXOF=s,e.destroyed=this.destroyed,e}}const En=(()=>{return e=1,t=136,n=32,on(()=>new xn(t,e,n));var e,t,n})();function Pn(e,t){const n=t||"hex",r=En(je(e,{strict:!1})?Ft(e):e);return"bytes"===n?r:Bt(r)}function kn(e){return Pn(Ft(e))}const An=e=>function(e){let t=!0,n="",r=0,o="",s=!1;for(let a=0;a<e.length;a++){const i=e[a];if(["(",")",","].includes(i)&&(t=!0),"("===i&&r++,")"===i&&r--,t)if(0!==r)" "!==i?(o+=i,n+=i):","!==e[a-1]&&","!==n&&",("!==n&&(n="",t=!1);else if(" "===i&&["event","function",""].includes(o))o="";else if(o+=i,")"===i){s=!0;break}}if(!s)throw new qe("Unable to normalize signature.");return o}("string"==typeof e?e:Y(e));function In(e){return kn(An(e))}const Nn=In;let Sn=class extends qe{constructor({address:e}){super(`Address "${e}" is invalid.`,{metaMessages:["- Address must be a hex value of 20 bytes (40 hex characters).","- Address must match its checksum counterpart."],name:"InvalidAddressError"})}},Tn=class extends Map{constructor(e){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=e}get(e){const t=super.get(e);return super.has(e)&&void 0!==t&&(this.delete(e),super.set(e,t)),t}set(e,t){if(super.set(e,t),this.maxSize&&this.size>this.maxSize){const e=this.keys().next().value;e&&this.delete(e)}return this}};const $n=new Tn(8192);function Bn(e,t){if($n.has(`${e}.${t}`))return $n.get(`${e}.${t}`);const n=e.substring(2).toLowerCase(),r=Pn(Dt(n),"bytes"),o=n.split("");for(let e=0;e<40;e+=2)r[e>>1]>>4>=8&&o[e]&&(o[e]=o[e].toUpperCase()),(15&r[e>>1])>=8&&o[e+1]&&(o[e+1]=o[e+1].toUpperCase());const s=`0x${o.join("")}`;return $n.set(`${e}.${t}`,s),s}function Cn(e,t){if(!zn(e,{strict:!1}))throw new Sn({address:e});return Bn(e,t)}const On=/^0x[a-fA-F0-9]{40}$/,Rn=new Tn(8192);function zn(e,t){const{strict:n=!0}=t??{},r=`${e}.${n}`;if(Rn.has(r))return Rn.get(r);const o=!(!On.test(e)||e.toLowerCase()!==e&&n&&Bn(e)!==e);return Rn.set(r,o),o}function Mn(e){return"string"==typeof e[0]?_n(e):function(e){let t=0;for(const n of e)t+=n.length;const n=new Uint8Array(t);let r=0;for(const t of e)n.set(t,r),r+=t.length;return n}(e)}function _n(e){return`0x${e.reduce((e,t)=>e+t.replace("0x",""),"")}`}function Fn(e,t,n,{strict:r}={}){return je(e,{strict:!1})?function(e,t,n,{strict:r}={}){jn(e,t);const o=`0x${e.replace("0x","").slice(2*(t??0),2*(n??e.length))}`;r&&Ln(o,t,n);return o}(e,t,n,{strict:r}):Un(e,t,n,{strict:r})}function jn(e,t){if("number"==typeof t&&t>0&&t>Le(e)-1)throw new bt({offset:t,position:"start",size:Le(e)})}function Ln(e,t,n){if("number"==typeof t&&"number"==typeof n&&Le(e)!==n-t)throw new bt({offset:n,position:"end",size:Le(e)})}function Un(e,t,n,{strict:r}={}){jn(e,t);const o=e.slice(t,n);return r&&Ln(o,t,n),o}const Dn=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,Gn=/^(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 qn(e,t){if(e.length!==t.length)throw new Qe({expectedLength:e.length,givenLength:t.length});const n=function({params:e,values:t}){const n=[];for(let r=0;r<e.length;r++)n.push(Vn({param:e[r],value:t[r]}));return n}({params:e,values:t}),r=Wn(n);return 0===r.length?"0x":r}function Vn({param:e,value:t}){const n=Hn(e.type);if(n){const[r,o]=n;return function(e,{length:t,param:n}){const r=null===t;if(!Array.isArray(e))throw new pt(e);if(!r&&e.length!==t)throw new Ke({expectedLength:t,givenLength:e.length,type:`${n.type}[${t}]`});let o=!1;const s=[];for(let t=0;t<e.length;t++){const r=Vn({param:n,value:e[t]});r.dynamic&&(o=!0),s.push(r)}if(r||o){const e=Wn(s);if(r){const t=Rt(s.length,{size:32});return{dynamic:!0,encoded:s.length>0?Mn([t,e]):t}}if(o)return{dynamic:!0,encoded:e}}return{dynamic:!1,encoded:Mn(s.map(({encoded:e})=>e))}}(t,{length:r,param:{...e,type:o}})}if("tuple"===e.type)return function(e,{param:t}){let n=!1;const r=[];for(let o=0;o<t.components.length;o++){const s=t.components[o],a=Vn({param:s,value:e[Array.isArray(e)?o:s.name]});r.push(a),a.dynamic&&(n=!0)}return{dynamic:n,encoded:n?Wn(r):Mn(r.map(({encoded:e})=>e))}}(t,{param:e});if("address"===e.type)return function(e){if(!zn(e))throw new Sn({address:e});return{dynamic:!1,encoded:xt(e.toLowerCase())}}(t);if("bool"===e.type)return function(e){if("boolean"!=typeof e)throw new qe(`Invalid boolean value: "${e}" (type: ${typeof e}). Expected: \`true\` or \`false\`.`);return{dynamic:!1,encoded:xt(Ct(e))}}(t);if(e.type.startsWith("uint")||e.type.startsWith("int")){const n=e.type.startsWith("int"),[,,r="256"]=Gn.exec(e.type)??[];return function(e,{signed:t,size:n=256}){if("number"==typeof n){const r=2n**(BigInt(n)-(t?1n:0n))-1n,o=t?-r-1n:0n;if(e>r||e<o)throw new Et({max:r.toString(),min:o.toString(),signed:t,size:n/8,value:e.toString()})}return{dynamic:!1,encoded:Rt(e,{size:32,signed:t})}}(t,{signed:n,size:Number(r)})}if(e.type.startsWith("bytes"))return function(e,{param:t}){const[,n]=t.type.split("bytes"),r=Le(e);if(!n){let t=e;return r%32!=0&&(t=xt(t,{dir:"right",size:32*Math.ceil((e.length-2)/2/32)})),{dynamic:!0,encoded:Mn([xt(Rt(r,{size:32})),t])}}if(r!==Number.parseInt(n,10))throw new Je({expectedSize:Number.parseInt(n,10),value:e});return{dynamic:!1,encoded:xt(e,{dir:"right"})}}(t,{param:e});if("string"===e.type)return function(e){const t=Mt(e),n=Math.ceil(Le(t)/32),r=[];for(let e=0;e<n;e++)r.push(xt(Fn(t,32*e,32*(e+1)),{dir:"right"}));return{dynamic:!0,encoded:Mn([xt(Rt(Le(t),{size:32})),...r])}}(t);throw new ft(e.type,{docsPath:"/docs/contract/encodeAbiParameters"})}function Wn(e){let t=0;for(let n=0;n<e.length;n++){const{dynamic:r,encoded:o}=e[n];t+=r?32:Le(o)}const n=[],r=[];let o=0;for(let s=0;s<e.length;s++){const{dynamic:a,encoded:i}=e[s];a?(n.push(Rt(t+o,{size:32})),r.push(i),o+=Le(i)):n.push(i)}return Mn([...n,...r])}function Hn(e){const t=e.match(/^(.*)\[(\d+)?\]$/);return t?[t[2]?Number(t[2]):null,t[1]]:void 0}const Yn=e=>Fn(In(e),0,4);function Zn(e){const{abi:t,args:n=[],name:r}=e,o=je(r,{strict:!1}),s=t.filter(e=>o?"function"===e.type?Yn(e)===r:"event"===e.type&&Nn(e)===r:"name"in e&&e.name===r);if(0===s.length)return;if(1===s.length)return s[0];let a;for(const e of s){if(!("inputs"in e))continue;if(!n||0===n.length){if(!e.inputs||0===e.inputs.length)return e;continue}if(!e.inputs)continue;if(0===e.inputs.length)continue;if(e.inputs.length!==n.length)continue;const t=n.every((t,n)=>{const r="inputs"in e&&e.inputs[n];return!!r&&Kn(t,r)});if(t){if(a&&"inputs"in a&&a.inputs){const t=Jn(e.inputs,a.inputs,n);if(t)throw new ct({abiItem:e,type:t[0]},{abiItem:a,type:t[1]})}a=e}}return a||s[0]}function Kn(e,t){const n=typeof e,r=t.type;switch(r){case"address":return zn(e,{strict:!1});case"bool":return"boolean"===n;case"function":case"string":return"string"===n;default:return"tuple"===r&&"components"in t?Object.values(t.components).every((t,n)=>Kn(Object.values(e)[n],t)):/^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||e instanceof Uint8Array:!!/[a-z]+[1-9]{0,3}(\[[0-9]{0,}\])+$/.test(r)&&(Array.isArray(e)&&e.every(e=>Kn(e,{...t,type:r.replace(/(\[[0-9]{0,}\])$/,"")})))}}function Jn(e,t,n){for(const r in e){const o=e[r],s=t[r];if("tuple"===o.type&&"tuple"===s.type&&"components"in o&&"components"in s)return Jn(o.components,s.components,n[r]);const a=[o.type,s.type];if((()=>!(!a.includes("address")||!a.includes("bytes20"))||(a.includes("address")&&a.includes("string")||!(!a.includes("address")||!a.includes("bytes")))&&zn(n[r],{strict:!1}))())return a}}const Qn="/docs/contract/encodeEventTopics";function Xn(e){const{abi:t,eventName:n,args:r}=e;let o=t[0];if(n){const e=Zn({abi:t,name:n});if(!e)throw new ot(n,{docsPath:Qn});o=e}if("event"!==o.type)throw new ot(void 0,{docsPath:Qn});const s=_e(o),a=Nn(s);let i=[];if(r&&"inputs"in o){const e=o.inputs?.filter(e=>"indexed"in e&&e.indexed),t=Array.isArray(r)?r:Object.values(r).length>0?e?.map(e=>r[e.name])??[]:[];t.length>0&&(i=e?.map((e,n)=>Array.isArray(t[n])?t[n].map((r,o)=>er({param:e,value:t[n][o]})):void 0!==t[n]&&null!==t[n]?er({param:e,value:t[n]}):null)??[])}return[a,...i]}function er({param:e,value:t}){if("string"===e.type||"bytes"===e.type)return Pn(Ft(t));if("tuple"===e.type||e.type.match(/^(.*)\[(\d+)?\]$/))throw new gt(e.type);return qn([e],[t])}function tr(e,{method:t}){const n={};return"fallback"===e.transport.type&&e.transport.onResponse?.(({method:e,response:r,status:o,transport:s})=>{"success"===o&&t===e&&(n[r]=s.request)}),t=>n[t]||e.request}async function nr(e,t){const{address:n,abi:r,args:o,eventName:s,fromBlock:a,strict:i,toBlock:c}=t,u=tr(e,{method:"eth_newFilter"}),l=s?Xn({abi:r,args:o,eventName:s}):void 0,d=await e.request({method:"eth_newFilter",params:[{address:n,fromBlock:"bigint"==typeof a?Rt(a):a,toBlock:"bigint"==typeof c?Rt(c):c,topics:l}]});return{abi:r,args:o,eventName:s,id:d,request:u(d),strict:Boolean(i),type:"event"}}function rr(e){return"string"==typeof e?{address:e,type:"json-rpc"}:e}const or="/docs/contract/encodeFunctionData";function sr(e){const{args:t}=e,{abi:n,functionName:r}=1===e.abi.length&&e.functionName?.startsWith("0x")?e:function(e){const{abi:t,args:n,functionName:r}=e;let o=t[0];if(r){const e=Zn({abi:t,args:n,name:r});if(!e)throw new st(r,{docsPath:or});o=e}if("function"!==o.type)throw new st(void 0,{docsPath:or});return{abi:[o],functionName:Yn(_e(o))}}(e),o=n[0];return _n([r,("inputs"in o&&o.inputs?qn(o.inputs,t??[]):void 0)??"0x"])}const ar={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."},ir={inputs:[{name:"message",type:"string"}],name:"Error",type:"error"},cr={inputs:[{name:"reason",type:"uint256"}],name:"Panic",type:"error"};let ur=class extends qe{constructor({offset:e}){super(`Offset \`${e}\` cannot be negative.`,{name:"NegativeOffsetError"})}},lr=class extends qe{constructor({length:e,position:t}){super(`Position \`${t}\` is out of bounds (\`0 < position < ${e}\`).`,{name:"PositionOutOfBoundsError"})}},dr=class extends qe{constructor({count:e,limit:t}){super(`Recursive read limit of \`${t}\` exceeded (recursive read count: \`${e}\`).`,{name:"RecursiveReadLimitExceededError"})}};const fr={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 dr({count:this.recursiveReadCount+1,limit:this.recursiveReadLimit})},assertPosition(e){if(e<0||e>this.bytes.length-1)throw new lr({length:this.bytes.length,position:e})},decrementPosition(e){if(e<0)throw new ur({offset:e});const t=this.position-e;this.assertPosition(t),this.position=t},getReadCount(e){return this.positionReadCount.get(e||this.position)||0},incrementPosition(e){if(e<0)throw new ur({offset:e});const t=this.position+e;this.assertPosition(t),this.position=t},inspectByte(e){const t=e??this.position;return this.assertPosition(t),this.bytes[t]},inspectBytes(e,t){const n=t??this.position;return this.assertPosition(n+e-1),this.bytes.subarray(n,n+e)},inspectUint8(e){const t=e??this.position;return this.assertPosition(t),this.bytes[t]},inspectUint16(e){const t=e??this.position;return this.assertPosition(t+1),this.dataView.getUint16(t)},inspectUint24(e){const t=e??this.position;return this.assertPosition(t+2),(this.dataView.getUint16(t)<<8)+this.dataView.getUint8(t+2)},inspectUint32(e){const t=e??this.position;return this.assertPosition(t+3),this.dataView.getUint32(t)},pushByte(e){this.assertPosition(this.position),this.bytes[this.position]=e,this.position++},pushBytes(e){this.assertPosition(this.position+e.length-1),this.bytes.set(e,this.position),this.position+=e.length},pushUint8(e){this.assertPosition(this.position),this.bytes[this.position]=e,this.position++},pushUint16(e){this.assertPosition(this.position+1),this.dataView.setUint16(this.position,e),this.position+=2},pushUint24(e){this.assertPosition(this.position+2),this.dataView.setUint16(this.position,e>>8),this.dataView.setUint8(this.position+2,255&e),this.position+=3},pushUint32(e){this.assertPosition(this.position+3),this.dataView.setUint32(this.position,e),this.position+=4},readByte(){this.assertReadLimit(),this._touch();const e=this.inspectByte();return this.position++,e},readBytes(e,t){this.assertReadLimit(),this._touch();const n=this.inspectBytes(e);return this.position+=t??e,n},readUint8(){this.assertReadLimit(),this._touch();const e=this.inspectUint8();return this.position+=1,e},readUint16(){this.assertReadLimit(),this._touch();const e=this.inspectUint16();return this.position+=2,e},readUint24(){this.assertReadLimit(),this._touch();const e=this.inspectUint24();return this.position+=3,e},readUint32(){this.assertReadLimit(),this._touch();const e=this.inspectUint32();return this.position+=4,e},get remaining(){return this.bytes.length-this.position},setPosition(e){const t=this.position;return this.assertPosition(e),this.position=e,()=>this.position=t},_touch(){if(this.recursiveReadLimit===Number.POSITIVE_INFINITY)return;const e=this.getReadCount();this.positionReadCount.set(this.position,e+1),e>0&&this.recursiveReadCount++}};function hr(e,{recursiveReadLimit:t=8192}={}){const n=Object.create(fr);return n.bytes=e,n.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength),n.positionReadCount=new Map,n.recursiveReadLimit=t,n}function pr(e,t={}){void 0!==t.size&&Nt(e,{size:t.size});return St(Ot(e,t),t)}function mr(e,t={}){let n=e;if(void 0!==t.size&&(Nt(n,{size:t.size}),n=It(n)),n.length>1||n[0]>1)throw new Pt(n);return Boolean(n[0])}function gr(e,t={}){void 0!==t.size&&Nt(e,{size:t.size});return Tt(Ot(e,t),t)}function br(e,t){const n="string"==typeof t?Ut(t):t,r=hr(n);if(0===Le(n)&&e.length>0)throw new Ze;if(Le(t)&&Le(t)<32)throw new Ye({data:"string"==typeof t?t:Ot(t),params:e,size:Le(t)});let o=0;const s=[];for(let t=0;t<e.length;++t){const n=e[t];r.setPosition(o);const[a,i]=yr(r,n,{staticPosition:0});o+=i,s.push(a)}return s}function yr(e,t,{staticPosition:n}){const r=Hn(t.type);if(r){const[o,s]=r;return function(e,t,{length:n,staticPosition:r}){if(!n){const n=r+gr(e.readBytes(vr)),o=n+wr;e.setPosition(n);const s=gr(e.readBytes(wr)),a=xr(t);let i=0;const c=[];for(let n=0;n<s;++n){e.setPosition(o+(a?32*n:i));const[r,s]=yr(e,t,{staticPosition:o});i+=s,c.push(r)}return e.setPosition(r+32),[c,32]}if(xr(t)){const o=r+gr(e.readBytes(vr)),s=[];for(let r=0;r<n;++r){e.setPosition(o+32*r);const[n]=yr(e,t,{staticPosition:o});s.push(n)}return e.setPosition(r+32),[s,32]}let o=0;const s=[];for(let a=0;a<n;++a){const[n,a]=yr(e,t,{staticPosition:r+o});o+=a,s.push(n)}return[s,o]}(e,{...t,type:s},{length:o,staticPosition:n})}if("tuple"===t.type)return function(e,t,{staticPosition:n}){const r=0===t.components.length||t.components.some(({name:e})=>!e),o=r?[]:{};let s=0;if(xr(t)){const a=n+gr(e.readBytes(vr));for(let n=0;n<t.components.length;++n){const i=t.components[n];e.setPosition(a+s);const[c,u]=yr(e,i,{staticPosition:a});s+=u,o[r?n:i?.name]=c}return e.setPosition(n+32),[o,32]}for(let a=0;a<t.components.length;++a){const i=t.components[a],[c,u]=yr(e,i,{staticPosition:n});o[r?a:i?.name]=c,s+=u}return[o,s]}(e,t,{staticPosition:n});if("address"===t.type)return function(e){const t=e.readBytes(32);return[Bn(Ot(Un(t,-20))),32]}(e);if("bool"===t.type)return function(e){return[mr(e.readBytes(32),{size:32}),32]}(e);if(t.type.startsWith("bytes"))return function(e,t,{staticPosition:n}){const[r,o]=t.type.split("bytes");if(!o){const t=gr(e.readBytes(32));e.setPosition(n+t);const r=gr(e.readBytes(32));if(0===r)return e.setPosition(n+32),["0x",32];const o=e.readBytes(r);return e.setPosition(n+32),[Ot(o),32]}const s=Ot(e.readBytes(Number.parseInt(o,10),32));return[s,32]}(e,t,{staticPosition:n});if(t.type.startsWith("uint")||t.type.startsWith("int"))return function(e,t){const n=t.type.startsWith("int"),r=Number.parseInt(t.type.split("int")[1]||"256",10),o=e.readBytes(32);return[r>48?pr(o,{signed:n}):gr(o,{signed:n}),32]}(e,t);if("string"===t.type)return function(e,{staticPosition:t}){const n=gr(e.readBytes(32)),r=t+n;e.setPosition(r);const o=gr(e.readBytes(32));if(0===o)return e.setPosition(t+32),["",32];const s=e.readBytes(o,32),a=function(e,t={}){let n=e;return void 0!==t.size&&(Nt(n,{size:t.size}),n=It(n,{dir:"right"})),(new TextDecoder).decode(n)}(It(s));return e.setPosition(t+32),[a,32]}(e,{staticPosition:n});throw new ht(t.type,{docsPath:"/docs/contract/decodeAbiParameters"})}const wr=32,vr=32;function xr(e){const{type:t}=e;if("string"===t)return!0;if("bytes"===t)return!0;if(t.endsWith("[]"))return!0;if("tuple"===t)return e.components?.some(xr);const n=Hn(e.type);return!(!n||!xr({...e,type:n[1]}))}function Er(e){const{abi:t,data:n}=e,r=Fn(n,0,4);if("0x"===r)throw new Ze;const o=[...t||[],ir,cr].find(e=>"error"===e.type&&r===Yn(_e(e)));if(!o)throw new tt(r,{docsPath:"/docs/contract/decodeErrorResult"});return{abiItem:o,args:"inputs"in o&&o.inputs&&o.inputs.length>0?br(o.inputs,Fn(n,4)):void 0,errorName:o.name}}const Pr=(e,t,n)=>JSON.stringify(e,(e,t)=>"bigint"==typeof t?t.toString():t,n);function kr({abiItem:e,args:t,includeFunctionName:n=!0,includeName:r=!1}){if("name"in e&&"inputs"in e&&e.inputs)return`${n?e.name:""}(${e.inputs.map((e,n)=>`${r&&e.name?`${e.name}: `:""}${"object"==typeof t[n]?Pr(t[n]):t[n]}`).join(", ")})`}const Ar={gwei:9,wei:18},Ir={ether:-9,wei:9};function Nr(e,t){let n=e.toString();const r=n.startsWith("-");r&&(n=n.slice(1)),n=n.padStart(t,"0");let[o,s]=[n.slice(0,n.length-t),n.slice(n.length-t)];return s=s.replace(/(0+)$/,""),`${r?"-":""}${o||"0"}${s?`.${s}`:""}`}function Sr(e,t="wei"){return Nr(e,Ar[t])}function Tr(e,t="wei"){return Nr(e,Ir[t])}class $r extends qe{constructor({address:e}){super(`State for account "${e}" is set multiple times.`,{name:"AccountStateConflictError"})}}class Br extends qe{constructor(){super("state and stateDiff are set on the same account.",{name:"StateAssignmentConflictError"})}}function Cr(e){return e.reduce((e,{slot:t,value:n})=>`${e} ${t}: ${n}\n`,"")}function Or(e){const t=Object.entries(e).map(([e,t])=>void 0===t||!1===t?null:[e,t]).filter(Boolean),n=t.reduce((e,[t])=>Math.max(e,t.length),0);return t.map(([e,t])=>` ${`${e}:`.padEnd(n+1)} ${t}`).join("\n")}class Rr extends qe{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 zr extends qe{constructor({transaction:e}){super("Cannot infer a transaction type from provided transaction.",{metaMessages:["Provided Transaction:","{",Or(e),"}","","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 Mr extends qe{constructor({blockHash:e,blockNumber:t,blockTag:n,hash:r,index:o}){let s="Transaction";n&&void 0!==o&&(s=`Transaction at block time "${n}" at index "${o}"`),e&&void 0!==o&&(s=`Transaction at block hash "${e}" at index "${o}"`),t&&void 0!==o&&(s=`Transaction at block number "${t}" at index "${o}"`),r&&(s=`Transaction with hash "${r}"`),super(`${s} could not be found.`,{name:"TransactionNotFoundError"})}}class _r extends qe{constructor({hash:e}){super(`Transaction receipt with hash "${e}" could not be found. The Transaction may not be processed on a block yet.`,{name:"TransactionReceiptNotFoundError"})}}class Fr extends qe{constructor({hash:e}){super(`Timed out while waiting for transaction with hash "${e}" to be confirmed.`,{name:"WaitForTransactionReceiptTimeoutError"})}}class jr extends qe{constructor(e,{account:t,docsPath:n,chain:r,data:o,gas:s,gasPrice:a,maxFeePerGas:i,maxPriorityFeePerGas:c,nonce:u,to:l,value:d,stateOverride:f}){const h=t?rr(t):void 0;let p=Or({from:h?.address,to:l,value:void 0!==d&&`${Sr(d)} ${r?.nativeCurrency?.symbol||"ETH"}`,data:o,gas:s,gasPrice:void 0!==a&&`${Tr(a)} gwei`,maxFeePerGas:void 0!==i&&`${Tr(i)} gwei`,maxPriorityFeePerGas:void 0!==c&&`${Tr(c)} gwei`,nonce:u});f&&(p+=`\n${function(e){return e.reduce((e,{address:t,...n})=>{let r=`${e} ${t}:\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+=Cr(n.state)),n.stateDiff&&(r+=" stateDiff:\n",r+=Cr(n.stateDiff)),r}," State Override:\n").slice(0,-1)}(f)}`),super(e.shortMessage,{cause:e,docsPath:n,metaMessages:[...e.metaMessages?[...e.metaMessages," "]:[],"Raw Call Arguments:",p].filter(Boolean),name:"CallExecutionError"}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.cause=e}}class Lr extends qe{constructor(e,{abi:t,args:n,contractAddress:r,docsPath:o,functionName:s,sender:a}){const i=Zn({abi:t,args:n,name:s}),c=i?kr({abiItem:i,args:n,includeFunctionName:!1,includeName:!1}):void 0,u=Or({address:r&&r,function:i?_e(i,{includeName:!0}):void 0,args:c&&"()"!==c&&`${[...Array(s?.length??0).keys()].map(()=>" ").join("")}${c}`,sender:a});super(e.shortMessage||`An unknown error occurred while executing the contract function "${s}".`,{cause:e,docsPath:o,metaMessages:[...e.metaMessages?[...e.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=t,this.args=n,this.cause=e,this.contractAddress=r,this.functionName=s,this.sender=a}}class Ur extends qe{constructor({abi:e,data:t,functionName:n,message:r}){let o,s,a,i,c;if(t&&"0x"!==t)try{s=Er({abi:e,data:t});const{abiItem:n,errorName:r,args:o}=s;if("Error"===r)i=o[0];else if("Panic"===r){const[e]=o;i=ar[e]}else{const e=n?_e(n,{includeName:!0}):void 0,t=n&&o?kr({abiItem:n,args:o,includeFunctionName:!1,includeName:!1}):void 0;a=[e?`Error: ${e}`:"",t&&"()"!==t?` ${[...Array(r?.length??0).keys()].map(()=>" ").join("")}${t}`:""]}}catch(e){o=e}else r&&(i=r);o instanceof tt&&(c=o.signature,a=[`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(i&&"execution reverted"!==i||c?[`The contract function "${n}" reverted with the following ${c?"signature":"reason"}:`,i||c].join("\n"):`The contract function "${n}" reverted.`,{cause:o,metaMessages:a,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=t,this.reason=i,this.signature=c}}class Dr extends qe{constructor({functionName:e}){super(`The contract function "${e}" returned no data ("0x").`,{metaMessages:["This could be due to any of the following:",` - The contract does not have the function "${e}",`," - The parameters passed to the contract function may be invalid, or"," - The address is not a contract."],name:"ContractFunctionZeroDataError"})}}class Gr extends qe{constructor({factory:e}){super("Deployment for counterfactual contract call failed"+(e?` for factory "${e}".`:""),{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 qr extends qe{constructor({data:e,message:t}){super(t||"",{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=e}}class Vr extends qe{constructor({body:e,cause:t,details:n,headers:r,status:o,url:s}){super("HTTP request failed.",{cause:t,details:n,metaMessages:[o&&`Status: ${o}`,`URL: ${s}`,e&&`Request body: ${Pr(e)}`].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=e,this.headers=r,this.status=o,this.url=s}}class Wr extends qe{constructor({body:e,error:t,url:n}){super("RPC Request failed.",{cause:t,details:t.message,metaMessages:[`URL: ${n}`,`Request body: ${Pr(e)}`],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=t.code,this.data=t.data}}class Hr extends qe{constructor({body:e,url:t}){super("The request took too long to respond.",{details:"The request timed out.",metaMessages:[`URL: ${t}`,`Request body: ${Pr(e)}`],name:"TimeoutError"})}}class Yr extends qe{constructor(e,{code:t,docsPath:n,metaMessages:r,name:o,shortMessage:s}){super(s,{cause:e,docsPath:n,metaMessages:r||e?.metaMessages,name:o||"RpcError"}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name=o||e.name,this.code=e instanceof Wr?e.code:t??-1}}class Zr extends Yr{constructor(e,t){super(e,t),Object.defineProperty(this,"data",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.data=t.data}}class Kr extends Yr{constructor(e){super(e,{code:Kr.code,name:"ParseRpcError",shortMessage:"Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."})}}Object.defineProperty(Kr,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32700});class Jr extends Yr{constructor(e){super(e,{code:Jr.code,name:"InvalidRequestRpcError",shortMessage:"JSON is not a valid request object."})}}Object.defineProperty(Jr,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32600});class Qr extends Yr{constructor(e,{method:t}={}){super(e,{code:Qr.code,name:"MethodNotFoundRpcError",shortMessage:`The method${t?` "${t}"`:""} does not exist / is not available.`})}}Object.defineProperty(Qr,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32601});class Xr extends Yr{constructor(e){super(e,{code:Xr.code,name:"InvalidParamsRpcError",shortMessage:["Invalid parameters were provided to the RPC method.","Double check you have provided the correct parameters."].join("\n")})}}Object.defineProperty(Xr,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32602});class eo extends Yr{constructor(e){super(e,{code:eo.code,name:"InternalRpcError",shortMessage:"An internal error was received."})}}Object.defineProperty(eo,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32603});class to extends Yr{constructor(e){super(e,{code:to.code,name:"InvalidInputRpcError",shortMessage:["Missing or invalid parameters.","Double check you have provided the correct parameters."].join("\n")})}}Object.defineProperty(to,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32e3});class no extends Yr{constructor(e){super(e,{code:no.code,name:"ResourceNotFoundRpcError",shortMessage:"Requested resource not found."}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"ResourceNotFoundRpcError"})}}Object.defineProperty(no,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32001});class ro extends Yr{constructor(e){super(e,{code:ro.code,name:"ResourceUnavailableRpcError",shortMessage:"Requested resource not available."})}}Object.defineProperty(ro,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32002});class oo extends Yr{constructor(e){super(e,{code:oo.code,name:"TransactionRejectedRpcError",shortMessage:"Transaction creation failed."})}}Object.defineProperty(oo,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32003});class so extends Yr{constructor(e,{method:t}={}){super(e,{code:so.code,name:"MethodNotSupportedRpcError",shortMessage:`Method${t?` "${t}"`:""} is not supported.`})}}Object.defineProperty(so,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32004});class ao extends Yr{constructor(e){super(e,{code:ao.code,name:"LimitExceededRpcError",shortMessage:"Request exceeds defined limit."})}}Object.defineProperty(ao,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32005});class io extends Yr{constructor(e){super(e,{code:io.code,name:"JsonRpcVersionUnsupportedError",shortMessage:"Version of JSON-RPC protocol is not supported."})}}Object.defineProperty(io,"code",{enumerable:!0,configurable:!0,writable:!0,value:-32006});class co extends Zr{constructor(e){super(e,{code:co.code,name:"UserRejectedRequestError",shortMessage:"User rejected the request."})}}Object.defineProperty(co,"code",{enumerable:!0,configurable:!0,writable:!0,value:4001});class uo extends Zr{constructor(e){super(e,{code:uo.code,name:"UnauthorizedProviderError",shortMessage:"The requested method and/or account has not been authorized by the user."})}}Object.defineProperty(uo,"code",{enumerable:!0,configurable:!0,writable:!0,value:4100});class lo extends Zr{constructor(e,{method:t}={}){super(e,{code:lo.code,name:"UnsupportedProviderMethodError",shortMessage:`The Provider does not support the requested method${t?` " ${t}"`:""}.`})}}Object.defineProperty(lo,"code",{enumerable:!0,configurable:!0,writable:!0,value:4200});class fo extends Zr{constructor(e){super(e,{code:fo.code,name:"ProviderDisconnectedError",shortMessage:"The Provider is disconnected from all chains."})}}Object.defineProperty(fo,"code",{enumerable:!0,configurable:!0,writable:!0,value:4900});class ho extends Zr{constructor(e){super(e,{code:ho.code,name:"ChainDisconnectedError",shortMessage:"The Provider is not connected to the requested chain."})}}Object.defineProperty(ho,"code",{enumerable:!0,configurable:!0,writable:!0,value:4901});class po extends Zr{constructor(e){super(e,{code:po.code,name:"SwitchChainError",shortMessage:"An error occurred when attempting to switch chain."})}}Object.defineProperty(po,"code",{enumerable:!0,configurable:!0,writable:!0,value:4902});class mo extends Zr{constructor(e){super(e,{code:mo.code,name:"UnsupportedNonOptionalCapabilityError",shortMessage:"This Wallet does not support a capability that was not marked as optional."})}}Object.defineProperty(mo,"code",{enumerable:!0,configurable:!0,writable:!0,value:5700});class go extends Zr{constructor(e){super(e,{code:go.code,name:"UnsupportedChainIdError",shortMessage:"This Wallet does not support the requested chain ID."})}}Object.defineProperty(go,"code",{enumerable:!0,configurable:!0,writable:!0,value:5710});class bo extends Zr{constructor(e){super(e,{code:bo.code,name:"DuplicateIdError",shortMessage:"There is already a bundle submitted with this ID."})}}Object.defineProperty(bo,"code",{enumerable:!0,configurable:!0,writable:!0,value:5720});class yo extends Zr{constructor(e){super(e,{code:yo.code,name:"UnknownBundleIdError",shortMessage:"This bundle id is unknown / has not been submitted"})}}Object.defineProperty(yo,"code",{enumerable:!0,configurable:!0,writable:!0,value:5730});class wo extends Zr{constructor(e){super(e,{code:wo.code,name:"BundleTooLargeError",shortMessage:"The call bundle is too large for the Wallet to process."})}}Object.defineProperty(wo,"code",{enumerable:!0,configurable:!0,writable:!0,value:5740});class vo extends Zr{constructor(e){super(e,{code:vo.code,name:"AtomicReadyWalletRejectedUpgradeError",shortMessage:"The Wallet can support atomicity after an upgrade, but the user rejected the upgrade."})}}Object.defineProperty(vo,"code",{enumerable:!0,configurable:!0,writable:!0,value:5750});class xo extends Zr{constructor(e){super(e,{code:xo.code,name:"AtomicityNotSupportedError",shortMessage:"The wallet does not support atomic execution but the request requires it."})}}Object.defineProperty(xo,"code",{enumerable:!0,configurable:!0,writable:!0,value:5760});class Eo extends Yr{constructor(e){super(e,{name:"UnknownRpcError",shortMessage:"An unknown RPC error occurred."})}}const Po=3;function ko(e,{abi:t,address:n,args:r,docsPath:o,functionName:s,sender:a}){const i=e instanceof qr?e:e instanceof qe?e.walk(e=>"data"in e)||e.walk():{},{code:c,data:u,details:l,message:d,shortMessage:f}=i,h=e instanceof Ze?new Dr({functionName:s}):[Po,eo.code].includes(c)&&(u||l||d||f)?new Ur({abi:t,data:"object"==typeof u?u.data:u,functionName:s,message:i instanceof Wr?l:f??d}):e;return new Lr(h,{abi:t,args:r,contractAddress:n,docsPath:o,functionName:s,sender:a})}function Ao(e){if(0===e||1===e)return e;if(27===e)return 0;if(28===e)return 1;throw new Error("Invalid yParityOrV value")}async function Io({hash:e,signature:t}){return n=await async function({hash:e,signature:t}){const n=je(e)?e:Bt(e),{secp256k1:r}=await Promise.resolve().then(function(){return Sd}),o=(()=>{if("object"==typeof t&&"r"in t&&"s"in t){const{r:e,s:n,v:o,yParity:s}=t,a=Ao(Number(s??o));return new r.Signature(St(e),St(n)).addRecoveryBit(a)}const e=je(t)?t:Bt(t);if(65!==Le(e))throw new Error("invalid signature length");const n=Ao(Tt(`0x${e.slice(130)}`));return r.Signature.fromCompact(e.substring(2,130)).addRecoveryBit(n)})();return`0x${o.recoverPublicKey(n.substring(2)).toHex(!1)}`}({hash:e,signature:t}),Bn(`0x${Pn(`0x${n.substring(4)}`).substring(26)}`);var n}function No(e,t="hex"){const n=So(e),r=hr(new Uint8Array(n.length));return n.encode(r),"hex"===t?Ot(r.bytes):r.bytes}function So(e){return Array.isArray(e)?function(e){const t=e.reduce((e,t)=>e+t.length,0),n=To(t),r=t<=55?1+t:1+n+t;return{length:r,encode(r){t<=55?r.pushByte(192+t):(r.pushByte(247+n),1===n?r.pushUint8(t):2===n?r.pushUint16(t):3===n?r.pushUint24(t):r.pushUint32(t));for(const{encode:t}of e)t(r)}}}(e.map(e=>So(e))):function(e){const t="string"==typeof e?Ut(e):e,n=To(t.length),r=1===t.length&&t[0]<128?1:t.length<=55?1+t.length:1+n+t.length;return{length:r,encode(e){1===t.length&&t[0]<128?e.pushBytes(t):t.length<=55?(e.pushByte(128+t.length),e.pushBytes(t)):(e.pushByte(183+n),1===n?e.pushUint8(t.length):2===n?e.pushUint16(t.length):3===n?e.pushUint24(t.length):e.pushUint32(t.length),e.pushBytes(t))}}}(e)}function To(e){if(e<256)return 1;if(e<65536)return 2;if(e<2**24)return 3;if(e<2**32)return 4;throw new qe("Length is too large.")}function $o(e){const{chainId:t,nonce:n,to:r}=e,o=e.contractAddress??e.address,s=Pn(_n(["0x05",No([t?Rt(t):"0x",o,n?Rt(n):"0x"])]));return"bytes"===r?Ut(s):s}async function Bo(e){const{authorization:t,signature:n}=e;return Io({hash:$o(t),signature:n??t})}class Co extends qe{constructor(e,{account:t,docsPath:n,chain:r,data:o,gas:s,gasPrice:a,maxFeePerGas:i,maxPriorityFeePerGas:c,nonce:u,to:l,value:d}){const f=Or({from:t?.address,to:l,value:void 0!==d&&`${Sr(d)} ${r?.nativeCurrency?.symbol||"ETH"}`,data:o,gas:s,gasPrice:void 0!==a&&`${Tr(a)} gwei`,maxFeePerGas:void 0!==i&&`${Tr(i)} gwei`,maxPriorityFeePerGas:void 0!==c&&`${Tr(c)} gwei`,nonce:u});super(e.shortMessage,{cause:e,docsPath:n,metaMessages:[...e.metaMessages?[...e.metaMessages," "]:[],"Estimate Gas Arguments:",f].filter(Boolean),name:"EstimateGasExecutionError"}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.cause=e}}class Oo extends qe{constructor({cause:e,message:t}={}){const n=t?.replace("execution reverted: ","")?.replace("execution reverted","");super(`Execution reverted ${n?`with reason: ${n}`:"for an unknown reason"}.`,{cause:e,name:"ExecutionRevertedError"})}}Object.defineProperty(Oo,"code",{enumerable:!0,configurable:!0,writable:!0,value:3}),Object.defineProperty(Oo,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/execution reverted/});class Ro extends qe{constructor({cause:e,maxFeePerGas:t}={}){super(`The fee cap (\`maxFeePerGas\`${t?` = ${Tr(t)} gwei`:""}) cannot be higher than the maximum allowed value (2^256-1).`,{cause:e,name:"FeeCapTooHighError"})}}Object.defineProperty(Ro,"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 zo extends qe{constructor({cause:e,maxFeePerGas:t}={}){super(`The fee cap (\`maxFeePerGas\`${t?` = ${Tr(t)}`:""} gwei) cannot be lower than the block base fee.`,{cause:e,name:"FeeCapTooLowError"})}}Object.defineProperty(zo,"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 Mo extends qe{constructor({cause:e,nonce:t}={}){super(`Nonce provided for the transaction ${t?`(${t}) `:""}is higher than the next one expected.`,{cause:e,name:"NonceTooHighError"})}}Object.defineProperty(Mo,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too high/});class _o extends qe{constructor({cause:e,nonce:t}={}){super([`Nonce provided for the transaction ${t?`(${t}) `:""}is lower than the current nonce of the account.`,"Try increasing the nonce or find the latest nonce with `getTransactionCount`."].join("\n"),{cause:e,name:"NonceTooLowError"})}}Object.defineProperty(_o,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too low|transaction already imported|already known/});class Fo extends qe{constructor({cause:e,nonce:t}={}){super(`Nonce provided for the transaction ${t?`(${t}) `:""}exceeds the maximum allowed nonce.`,{cause:e,name:"NonceMaxValueError"})}}Object.defineProperty(Fo,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce has max value/});class jo extends qe{constructor({cause:e}={}){super(["The total cost (gas * gas fee + value) of executing this transaction exceeds the balance of the account."].join("\n"),{cause:e,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(jo,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/insufficient funds|exceeds transaction sender account balance/});class Lo extends qe{constructor({cause:e,gas:t}={}){super(`The amount of gas ${t?`(${t}) `:""}provided for the transaction exceeds the limit allowed for the block.`,{cause:e,name:"IntrinsicGasTooHighError"})}}Object.defineProperty(Lo,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too high|gas limit reached/});class Uo extends qe{constructor({cause:e,gas:t}={}){super(`The amount of gas ${t?`(${t}) `:""}provided for the transaction is too low.`,{cause:e,name:"IntrinsicGasTooLowError"})}}Object.defineProperty(Uo,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too low/});class Do extends qe{constructor({cause:e}){super("The transaction type is not supported for this chain.",{cause:e,name:"TransactionTypeNotSupportedError"})}}Object.defineProperty(Do,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/transaction type not valid/});class Go extends qe{constructor({cause:e,maxPriorityFeePerGas:t,maxFeePerGas:n}={}){super([`The provided tip (\`maxPriorityFeePerGas\`${t?` = ${Tr(t)} gwei`:""}) cannot be higher than the fee cap (\`maxFeePerGas\`${n?` = ${Tr(n)} gwei`:""}).`].join("\n"),{cause:e,name:"TipAboveFeeCapError"})}}Object.defineProperty(Go,"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 qo extends qe{constructor({cause:e}){super(`An error occurred while executing: ${e?.shortMessage}`,{cause:e,name:"UnknownNodeError"})}}function Vo(e,t){const n=(e.details||"").toLowerCase(),r=e instanceof qe?e.walk(e=>e?.code===Oo.code):e;return r instanceof qe?new Oo({cause:e,message:r.details}):Oo.nodeMessage.test(n)?new Oo({cause:e,message:e.details}):Ro.nodeMessage.test(n)?new Ro({cause:e,maxFeePerGas:t?.maxFeePerGas}):zo.nodeMessage.test(n)?new zo({cause:e,maxFeePerGas:t?.maxFeePerGas}):Mo.nodeMessage.test(n)?new Mo({cause:e,nonce:t?.nonce}):_o.nodeMessage.test(n)?new _o({cause:e,nonce:t?.nonce}):Fo.nodeMessage.test(n)?new Fo({cause:e,nonce:t?.nonce}):jo.nodeMessage.test(n)?new jo({cause:e}):Lo.nodeMessage.test(n)?new Lo({cause:e,gas:t?.gas}):Uo.nodeMessage.test(n)?new Uo({cause:e,gas:t?.gas}):Do.nodeMessage.test(n)?new Do({cause:e}):Go.nodeMessage.test(n)?new Go({cause:e,maxFeePerGas:t?.maxFeePerGas,maxPriorityFeePerGas:t?.maxPriorityFeePerGas}):new qo({cause:e})}function Wo(e,{format:t}){if(!t)return{};const n={};return function t(r){const o=Object.keys(r);for(const s of o)s in e&&(n[s]=e[s]),r[s]&&"object"==typeof r[s]&&!Array.isArray(r[s])&&t(r[s])}(t(e||{})),n}const Ho={legacy:"0x0",eip2930:"0x1",eip1559:"0x2",eip4844:"0x3",eip7702:"0x4"};function Yo(e){const t={};return void 0!==e.authorizationList&&(t.authorizationList=e.authorizationList.map(e=>({address:e.address,r:e.r?Rt(BigInt(e.r)):e.r,s:e.s?Rt(BigInt(e.s)):e.s,chainId:Rt(e.chainId),nonce:Rt(e.nonce),...void 0!==e.yParity?{yParity:Rt(e.yParity)}:{},...void 0!==e.v&&void 0===e.yParity?{v:Rt(e.v)}:{}}))),void 0!==e.accessList&&(t.accessList=e.accessList),void 0!==e.blobVersionedHashes&&(t.blobVersionedHashes=e.blobVersionedHashes),void 0!==e.blobs&&("string"!=typeof e.blobs[0]?t.blobs=e.blobs.map(e=>Ot(e)):t.blobs=e.blobs),void 0!==e.data&&(t.data=e.data),void 0!==e.from&&(t.from=e.from),void 0!==e.gas&&(t.gas=Rt(e.gas)),void 0!==e.gasPrice&&(t.gasPrice=Rt(e.gasPrice)),void 0!==e.maxFeePerBlobGas&&(t.maxFeePerBlobGas=Rt(e.maxFeePerBlobGas)),void 0!==e.maxFeePerGas&&(t.maxFeePerGas=Rt(e.maxFeePerGas)),void 0!==e.maxPriorityFeePerGas&&(t.maxPriorityFeePerGas=Rt(e.maxPriorityFeePerGas)),void 0!==e.nonce&&(t.nonce=Rt(e.nonce)),void 0!==e.to&&(t.to=e.to),void 0!==e.type&&(t.type=Ho[e.type]),void 0!==e.value&&(t.value=Rt(e.value)),t}function Zo(e){if(e&&0!==e.length)return e.reduce((e,{slot:t,value:n})=>{if(66!==t.length)throw new wt({size:t.length,targetSize:66,type:"hex"});if(66!==n.length)throw new wt({size:n.length,targetSize:66,type:"hex"});return e[t]=n,e},{})}function Ko(e){const{balance:t,nonce:n,state:r,stateDiff:o,code:s}=e,a={};if(void 0!==s&&(a.code=s),void 0!==t&&(a.balance=Rt(t)),void 0!==n&&(a.nonce=Rt(n)),void 0!==r&&(a.state=Zo(r)),void 0!==o){if(a.state)throw new Br;a.stateDiff=Zo(o)}return a}function Jo(e){if(!e)return;const t={};for(const{address:n,...r}of e){if(!zn(n,{strict:!1}))throw new Sn({address:n});if(t[n])throw new $r({address:n});t[n]=Ko(r)}return t}const Qo=2n**256n-1n;function Xo(e){const{account:t,gasPrice:n,maxFeePerGas:r,maxPriorityFeePerGas:o,to:s}=e,a=t?rr(t):void 0;if(a&&!zn(a.address))throw new Sn({address:a.address});if(s&&!zn(s))throw new Sn({address:s});if(void 0!==n&&(void 0!==r||void 0!==o))throw new Rr;if(r&&r>Qo)throw new Ro({maxFeePerGas:r});if(o&&r&&o>r)throw new Go({maxFeePerGas:r,maxPriorityFeePerGas:o})}class es extends qe{constructor(){super("`baseFeeMultiplier` must be greater than 1.",{name:"BaseFeeScalarError"})}}class ts extends qe{constructor(){super("Chain does not support EIP-1559 fees.",{name:"Eip1559FeesNotSupportedError"})}}class ns extends qe{constructor({maxPriorityFeePerGas:e}){super(`\`maxFeePerGas\` cannot be less than the \`maxPriorityFeePerGas\` (${Tr(e)} gwei).`,{name:"MaxFeePerGasTooLowError"})}}class rs extends qe{constructor({blockHash:e,blockNumber:t}){let n="Block";e&&(n=`Block at hash "${e}"`),t&&(n=`Block at number "${t}"`),super(`${n} could not be found.`,{name:"BlockNotFoundError"})}}const os={"0x0":"legacy","0x1":"eip2930","0x2":"eip1559","0x3":"eip4844","0x4":"eip7702"};function ss(e){const t={...e,blockHash:e.blockHash?e.blockHash:null,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,chainId:e.chainId?Tt(e.chainId):void 0,gas:e.gas?BigInt(e.gas):void 0,gasPrice:e.gasPrice?BigInt(e.gasPrice):void 0,maxFeePerBlobGas:e.maxFeePerBlobGas?BigInt(e.maxFeePerBlobGas):void 0,maxFeePerGas:e.maxFeePerGas?BigInt(e.maxFeePerGas):void 0,maxPriorityFeePerGas:e.maxPriorityFeePerGas?BigInt(e.maxPriorityFeePerGas):void 0,nonce:e.nonce?Tt(e.nonce):void 0,to:e.to?e.to:null,transactionIndex:e.transactionIndex?Number(e.transactionIndex):null,type:e.type?os[e.type]:void 0,typeHex:e.type?e.type:void 0,value:e.value?BigInt(e.value):void 0,v:e.v?BigInt(e.v):void 0};return e.authorizationList&&(t.authorizationList=e.authorizationList.map(e=>({address:e.address,chainId:Number(e.chainId),nonce:Number(e.nonce),r:e.r,s:e.s,yParity:Number(e.yParity)}))),t.yParity=(()=>{if(e.yParity)return Number(e.yParity);if("bigint"==typeof t.v){if(0n===t.v||27n===t.v)return 0;if(1n===t.v||28n===t.v)return 1;if(t.v>=35n)return t.v%2n==0n?1:0}})(),"legacy"===t.type&&(delete t.accessList,delete t.maxFeePerBlobGas,delete t.maxFeePerGas,delete t.maxPriorityFeePerGas,delete t.yParity),"eip2930"===t.type&&(delete t.maxFeePerBlobGas,delete t.maxFeePerGas,delete t.maxPriorityFeePerGas),"eip1559"===t.type&&delete t.maxFeePerBlobGas,t}function as(e){const t=(e.transactions??[]).map(e=>"string"==typeof e?e:ss(e));return{...e,baseFeePerGas:e.baseFeePerGas?BigInt(e.baseFeePerGas):null,blobGasUsed:e.blobGasUsed?BigInt(e.blobGasUsed):void 0,difficulty:e.difficulty?BigInt(e.difficulty):void 0,excessBlobGas:e.excessBlobGas?BigInt(e.excessBlobGas):void 0,gasLimit:e.gasLimit?BigInt(e.gasLimit):void 0,gasUsed:e.gasUsed?BigInt(e.gasUsed):void 0,hash:e.hash?e.hash:null,logsBloom:e.logsBloom?e.logsBloom:null,nonce:e.nonce?e.nonce:null,number:e.number?BigInt(e.number):null,size:e.size?BigInt(e.size):void 0,timestamp:e.timestamp?BigInt(e.timestamp):void 0,transactions:t,totalDifficulty:e.totalDifficulty?BigInt(e.totalDifficulty):null}}async function is(e,{blockHash:t,blockNumber:n,blockTag:r=e.experimental_blockTag??"latest",includeTransactions:o}={}){const s=o??!1,a=void 0!==n?Rt(n):void 0;let i=null;if(i=t?await e.request({method:"eth_getBlockByHash",params:[t,s]},{dedupe:!0}):await e.request({method:"eth_getBlockByNumber",params:[a||r,s]},{dedupe:Boolean(a)}),!i)throw new rs({blockHash:t,blockNumber:n});return(e.chain?.formatters?.block?.format||as)(i)}async function cs(e){const t=await e.request({method:"eth_gasPrice"});return BigInt(t)}async function us(e,t){const{block:n,chain:r=e.chain,request:o}=t||{};try{const t=r?.fees?.maxPriorityFeePerGas??r?.fees?.defaultPriorityFee;if("function"==typeof t){const r=n||await Me(e,is,"getBlock")({}),s=await t({block:r,client:e,request:o});if(null===s)throw new Error;return s}if(void 0!==t)return t;return St(await e.request({method:"eth_maxPriorityFeePerGas"}))}catch{const[t,r]=await Promise.all([n?Promise.resolve(n):Me(e,is,"getBlock")({}),Me(e,cs,"getGasPrice")({})]);if("bigint"!=typeof t.baseFeePerGas)throw new ts;const o=r-t.baseFeePerGas;return o<0n?0n:o}}async function ls(e,t){const{block:n,chain:r=e.chain,request:o,type:s="eip1559"}=t||{},a=await(async()=>"function"==typeof r?.fees?.baseFeeMultiplier?r.fees.baseFeeMultiplier({block:n,client:e,request:o}):r?.fees?.baseFeeMultiplier??1.2)();if(a<1)throw new es;const i=10**(a.toString().split(".")[1]?.length??0),c=e=>e*BigInt(Math.ceil(a*i))/BigInt(i),u=n||await Me(e,is,"getBlock")({});if("function"==typeof r?.fees?.estimateFeesPerGas){const t=await r.fees.estimateFeesPerGas({block:n,client:e,multiply:c,request:o,type:s});if(null!==t)return t}if("eip1559"===s){if("bigint"!=typeof u.baseFeePerGas)throw new ts;const t="bigint"==typeof o?.maxPriorityFeePerGas?o.maxPriorityFeePerGas:await us(e,{block:u,chain:r,request:o}),n=c(u.baseFeePerGas);return{maxFeePerGas:o?.maxFeePerGas??n+t,maxPriorityFeePerGas:t}}return{gasPrice:o?.gasPrice??c(await Me(e,cs,"getGasPrice")({}))}}async function ds(e,{address:t,blockTag:n="latest",blockNumber:r}){return Tt(await e.request({method:"eth_getTransactionCount",params:[t,"bigint"==typeof r?Rt(r):n]},{dedupe:Boolean(r)}))}function fs(e){const{kzg:t}=e,n=e.to??("string"==typeof e.blobs[0]?"hex":"bytes"),r="string"==typeof e.blobs[0]?e.blobs.map(e=>Ut(e)):e.blobs,o=[];for(const e of r)o.push(Uint8Array.from(t.blobToKzgCommitment(e)));return"bytes"===n?o:o.map(e=>Ot(e))}function hs(e){const{kzg:t}=e,n=e.to??("string"==typeof e.blobs[0]?"hex":"bytes"),r="string"==typeof e.blobs[0]?e.blobs.map(e=>Ut(e)):e.blobs,o="string"==typeof e.commitments[0]?e.commitments.map(e=>Ut(e)):e.commitments,s=[];for(let e=0;e<r.length;e++){const n=r[e],a=o[e];s.push(Uint8Array.from(t.computeBlobKzgProof(n,a)))}return"bytes"===n?s:s.map(e=>Ot(e))}function ps(e,t,n){return e&t^~e&n}function ms(e,t,n){return e&t^e&n^t&n}class gs extends rn{constructor(e,t,n,r){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.buffer=new Uint8Array(e),this.view=Qt(this.buffer)}update(e){Zt(this),Yt(e=nn(e));const{view:t,buffer:n,blockLen:r}=this,o=e.length;for(let s=0;s<o;){const a=Math.min(r-this.pos,o-s);if(a===r){const t=Qt(e);for(;r<=o-s;s+=r)this.process(t,s);continue}n.set(e.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===r&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Zt(this),Kt(e,this),this.finished=!0;const{buffer:t,view:n,blockLen:r,isLE:o}=this;let{pos:s}=this;t[s++]=128,Jt(this.buffer.subarray(s)),this.padOffset>r-s&&(this.process(n,0),s=0);for(let e=s;e<r;e++)t[e]=0;!function(e,t,n,r){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,n,r);const o=BigInt(32),s=BigInt(4294967295),a=Number(n>>o&s),i=Number(n&s),c=r?4:0,u=r?0:4;e.setUint32(t+c,a,r),e.setUint32(t+u,i,r)}(n,r-8,BigInt(8*this.length),o),this.process(n,0);const a=Qt(e),i=this.outputLen;if(i%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=i/4,u=this.get();if(c>u.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e<c;e++)a.setUint32(4*e,u[e],o)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:n,length:r,finished:o,destroyed:s,pos:a}=this;return e.destroyed=s,e.finished=o,e.length=r,e.pos=a,r%t&&e.buffer.set(n),e}clone(){return this._cloneInto()}}const bs=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),ys=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]),ws=new Uint32Array(64);class vs extends gs{constructor(e=32){super(64,e,8,!1),this.A=0|bs[0],this.B=0|bs[1],this.C=0|bs[2],this.D=0|bs[3],this.E=0|bs[4],this.F=0|bs[5],this.G=0|bs[6],this.H=0|bs[7]}get(){const{A:e,B:t,C:n,D:r,E:o,F:s,G:a,H:i}=this;return[e,t,n,r,o,s,a,i]}set(e,t,n,r,o,s,a,i){this.A=0|e,this.B=0|t,this.C=0|n,this.D=0|r,this.E=0|o,this.F=0|s,this.G=0|a,this.H=0|i}process(e,t){for(let n=0;n<16;n++,t+=4)ws[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=ws[e-15],n=ws[e-2],r=Xt(t,7)^Xt(t,18)^t>>>3,o=Xt(n,17)^Xt(n,19)^n>>>10;ws[e]=o+ws[e-7]+r+ws[e-16]|0}let{A:n,B:r,C:o,D:s,E:a,F:i,G:c,H:u}=this;for(let e=0;e<64;e++){const t=u+(Xt(a,6)^Xt(a,11)^Xt(a,25))+ps(a,i,c)+ys[e]+ws[e]|0,l=(Xt(n,2)^Xt(n,13)^Xt(n,22))+ms(n,r,o)|0;u=c,c=i,i=a,a=s+t|0,s=o,o=r,r=n,n=t+l|0}n=n+this.A|0,r=r+this.B|0,o=o+this.C|0,s=s+this.D|0,a=a+this.E|0,i=i+this.F|0,c=c+this.G|0,u=u+this.H|0,this.set(n,r,o,s,a,i,c,u)}roundClean(){Jt(ws)}destroy(){this.set(0,0,0,0,0,0,0,0),Jt(this.buffer)}}const xs=on(()=>new vs),Es=xs;function Ps(e){const{commitment:t,version:n=1}=e,r=e.to??("string"==typeof t?"hex":"bytes"),o=Es(je(s=t,{strict:!1})?Ft(s):s);var s;return o.set([n],0),"bytes"===r?o:Ot(o)}const ks=4096,As=131072,Is=761855;class Ns extends qe{constructor({maxSize:e,size:t}){super("Blob size is too large.",{metaMessages:[`Max: ${e} bytes`,`Given: ${t} bytes`],name:"BlobSizeTooLargeError"})}}class Ss extends qe{constructor(){super("Blob data must not be empty.",{name:"EmptyBlobError"})}}function Ts(e){const{data:t,kzg:n,to:r}=e,o=e.blobs??function(e){const t="string"==typeof e.data?Ut(e.data):e.data,n=Le(t);if(!n)throw new Ss;if(n>Is)throw new Ns({maxSize:Is,size:n});const r=[];let o=!0,s=0;for(;o;){const e=hr(new Uint8Array(As));let n=0;for(;n<ks;){const r=t.slice(s,s+31);if(e.pushByte(0),e.pushBytes(r),r.length<31){e.pushByte(128),o=!1;break}n++,s+=31}r.push(e)}return r.map(e=>Ot(e.bytes))}({data:t}),s=e.commitments??fs({blobs:o,kzg:n,to:r}),a=e.proofs??hs({blobs:o,commitments:s,kzg:n,to:r}),i=[];for(let e=0;e<o.length;e++)i.push({blob:o[e],commitment:s[e],proof:a[e]});return i}async function $s(e){return Tt(await e.request({method:"eth_chainId"},{dedupe:!0}))}const Bs=["blobVersionedHashes","chainId","fees","gas","nonce","type"],Cs=new Map;async function Os(e,t){const{account:n=e.account,blobs:r,chain:o,gas:s,kzg:a,nonce:i,nonceManager:c,parameters:u=Bs,type:l}=t,d=n?rr(n):n,f={...t,...d?{from:d?.address}:{}};let h,p;async function m(){return h||(h=await Me(e,is,"getBlock")({blockTag:"latest"}),h)}async function g(){if(p)return p;if(o)return o.id;if(void 0!==t.chainId)return t.chainId;const n=await Me(e,$s,"getChainId")({});return p=n,p}if(u.includes("nonce")&&void 0===i&&d)if(c){const t=await g();f.nonce=await c.consume({address:d.address,chainId:t,client:e})}else f.nonce=await Me(e,ds,"getTransactionCount")({address:d.address,blockTag:"pending"});if((u.includes("blobVersionedHashes")||u.includes("sidecars"))&&r&&a){const e=fs({blobs:r,kzg:a});if(u.includes("blobVersionedHashes")){const t=function(e){const{commitments:t,version:n}=e,r=e.to,o=[];for(const e of t)o.push(Ps({commitment:e,to:r,version:n}));return o}({commitments:e,to:"hex"});f.blobVersionedHashes=t}if(u.includes("sidecars")){const t=Ts({blobs:r,commitments:e,proofs:hs({blobs:r,commitments:e,kzg:a}),to:"hex"});f.sidecars=t}}if(u.includes("chainId")&&(f.chainId=await g()),(u.includes("fees")||u.includes("type"))&&void 0===l)try{f.type=function(e){if(e.type)return e.type;if(void 0!==e.authorizationList)return"eip7702";if(void 0!==e.blobs||void 0!==e.blobVersionedHashes||void 0!==e.maxFeePerBlobGas||void 0!==e.sidecars)return"eip4844";if(void 0!==e.maxFeePerGas||void 0!==e.maxPriorityFeePerGas)return"eip1559";if(void 0!==e.gasPrice)return void 0!==e.accessList?"eip2930":"legacy";throw new zr({transaction:e})}(f)}catch{let t=Cs.get(e.uid);if(void 0===t){const n=await m();t="bigint"==typeof n?.baseFeePerGas,Cs.set(e.uid,t)}f.type=t?"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 m(),{maxFeePerGas:r,maxPriorityFeePerGas:s}=await ls(e,{block:n,chain:o,request:f});if(void 0===t.maxPriorityFeePerGas&&t.maxFeePerGas&&t.maxFeePerGas<s)throw new ns({maxPriorityFeePerGas:s});f.maxPriorityFeePerGas=s,f.maxFeePerGas=r}}else{if(void 0!==t.maxFeePerGas||void 0!==t.maxPriorityFeePerGas)throw new ts;if(void 0===t.gasPrice){const t=await m(),{gasPrice:n}=await ls(e,{block:t,chain:o,request:f,type:"legacy"});f.gasPrice=n}}return u.includes("gas")&&void 0===s&&(f.gas=await Me(e,Rs,"estimateGas")({...f,account:d?{address:d.address,type:"json-rpc"}:d})),Xo(f),delete f.parameters,f}async function Rs(e,t){const{account:n=e.account}=t,r=n?rr(n):void 0;try{const{accessList:n,authorizationList:o,blobs:s,blobVersionedHashes:a,blockNumber:i,blockTag:c,data:u,gas:l,gasPrice:d,maxFeePerBlobGas:f,maxFeePerGas:h,maxPriorityFeePerGas:p,nonce:m,value:g,stateOverride:b,...y}=await Os(e,{...t,parameters:"local"===r?.type?void 0:["blobVersionedHashes"]}),w=("bigint"==typeof i?Rt(i):void 0)||c,v=Jo(b),x=await(async()=>y.to?y.to:o&&o.length>0?await Bo({authorization:o[0]}).catch(()=>{throw new qe("`to` is required. Could not infer from `authorizationList`")}):void 0)();Xo(t);const E=e.chain?.formatters?.transactionRequest?.format,P=(E||Yo)({...Wo(y,{format:E}),from:r?.address,accessList:n,authorizationList:o,blobs:s,blobVersionedHashes:a,data:u,gas:l,gasPrice:d,maxFeePerBlobGas:f,maxFeePerGas:h,maxPriorityFeePerGas:p,nonce:m,to:x,value:g});return BigInt(await e.request({method:"eth_estimateGas",params:v?[P,w??e.experimental_blockTag??"latest",v]:w?[P,w]:[P]}))}catch(n){throw function(e,{docsPath:t,...n}){const r=(()=>{const t=Vo(e,n);return t instanceof qo?e:t})();return new Co(r,{docsPath:t,...n})}(n,{...t,account:r,chain:e.chain})}}function zs(e,t){if(!zn(e,{strict:!1}))throw new Sn({address:e});if(!zn(t,{strict:!1}))throw new Sn({address:t});return e.toLowerCase()===t.toLowerCase()}const Ms="/docs/contract/decodeEventLog";function _s(e){const{abi:t,data:n,strict:r,topics:o}=e,s=r??!0,[a,...i]=o;if(!a)throw new nt({docsPath:Ms});const c=t.find(e=>"event"===e.type&&a===Nn(_e(e)));if(!c||!("name"in c)||"event"!==c.type)throw new rt(a,{docsPath:Ms});const{name:u,inputs:l}=c,d=l?.some(e=>!("name"in e&&e.name)),f=d?[]:{},h=l.map((e,t)=>[e,t]).filter(([e])=>"indexed"in e&&e.indexed);for(let e=0;e<h.length;e++){const[t,n]=h[e],r=i[e];if(!r)throw new dt({abiItem:c,param:t});f[d?n:t.name||n]=Fs({param:t,value:r})}const p=l.filter(e=>!("indexed"in e&&e.indexed));if(p.length>0)if(n&&"0x"!==n)try{const e=br(p,n);if(e)if(d)for(let t=0;t<l.length;t++)f[t]=f[t]??e.shift();else for(let t=0;t<p.length;t++)f[p[t].name]=e[t]}catch(e){if(s){if(e instanceof Ye||e instanceof lr)throw new lt({abiItem:c,data:n,params:p,size:Le(n)});throw e}}else if(s)throw new lt({abiItem:c,data:"0x",params:p,size:0});return{eventName:u,args:Object.values(f).length>0?f:void 0}}function Fs({param:e,value:t}){if("string"===e.type||"bytes"===e.type||"tuple"===e.type||e.type.match(/^(.*)\[(\d+)?\]$/))return t;return(br([e],t)||[])[0]}function js(e){const{abi:t,args:n,logs:r,strict:o=!0}=e,s=(()=>{if(e.eventName)return Array.isArray(e.eventName)?e.eventName:[e.eventName]})();return r.map(e=>{try{const r=t.find(t=>"event"===t.type&&e.topics[0]===Nn(t));if(!r)return null;const a=_s({...e,abi:[r],strict:o});return s&&!s.includes(a.eventName)?null:function(e){const{args:t,inputs:n,matchArgs:r}=e;if(!r)return!0;if(!t)return!1;function o(e,t,n){try{return"address"===e.type?zs(t,n):"string"===e.type||"bytes"===e.type?Pn(Ft(t))===n:t===n}catch{return!1}}if(Array.isArray(t)&&Array.isArray(r))return r.every((e,r)=>{if(null==e)return!0;const s=n[r];if(!s)return!1;return(Array.isArray(e)?e:[e]).some(e=>o(s,e,t[r]))});return"object"==typeof t&&!Array.isArray(t)&&"object"==typeof r&&!Array.isArray(r)&&Object.entries(r).every(([e,r])=>{if(null==r)return!0;const s=n.find(t=>t.name===e);if(!s)return!1;return(Array.isArray(r)?r:[r]).some(n=>o(s,n,t[e]))})}({args:a.args,inputs:r.inputs,matchArgs:n})?{...a,...e}:null}catch(t){let n,r;if(t instanceof rt)return null;if(t instanceof lt||t instanceof dt){if(o)return null;n=t.abiItem.name,r=t.abiItem.inputs?.some(e=>!("name"in e&&e.name))}return{...e,args:r?[]:{},eventName:n}}}).filter(Boolean)}function Ls(e,{args:t,eventName:n}={}){return{...e,blockHash:e.blockHash?e.blockHash:null,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,logIndex:e.logIndex?Number(e.logIndex):null,transactionHash:e.transactionHash?e.transactionHash:null,transactionIndex:e.transactionIndex?Number(e.transactionIndex):null,...n?{args:t,eventName:n}:{}}}async function Us(e,{address:t,blockHash:n,fromBlock:r,toBlock:o,event:s,events:a,args:i,strict:c}={}){const u=c??!1,l=a??(s?[s]:void 0);let d,f=[];if(l){const e=l.flatMap(e=>Xn({abi:[e],eventName:e.name,args:a?void 0:i}));f=[e],s&&(f=f[0])}d=n?await e.request({method:"eth_getLogs",params:[{address:t,topics:f,blockHash:n}]}):await e.request({method:"eth_getLogs",params:[{address:t,topics:f,fromBlock:"bigint"==typeof r?Rt(r):r,toBlock:"bigint"==typeof o?Rt(o):o}]});const h=d.map(e=>Ls(e));return l?js({abi:l,args:i,logs:h,strict:u}):h}async function Ds(e,t){const{abi:n,address:r,args:o,blockHash:s,eventName:a,fromBlock:i,toBlock:c,strict:u}=t,l=a?Zn({abi:n,name:a}):void 0,d=l?void 0:n.filter(e=>"event"===e.type);return Me(e,Us,"getLogs")({address:r,args:o,blockHash:s,event:l,events:d,fromBlock:i,toBlock:c,strict:u})}const Gs="/docs/contract/decodeFunctionResult";function qs(e){const{abi:t,args:n,functionName:r,data:o}=e;let s=t[0];if(r){const e=Zn({abi:t,args:n,name:r});if(!e)throw new st(r,{docsPath:Gs});s=e}if("function"!==s.type)throw new st(void 0,{docsPath:Gs});if(!s.outputs)throw new at(s.name,{docsPath:Gs});const a=br(s.outputs,o);return a&&a.length>1?a:a&&1===a.length?a[0]:void 0}class Vs extends Error{constructor(e,t={}){const n=(()=>{if(t.cause instanceof Vs){if(t.cause.details)return t.cause.details;if(t.cause.shortMessage)return t.cause.shortMessage}return t.cause&&"details"in t.cause&&"string"==typeof t.cause.details?t.cause.details:t.cause?.message?t.cause.message:t.details})(),r=t.cause instanceof Vs&&t.cause.docsPath||t.docsPath,o=`https://oxlib.sh${r??""}`,s=[e||"An error occurred.",...t.metaMessages?["",...t.metaMessages]:[],...n||r?["",n?`Details: ${n}`:void 0,r?`See: ${o}`:void 0]:[]].filter(e=>"string"==typeof e).join("\n");super(s,t.cause?{cause:t.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,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:"ox@0.1.1"}),this.cause=t.cause,this.details=n,this.docs=o,this.docsPath=r,this.shortMessage=e}walk(e){return Ws(this,e)}}function Ws(e,t){return t?.(e)?e:e&&"object"==typeof e&&"cause"in e&&e.cause?Ws(e.cause,t):t?null:e}function Hs(e,t){if(la(e)>t)throw new ya({givenSize:la(e),maxSize:t})}const Ys=48,Zs=57,Ks=65,Js=70,Qs=97,Xs=102;function ea(e){return e>=Ys&&e<=Zs?e-Ys:e>=Ks&&e<=Js?e-(Ks-10):e>=Qs&&e<=Xs?e-(Qs-10):void 0}function ta(e,t={}){const{dir:n="left"}=t;let r=e,o=0;for(let e=0;e<r.length-1&&"0"===r["left"===n?e:r.length-e-1].toString();e++)o++;return r="left"===n?r.slice(o):r.slice(0,r.length-o),r}function na(e,t){if($a(e)>t)throw new _a({givenSize:$a(e),maxSize:t})}function ra(e,t={}){const{dir:n,size:r=32}=t;if(0===r)return e;const o=e.replace("0x","");if(o.length>2*r)throw new ja({size:Math.ceil(o.length/2),targetSize:r,type:"Hex"});return`0x${o["right"===n?"padEnd":"padStart"](2*r,"0")}`}function oa(e,t,n){return JSON.stringify(e,(e,t)=>"bigint"==typeof t?t.toString()+"#__bigint":t,n)}const sa=new TextDecoder,aa=new TextEncoder;function ia(e){return e instanceof Uint8Array?e:"string"==typeof e?ca(e):function(e){return e instanceof Uint8Array?e:new Uint8Array(e)}(e)}function ca(e,t={}){const{size:n}=t;let r=e;n&&(na(e,n),r=Sa(e,n));let o=r.slice(2);o.length%2&&(o=`0${o}`);const s=o.length/2,a=new Uint8Array(s);for(let e=0,t=0;e<s;e++){const n=ea(o.charCodeAt(t++)),r=ea(o.charCodeAt(t++));if(void 0===n||void 0===r)throw new Vs(`Invalid byte sequence ("${o[t-2]}${o[t-1]}" in "${o}").`);a[e]=16*n+r}return a}function ua(e,t={}){const{size:n}=t,r=aa.encode(e);return"number"==typeof n?(Hs(r,n),function(e,t){return function(e,t={}){const{dir:n,size:r=32}=t;if(0===r)return e;if(e.length>r)throw new wa({size:e.length,targetSize:r,type:"Bytes"});const o=new Uint8Array(r);for(let t=0;t<r;t++){const s="right"===n;o[s?t:r-t-1]=e[s?t:e.length-t-1]}return o}(e,{dir:"right",size:t})}(r,n)):r}function la(e){return e.length}function da(e,t,n,r={}){const{strict:o}=r;return e.slice(t,n)}function fa(e,t={}){const{size:n}=t;void 0!==n&&Hs(e,n);return Ba(ka(e,t),t)}function ha(e,t={}){const{size:n}=t;let r=e;if(void 0!==n&&(Hs(r,n),r=ga(r)),r.length>1||r[0]>1)throw new ba(r);return Boolean(r[0])}function pa(e,t={}){const{size:n}=t;void 0!==n&&Hs(e,n);return Ca(ka(e,t),t)}function ma(e,t={}){const{size:n}=t;let r=e;return void 0!==n&&(Hs(r,n),r=ta(r,{dir:"right"})),sa.decode(r)}function ga(e){return ta(e,{dir:"left"})}class ba extends Vs{constructor(e){super(`Bytes value \`${e}\` 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"})}}let ya=class extends Vs{constructor({givenSize:e,maxSize:t}){super(`Size cannot exceed \`${t}\` bytes. Given size: \`${e}\` bytes.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.SizeOverflowError"})}},wa=class extends Vs{constructor({size:e,targetSize:t,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (\`${e}\`) exceeds padding size (\`${t}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.SizeExceedsPaddingSizeError"})}};const va=new TextEncoder,xa=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Ea(...e){return`0x${e.reduce((e,t)=>e+t.replace("0x",""),"")}`}function Pa(e,t={}){const n=`0x${Number(e)}`;return"number"==typeof t.size?(na(n,t.size),Na(n,t.size)):n}function ka(e,t={}){let n="";for(let t=0;t<e.length;t++)n+=xa[e[t]];const r=`0x${n}`;return"number"==typeof t.size?(na(r,t.size),Sa(r,t.size)):r}function Aa(e,t={}){const{signed:n,size:r}=t,o=BigInt(e);let s;r?s=n?(1n<<8n*BigInt(r)-1n)-1n:2n**(8n*BigInt(r))-1n:"number"==typeof e&&(s=BigInt(Number.MAX_SAFE_INTEGER));const a="bigint"==typeof s&&n?-s-1n:0;if(s&&o>s||o<a){const t="bigint"==typeof e?"n":"";throw new Ra({max:s?`${s}${t}`:void 0,min:`${a}${t}`,signed:n,size:r,value:`${e}${t}`})}const i=`0x${(n&&o<0?(1n<<BigInt(8*r))+BigInt(o):o).toString(16)}`;return r?Na(i,r):i}function Ia(e,t={}){return ka(va.encode(e),t)}function Na(e,t){return ra(e,{dir:"left",size:t})}function Sa(e,t){return ra(e,{dir:"right",size:t})}function Ta(e,t,n,r={}){const{strict:o}=r;!function(e,t){if("number"==typeof t&&t>0&&t>$a(e)-1)throw new Fa({offset:t,position:"start",size:$a(e)})}(e,t);const s=`0x${e.replace("0x","").slice(2*(t??0),2*(n??e.length))}`;return o&&function(e,t,n){if("number"==typeof t&&"number"==typeof n&&$a(e)!==n-t)throw new Fa({offset:n,position:"end",size:$a(e)})}(s,t,n),s}function $a(e){return Math.ceil((e.length-2)/2)}function Ba(e,t={}){const{signed:n}=t;t.size&&na(e,t.size);const r=BigInt(e);if(!n)return r;const o=(e.length-2)/2,s=(1n<<8n*BigInt(o))-1n;return r<=s>>1n?r:r-s-1n}function Ca(e,t={}){const{signed:n,size:r}=t;return Number(n||r?Ba(e,t):e)}function Oa(e,t={}){const{strict:n=!1}=t;try{return function(e,t={}){const{strict:n=!1}=t;if(!e)throw new za(e);if("string"!=typeof e)throw new za(e);if(n&&!/^0x[0-9a-fA-F]*$/.test(e))throw new Ma(e);if(!e.startsWith("0x"))throw new Ma(e)}(e,{strict:n}),!0}catch{return!1}}class Ra extends Vs{constructor({max:e,min:t,signed:n,size:r,value:o}){super(`Number \`${o}\` is not in safe${r?` ${8*r}-bit`:""}${n?" signed":" unsigned"} integer range ${e?`(\`${t}\` to \`${e}\`)`:`(above \`${t}\`)`}`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.IntegerOutOfRangeError"})}}class za extends Vs{constructor(e){super(`Value \`${"object"==typeof e?oa(e):e}\` of type \`${typeof e}\` 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 Ma extends Vs{constructor(e){super(`Value \`${e}\` 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 _a extends Vs{constructor({givenSize:e,maxSize:t}){super(`Size cannot exceed \`${t}\` bytes. Given size: \`${e}\` bytes.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SizeOverflowError"})}}class Fa extends Vs{constructor({offset:e,position:t,size:n}){super(`Slice ${"start"===t?"starting":"ending"} at offset \`${e}\` is out-of-bounds (size: \`${n}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SliceOffsetOutOfBoundsError"})}}class ja extends Vs{constructor({size:e,targetSize:t,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (\`${e}\`) exceeds padding size (\`${t}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SizeExceedsPaddingSizeError"})}}function La(e){return{address:e.address,amount:Aa(e.amount),index:Aa(e.index),validatorIndex:Aa(e.validatorIndex)}}function Ua(e){return{..."bigint"==typeof e.baseFeePerGas&&{baseFeePerGas:Aa(e.baseFeePerGas)},..."bigint"==typeof e.blobBaseFee&&{blobBaseFee:Aa(e.blobBaseFee)},..."string"==typeof e.feeRecipient&&{feeRecipient:e.feeRecipient},..."bigint"==typeof e.gasLimit&&{gasLimit:Aa(e.gasLimit)},..."bigint"==typeof e.number&&{number:Aa(e.number)},..."bigint"==typeof e.prevRandao&&{prevRandao:Aa(e.prevRandao)},..."bigint"==typeof e.time&&{time:Aa(e.time)},...e.withdrawals&&{withdrawals:e.withdrawals.map(La)}}}const Da=[{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"}],Ga=[{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"}]}],qa=[{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"}],Va=[...qa,{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"}]}],Wa=[...qa,{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"}]}],Ha=[{name:"text",type:"function",stateMutability:"view",inputs:[{name:"name",type:"bytes32"},{name:"key",type:"string"}],outputs:[{name:"",type:"string"}]}],Ya=[{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"}]}],Za=[{name:"isValidSignature",type:"function",stateMutability:"view",inputs:[{name:"hash",type:"bytes32"},{name:"signature",type:"bytes"}],outputs:[{name:"",type:"bytes4"}]}],Ka=[{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"}],Ja="0x82ad56cb",Qa="0x608060405234801561001057600080fd5b5060405161018e38038061018e83398101604081905261002f91610124565b6000808351602085016000f59050803b61004857600080fd5b6000808351602085016000855af16040513d6000823e81610067573d81fd5b3d81f35b634e487b7160e01b600052604160045260246000fd5b600082601f83011261009257600080fd5b81516001600160401b038111156100ab576100ab61006b565b604051601f8201601f19908116603f011681016001600160401b03811182821017156100d9576100d961006b565b6040528181528382016020018510156100f157600080fd5b60005b82811015610110576020818601810151838301820152016100f4565b506000918101602001919091529392505050565b6000806040838503121561013757600080fd5b82516001600160401b0381111561014d57600080fd5b61015985828601610081565b602085015190935090506001600160401b0381111561017757600080fd5b61018385828601610081565b915050925092905056fe",Xa="0x608060405234801561001057600080fd5b506040516102c03803806102c083398101604081905261002f916101e6565b836001600160a01b03163b6000036100e457600080836001600160a01b03168360405161005c9190610270565b6000604051808303816000865af19150503d8060008114610099576040519150601f19603f3d011682016040523d82523d6000602084013e61009e565b606091505b50915091508115806100b857506001600160a01b0386163b155b156100e1578060405163101bb98d60e01b81526004016100d8919061028c565b60405180910390fd5b50505b6000808451602086016000885af16040513d6000823e81610103573d81fd5b3d81f35b80516001600160a01b038116811461011e57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b8381101561015457818101518382015260200161013c565b50506000910152565b600082601f83011261016e57600080fd5b81516001600160401b0381111561018757610187610123565b604051601f8201601f19908116603f011681016001600160401b03811182821017156101b5576101b5610123565b6040528181528382016020018510156101cd57600080fd5b6101de826020830160208701610139565b949350505050565b600080600080608085870312156101fc57600080fd5b61020585610107565b60208601519094506001600160401b0381111561022157600080fd5b61022d8782880161015d565b93505061023c60408601610107565b60608601519092506001600160401b0381111561025857600080fd5b6102648782880161015d565b91505092959194509250565b60008251610282818460208701610139565b9190910192915050565b60208152600082518060208401526102ab816040850160208701610139565b601f01601f1916919091016040019291505056fe",ei="0x608060405234801561001057600080fd5b5060405161069438038061069483398101604081905261002f9161051e565b600061003c848484610048565b9050806000526001601ff35b60007f64926492649264926492649264926492649264926492649264926492649264926100748361040c565b036101e7576000606080848060200190518101906100929190610577565b60405192955090935091506000906001600160a01b038516906100b69085906105dd565b6000604051808303816000865af19150503d80600081146100f3576040519150601f19603f3d011682016040523d82523d6000602084013e6100f8565b606091505b50509050876001600160a01b03163b60000361016057806101605760405162461bcd60e51b815260206004820152601e60248201527f5369676e617475726556616c696461746f723a206465706c6f796d656e74000060448201526064015b60405180910390fd5b604051630b135d3f60e11b808252906001600160a01b038a1690631626ba7e90610190908b9087906004016105f9565b602060405180830381865afa1580156101ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101d19190610633565b6001600160e01b03191614945050505050610405565b6001600160a01b0384163b1561027a57604051630b135d3f60e11b808252906001600160a01b03861690631626ba7e9061022790879087906004016105f9565b602060405180830381865afa158015610244573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102689190610633565b6001600160e01b031916149050610405565b81516041146102df5760405162461bcd60e51b815260206004820152603a602482015260008051602061067483398151915260448201527f3a20696e76616c6964207369676e6174757265206c656e6774680000000000006064820152608401610157565b6102e7610425565b5060208201516040808401518451859392600091859190811061030c5761030c61065d565b016020015160f81c9050601b811480159061032b57508060ff16601c14155b1561038c5760405162461bcd60e51b815260206004820152603b602482015260008051602061067483398151915260448201527f3a20696e76616c6964207369676e617475726520762076616c756500000000006064820152608401610157565b60408051600081526020810180835289905260ff83169181019190915260608101849052608081018390526001600160a01b0389169060019060a0016020604051602081039080840390855afa1580156103ea573d6000803e3d6000fd5b505050602060405103516001600160a01b0316149450505050505b9392505050565b600060208251101561041d57600080fd5b508051015190565b60405180606001604052806003906020820280368337509192915050565b6001600160a01b038116811461045857600080fd5b50565b634e487b7160e01b600052604160045260246000fd5b60005b8381101561048c578181015183820152602001610474565b50506000910152565b600082601f8301126104a657600080fd5b81516001600160401b038111156104bf576104bf61045b565b604051601f8201601f19908116603f011681016001600160401b03811182821017156104ed576104ed61045b565b60405281815283820160200185101561050557600080fd5b610516826020830160208701610471565b949350505050565b60008060006060848603121561053357600080fd5b835161053e81610443565b6020850151604086015191945092506001600160401b0381111561056157600080fd5b61056d86828701610495565b9150509250925092565b60008060006060848603121561058c57600080fd5b835161059781610443565b60208501519093506001600160401b038111156105b357600080fd5b6105bf86828701610495565b604086015190935090506001600160401b0381111561056157600080fd5b600082516105ef818460208701610471565b9190910192915050565b828152604060208201526000825180604084015261061e816060850160208701610471565b601f01601f1916919091016060019392505050565b60006020828403121561064557600080fd5b81516001600160e01b03198116811461040557600080fd5b634e487b7160e01b600052603260045260246000fdfe5369676e617475726556616c696461746f72237265636f7665725369676e6572",ti="0x608060405234801561001057600080fd5b506115b9806100206000396000f3fe6080604052600436106100f35760003560e01c80634d2301cc1161008a578063a8b0574e11610059578063a8b0574e14610325578063bce38bd714610350578063c3077fa914610380578063ee82ac5e146103b2576100f3565b80634d2301cc1461026257806372425d9d1461029f57806382ad56cb146102ca57806386d516e8146102fa576100f3565b80633408e470116100c65780633408e470146101af578063399542e9146101da5780633e64a6961461020c57806342cbb15c14610237576100f3565b80630f28c97d146100f8578063174dea7114610123578063252dba421461015357806327e86d6e14610184575b600080fd5b34801561010457600080fd5b5061010d6103ef565b60405161011a9190610c0a565b60405180910390f35b61013d60048036038101906101389190610c94565b6103f7565b60405161014a9190610e94565b60405180910390f35b61016d60048036038101906101689190610f0c565b610615565b60405161017b92919061101b565b60405180910390f35b34801561019057600080fd5b506101996107ab565b6040516101a69190611064565b60405180910390f35b3480156101bb57600080fd5b506101c46107b7565b6040516101d19190610c0a565b60405180910390f35b6101f460048036038101906101ef91906110ab565b6107bf565b6040516102039392919061110b565b60405180910390f35b34801561021857600080fd5b506102216107e1565b60405161022e9190610c0a565b60405180910390f35b34801561024357600080fd5b5061024c6107e9565b6040516102599190610c0a565b60405180910390f35b34801561026e57600080fd5b50610289600480360381019061028491906111a7565b6107f1565b6040516102969190610c0a565b60405180910390f35b3480156102ab57600080fd5b506102b4610812565b6040516102c19190610c0a565b60405180910390f35b6102e460048036038101906102df919061122a565b61081a565b6040516102f19190610e94565b60405180910390f35b34801561030657600080fd5b5061030f6109e4565b60405161031c9190610c0a565b60405180910390f35b34801561033157600080fd5b5061033a6109ec565b6040516103479190611286565b60405180910390f35b61036a600480360381019061036591906110ab565b6109f4565b6040516103779190610e94565b60405180910390f35b61039a60048036038101906103959190610f0c565b610ba6565b6040516103a99392919061110b565b60405180910390f35b3480156103be57600080fd5b506103d960048036038101906103d491906112cd565b610bca565b6040516103e69190611064565b60405180910390f35b600042905090565b60606000808484905090508067ffffffffffffffff81111561041c5761041b6112fa565b5b60405190808252806020026020018201604052801561045557816020015b610442610bd5565b81526020019060019003908161043a5790505b5092503660005b828110156105c957600085828151811061047957610478611329565b5b6020026020010151905087878381811061049657610495611329565b5b90506020028101906104a89190611367565b925060008360400135905080860195508360000160208101906104cb91906111a7565b73ffffffffffffffffffffffffffffffffffffffff16818580606001906104f2919061138f565b604051610500929190611431565b60006040518083038185875af1925050503d806000811461053d576040519150601f19603f3d011682016040523d82523d6000602084013e610542565b606091505b5083600001846020018290528215151515815250505081516020850135176105bc577f08c379a000000000000000000000000000000000000000000000000000000000600052602060045260176024527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060445260846000fd5b826001019250505061045c565b5082341461060c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610603906114a7565b60405180910390fd5b50505092915050565b6000606043915060008484905090508067ffffffffffffffff81111561063e5761063d6112fa565b5b60405190808252806020026020018201604052801561067157816020015b606081526020019060019003908161065c5790505b5091503660005b828110156107a157600087878381811061069557610694611329565b5b90506020028101906106a791906114c7565b92508260000160208101906106bc91906111a7565b73ffffffffffffffffffffffffffffffffffffffff168380602001906106e2919061138f565b6040516106f0929190611431565b6000604051808303816000865af19150503d806000811461072d576040519150601f19603f3d011682016040523d82523d6000602084013e610732565b606091505b5086848151811061074657610745611329565b5b60200260200101819052819250505080610795576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161078c9061153b565b60405180910390fd5b81600101915050610678565b5050509250929050565b60006001430340905090565b600046905090565b6000806060439250434091506107d68686866109f4565b905093509350939050565b600048905090565b600043905090565b60008173ffffffffffffffffffffffffffffffffffffffff16319050919050565b600044905090565b606060008383905090508067ffffffffffffffff81111561083e5761083d6112fa565b5b60405190808252806020026020018201604052801561087757816020015b610864610bd5565b81526020019060019003908161085c5790505b5091503660005b828110156109db57600084828151811061089b5761089a611329565b5b602002602001015190508686838181106108b8576108b7611329565b5b90506020028101906108ca919061155b565b92508260000160208101906108df91906111a7565b73ffffffffffffffffffffffffffffffffffffffff16838060400190610905919061138f565b604051610913929190611431565b6000604051808303816000865af19150503d8060008114610950576040519150601f19603f3d011682016040523d82523d6000602084013e610955565b606091505b5082600001836020018290528215151515815250505080516020840135176109cf577f08c379a000000000000000000000000000000000000000000000000000000000600052602060045260176024527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060445260646000fd5b8160010191505061087e565b50505092915050565b600045905090565b600041905090565b606060008383905090508067ffffffffffffffff811115610a1857610a176112fa565b5b604051908082528060200260200182016040528015610a5157816020015b610a3e610bd5565b815260200190600190039081610a365790505b5091503660005b82811015610b9c576000848281518110610a7557610a74611329565b5b60200260200101519050868683818110610a9257610a91611329565b5b9050602002810190610aa491906114c7565b9250826000016020810190610ab991906111a7565b73ffffffffffffffffffffffffffffffffffffffff16838060200190610adf919061138f565b604051610aed929190611431565b6000604051808303816000865af19150503d8060008114610b2a576040519150601f19603f3d011682016040523d82523d6000602084013e610b2f565b606091505b508260000183602001829052821515151581525050508715610b90578060000151610b8f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b869061153b565b60405180910390fd5b5b81600101915050610a58565b5050509392505050565b6000806060610bb7600186866107bf565b8093508194508295505050509250925092565b600081409050919050565b6040518060400160405280600015158152602001606081525090565b6000819050919050565b610c0481610bf1565b82525050565b6000602082019050610c1f6000830184610bfb565b92915050565b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b60008083601f840112610c5457610c53610c2f565b5b8235905067ffffffffffffffff811115610c7157610c70610c34565b5b602083019150836020820283011115610c8d57610c8c610c39565b5b9250929050565b60008060208385031215610cab57610caa610c25565b5b600083013567ffffffffffffffff811115610cc957610cc8610c2a565b5b610cd585828601610c3e565b92509250509250929050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b60008115159050919050565b610d2281610d0d565b82525050565b600081519050919050565b600082825260208201905092915050565b60005b83811015610d62578082015181840152602081019050610d47565b83811115610d71576000848401525b50505050565b6000601f19601f8301169050919050565b6000610d9382610d28565b610d9d8185610d33565b9350610dad818560208601610d44565b610db681610d77565b840191505092915050565b6000604083016000830151610dd96000860182610d19565b5060208301518482036020860152610df18282610d88565b9150508091505092915050565b6000610e0a8383610dc1565b905092915050565b6000602082019050919050565b6000610e2a82610ce1565b610e348185610cec565b935083602082028501610e4685610cfd565b8060005b85811015610e825784840389528151610e638582610dfe565b9450610e6e83610e12565b925060208a01995050600181019050610e4a565b50829750879550505050505092915050565b60006020820190508181036000830152610eae8184610e1f565b905092915050565b60008083601f840112610ecc57610ecb610c2f565b5b8235905067ffffffffffffffff811115610ee957610ee8610c34565b5b602083019150836020820283011115610f0557610f04610c39565b5b9250929050565b60008060208385031215610f2357610f22610c25565b5b600083013567ffffffffffffffff811115610f4157610f40610c2a565b5b610f4d85828601610eb6565b92509250509250929050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b6000610f918383610d88565b905092915050565b6000602082019050919050565b6000610fb182610f59565b610fbb8185610f64565b935083602082028501610fcd85610f75565b8060005b858110156110095784840389528151610fea8582610f85565b9450610ff583610f99565b925060208a01995050600181019050610fd1565b50829750879550505050505092915050565b60006040820190506110306000830185610bfb565b81810360208301526110428184610fa6565b90509392505050565b6000819050919050565b61105e8161104b565b82525050565b60006020820190506110796000830184611055565b92915050565b61108881610d0d565b811461109357600080fd5b50565b6000813590506110a58161107f565b92915050565b6000806000604084860312156110c4576110c3610c25565b5b60006110d286828701611096565b935050602084013567ffffffffffffffff8111156110f3576110f2610c2a565b5b6110ff86828701610eb6565b92509250509250925092565b60006060820190506111206000830186610bfb565b61112d6020830185611055565b818103604083015261113f8184610e1f565b9050949350505050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061117482611149565b9050919050565b61118481611169565b811461118f57600080fd5b50565b6000813590506111a18161117b565b92915050565b6000602082840312156111bd576111bc610c25565b5b60006111cb84828501611192565b91505092915050565b60008083601f8401126111ea576111e9610c2f565b5b8235905067ffffffffffffffff81111561120757611206610c34565b5b60208301915083602082028301111561122357611222610c39565b5b9250929050565b6000806020838503121561124157611240610c25565b5b600083013567ffffffffffffffff81111561125f5761125e610c2a565b5b61126b858286016111d4565b92509250509250929050565b61128081611169565b82525050565b600060208201905061129b6000830184611277565b92915050565b6112aa81610bf1565b81146112b557600080fd5b50565b6000813590506112c7816112a1565b92915050565b6000602082840312156112e3576112e2610c25565b5b60006112f1848285016112b8565b91505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600080fd5b600080fd5b600080fd5b60008235600160800383360303811261138357611382611358565b5b80830191505092915050565b600080833560016020038436030381126113ac576113ab611358565b5b80840192508235915067ffffffffffffffff8211156113ce576113cd61135d565b5b6020830192506001820236038313156113ea576113e9611362565b5b509250929050565b600081905092915050565b82818337600083830152505050565b600061141883856113f2565b93506114258385846113fd565b82840190509392505050565b600061143e82848661140c565b91508190509392505050565b600082825260208201905092915050565b7f4d756c746963616c6c333a2076616c7565206d69736d61746368000000000000600082015250565b6000611491601a8361144a565b915061149c8261145b565b602082019050919050565b600060208201905081810360008301526114c081611484565b9050919050565b6000823560016040038336030381126114e3576114e2611358565b5b80830191505092915050565b7f4d756c746963616c6c333a2063616c6c206661696c6564000000000000000000600082015250565b600061152560178361144a565b9150611530826114ef565b602082019050919050565b6000602082019050818103600083015261155481611518565b9050919050565b60008235600160600383360303811261157757611576611358565b5b8083019150509291505056fea264697066735822122020c1bc9aacf8e4a6507193432a895a8e77094f45a1395583f07b24e860ef06cd64736f6c634300080c0033";class ni extends qe{constructor({blockNumber:e,chain:t,contract:n}){super(`Chain "${t.name}" does not support contract "${n.name}".`,{metaMessages:["This could be due to any of the following:",...e&&n.blockCreated&&n.blockCreated>e?[`- The contract "${n.name}" was not deployed until block ${n.blockCreated} (current block ${e}).`]:[`- The chain does not have the contract "${n.name}" configured.`]],name:"ChainDoesNotSupportContract"})}}class ri extends qe{constructor(){super("No chain was provided to the Client.",{name:"ClientChainNotConfiguredError"})}}const oi="/docs/contract/encodeDeployData";function si(e){const{abi:t,args:n,bytecode:r}=e;if(!n||0===n.length)return r;const o=t.find(e=>"type"in e&&"constructor"===e.type);if(!o)throw new We({docsPath:oi});if(!("inputs"in o))throw new He({docsPath:oi});if(!o.inputs||0===o.inputs.length)throw new He({docsPath:oi});return _n([r,qn(o.inputs,n)])}function ai({blockNumber:e,chain:t,contract:n}){const r=t?.contracts?.[n];if(!r)throw new ni({chain:t,contract:{name:n}});if(e&&r.blockCreated&&r.blockCreated>e)throw new ni({blockNumber:e,chain:t,contract:{name:n,blockCreated:r.blockCreated}});return r.address}function ii(e,{docsPath:t,...n}){const r=(()=>{const t=Vo(e,n);return t instanceof qo?e:t})();return new jr(r,{docsPath:t,...n})}function ci(){let e=()=>{},t=()=>{};return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}const ui=new Map;function li({fn:e,id:t,shouldSplitBatch:n,wait:r=0,sort:o}){const s=async()=>{const t=i();a();const n=t.map(({args:e})=>e);0!==n.length&&e(n).then(e=>{o&&Array.isArray(e)&&e.sort(o);for(let n=0;n<t.length;n++){const{resolve:r}=t[n];r?.([e[n],e])}}).catch(e=>{for(let n=0;n<t.length;n++){const{reject:r}=t[n];r?.(e)}})},a=()=>ui.delete(t),i=()=>ui.get(t)||[],c=e=>ui.set(t,[...i(),e]);return{flush:a,async schedule(e){const{promise:t,resolve:o,reject:a}=ci(),u=n?.([...i().map(({args:e})=>e),e]);u&&s();return i().length>0?(c({args:e,resolve:o,reject:a}),t):(c({args:e,resolve:o,reject:a}),setTimeout(s,r),t)}}}async function di(e,t){const{account:n=e.account,authorizationList:r,batch:o=Boolean(e.batch?.multicall),blockNumber:s,blockTag:a=e.experimental_blockTag??"latest",accessList:i,blobs:c,blockOverrides:u,code:l,data:d,factory:f,factoryData:h,gas:p,gasPrice:m,maxFeePerBlobGas:g,maxFeePerGas:b,maxPriorityFeePerGas:y,nonce:w,to:v,value:x,stateOverride:E,...P}=t,k=n?rr(n):void 0;if(l&&(f||h))throw new qe("Cannot provide both `code` & `factory`/`factoryData` as parameters.");if(l&&v)throw new qe("Cannot provide both `code` & `to` as parameters.");const A=l&&d,I=f&&h&&v&&d,N=A||I,S=A?fi({code:l,data:d}):I?function(e){const{data:t,factory:n,factoryData:r,to:o}=e;return si({abi:Oe(["constructor(address, bytes, address, bytes)"]),bytecode:Xa,args:[o,t,n,r]})}({data:d,factory:f,factoryData:h,to:v}):d;try{Xo(t);const n=("bigint"==typeof s?Rt(s):void 0)||a,l=u?Ua(u):void 0,d=Jo(E),f=e.chain?.formatters?.transactionRequest?.format,h=(f||Yo)({...Wo(P,{format:f}),from:k?.address,accessList:i,authorizationList:r,blobs:c,data:S,gas:p,gasPrice:m,maxFeePerBlobGas:g,maxFeePerGas:b,maxPriorityFeePerGas:y,nonce:w,to:N?void 0:v,value:x});if(o&&function({request:e}){const{data:t,to:n,...r}=e;return!!t&&(!t.startsWith(Ja)&&(!!n&&!(Object.values(r).filter(e=>void 0!==e).length>0)))}({request:h})&&!d&&!l)try{return await async function(e,t){const{batchSize:n=1024,deployless:r=!1,wait:o=0}="object"==typeof e.batch?.multicall?e.batch.multicall:{},{blockNumber:s,blockTag:a=e.experimental_blockTag??"latest",data:i,to:c}=t,u=(()=>{if(r)return null;if(t.multicallAddress)return t.multicallAddress;if(e.chain)return ai({blockNumber:s,chain:e.chain,contract:"multicall3"});throw new ri})(),l="bigint"==typeof s?Rt(s):void 0,d=l||a,{schedule:f}=li({id:`${e.uid}.${d}`,wait:o,shouldSplitBatch(e){const t=e.reduce((e,{data:t})=>e+(t.length-2),0);return t>2*n},fn:async t=>{const n=t.map(e=>({allowFailure:!0,callData:e.data,target:e.to})),r=sr({abi:Da,args:[n],functionName:"aggregate3"}),o=await e.request({method:"eth_call",params:[{...null===u?{data:fi({code:ti,data:r})}:{to:u,data:r}},d]});return qs({abi:Da,args:[n],functionName:"aggregate3",data:o||"0x"})}}),[{returnData:h,success:p}]=await f({data:i,to:c});if(!p)throw new qr({data:h});return"0x"===h?{data:void 0}:{data:h}}(e,{...h,blockNumber:s,blockTag:a})}catch(e){if(!(e instanceof ri||e instanceof ni))throw e}const A=(()=>{const e=[h,n];return d&&l?[...e,d,l]:d?[...e,d]:l?[...e,{},l]:e})(),I=await e.request({method:"eth_call",params:A});return"0x"===I?{data:void 0}:{data:I}}catch(n){const r=function(e){if(!(e instanceof qe))return;const t=e.walk();return"object"==typeof t?.data?t.data?.data:t.data}(n),{offchainLookup:o,offchainLookupSignature:s}=await Promise.resolve().then(function(){return bc});if(!1!==e.ccipRead&&r?.slice(0,10)===s&&v)return{data:await o(e,{data:r,to:v})};if(N&&"0x101bb98d"===r?.slice(0,10))throw new Gr({factory:f});throw ii(n,{...t,account:k,chain:e.chain})}}function fi(e){const{code:t,data:n}=e;return si({abi:Oe(["constructor(bytes, bytes)"]),bytecode:Qa,args:[t,n]})}async function hi(e,t){const{abi:n,address:r,args:o,functionName:s,...a}=t,i=sr({abi:n,args:o,functionName:s});try{const{data:t}=await Me(e,di,"call")({...a,data:i,to:r});return qs({abi:n,args:o,functionName:s,data:t||"0x"})}catch(e){throw ko(e,{abi:n,address:r,args:o,docsPath:"/docs/contract/readContract",functionName:s})}}const pi=new Map,mi=new Map;let gi=0;function bi(e,t,n){const r=++gi,o=()=>pi.get(e)||[],s=()=>{const t=o();if(!t.some(e=>e.id===r))return;const n=mi.get(e);if(1===t.length&&n){const e=n();e instanceof Promise&&e.catch(()=>{})}(()=>{const t=o();pi.set(e,t.filter(e=>e.id!==r))})()},a=o();if(pi.set(e,[...a,{id:r,fns:t}]),a&&a.length>0)return s;const i={};for(const e in t)i[e]=(...t)=>{const n=o();if(0!==n.length)for(const r of n)r.fns[e]?.(...t)};const c=n(i);return"function"==typeof c&&mi.set(e,c),s}async function yi(e){return new Promise(t=>setTimeout(t,e))}function wi(e,{emitOnBegin:t,initialWaitTime:n,interval:r}){let o=!0;const s=()=>o=!1;return(async()=>{let a;t&&(a=await e({unpoll:s}));const i=await(n?.(a))??r;await yi(i);const c=async()=>{o&&(await e({unpoll:s}),await yi(r),c())};c()})(),s}const vi=new Map,xi=new Map;async function Ei(e,{cacheKey:t,cacheTime:n=Number.POSITIVE_INFINITY}){const r=function(e){const t=(e,t)=>({clear:()=>t.delete(e),get:()=>t.get(e),set:n=>t.set(e,n)}),n=t(e,vi),r=t(e,xi);return{clear:()=>{n.clear(),r.clear()},promise:n,response:r}}(t),o=r.response.get();if(o&&n>0){if(Date.now()-o.created.getTime()<n)return o.data}let s=r.promise.get();s||(s=e(),r.promise.set(s));try{const e=await s;return r.response.set({created:new Date,data:e}),e}finally{r.promise.clear()}}async function Pi(e,{cacheTime:t=e.cacheTime}={}){const n=await Ei(()=>e.request({method:"eth_blockNumber"}),{cacheKey:(r=e.uid,`blockNumber.${r}`),cacheTime:t});var r;return BigInt(n)}async function ki(e,{filter:t}){const n="strict"in t&&t.strict,r=await t.request({method:"eth_getFilterChanges",params:[t.id]});if("string"==typeof r[0])return r;const o=r.map(e=>Ls(e));return"abi"in t&&t.abi?js({abi:t.abi,logs:o,strict:n}):o}async function Ai(e,{filter:t}){return t.request({method:"eth_uninstallFilter",params:[t.id]})}function Ii(e,{delay:t=100,retryCount:n=2,shouldRetry:r=()=>!0}={}){return new Promise((o,s)=>{const a=async({count:i=0}={})=>{try{const t=await e();o(t)}catch(e){if(i<n&&await r({count:i,error:e}))return(async({error:e})=>{const n="function"==typeof t?t({count:i,error:e}):t;n&&await yi(n),a({count:i+1})})({error:e});s(e)}};a()})}const Ni={"0x0":"reverted","0x1":"success"};function Si(e){const t={...e,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,contractAddress:e.contractAddress?e.contractAddress:null,cumulativeGasUsed:e.cumulativeGasUsed?BigInt(e.cumulativeGasUsed):null,effectiveGasPrice:e.effectiveGasPrice?BigInt(e.effectiveGasPrice):null,gasUsed:e.gasUsed?BigInt(e.gasUsed):null,logs:e.logs?e.logs.map(e=>Ls(e)):null,to:e.to?e.to:null,transactionIndex:e.transactionIndex?Tt(e.transactionIndex):null,status:e.status?Ni[e.status]:null,type:e.type?os[e.type]||e.type:null};return e.blobGasPrice&&(t.blobGasPrice=BigInt(e.blobGasPrice)),e.blobGasUsed&&(t.blobGasUsed=BigInt(e.blobGasUsed)),t}let Ti,$i=256;function Bi(e=11){if(!Ti||$i+e>512){Ti="",$i=0;for(let e=0;e<256;e++)Ti+=(256+256*Math.random()|0).toString(16).substring(1)}return Ti.substring($i,$i+++e)}function Ci(e){if(!(e instanceof qe))return!1;const t=e.walk(e=>e instanceof Ur);return t instanceof Ur&&("HttpError"===t.data?.errorName||("ResolverError"===t.data?.errorName||("ResolverNotContract"===t.data?.errorName||("ResolverNotFound"===t.data?.errorName||("ReverseAddressMismatch"===t.data?.errorName||"UnsupportedResolverProfile"===t.data?.errorName)))))}const Oi="/docs/contract/encodeErrorResult";function Ri(e){const{abi:t,errorName:n,args:r}=e;let o=t[0];if(n){const e=Zn({abi:t,args:r,name:n});if(!e)throw new et(n,{docsPath:Oi});o=e}if("error"!==o.type)throw new et(void 0,{docsPath:Oi});const s=_e(o),a=Yn(s);let i="0x";if(r&&r.length>0){if(!o.inputs)throw new Xe(o.name,{docsPath:Oi});i=qn(o.inputs,r)}return _n([a,i])}const zi="/docs/contract/encodeFunctionResult";const Mi="x-batch-gateway:true";async function _i(e){const{data:t,ccipRequest:n}=e,{args:[r]}=function(e){const{abi:t,data:n}=e,r=Fn(n,0,4),o=t.find(e=>"function"===e.type&&r===Yn(_e(e)));if(!o)throw new it(r,{docsPath:"/docs/contract/decodeFunctionData"});return{functionName:o.name,args:"inputs"in o&&o.inputs&&o.inputs.length>0?br(o.inputs,Fn(n,4)):void 0}}({abi:Ga,data:t}),o=[],s=[];return await Promise.all(r.map(async(e,t)=>{try{s[t]=e.urls.includes(Mi)?await _i({data:e.data,ccipRequest:n}):await n(e),o[t]=!1}catch(e){o[t]=!0,s[t]="HttpRequestError"===(r=e).name&&r.status?Ri({abi:Ga,errorName:"HttpError",args:[r.status,r.shortMessage]}):Ri({abi:[ir],errorName:"Error",args:["shortMessage"in r?r.shortMessage:r.message]})}var r})),function(e){const{abi:t,functionName:n,result:r}=e;let o=t[0];if(n){const e=Zn({abi:t,name:n});if(!e)throw new st(n,{docsPath:zi});o=e}if("function"!==o.type)throw new st(void 0,{docsPath:zi});if(!o.outputs)throw new at(o.name,{docsPath:zi});const s=(()=>{if(0===o.outputs.length)return[];if(1===o.outputs.length)return[r];if(Array.isArray(r))return r;throw new pt(r)})();return qn(o.outputs,s)}({abi:Ga,functionName:"query",result:[o,s]})}function Fi(e){if(66!==e.length)return null;if(0!==e.indexOf("["))return null;if(65!==e.indexOf("]"))return null;const t=`0x${e.slice(1,65)}`;return je(t)?t:null}function ji(e){let t=new Uint8Array(32).fill(0);if(!e)return Ot(t);const n=e.split(".");for(let e=n.length-1;e>=0;e-=1){const r=Fi(n[e]),o=r?Ft(r):Pn(Dt(n[e]),"bytes");t=Pn(Mn([t,o]),"bytes")}return Ot(t)}function Li(e){return`[${e.slice(2)}]`}function Ui(e){const t=new Uint8Array(32).fill(0);return e?Fi(e)||Pn(Dt(e)):Ot(t)}function Di(e){const t=e.replace(/^\.|\.$/gm,"");if(0===t.length)return new Uint8Array(1);const n=new Uint8Array(Dt(t).byteLength+2);let r=0;const o=t.split(".");for(let e=0;e<o.length;e++){let t=Dt(o[e]);t.byteLength>255&&(t=Dt(Li(Ui(o[e])))),n[r]=t.length,n.set(t,r+1),r+=t.length+1}return n.byteLength!==r+1?n.slice(0,r+1):n}class Gi extends qe{constructor({data:e}){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(e)}`],name:"EnsAvatarInvalidMetadataError"})}}class qi extends qe{constructor({reason:e}){super(`ENS NFT avatar URI is invalid. ${e}`,{name:"EnsAvatarInvalidNftUriError"})}}class Vi extends qe{constructor({uri:e}){super(`Unable to resolve ENS avatar URI "${e}". The URI may be malformed, invalid, or does not respond with a valid image.`,{name:"EnsAvatarUriResolutionError"})}}class Wi extends qe{constructor({namespace:e}){super(`ENS NFT avatar namespace "${e}" is not supported. Must be "erc721" or "erc1155".`,{name:"EnsAvatarUnsupportedNamespaceError"})}}const Hi=/(?<protocol>https?:\/\/[^/]*|ipfs:\/|ipns:\/|ar:\/)?(?<root>\/)?(?<subpath>ipfs\/|ipns\/)?(?<target>[\w\-.]+)(?<subtarget>\/.*)?/,Yi=/^(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>\/.*)?$/,Zi=/^data:([a-zA-Z\-/+]*);base64,([^"].*)/,Ki=/^data:([a-zA-Z\-/+]*)?(;[a-zA-Z0-9].*?)?(,)/;function Ji(e,t){return e?e.endsWith("/")?e.slice(0,-1):e:t}function Qi({uri:e,gatewayUrls:t}){const n=Zi.test(e);if(n)return{uri:e,isOnChain:!0,isEncoded:n};const r=Ji(t?.ipfs,"https://ipfs.io"),o=Ji(t?.arweave,"https://arweave.net"),s=e.match(Hi),{protocol:a,subpath:i,target:c,subtarget:u=""}=s?.groups||{},l="ipns:/"===a||"ipns/"===i,d="ipfs:/"===a||"ipfs/"===i||Yi.test(e);if(e.startsWith("http")&&!l&&!d){let n=e;return t?.arweave&&(n=e.replace(/https:\/\/arweave.net/g,t?.arweave)),{uri:n,isOnChain:!1,isEncoded:!1}}if((l||d)&&c)return{uri:`${r}/${l?"ipns":"ipfs"}/${c}${u}`,isOnChain:!1,isEncoded:!1};if("ar:/"===a&&c)return{uri:`${o}/${c}${u||""}`,isOnChain:!1,isEncoded:!1};let f=e.replace(Ki,"");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 Vi({uri:e})}function Xi(e){if("object"!=typeof e||!("image"in e)&&!("image_url"in e)&&!("image_data"in e))throw new Gi({data:e});return e.image||e.image_url||e.image_data}async function ec({gatewayUrls:e,uri:t}){const{uri:n,isOnChain:r}=Qi({uri:t,gatewayUrls:e});if(r)return n;const o=await async function(e){try{const t=await fetch(e,{method:"HEAD"});if(200===t.status){const e=t.headers.get("content-type");return e?.startsWith("image/")}return!1}catch(t){return("object"!=typeof t||void 0===t.response)&&!!Object.hasOwn(globalThis,"Image")&&new Promise(t=>{const n=new Image;n.onload=()=>{t(!0)},n.onerror=()=>{t(!1)},n.src=e})}}(n);if(o)return n;throw new Vi({uri:t})}async function tc(e,{gatewayUrls:t,record:n}){return/eip155:/i.test(n)?async function(e,{gatewayUrls:t,record:n}){const r=function(e){let t=e;t.startsWith("did:nft:")&&(t=t.replace("did:nft:","").replace(/_/g,"/"));const[n,r,o]=t.split("/"),[s,a]=n.split(":"),[i,c]=r.split(":");if(!s||"eip155"!==s.toLowerCase())throw new qi({reason:"Only EIP-155 supported"});if(!a)throw new qi({reason:"Chain ID not found"});if(!c)throw new qi({reason:"Contract address not found"});if(!o)throw new qi({reason:"Token ID not found"});if(!i)throw new qi({reason:"ERC namespace not found"});return{chainID:Number.parseInt(a,10),namespace:i.toLowerCase(),contractAddress:c,tokenID:o}}(n),o=await async function(e,{nft:t}){if("erc721"===t.namespace)return hi(e,{address:t.contractAddress,abi:[{name:"tokenURI",type:"function",stateMutability:"view",inputs:[{name:"tokenId",type:"uint256"}],outputs:[{name:"",type:"string"}]}],functionName:"tokenURI",args:[BigInt(t.tokenID)]});if("erc1155"===t.namespace)return hi(e,{address:t.contractAddress,abi:[{name:"uri",type:"function",stateMutability:"view",inputs:[{name:"_id",type:"uint256"}],outputs:[{name:"",type:"string"}]}],functionName:"uri",args:[BigInt(t.tokenID)]});throw new Wi({namespace:t.namespace})}(e,{nft:r}),{uri:s,isOnChain:a,isEncoded:i}=Qi({uri:o,gatewayUrls:t});if(a&&(s.includes("data:application/json;base64,")||s.startsWith("{"))){const e=i?atob(s.replace("data:application/json;base64,","")):s;return ec({uri:Xi(JSON.parse(e)),gatewayUrls:t})}let c=r.tokenID;"erc1155"===r.namespace&&(c=c.replace("0x","").padStart(64,"0"));return async function({gatewayUrls:e,uri:t}){try{const n=await fetch(t).then(e=>e.json());return await ec({gatewayUrls:e,uri:Xi(n)})}catch{throw new Vi({uri:t})}}({gatewayUrls:t,uri:s.replace(/(?:0x)?{id}/,c)})}(e,{gatewayUrls:t,record:n}):ec({uri:n,gatewayUrls:t})}async function nc(e,t){const{blockNumber:n,blockTag:r,key:o,name:s,gatewayUrls:a,strict:i}=t,{chain:c}=e,u=(()=>{if(t.universalResolverAddress)return t.universalResolverAddress;if(!c)throw new Error("client chain not configured. universalResolverAddress is required.");return ai({blockNumber:n,chain:c,contract:"ensUniversalResolver"})})(),l=c?.ensTlds;if(l&&!l.some(e=>s.endsWith(e)))return null;try{const t={address:u,abi:Va,args:[Bt(Di(s)),sr({abi:Ha,functionName:"text",args:[ji(s),o]}),a??[Mi]],functionName:"resolveWithGateways",blockNumber:n,blockTag:r},i=Me(e,hi,"readContract"),c=await i(t);if("0x"===c[0])return null;const l=qs({abi:Ha,functionName:"text",data:c[0]});return""===l?null:l}catch(e){if(i)throw e;if(Ci(e))return null;throw e}}async function rc(e,t){const{account:n=e.account,blockNumber:r,blockTag:o="latest",blobs:s,data:a,gas:i,gasPrice:c,maxFeePerBlobGas:u,maxFeePerGas:l,maxPriorityFeePerGas:d,to:f,value:h,...p}=t,m=n?rr(n):void 0;try{Xo(t);const n=("bigint"==typeof r?Rt(r):void 0)||o,g=e.chain?.formatters?.transactionRequest?.format,b=(g||Yo)({...Wo(p,{format:g}),from:m?.address,blobs:s,data:a,gas:i,gasPrice:c,maxFeePerBlobGas:u,maxFeePerGas:l,maxPriorityFeePerGas:d,to:f,value:h}),y=await e.request({method:"eth_createAccessList",params:[b,n]});return{accessList:y.accessList,gasUsed:BigInt(y.gasUsed)}}catch(n){throw ii(n,{...t,account:m,chain:e.chain})}}async function oc(e,{address:t,args:n,event:r,events:o,fromBlock:s,strict:a,toBlock:i}={}){const c=o??(r?[r]:void 0),u=tr(e,{method:"eth_newFilter"});let l=[];if(c){const e=c.flatMap(e=>Xn({abi:[e],eventName:e.name,args:n}));l=[e],r&&(l=l[0])}const d=await e.request({method:"eth_newFilter",params:[{address:t,fromBlock:"bigint"==typeof s?Rt(s):s,toBlock:"bigint"==typeof i?Rt(i):i,...l.length?{topics:l}:{}}]});return{abi:c,args:n,eventName:r?r.name:void 0,fromBlock:s,id:d,request:u(d),strict:Boolean(a),toBlock:i,type:"event"}}async function sc(e){const t=tr(e,{method:"eth_newPendingTransactionFilter"}),n=await e.request({method:"eth_newPendingTransactionFilter"});return{id:n,request:t(n),type:"transaction"}}async function ac(e,{address:t,blockNumber:n,blockTag:r="latest"}){const o=void 0!==n?Rt(n):void 0,s=await e.request({method:"eth_getCode",params:[t,o||r]},{dedupe:Boolean(o)});if("0x"!==s)return s}class ic extends qe{constructor({address:e}){super(`No EIP-712 domain found on contract "${e}".`,{metaMessages:["Ensure that:",`- The contract is deployed at the address "${e}".`,"- `eip712Domain()` function exists on the contract.","- `eip712Domain()` function matches signature to ERC-5267 specification."],name:"Eip712DomainNotFoundError"})}}const cc=[{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 uc(e,{blockCount:t,blockNumber:n,blockTag:r="latest",rewardPercentiles:o}){const s="bigint"==typeof n?Rt(n):void 0;return function(e){return{baseFeePerGas:e.baseFeePerGas.map(e=>BigInt(e)),gasUsedRatio:e.gasUsedRatio,oldestBlock:BigInt(e.oldestBlock),reward:e.reward?.map(e=>e.map(e=>BigInt(e)))}}(await e.request({method:"eth_feeHistory",params:[Rt(t),s||r,o]},{dedupe:Boolean(s)}))}const lc=new Tn(8192);function dc(e,t={}){return async(n,r={})=>{const{dedupe:o=!1,methods:s,retryDelay:a=150,retryCount:i=3,uid:c}={...t,...r},{method:u}=n;if(s?.exclude?.includes(u))throw new so(new Error("method not supported"),{method:u});if(s?.include&&!s.include.includes(u))throw new so(new Error("method not supported"),{method:u});return function(e,{enabled:t=!0,id:n}){if(!t||!n)return e();if(lc.get(n))return lc.get(n);const r=e().finally(()=>lc.delete(n));return lc.set(n,r),r}(()=>Ii(async()=>{try{return await e(n)}catch(e){const t=e;switch(t.code){case Kr.code:throw new Kr(t);case Jr.code:throw new Jr(t);case Qr.code:throw new Qr(t,{method:n.method});case Xr.code:throw new Xr(t);case eo.code:throw new eo(t);case to.code:throw new to(t);case no.code:throw new no(t);case ro.code:throw new ro(t);case oo.code:throw new oo(t);case so.code:throw new so(t,{method:n.method});case ao.code:throw new ao(t);case io.code:throw new io(t);case co.code:throw new co(t);case uo.code:throw new uo(t);case lo.code:throw new lo(t);case fo.code:throw new fo(t);case ho.code:throw new ho(t);case po.code:throw new po(t);case mo.code:throw new mo(t);case go.code:throw new go(t);case bo.code:throw new bo(t);case yo.code:throw new yo(t);case wo.code:throw new wo(t);case vo.code:throw new vo(t);case xo.code:throw new xo(t);case 5e3:throw new co(t);default:if(e instanceof qe)throw e;throw new Eo(t)}}},{delay:({count:e,error:t})=>{if(t&&t instanceof Vr){const e=t?.headers?.get("Retry-After");if(e?.match(/\d/))return 1e3*Number.parseInt(e,10)}return(1<<e)*a},retryCount:i,shouldRetry:({error:e})=>function(e){if("code"in e&&"number"==typeof e.code)return-1===e.code||(e.code===ao.code||e.code===eo.code);if(e instanceof Vr&&e.status)return 403===e.status||(408===e.status||(413===e.status||(429===e.status||(500===e.status||(502===e.status||(503===e.status||504===e.status))))));return!0}(e)}),{enabled:o,id:o?Mt(`${c}.${Pr(n)}`):void 0})}}class fc extends qe{constructor({callbackSelector:e,cause:t,data:n,extraData:r,sender:o,urls:s}){super(t.shortMessage||"An error occurred while fetching for an offchain result.",{cause:t,metaMessages:[...t.metaMessages||[],t.metaMessages?.length?"":[],"Offchain Gateway Call:",s&&[" Gateway URL(s):",...s.map(e=>` ${e}`)],` Sender: ${o}`,` Data: ${n}`,` Callback selector: ${e}`,` Extra data: ${r}`].flat(),name:"OffchainLookupError"})}}class hc extends qe{constructor({result:e,url:t}){super("Offchain gateway response is malformed. Response data must be a hex value.",{metaMessages:[`Gateway URL: ${t}`,`Response: ${Pr(e)}`],name:"OffchainLookupResponseMalformedError"})}}class pc extends qe{constructor({sender:e,to:t}){super("Reverted sender address does not match target contract address (`to`).",{metaMessages:[`Contract address: ${t}`,`OffchainLookup sender address: ${e}`],name:"OffchainLookupSenderMismatchError"})}}const mc={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 gc({data:e,sender:t,urls:n}){let r=new Error("An unknown error occurred.");for(let o=0;o<n.length;o++){const s=n[o],a=s.includes("{data}")?"GET":"POST",i="POST"===a?{data:e,sender:t}:void 0,c="POST"===a?{"Content-Type":"application/json"}:{};try{const n=await fetch(s.replace("{sender}",t.toLowerCase()).replace("{data}",e),{body:JSON.stringify(i),headers:c,method:a});let o;if(o=n.headers.get("Content-Type")?.startsWith("application/json")?(await n.json()).data:await n.text(),!n.ok){r=new Vr({body:i,details:o?.error?Pr(o.error):n.statusText,headers:n.headers,status:n.status,url:s});continue}if(!je(o)){r=new hc({result:o,url:s});continue}return o}catch(e){r=new Vr({body:i,details:e.message,url:s})}}throw r}var bc=Object.freeze({__proto__:null,ccipRequest:gc,offchainLookup:async function(e,{blockNumber:t,blockTag:n,data:r,to:o}){const{args:s}=Er({data:r,abi:[mc]}),[a,i,c,u,l]=s,{ccipRead:d}=e,f=d&&"function"==typeof d?.request?d.request:gc;try{if(!zs(o,a))throw new pc({sender:a,to:o});const r=i.includes(Mi)?await _i({data:c,ccipRequest:f}):await f({data:c,sender:a,urls:i}),{data:s}=await di(e,{blockNumber:t,blockTag:n,data:Mn([u,qn([{type:"bytes"},{type:"bytes"}],[r,l])]),to:o});return s}catch(e){throw new fc({callbackSelector:u,cause:e,data:r,extraData:l,sender:a,urls:i})}},offchainLookupAbiItem:mc,offchainLookupSignature:"0x556f1830"});function yc(){return{current:0,take(){return this.current++},reset(){this.current=0}}}const wc=yc();function vc(e,t={}){return{async request(n){const{body:r,fetchFn:o=t.fetchFn??fetch,onRequest:s=t.onRequest,onResponse:a=t.onResponse,timeout:i=t.timeout??1e4}=n,c={...t.fetchOptions??{},...n.fetchOptions??{}},{headers:u,method:l,signal:d}=c;try{const t=await function(e,{errorInstance:t=new Error("timed out"),timeout:n,signal:r}){return new Promise((o,s)=>{(async()=>{let a;try{const t=new AbortController;n>0&&(a=setTimeout(()=>{r&&t.abort()},n)),o(await e({signal:t?.signal||null}))}catch(e){"AbortError"===e?.name&&s(t),s(e)}finally{clearTimeout(a)}})()})}(async({signal:t})=>{const n={...c,body:Array.isArray(r)?Pr(r.map(e=>({jsonrpc:"2.0",id:e.id??wc.take(),...e}))):Pr({jsonrpc:"2.0",id:r.id??wc.take(),...r}),headers:{"Content-Type":"application/json",...u},method:l||"POST",signal:d||(i>0?t:null)},a=new Request(e,n),f=await(s?.(a,n))??{...n,url:e};return await o(f.url??e,f)},{errorInstance:new Hr({body:r,url:e}),timeout:i,signal:!0});let n;if(a&&await a(t),t.headers.get("Content-Type")?.startsWith("application/json"))n=await t.json();else{n=await t.text();try{n=JSON.parse(n||"{}")}catch(e){if(t.ok)throw e;n={error:n}}}if(!t.ok)throw new Vr({body:r,details:Pr(n.error)||t.statusText,headers:t.headers,status:t.status,url:e});return n}catch(t){if(t instanceof Vr)throw t;if(t instanceof Hr)throw t;throw new Vr({body:r,cause:t,url:e})}}}}function xc(e,t){return Pn(function(e){const t="string"==typeof e?Mt(e):"string"==typeof e.raw?e.raw:Ot(e.raw);return Mn([Mt(`Ethereum Signed Message:\n${Le(t)}`),t])}(e),t)}class Ec extends qe{constructor({domain:e}){super(`Invalid domain "${Pr(e)}".`,{metaMessages:["Must be a valid EIP-712 domain."]})}}class Pc extends qe{constructor({primaryType:e,types:t}){super(`Invalid primary type \`${e}\` must be one of \`${JSON.stringify(Object.keys(t))}\`.`,{docsPath:"/api/glossary/Errors#typeddatainvalidprimarytypeerror",metaMessages:["Check that the primary type is a key in `types`."]})}}class kc extends qe{constructor({type:e}){super(`Struct type "${e}" is invalid.`,{metaMessages:["Struct type must not be a Solidity type."],name:"InvalidStructTypeError"})}}function Ac({domain:e}){return["string"==typeof e?.name&&{name:"name",type:"string"},e?.version&&{name:"version",type:"string"},("number"==typeof e?.chainId||"bigint"==typeof e?.chainId)&&{name:"chainId",type:"uint256"},e?.verifyingContract&&{name:"verifyingContract",type:"address"},e?.salt&&{name:"salt",type:"bytes32"}].filter(Boolean)}function Ic(e){if("address"===e||"bool"===e||"string"===e||e.startsWith("bytes")||e.startsWith("uint")||e.startsWith("int"))throw new kc({type:e})}function Nc(e){const{domain:t={},message:n,primaryType:r}=e,o={EIP712Domain:Ac({domain:t}),...e.types};!function(e){const{domain:t,message:n,primaryType:r,types:o}=e,s=(e,t)=>{for(const n of e){const{name:e,type:r}=n,a=t[e],i=r.match(Gn);if(i&&("number"==typeof a||"bigint"==typeof a)){const[e,t,n]=i;Rt(a,{signed:"int"===t,size:Number.parseInt(n,10)/8})}if("address"===r&&"string"==typeof a&&!zn(a))throw new Sn({address:a});const c=r.match(Dn);if(c){const[e,t]=c;if(t&&Le(a)!==Number.parseInt(t,10))throw new ut({expectedSize:Number.parseInt(t,10),givenSize:Le(a)})}const u=o[r];u&&(Ic(r),s(u,a))}};if(o.EIP712Domain&&t){if("object"!=typeof t)throw new Ec({domain:t});s(o.EIP712Domain,t)}if("EIP712Domain"!==r){if(!o[r])throw new Pc({primaryType:r,types:o});s(o[r],n)}}({domain:t,message:n,primaryType:r,types:o});const s=["0x1901"];return t&&s.push(function({domain:e,types:t}){return Sc({data:e,primaryType:"EIP712Domain",types:t})}({domain:t,types:o})),"EIP712Domain"!==r&&s.push(Sc({data:n,primaryType:r,types:o})),Pn(Mn(s))}function Sc({data:e,primaryType:t,types:n}){return Pn(Tc({data:e,primaryType:t,types:n}))}function Tc({data:e,primaryType:t,types:n}){const r=[{type:"bytes32"}],o=[$c({primaryType:t,types:n})];for(const s of n[t]){const[t,a]=Cc({types:n,name:s.name,type:s.type,value:e[s.name]});r.push(t),o.push(a)}return qn(r,o)}function $c({primaryType:e,types:t}){const n=Bt(function({primaryType:e,types:t}){let n="";const r=Bc({primaryType:e,types:t});r.delete(e);const o=[e,...Array.from(r).sort()];for(const e of o)n+=`${e}(${t[e].map(({name:e,type:t})=>`${t} ${e}`).join(",")})`;return n}({primaryType:e,types:t}));return Pn(n)}function Bc({primaryType:e,types:t},n=new Set){const r=e.match(/^\w*/u),o=r?.[0];if(n.has(o)||void 0===t[o])return n;n.add(o);for(const e of t[o])Bc({primaryType:e.type,types:t},n);return n}function Cc({types:e,name:t,type:n,value:r}){if(void 0!==e[n])return[{type:"bytes32"},Pn(Tc({data:r,primaryType:n,types:e}))];if("bytes"===n){return[{type:"bytes32"},Pn(r=`0x${(r.length%2?"0":"")+r.slice(2)}`)]}if("string"===n)return[{type:"bytes32"},Pn(Bt(r))];if(n.lastIndexOf("]")===n.length-1){const o=n.slice(0,n.lastIndexOf("[")),s=r.map(n=>Cc({name:t,type:o,types:e,value:n}));return[{type:"bytes32"},Pn(qn(s.map(([e])=>e),s.map(([,e])=>e)))]}return[{type:n},r]}class Oc extends Map{constructor(e){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=e}get(e){const t=super.get(e);return super.has(e)&&void 0!==t&&(this.delete(e),super.set(e,t)),t}set(e,t){if(super.set(e,t),this.maxSize&&this.size>this.maxSize){const e=this.keys().next().value;e&&this.delete(e)}return this}}const Rc={checksum:new Oc(8192)}.checksum;function zc(e,t={}){const{as:n=("string"==typeof e?"Hex":"Bytes")}=t,r=En(ia(e));return"Bytes"===n?r:ka(r)}const Mc=/^0x[a-fA-F0-9]{40}$/;function _c(e,t={}){const{strict:n=!0}=t;if(!Mc.test(e))throw new Lc({address:e,cause:new Uc});if(n){if(e.toLowerCase()===e)return;if(Fc(e)!==e)throw new Lc({address:e,cause:new Dc})}}function Fc(e){if(Rc.has(e))return Rc.get(e);_c(e,{strict:!1});const t=e.substring(2).toLowerCase(),n=zc(ua(t),{as:"Bytes"}),r=t.split("");for(let e=0;e<40;e+=2)n[e>>1]>>4>=8&&r[e]&&(r[e]=r[e].toUpperCase()),(15&n[e>>1])>=8&&r[e+1]&&(r[e+1]=r[e+1].toUpperCase());const o=`0x${r.join("")}`;return Rc.set(e,o),o}function jc(e,t={}){const{strict:n=!0}=t??{};try{return _c(e,{strict:n}),!0}catch{return!1}}class Lc extends Vs{constructor({address:e,cause:t}){super(`Address "${e}" is invalid.`,{cause:t}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidAddressError"})}}class Uc extends Vs{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 Dc extends Vs{constructor(){super("Address does not match its checksum counterpart."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidChecksumError"})}}const Gc=/^(.*)\[([0-9]*)\]$/,qc=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,Vc=/^(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)?$/,Wc=2n**256n-1n;function Hc(e,t,n){const{checksumAddress:r,staticPosition:o}=n,s=Qc(t.type);if(s){const[n,a]=s;return function(e,t,n){const{checksumAddress:r,length:o,staticPosition:s}=n;if(!o){const n=s+pa(e.readBytes(Zc)),o=n+Yc;e.setPosition(n);const a=pa(e.readBytes(Yc)),i=Xc(t);let c=0;const u=[];for(let n=0;n<a;++n){e.setPosition(o+(i?32*n:c));const[s,a]=Hc(e,t,{checksumAddress:r,staticPosition:o});c+=a,u.push(s)}return e.setPosition(s+32),[u,32]}if(Xc(t)){const n=s+pa(e.readBytes(Zc)),a=[];for(let s=0;s<o;++s){e.setPosition(n+32*s);const[o]=Hc(e,t,{checksumAddress:r,staticPosition:n});a.push(o)}return e.setPosition(s+32),[a,32]}let a=0;const i=[];for(let n=0;n<o;++n){const[n,o]=Hc(e,t,{checksumAddress:r,staticPosition:s+a});a+=o,i.push(n)}return[i,a]}(e,{...t,type:a},{checksumAddress:r,length:n,staticPosition:o})}if("tuple"===t.type)return function(e,t,n){const{checksumAddress:r,staticPosition:o}=n,s=0===t.components.length||t.components.some(({name:e})=>!e),a=s?[]:{};let i=0;if(Xc(t)){const n=o+pa(e.readBytes(Zc));for(let o=0;o<t.components.length;++o){const c=t.components[o];e.setPosition(n+i);const[u,l]=Hc(e,c,{checksumAddress:r,staticPosition:n});i+=l,a[s?o:c?.name]=u}return e.setPosition(o+32),[a,32]}for(let n=0;n<t.components.length;++n){const c=t.components[n],[u,l]=Hc(e,c,{checksumAddress:r,staticPosition:o});a[s?n:c?.name]=u,i+=l}return[a,i]}(e,t,{checksumAddress:r,staticPosition:o});if("address"===t.type)return function(e,t={}){const{checksum:n=!1}=t,r=e.readBytes(32),o=e=>n?Fc(e):e;return[o(ka(da(r,-20))),32]}(e,{checksum:r});if("bool"===t.type)return function(e){return[ha(e.readBytes(32),{size:32}),32]}(e);if(t.type.startsWith("bytes"))return function(e,t,{staticPosition:n}){const[r,o]=t.type.split("bytes");if(!o){const t=pa(e.readBytes(32));e.setPosition(n+t);const r=pa(e.readBytes(32));if(0===r)return e.setPosition(n+32),["0x",32];const o=e.readBytes(r);return e.setPosition(n+32),[ka(o),32]}const s=ka(e.readBytes(Number.parseInt(o,10),32));return[s,32]}(e,t,{staticPosition:o});if(t.type.startsWith("uint")||t.type.startsWith("int"))return function(e,t){const n=t.type.startsWith("int"),r=Number.parseInt(t.type.split("int")[1]||"256",10),o=e.readBytes(32);return[r>48?fa(o,{signed:n}):pa(o,{signed:n}),32]}(e,t);if("string"===t.type)return function(e,{staticPosition:t}){const n=pa(e.readBytes(32)),r=t+n;e.setPosition(r);const o=pa(e.readBytes(32));if(0===o)return e.setPosition(t+32),["",32];const s=e.readBytes(o,32),a=ma(ga(s));return e.setPosition(t+32),[a,32]}(e,{staticPosition:o});throw new pu(t.type)}const Yc=32,Zc=32;function Kc({checksumAddress:e=!1,parameter:t,value:n}){const r=t,o=Qc(r.type);if(o){const[t,s]=o;return function(e,t){const{checksumAddress:n,length:r,parameter:o}=t,s=null===r;if(!Array.isArray(e))throw new hu(e);if(!s&&e.length!==r)throw new lu({expectedLength:r,givenLength:e.length,type:`${o.type}[${r}]`});let a=!1;const i=[];for(let t=0;t<e.length;t++){const r=Kc({checksumAddress:n,parameter:o,value:e[t]});r.dynamic&&(a=!0),i.push(r)}if(s||a){const e=Jc(i);if(s){const t=Aa(i.length,{size:32});return{dynamic:!0,encoded:i.length>0?Ea(t,e):t}}if(a)return{dynamic:!0,encoded:e}}return{dynamic:!1,encoded:Ea(...i.map(({encoded:e})=>e))}}(n,{checksumAddress:e,length:t,parameter:{...r,type:s}})}if("tuple"===r.type)return function(e,t){const{checksumAddress:n,parameter:r}=t;let o=!1;const s=[];for(let t=0;t<r.components.length;t++){const a=r.components[t],i=Kc({checksumAddress:n,parameter:a,value:e[Array.isArray(e)?t:a.name]});s.push(i),i.dynamic&&(o=!0)}return{dynamic:o,encoded:o?Jc(s):Ea(...s.map(({encoded:e})=>e))}}(n,{checksumAddress:e,parameter:r});if("address"===r.type)return function(e,t){const{checksum:n=!1}=t;return _c(e,{strict:n}),{dynamic:!1,encoded:Na(e.toLowerCase())}}(n,{checksum:e});if("bool"===r.type)return function(e){if("boolean"!=typeof e)throw new Vs(`Invalid boolean value: "${e}" (type: ${typeof e}). Expected: \`true\` or \`false\`.`);return{dynamic:!1,encoded:Na(Pa(e))}}(n);if(r.type.startsWith("uint")||r.type.startsWith("int")){const e=r.type.startsWith("int"),[,,t="256"]=Vc.exec(r.type)??[];return function(e,{signed:t,size:n}){if("number"==typeof n){const r=2n**(BigInt(n)-(t?1n:0n))-1n,o=t?-r-1n:0n;if(e>r||e<o)throw new Ra({max:r.toString(),min:o.toString(),signed:t,size:n/8,value:e.toString()})}return{dynamic:!1,encoded:Aa(e,{size:32,signed:t})}}(n,{signed:e,size:Number(t)})}if(r.type.startsWith("bytes"))return function(e,{type:t}){const[,n]=t.split("bytes"),r=$a(e);if(!n){let t=e;return r%32!=0&&(t=Sa(t,32*Math.ceil((e.length-2)/2/32))),{dynamic:!0,encoded:Ea(Na(Aa(r,{size:32})),t)}}if(r!==Number.parseInt(n,10))throw new du({expectedSize:Number.parseInt(n,10),value:e});return{dynamic:!1,encoded:Sa(e)}}(n,{type:r.type});if("string"===r.type)return function(e){const t=Ia(e),n=Math.ceil($a(t)/32),r=[];for(let e=0;e<n;e++)r.push(Sa(Ta(t,32*e,32*(e+1))));return{dynamic:!0,encoded:Ea(Sa(Aa($a(t),{size:32})),...r)}}(n);throw new pu(r.type)}function Jc(e){let t=0;for(let n=0;n<e.length;n++){const{dynamic:r,encoded:o}=e[n];t+=r?32:$a(o)}const n=[],r=[];let o=0;for(let s=0;s<e.length;s++){const{dynamic:a,encoded:i}=e[s];a?(n.push(Aa(t+o,{size:32})),r.push(i),o+=$a(i)):n.push(i)}return Ea(...n,...r)}function Qc(e){const t=e.match(/^(.*)\[(\d+)?\]$/);return t?[t[2]?Number(t[2]):null,t[1]]:void 0}function Xc(e){const{type:t}=e;if("string"===t)return!0;if("bytes"===t)return!0;if(t.endsWith("[]"))return!0;if("tuple"===t)return e.components?.some(Xc);const n=Qc(e.type);return!(!n||!Xc({...e,type:n[1]}))}const eu={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 ru({count:this.recursiveReadCount+1,limit:this.recursiveReadLimit})},assertPosition(e){if(e<0||e>this.bytes.length-1)throw new nu({length:this.bytes.length,position:e})},decrementPosition(e){if(e<0)throw new tu({offset:e});const t=this.position-e;this.assertPosition(t),this.position=t},getReadCount(e){return this.positionReadCount.get(e||this.position)||0},incrementPosition(e){if(e<0)throw new tu({offset:e});const t=this.position+e;this.assertPosition(t),this.position=t},inspectByte(e){const t=e??this.position;return this.assertPosition(t),this.bytes[t]},inspectBytes(e,t){const n=t??this.position;return this.assertPosition(n+e-1),this.bytes.subarray(n,n+e)},inspectUint8(e){const t=e??this.position;return this.assertPosition(t),this.bytes[t]},inspectUint16(e){const t=e??this.position;return this.assertPosition(t+1),this.dataView.getUint16(t)},inspectUint24(e){const t=e??this.position;return this.assertPosition(t+2),(this.dataView.getUint16(t)<<8)+this.dataView.getUint8(t+2)},inspectUint32(e){const t=e??this.position;return this.assertPosition(t+3),this.dataView.getUint32(t)},pushByte(e){this.assertPosition(this.position),this.bytes[this.position]=e,this.position++},pushBytes(e){this.assertPosition(this.position+e.length-1),this.bytes.set(e,this.position),this.position+=e.length},pushUint8(e){this.assertPosition(this.position),this.bytes[this.position]=e,this.position++},pushUint16(e){this.assertPosition(this.position+1),this.dataView.setUint16(this.position,e),this.position+=2},pushUint24(e){this.assertPosition(this.position+2),this.dataView.setUint16(this.position,e>>8),this.dataView.setUint8(this.position+2,255&e),this.position+=3},pushUint32(e){this.assertPosition(this.position+3),this.dataView.setUint32(this.position,e),this.position+=4},readByte(){this.assertReadLimit(),this._touch();const e=this.inspectByte();return this.position++,e},readBytes(e,t){this.assertReadLimit(),this._touch();const n=this.inspectBytes(e);return this.position+=t??e,n},readUint8(){this.assertReadLimit(),this._touch();const e=this.inspectUint8();return this.position+=1,e},readUint16(){this.assertReadLimit(),this._touch();const e=this.inspectUint16();return this.position+=2,e},readUint24(){this.assertReadLimit(),this._touch();const e=this.inspectUint24();return this.position+=3,e},readUint32(){this.assertReadLimit(),this._touch();const e=this.inspectUint32();return this.position+=4,e},get remaining(){return this.bytes.length-this.position},setPosition(e){const t=this.position;return this.assertPosition(e),this.position=e,()=>this.position=t},_touch(){if(this.recursiveReadLimit===Number.POSITIVE_INFINITY)return;const e=this.getReadCount();this.positionReadCount.set(this.position,e+1),e>0&&this.recursiveReadCount++}};class tu extends Vs{constructor({offset:e}){super(`Offset \`${e}\` cannot be negative.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Cursor.NegativeOffsetError"})}}class nu extends Vs{constructor({length:e,position:t}){super(`Position \`${t}\` is out of bounds (\`0 < position < ${e}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Cursor.PositionOutOfBoundsError"})}}class ru extends Vs{constructor({count:e,limit:t}){super(`Recursive read limit of \`${t}\` exceeded (recursive read count: \`${e}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Cursor.RecursiveReadLimitExceededError"})}}function ou(e,t,n={}){const{as:r="Array",checksumAddress:o=!1}=n,s="string"==typeof t?ca(t):t,a=function(e,{recursiveReadLimit:t=8192}={}){const n=Object.create(eu);return n.bytes=e,n.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength),n.positionReadCount=new Map,n.recursiveReadLimit=t,n}(s);if(0===la(s)&&e.length>0)throw new uu;if(la(s)&&la(s)<32)throw new cu({data:"string"==typeof t?t:ka(t),parameters:e,size:la(s)});let i=0;const c="Array"===r?[]:{};for(let t=0;t<e.length;++t){const n=e[t];a.setPosition(i);const[s,u]=Hc(a,n,{checksumAddress:o,staticPosition:0});i+=u,"Array"===r?c.push(s):c[n.name??t]=s}return c}function su(e,t,n){const{checksumAddress:r=!1}={};if(e.length!==t.length)throw new fu({expectedLength:e.length,givenLength:t.length});const o=function({checksumAddress:e,parameters:t,values:n}){const r=[];for(let o=0;o<t.length;o++)r.push(Kc({checksumAddress:e,parameter:t[o],value:n[o]}));return r}({checksumAddress:r,parameters:e,values:t}),s=Jc(o);return 0===s.length?"0x":s}function au(e,t){if(e.length!==t.length)throw new fu({expectedLength:e.length,givenLength:t.length});const n=[];for(let r=0;r<e.length;r++){const o=e[r],s=t[r];n.push(au.encode(o,s))}return Ea(...n)}function iu(e){return Array.isArray(e)&&"string"==typeof e[0]||"string"==typeof e?ze(e):e}!function(e){e.encode=function e(t,n,r=!1){if("address"===t){const e=n;return _c(e),Na(e.toLowerCase(),r?32:0)}if("string"===t)return Ia(n);if("bytes"===t)return n;if("bool"===t)return Na(Pa(n),r?32:1);const o=t.match(Vc);if(o){const[e,t,s="256"]=o,a=Number.parseInt(s,10)/8;return Aa(n,{size:r?32:a,signed:"int"===t})}const s=t.match(qc);if(s){const[e,t]=s;if(Number.parseInt(t,10)!==(n.length-2)/2)throw new du({expectedSize:Number.parseInt(t,10),value:n});return Sa(n,r?32:0)}const a=t.match(Gc);if(a&&Array.isArray(n)){const[t,r]=a,o=[];for(let t=0;t<n.length;t++)o.push(e(r,n[t],!0));return 0===o.length?"0x":Ea(...o)}throw new pu(t)}}(au||(au={}));class cu extends Vs{constructor({data:e,parameters:t,size:n}){super(`Data size of ${n} bytes is too small for given parameters.`,{metaMessages:[`Params: (${H(t)})`,`Data: ${e} (${n} bytes)`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.DataSizeTooSmallError"})}}class uu extends Vs{constructor(){super('Cannot decode zero data ("0x") with ABI parameters.'),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.ZeroDataError"})}}class lu extends Vs{constructor({expectedLength:e,givenLength:t,type:n}){super(`Array length mismatch for type \`${n}\`. Expected: \`${e}\`. Given: \`${t}\`.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.ArrayLengthMismatchError"})}}class du extends Vs{constructor({expectedSize:e,value:t}){super(`Size of bytes "${t}" (bytes${$a(t)}) does not match expected size (bytes${e}).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.BytesSizeMismatchError"})}}class fu extends Vs{constructor({expectedLength:e,givenLength:t}){super(["ABI encoding parameters/values length mismatch.",`Expected length (parameters): ${e}`,`Given length (values): ${t}`].join("\n")),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.LengthMismatchError"})}}class hu extends Vs{constructor(e){super(`Value \`${e}\` is not a valid array.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.InvalidArrayError"})}}class pu extends Vs{constructor(e){super(`Type \`${e}\` is not a valid ABI Type.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.InvalidTypeError"})}}class mu extends rn{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,function(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.createHasher");Ht(e.outputLen),Ht(e.blockLen)}(e);const n=nn(t);if(this.iHash=e.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,o=new Uint8Array(r);o.set(n.length>r?e.create().update(n).digest():n);for(let e=0;e<o.length;e++)o[e]^=54;this.iHash.update(o),this.oHash=e.create();for(let e=0;e<o.length;e++)o[e]^=106;this.oHash.update(o),Jt(o)}update(e){return Zt(this),this.iHash.update(e),this}digestInto(e){Zt(this),Yt(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:n,finished:r,destroyed:o,blockLen:s,outputLen:a}=this;return e.finished=r,e.destroyed=o,e.blockLen=s,e.outputLen=a,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const gu=(e,t,n)=>new mu(e,t).update(n).digest();function bu(e,t={}){const{recovered:n}=t;if(void 0===e.r)throw new Eu({signature:e});if(void 0===e.s)throw new Eu({signature:e});if(n&&void 0===e.yParity)throw new Eu({signature:e});if(e.r<0n||e.r>Wc)throw new Pu({value:e.r});if(e.s<0n||e.s>Wc)throw new ku({value:e.s});if("number"==typeof e.yParity&&0!==e.yParity&&1!==e.yParity)throw new Au({value:e.yParity})}function yu(e){if(130!==e.length&&132!==e.length)throw new xu({signature:e});const t=BigInt(Ta(e,0,32)),n=BigInt(Ta(e,32,64)),r=(()=>{const t=Number(`0x${e.slice(130)}`);if(!Number.isNaN(t))try{return vu(t)}catch{throw new Au({value:t})}})();return void 0===r?{r:t,s:n}:{r:t,s:n,yParity:r}}function wu(e){if(void 0!==e.r&&void 0!==e.s)return function(e){const t="string"==typeof e?yu(e):e instanceof Uint8Array?function(e){return yu(ka(e))}(e):"string"==typeof e.r?function(e){const t=(()=>{const t=e.v?Number(e.v):void 0;let n=e.yParity?Number(e.yParity):void 0;if("number"==typeof t&&"number"!=typeof n&&(n=vu(t)),"number"!=typeof n)throw new Au({value:e.yParity});return n})();return{r:BigInt(e.r),s:BigInt(e.s),yParity:t}}(e):e.v?function(e){return{r:e.r,s:e.s,yParity:vu(e.v)}}(e):{r:e.r,s:e.s,...void 0!==e.yParity?{yParity:e.yParity}:{}};return bu(t),t}(e)}function vu(e){if(0===e||27===e)return 0;if(1===e||28===e)return 1;if(e>=35)return e%2==0?1:0;throw new Iu({value:e})}gu.create=(e,t)=>new mu(e,t);class xu extends Vs{constructor({signature:e}){var t;super(`Value \`${e}\` is an invalid signature size.`,{metaMessages:["Expected: 64 bytes or 65 bytes.",`Received ${$a((t=e,t instanceof Uint8Array?ka(t):Array.isArray(t)?ka(new Uint8Array(t)):t))} bytes.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidSerializedSizeError"})}}class Eu extends Vs{constructor({signature:e}){super(`Signature \`${oa(e)}\` is missing either an \`r\`, \`s\`, or \`yParity\` property.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.MissingPropertiesError"})}}class Pu extends Vs{constructor({value:e}){super(`Value \`${e}\` is an invalid r value. r must be a positive integer less than 2^256.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidRError"})}}class ku extends Vs{constructor({value:e}){super(`Value \`${e}\` is an invalid s value. s must be a positive integer less than 2^256.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidSError"})}}class Au extends Vs{constructor({value:e}){super(`Value \`${e}\` is an invalid y-parity value. Y-parity must be 0 or 1.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidYParityError"})}}class Iu extends Vs{constructor({value:e}){super(`Value \`${e}\` is an invalid v value. v must be 27, 28 or >=35.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Signature.InvalidVError"})}}function Nu(e,t={}){return"string"==typeof e.chainId?function(e){const{address:t,chainId:n,nonce:r}=e,o=wu(e);return{address:t,chainId:Number(n),nonce:BigInt(r),...o}}(e):{...e,...t.signature}}const Su=iu("(uint256 chainId, address delegation, uint256 nonce, uint8 yParity, uint256 r, uint256 s), address to, bytes data");function Tu(e){if("string"==typeof e){if("0x8010801080108010801080108010801080108010801080108010801080108010"!==Ta(e,-32))throw new $u(e)}else bu(e.authorization)}let $u=class extends Vs{constructor(e){super(`Value \`${e}\` is an invalid ERC-8010 wrapped signature.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"SignatureErc8010.InvalidWrappedSignatureError"})}};async function Bu(e,{address:t,blockNumber:n,blockTag:r,storageKeys:o}){const s=r??"latest",a=void 0!==n?Rt(n):void 0;return function(e){return{...e,balance:e.balance?BigInt(e.balance):void 0,nonce:e.nonce?Tt(e.nonce):void 0,storageProof:e.storageProof?(t=e.storageProof,t.map(e=>({...e,value:BigInt(e.value)}))):void 0};var t}(await e.request({method:"eth_getProof",params:[t,o,a||s]}))}async function Cu(e,{blockHash:t,blockNumber:n,blockTag:r,hash:o,index:s}){const a=r||"latest",i=void 0!==n?Rt(n):void 0;let c=null;if(c=o?await e.request({method:"eth_getTransactionByHash",params:[o]},{dedupe:!0}):t?await e.request({method:"eth_getTransactionByBlockHashAndIndex",params:[t,Rt(s)]},{dedupe:!0}):await e.request({method:"eth_getTransactionByBlockNumberAndIndex",params:[i||a,Rt(s)]},{dedupe:Boolean(i)}),!c)throw new Mr({blockHash:t,blockNumber:n,blockTag:a,hash:o,index:s});return(e.chain?.formatters?.transaction?.format||ss)(c)}async function Ou(e,{hash:t}){const n=await e.request({method:"eth_getTransactionReceipt",params:[t]},{dedupe:!0});if(!n)throw new _r({hash:t});return(e.chain?.formatters?.transactionReceipt?.format||Si)(n)}async function Ru(e,t){const{blockNumber:n,blockTag:r=e.experimental_blockTag??"latest",blocks:o,returnFullTransactions:s,traceTransfers:a,validation:i}=t;try{const t=[];for(const e of o){const n=e.blockOverrides?Ua(e.blockOverrides):void 0,r=e.calls.map(e=>{const t=e,n=t.account?rr(t.account):void 0,r=t.abi?sr(t):t.data,o={...t,data:t.dataSuffix?Mn([r||"0x",t.dataSuffix]):r,from:t.from??n?.address};return Xo(o),Yo(o)}),o=e.stateOverrides?Jo(e.stateOverrides):void 0;t.push({blockOverrides:n,calls:r,stateOverrides:o})}const c=("bigint"==typeof n?Rt(n):void 0)||r;return(await e.request({method:"eth_simulateV1",params:[{blockStateCalls:t,returnFullTransactions:s,traceTransfers:a,validation:i},c]})).map((e,t)=>({...as(e),calls:e.calls.map((e,n)=>{const{abi:r,args:s,functionName:a,to:i}=o[t].calls[n],c=e.error?.data??e.returnData,u=BigInt(e.gasUsed),l=e.logs?.map(e=>Ls(e)),d="0x1"===e.status?"success":"failure",f=r&&"success"===d&&"0x"!==c?qs({abi:r,data:c,functionName:a}):null,h=(()=>{if("success"===d)return;let t;return"0x"===e.error?.data?t=new Ze:e.error&&(t=new qr(e.error)),t?ko(t,{abi:r??[],address:i??"0x",args:s,functionName:a??"<unknown>"}):void 0})();return{data:c,gasUsed:u,logs:l,status:d,..."success"===d?{result:f}:{error:h}}})}))}catch(e){const t=e,n=Vo(t,{});if(n instanceof qo)throw t;throw n}}function zu(e){let t=!0,n="",r=0,o="",s=!1;for(let a=0;a<e.length;a++){const i=e[a];if(["(",")",","].includes(i)&&(t=!0),"("===i&&r++,")"===i&&r--,t)if(0!==r)" "!==i?(o+=i,n+=i):","!==e[a-1]&&","!==n&&",("!==n&&(n="",t=!1);else if(" "===i&&["event","function","error",""].includes(o))o="";else if(o+=i,")"===i){s=!0;break}}if(!s)throw new Vs("Unable to normalize signature.");return o}function Mu(e,t){const n=typeof e,r=t.type;switch(r){case"address":return jc(e,{strict:!1});case"bool":return"boolean"===n;case"function":case"string":return"string"===n;default:return"tuple"===r&&"components"in t?Object.values(t.components).every((t,n)=>Mu(Object.values(e)[n],t)):/^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||e instanceof Uint8Array:!!/[a-z]+[1-9]{0,3}(\[[0-9]{0,}\])+$/.test(r)&&(Array.isArray(e)&&e.every(e=>Mu(e,{...t,type:r.replace(/(\[[0-9]{0,}\])$/,"")})))}}function _u(e,t,n){for(const r in e){const o=e[r],s=t[r];if("tuple"===o.type&&"tuple"===s.type&&"components"in o&&"components"in s)return _u(o.components,s.components,n[r]);const a=[o.type,s.type];if((()=>!(!a.includes("address")||!a.includes("bytes20"))||(a.includes("address")&&a.includes("string")||!(!a.includes("address")||!a.includes("bytes")))&&jc(n[r],{strict:!1}))())return a}}function Fu(e,t={}){const{prepare:n=!0}=t,r=Array.isArray(e)||"string"==typeof e?Re(e):e;return{...r,...n?{hash:Uu(r)}:{}}}function ju(e,t,n){const{args:r=[],prepare:o=!0}=n??{},s=Oa(t,{strict:!1}),a=e.filter(e=>s?"function"===e.type||"error"===e.type?Lu(e)===Ta(t,0,4):"event"===e.type&&Uu(e)===t:"name"in e&&e.name===t);if(0===a.length)throw new Gu({name:t});if(1===a.length)return{...a[0],...o?{hash:Uu(a[0])}:{}};let i;for(const e of a){if(!("inputs"in e))continue;if(!r||0===r.length){if(!e.inputs||0===e.inputs.length)return{...e,...o?{hash:Uu(e)}:{}};continue}if(!e.inputs)continue;if(0===e.inputs.length)continue;if(e.inputs.length!==r.length)continue;const t=r.every((t,n)=>{const r="inputs"in e&&e.inputs[n];return!!r&&Mu(t,r)});if(t){if(i&&"inputs"in i&&i.inputs){const t=_u(e.inputs,i.inputs,r);if(t)throw new Du({abiItem:e,type:t[0]},{abiItem:i,type:t[1]})}i=e}}const c=(()=>{if(i)return i;const[e,...t]=a;return{...e,overloads:t}})();if(!c)throw new Gu({name:t});return{...c,...o?{hash:Uu(c)}:{}}}function Lu(...e){const t=(()=>{if(Array.isArray(e[0])){const[t,n]=e;return ju(t,n)}return e[0]})();return Ta(Uu(t),0,4)}function Uu(...e){const t=(()=>{if(Array.isArray(e[0])){const[t,n]=e;return ju(t,n)}return e[0]})();return"string"!=typeof t&&"hash"in t&&t.hash?t.hash:zc(Ia(function(...e){const t=(()=>{if(Array.isArray(e[0])){const[t,n]=e;return ju(t,n)}return e[0]})();return zu("string"==typeof t?t:Y(t))}(t)))}class Du extends Vs{constructor(e,t){super("Found ambiguous types in overloaded ABI Items.",{metaMessages:[`\`${e.type}\` in \`${zu(Y(e.abiItem))}\`, and`,`\`${t.type}\` in \`${zu(Y(t.abiItem))}\``,"","These types encode differently and cannot be distinguished at runtime.","Remove one of the ambiguous items in the ABI."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiItem.AmbiguityError"})}}class Gu extends Vs{constructor({name:e,data:t,type:n="item"}){super(`ABI ${n}${e?` with name "${e}"`:t?` with data "${t}"`:""} not found.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiItem.NotFoundError"})}}function qu(e){const t=e.find(e=>"constructor"===e.type);if(!t)throw new Gu({name:"constructor"});return t}function Vu(...e){const[t,n=[]]=(()=>{if(Array.isArray(e[0])){const[t,n,r]=e;return[Hu(t,n,{args:r}),r]}const[t,n]=e;return[t,n]})(),{overloads:r}=t,o=r?Hu([t,...r],t.name,{args:n}):t,s=Lu(o);const a=n.length>0?su(o.inputs,n):void 0;return a?Ea(s,a):s}function Wu(e,t={}){return Fu(e,t)}function Hu(e,t,n){const r=ju(e,t,n);if("function"!==r.type)throw new Gu({name:t,type:"function"});return r}const Yu="0x0000000000000000000000000000000000000000";async function Zu(e,t){const{blockNumber:n,blockTag:r,calls:o,stateOverrides:s,traceAssetChanges:a,traceTransfers:i,validation:c}=t,u=t.account?rr(t.account):void 0;if(a&&!u)throw new qe("`account` is required when `traceAssetChanges` is true");const l=u?function(...e){const[t,n]=(()=>{if(Array.isArray(e[0])){const[t,n]=e;return[qu(t),n]}return e})(),{bytecode:r,args:o}=n;return Ea(r,t.inputs?.length&&o?.length?su(t.inputs,o):"0x")}(Fu("constructor(bytes, bytes)"),{bytecode:Qa,args:["0x6080604052348015600e575f80fd5b5061016d8061001c5f395ff3fe608060405234801561000f575f80fd5b5060043610610029575f3560e01c8063f8b2cb4f1461002d575b5f80fd5b610047600480360381019061004291906100db565b61005d565b604051610054919061011e565b60405180910390f35b5f8173ffffffffffffffffffffffffffffffffffffffff16319050919050565b5f80fd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6100aa82610081565b9050919050565b6100ba816100a0565b81146100c4575f80fd5b50565b5f813590506100d5816100b1565b92915050565b5f602082840312156100f0576100ef61007d565b5b5f6100fd848285016100c7565b91505092915050565b5f819050919050565b61011881610106565b82525050565b5f6020820190506101315f83018461010f565b9291505056fea26469706673582212203b9fe929fe995c7cf9887f0bdba8a36dd78e8b73f149b17d2d9ad7cd09d2dc6264736f6c634300081a0033",Vu(Wu("function getBalance(address)"),[u.address])]}):void 0;const d=a?await Promise.all(t.calls.map(async t=>{if(!t.data&&!t.abi)return;const{accessList:n}=await rc(e,{account:u.address,...t,data:t.abi?sr(t):t.data});return n.map(({address:e,storageKeys:t})=>t.length>0?e:null)})).then(e=>e.flat().filter(Boolean)):[],f=await Ru(e,{blockNumber:n,blockTag:r,blocks:[...a?[{calls:[{data:l}],stateOverrides:s},{calls:d.map((e,t)=>({abi:[Wu("function balanceOf(address) returns (uint256)")],functionName:"balanceOf",args:[u.address],to:e,from:Yu,nonce:t})),stateOverrides:[{address:Yu,nonce:0}]}]:[],{calls:[...o,{}].map(e=>({...e,from:u?.address})),stateOverrides:s},...a?[{calls:[{data:l}]},{calls:d.map((e,t)=>({abi:[Wu("function balanceOf(address) returns (uint256)")],functionName:"balanceOf",args:[u.address],to:e,from:Yu,nonce:t})),stateOverrides:[{address:Yu,nonce:0}]},{calls:d.map((e,t)=>({to:e,abi:[Wu("function decimals() returns (uint256)")],functionName:"decimals",from:Yu,nonce:t})),stateOverrides:[{address:Yu,nonce:0}]},{calls:d.map((e,t)=>({to:e,abi:[Wu("function tokenURI(uint256) returns (string)")],functionName:"tokenURI",args:[0n],from:Yu,nonce:t})),stateOverrides:[{address:Yu,nonce:0}]},{calls:d.map((e,t)=>({to:e,abi:[Wu("function symbol() returns (string)")],functionName:"symbol",from:Yu,nonce:t})),stateOverrides:[{address:Yu,nonce:0}]}]:[]],traceTransfers:i,validation:c}),h=a?f[2]:f[0],[p,m,,g,b,y,w,v]=a?f:[],{calls:x,...E}=h,P=x.slice(0,-1)??[],k=[...p?.calls??[],...m?.calls??[]].map(e=>"success"===e.status?St(e.data):null),A=[...g?.calls??[],...b?.calls??[]].map(e=>"success"===e.status?St(e.data):null),I=(y?.calls??[]).map(e=>"success"===e.status?e.result:null),N=(v?.calls??[]).map(e=>"success"===e.status?e.result:null),S=(w?.calls??[]).map(e=>"success"===e.status?e.result:null),T=[];for(const[e,t]of A.entries()){const n=k[e];if("bigint"!=typeof t)continue;if("bigint"!=typeof n)continue;const r=I[e-1],o=N[e-1],s=S[e-1],a=(()=>0===e?{address:"0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",decimals:18,symbol:"ETH"}:{address:d[e-1],decimals:s||r?Number(r??1):void 0,symbol:o??void 0})();T.some(e=>e.token.address===a.address)||T.push({token:a,value:{pre:n,post:t,diff:t-n}})}return{assetChanges:T,block:E,results:P}}const Ku="0x6492649264926492649264926492649264926492649264926492649264926492";function Ju(e){try{return function(e){if(Ta(e,-32)!==Ku)throw new Qu(e)}(e),!0}catch{return!1}}class Qu extends Vs{constructor(e){super(`Value \`${e}\` is an invalid ERC-6492 wrapped signature.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"SignatureErc6492.InvalidWrappedSignatureError"})}}
|
|
4
4
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Xu=BigInt(0),el=BigInt(1);function tl(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function nl(e){if(!tl(e))throw new Error("Uint8Array expected")}function rl(e,t){if("boolean"!=typeof t)throw new Error(e+" boolean expected, got "+t)}function ol(e){const t=e.toString(16);return 1&t.length?"0"+t:t}function sl(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);return""===e?Xu:BigInt("0x"+e)}const al="function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex,il=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function cl(e){if(nl(e),al)return e.toHex();let t="";for(let n=0;n<e.length;n++)t+=il[e[n]];return t}const ul=48,ll=57,dl=65,fl=70,hl=97,pl=102;function ml(e){return e>=ul&&e<=ll?e-ul:e>=dl&&e<=fl?e-(dl-10):e>=hl&&e<=pl?e-(hl-10):void 0}function gl(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);if(al)return Uint8Array.fromHex(e);const t=e.length,n=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const r=new Uint8Array(n);for(let t=0,o=0;t<n;t++,o+=2){const n=ml(e.charCodeAt(o)),s=ml(e.charCodeAt(o+1));if(void 0===n||void 0===s){const t=e[o]+e[o+1];throw new Error('hex string expected, got non-hex character "'+t+'" at index '+o)}r[t]=16*n+s}return r}function bl(e){return sl(cl(e))}function yl(e){return nl(e),sl(cl(Uint8Array.from(e).reverse()))}function wl(e,t){return gl(e.toString(16).padStart(2*t,"0"))}function vl(e,t){return wl(e,t).reverse()}function xl(e,t,n){let r;if("string"==typeof t)try{r=gl(t)}catch(t){throw new Error(e+" must be hex string or Uint8Array, cause: "+t)}else{if(!tl(t))throw new Error(e+" must be hex string or Uint8Array");r=Uint8Array.from(t)}const o=r.length;if("number"==typeof n&&o!==n)throw new Error(e+" of length "+n+" expected, got "+o);return r}function El(...e){let t=0;for(let n=0;n<e.length;n++){const r=e[n];nl(r),t+=r.length}const n=new Uint8Array(t);for(let t=0,r=0;t<e.length;t++){const o=e[t];n.set(o,r),r+=o.length}return n}const Pl=e=>"bigint"==typeof e&&Xu<=e;function kl(e,t,n){return Pl(e)&&Pl(t)&&Pl(n)&&t<=e&&e<n}function Al(e,t,n,r){if(!kl(t,n,r))throw new Error("expected valid "+e+": "+n+" <= n < "+r+", got "+t)}const Il=e=>(el<<BigInt(e))-el,Nl=e=>new Uint8Array(e),Sl=e=>Uint8Array.from(e);const Tl={bigint:e=>"bigint"==typeof e,function:e=>"function"==typeof e,boolean:e=>"boolean"==typeof e,string:e=>"string"==typeof e,stringOrUint8Array:e=>"string"==typeof e||tl(e),isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>"function"==typeof e&&Number.isSafeInteger(e.outputLen)};function $l(e,t,n={}){const r=(t,n,r)=>{const o=Tl[n];if("function"!=typeof o)throw new Error("invalid validator function");const s=e[t];if(!(r&&void 0===s||o(s,e)))throw new Error("param "+String(t)+" is invalid. Expected "+n+", got "+s)};for(const[e,n]of Object.entries(t))r(e,n,!1);for(const[e,t]of Object.entries(n))r(e,t,!0);return e}function Bl(e){const t=new WeakMap;return(n,...r)=>{const o=t.get(n);if(void 0!==o)return o;const s=e(n,...r);return t.set(n,s),s}}
|
|
@@ -292,5 +292,5 @@ const vd=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffff
|
|
|
292
292
|
color: ${ng.colors.text.tertiary};
|
|
293
293
|
text-align: center;
|
|
294
294
|
margin-top: ${ng.spacing.lg};
|
|
295
|
-
`;async function $g(e){const t=e.toLowerCase(),n=r.v4(),o=await async function(e){const t=new TextEncoder,n=t.encode(e),r=await crypto.subtle.digest("SHA-256",n),o=Array.from(new Uint8Array(r));return btoa(String.fromCharCode(...o)).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}(n);return sessionStorage.setItem(`${t}_oauthCodeVerifier`,JSON.stringify({code_verifier:n,code_challenge:o,timestamp:Date.now()})),{codeVerifier:n,codeChallenge:o}}const Bg=()=>{if("undefined"!=typeof document&&document.getElementById("superstack-wallet-styles"))return;if("undefined"==typeof document)return;const e=document.createElement("link");e.id="superstack-wallet-fonts",e.rel="stylesheet",e.href="https://fonts.googleapis.com/css2?family=Montserrat:wght@300;400;500;600;700&display=swap",document.head.appendChild(e);const t=document.createElement("style");t.id="superstack-wallet-styles",t.textContent=`\n /* 只影响嵌入钱包模态框 */\n #embedded-wallet-modal {\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n z-index: 9999;\n display: flex;\n align-items: center;\n justify-content: center;\n background-color: rgba(0, 0, 0, 0.5);\n }\n \n /* 以下类选择器都只对SDK自己的元素生效 */\n .superstack-wallet-container {\n font-family: 'Montserrat', sans-serif;\n color: ${ng.colors.text.primary};\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n }\n \n /* 直接选择SDK组件,而不是使用通配符 */\n .superstack-wallet-container h1,\n .superstack-wallet-container h2,\n .superstack-wallet-container h3,\n .superstack-wallet-container h4,\n .superstack-wallet-container h5,\n .superstack-wallet-container h6 {\n font-family: 'Montserrat', sans-serif;\n font-weight: ${ng.typography.fontWeights.semibold};\n line-height: 1.2;\n margin-bottom: ${ng.spacing.md};\n }\n \n .superstack-wallet-container p {\n font-family: 'Montserrat', sans-serif;\n margin-bottom: ${ng.spacing.md};\n }\n \n /* 为SDK定义的按钮添加类名 */\n .superstack-wallet-btn {\n font-family: 'Montserrat', sans-serif;\n cursor: pointer;\n }\n \n /* 为SDK定义的输入域添加类名 */\n .superstack-wallet-input {\n font-family: 'Montserrat', sans-serif;\n }\n \n /* 模态内容应该有自己的样式,不影响外部 */\n #embedded-wallet-modal .modal-content {\n background-color: ${ng.colors.background.main};\n border-radius: ${ng.borderRadius.md};\n padding: ${ng.spacing.lg};\n box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);\n max-width: 480px;\n width: 100%;\n }\n `,document.head.appendChild(t)};var Cg=Object.freeze({__proto__:null,injectStyles:Bg,theme:ng});function Og({client:e,isOpen:t,onClose:n,onLogin:s,isLoading:a=!1}){const[i,c]=o.useState(""),[u,l]=o.useState(""),[d,f]=o.useState(!1),[h,p]=o.useState(!1),[g,b]=o.useState(["","","","","",""]),[y,w]=o.useState(!1),[v,x]=o.useState(!1),[E,P]=o.useState(!1),k=o.useMemo(()=>Array(6).fill(null).map(()=>o.createRef()),[]),A=e=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e),I=e=>/^\+[1-9]\d{1,3}\d{6,14}$/.test(e);return o.useEffect(()=>{g.forEach((e,t)=>{if(k[t]&&k[t].current){const n=k[t].current;n&&e&&(n.style.fontSize=ng.typography.fontSizes.xl)}})},[g,k]),{email:i,setEmail:c,emailSent:h,setEmailSent:p,sendingCode:y,setVerificationCode:b,verificationCode:g,verifyingCode:v,connectingPhantom:E,inputRefs:k,handleCodeChange:(e,t)=>{var n,r,o;if(t.length<=1){const r=[...g];r[e]=t,b(r),t&&e<5&&(null===(n=k[e+1].current)||void 0===n||n.focus())}else if(t.length>1){const e=t.replace(/\D/g,"").slice(0,6).split(""),n=[...Array(6).fill("")];e.forEach((e,t)=>{t<6&&(n[t]=e)}),b(n);const s=n.findIndex(e=>""===e);-1!==s?null===(r=k[s].current)||void 0===r||r.focus():n[5]&&(null===(o=k[5].current)||void 0===o||o.focus())}},handleKeyDown:(e,t)=>{var n;"Backspace"===t.key&&!g[e]&&e>0&&(null===(n=k[e-1].current)||void 0===n||n.focus())},handleContainerPaste:e=>{var t,n;e.preventDefault();const r=e.clipboardData.getData("text").replace(/\D/g,"").slice(0,6).split(""),o=[...Array(6).fill("")];r.forEach((e,t)=>{t<6&&(o[t]=e)}),b(o);const s=o.findIndex(e=>""===e);-1!==s?null===(t=k[s].current)||void 0===t||t.focus():o[5]&&(null===(n=k[5].current)||void 0===n||n.focus())},handleSendVerificationCode:async(t=i)=>{try{if(!A(t))return void alert("Please enter a valid email address");w(!0),await e.sendEmailVerificationCode(t),p(!0)}catch(e){alert("Failed to send verification code"),console.error("Failed to send verification code",e)}finally{w(!1)}},handleCodeSubmit:async(t=g.join(""),r=i)=>{try{if(6!==t.length)return void alert("Please enter a valid verification code");x(!0);const o=await e.verifyEmailVerificationCode({email:r,code:t});o&&(null==s||s(o),null==n||n())}catch(e){alert("Failed to verify code"),console.error("Failed to verify code",e)}finally{x(!1)}},handlePhoneCodeSubmit:async(t=g.join(""),r=u)=>{try{if(6!==t.length)return void alert("Please enter a valid verification code");x(!0);const o=await e.verifyPhoneVerificationCode({phone:r,code:t});o&&(null==s||s(o),null==n||n())}catch(e){alert("Failed to verify code"),console.error("Failed to verify code",e)}finally{x(!1)}},handleSendPhoneVerificationCode:async(t=u)=>{try{if(!I(t))return void alert("Please enter a valid phone number");await e.sendPhoneVerificationCode(t),f(!0)}catch(e){alert("Failed to send verification code"),console.error("Failed to send verification code",e)}finally{w(!1)}},handleGetChallenge:async t=>await e.getSignChallenge({method:"phantom",id:t}),handleLoginWithChallenge:async(t,r)=>{try{const o=await e.loginWithChallenge(t,r);o&&(null==s||s(o),null==n||n())}catch(e){alert("Failed to login with challenge"),console.error("Failed to login with challenge",e)}finally{x(!1)}},phone:u,setPhone:l,phoneSent:d,setPhoneSent:f,onOauthLogin:async t=>{const n=function(e){const t=e.toLowerCase(),n=r.v4();return sessionStorage.setItem(`${t}_oauthState`,JSON.stringify({state:n,timestamp:Date.now()})),n}(t),{codeVerifier:o,codeChallenge:s}=await $g(t),a=await e.oauthInit({provider:t,redirect_uri:window.location.href,state:n,code_challenge:s}),{url:i,client_id:c}=a;if(!i&&!c)throw console.error("OAuth init failed."),new Error("init failed");const u={client_id:c,redirect_uri:i,state:n,code_challenge:s},l="google"===t?await async function(e){const t={response_type:"code",client_id:e.client_id,redirect_uri:e.redirect_uri,scope:["openid","email","profile"].join("%20"),code_challenge:e.code_challenge,code_challenge_method:"S256",state:e.state};return`https://accounts.google.com/o/oauth2/v2/auth?${m.stringify(t,{encode:!1})}`}(u):await async function(e){const t={response_type:"code",client_id:e.client_id,redirect_uri:e.redirect_uri,scope:["tweet.read","users.read"].join("%20"),code_challenge:e.code_challenge,code_challenge_method:"S256",state:e.state};return`https://twitter.com/i/oauth2/authorize?${m.stringify(t,{encode:!1})}`}(u);window.location.href=l},handlePhantomLogin:async()=>{try{P(!0);const t=await e.connectPhantom();t&&(null==s||s(t),null==n||n())}catch(e){console.error("Phantom login error:",e),alert("Failed to connect to Phantom wallet. Please make sure you have the Phantom extension installed.")}finally{P(!1)}},isOpen:t,onClose:n,onLogin:s,isLoading:a}}const Rg=({client:e,isOpen:t,onClose:n,onLogin:r,isLoading:o=!1,enableEmail:a=!0,enablePhone:i=!1,enableGoogle:c=!0,enableTwitter:u=!1,enablePhantom:l=!0})=>{const{email:d,setEmail:f,emailSent:h,sendingCode:m,setEmailSent:g,verifyingCode:b,verificationCode:y,connectingPhantom:w,inputRefs:v,handleCodeChange:x,handleKeyDown:E,handleContainerPaste:P,handleSendVerificationCode:k,handleCodeSubmit:A,onOauthLogin:I,handlePhantomLogin:N}=Og({client:e,isOpen:t,onClose:n,onLogin:r,isLoading:o});return t?p.default.createElement(og,null,p.default.createElement(sg,null,p.default.createElement(ag,null,p.default.createElement(ig,null,"Connect Wallet"),p.default.createElement(cg,{onClick:n},p.default.createElement(ug,{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},p.default.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})))),o?p.default.createElement(lg,null,p.default.createElement(dg,null,p.default.createElement(s.Loader2,{size:24})),p.default.createElement(fg,null,"Loading...")):p.default.createElement(p.default.Fragment,null,h?p.default.createElement(Eg,null,p.default.createElement("div",null,p.default.createElement(Pg,null,"Enter Verification Code"),p.default.createElement(kg,null,"We sent a verification code to ",d)),p.default.createElement(Ag,{onPaste:P},y.map((e,t)=>p.default.createElement(Ig,{key:t},p.default.createElement(Ng,{ref:v[t],type:"text",maxLength:1,value:e,onChange:e=>x(t,e.target.value),onKeyDown:e=>E(t,e),onPaste:e=>{0!==t&&(e.preventDefault(),P(e))}})))),p.default.createElement(mg,{onClick:()=>A(),disabled:6!==y.join("").length||b},b?"Verifying...":"Verify Code"),p.default.createElement(Sg,{onClick:()=>g(!1)},"Back to Email")):p.default.createElement(hg,null,a&&p.default.createElement(hg,null,p.default.createElement(pg,{type:"email",value:d,onChange:e=>f(e.target.value),placeholder:"Enter your email",disabled:m}),p.default.createElement(mg,{onClick:()=>k(),disabled:!d||m},m?"Sending...":"Send Verification Code")),(c||u||l)&&a&&p.default.createElement(gg,null,p.default.createElement(bg,null),p.default.createElement(yg,null,"Or continue with"),p.default.createElement(bg,null)),(c||u||l)&&p.default.createElement(p.default.Fragment,null,p.default.createElement(wg,null,c&&p.default.createElement(vg,{onClick:()=>I("google")},p.default.createElement(xg,null,p.default.createElement("img",{src:"https://cdn.jsdelivr.net/gh/devicons/devicon/icons/google/google-original.svg",alt:"Google",width:20,height:20})),"Google"),u&&p.default.createElement(vg,{onClick:()=>I("twitter")},p.default.createElement(xg,null,p.default.createElement("img",{src:"https://cdn.jsdelivr.net/gh/devicons/devicon/icons/twitter/twitter-original.svg",alt:"Twitter",width:20,height:20})),"X")),l&&p.default.createElement(vg,{onClick:N,disabled:w},p.default.createElement(xg,null,p.default.createElement("img",{src:"https://explorer-api.walletconnect.com/v3/logo/md/b6ec7b81-bb4f-427d-e290-7631e6e50d00?projectId=34357d3c125c2bcf2ce2bc3309d98715",alt:"Phantom",width:20,height:20})),w?"Connecting...":"Phantom")),!a&&!i&&!c&&!u&&!l&&p.default.createElement("div",{style:{textAlign:"center",padding:"20px",color:"#666"}},"No login methods are currently enabled."))),p.default.createElement(Tg,null,"By connecting your wallet, you agree to our Terms of Service and Privacy Policy"))):null};class zg{constructor(){this.container=null,this.root=null}createContainer(){if("undefined"==typeof document)return null;this.removeExistingContainer();const e=document.createElement("div");return e.id="embedded-wallet-modal",document.body.appendChild(e),e}removeExistingContainer(){if("undefined"==typeof document)return;const e=document.getElementById("embedded-wallet-modal");e&&e.parentNode&&e.parentNode.removeChild(e)}showLoginModal({client:e,isLoading:t=!1,onClose:n,onLogin:r,enableEmail:o=!0,enablePhone:s=!1,enableGoogle:a=!0,enableTwitter:i=!1,enablePhantom:c=!0}){return new Promise((u,l)=>{try{if("undefined"==typeof window)return void u();import("react-dom/client").then(({createRoot:l})=>{if(this.container=this.createContainer(),!this.container)return void u();this.root=l(this.container);const d=()=>{this.hideModal(),null==n||n()},f=e=>{this.hideModal(),null==r||r(e)};this.root&&this.root.render(p.default.createElement(Rg,{client:e,isOpen:!0,onClose:d,isLoading:t,onLogin:f,enableEmail:o,enablePhone:s,enableGoogle:a,enableTwitter:i,enablePhantom:c})),u()}).catch(e=>{console.error("Error importing createRoot:",e),l(e)})}catch(e){console.error("Error showing modal:",e),l(e)}})}hideModal(){this.root&&(this.root.unmount(),this.container&&this.container.parentNode&&(document.body.removeChild(this.container),this.container=null))}}const Mg={isAuthenticated:!1,isConnecting:!1,isInitialized:!1,walletInfo:null,wallet:null,session:null,error:null,enableEmail:!0,enablePhone:!1,enableGoogle:!0,enableTwitter:!1,enablePhantom:!0},_g=o.createContext({});function Fg(e,t){switch(t.type){case"SET_CONNECTING":return{...e,isConnecting:t.payload};case"SET_INITIALIZED":return{...e,isInitialized:t.payload};case"SET_SESSION":return{...e,isAuthenticated:!0,session:t.payload,error:null};case"SET_WALLET_INFO":return{...e,walletInfo:t.payload};case"SET_WALLET":return{...e,wallet:t.payload};case"SET_ERROR":return{...e,error:t.payload};case"RESET":return{...Mg,isInitialized:!0};default:return e}}function jg(){const e=o.useContext(_g);if(!e)throw new Error("useWallet must be used within a WalletProvider");return e}"undefined"!=typeof window&&Promise.resolve().then(function(){return Cg}).then(({injectStyles:e})=>{e()}),exports.Storage=w,exports.WalletClient=fh,exports.WalletProvider=function({children:e,config:t}){var n,r,s,a,i,c;const u=o.useRef(null);u.current||(u.current=new fh(t));const l=u.current,d=o.useRef(null!==(n=t.modalManager)&&void 0!==n?n:null),[f,h]=o.useReducer(Fg,{...Mg,enableEmail:null===(r=t.enableEmail)||void 0===r||r,enablePhone:null!==(s=t.enablePhone)&&void 0!==s&&s,enableGoogle:null===(a=t.enableGoogle)||void 0===a||a,enableTwitter:null!==(i=t.enableTwitter)&&void 0!==i&&i,enablePhantom:null===(c=t.enablePhantom)||void 0===c||c}),{walletInfo:m}=f,g=o.useRef(!1),b=o.useCallback(()=>(d.current||"undefined"==typeof window||(d.current=new zg),d.current),[]);o.useEffect(()=>{t.modalManager&&(d.current=t.modalManager)},[t.modalManager]),o.useEffect(()=>{!async function(){if(!(m||g.current||f.isInitialized)){g.current=!0;try{const e=await l.reconnect();e&&(h({type:"SET_WALLET_INFO",payload:e}),h({type:"SET_WALLET",payload:l}))}catch(e){console.error("Auto reconnect failed:",e)}finally{h({type:"SET_INITIALIZED",payload:!0})}}}()},[l]),o.useEffect(()=>{const e=async()=>{try{if(x.isConnecting)return;h({type:"SET_CONNECTING",payload:!0});const e=new URLSearchParams(window.location.search),t=e.get("wallet_oauth_provider"),n=e.get("wallet_oauth_state"),r=e.get("wallet_oauth_code");if(t&&n&&r){const e=function(e){const t=e.toLowerCase(),n=sessionStorage.getItem(`${t}_oauthCodeVerifier`);if(!n)return null;const r=JSON.parse(n);return sessionStorage.removeItem(`${t}_oauthCodeVerifier`),Date.now()-r.timestamp>6e5?null:{codeVerifier:r.code_verifier,codeChallenge:r.code_challenge}}(t);if(!e)throw new Error("No code verifier found");const{codeVerifier:o,codeChallenge:s}=e;let a;if("twitter"===t)a="TwitterOAuth";else{if("google"!==t)throw new Error("Unsupported provider");a="GoogleOAuth"}b().showLoginModal({client:l,isLoading:!0,enableEmail:f.enableEmail,enablePhone:f.enablePhone,enableGoogle:f.enableGoogle,enableTwitter:f.enableTwitter,enablePhantom:f.enablePhantom});const i=await l.oauthLogin(a,{state:n,code:r,code_verifier:o});if(i){h({type:"SET_WALLET_INFO",payload:i}),h({type:"SET_WALLET",payload:l});const e=new URL(window.location.href);e.searchParams.delete("wallet_oauth_provider"),e.searchParams.delete("wallet_oauth_state"),e.searchParams.delete("wallet_oauth_code"),history.replaceState(null,"",e.toString())}}}catch(e){console.log("oauth login error: ",e)}finally{h({type:"SET_CONNECTING",payload:!1}),await b().hideModal()}};return e(),window.addEventListener("popstate",e),()=>{window.removeEventListener("popstate",e)}},[]);const y=o.useCallback(async()=>{try{h({type:"SET_CONNECTING",payload:!0});b().showLoginModal({client:l,enableEmail:f.enableEmail,enablePhone:f.enablePhone,enableGoogle:f.enableGoogle,enableTwitter:f.enableTwitter,enablePhantom:f.enablePhantom,onClose:()=>{h({type:"SET_CONNECTING",payload:!1})},onLogin:e=>{h({type:"SET_CONNECTING",payload:!1}),h({type:"SET_WALLET_INFO",payload:e}),h({type:"SET_WALLET",payload:l})}})}catch(e){h({type:"SET_ERROR",payload:e instanceof Error?e.message:"Failed to connect"}),h({type:"SET_CONNECTING",payload:!1})}},[l]),v=o.useCallback(async()=>{await l.logout(),h({type:"RESET"})},[l]);o.useEffect(()=>{var e;"phantom"===w.getWalletType()&&l.getPhantomAdapter()&&(null===(e=l.getPhantomAdapter())||void 0===e||e.on("disconnect",()=>{v()}))},[l]);const x={...f,connect:y,disconnect:v};return p.default.createElement(_g.Provider,{value:x},e)},exports.injectStyles=Bg,exports.isVersionedTransaction=g,exports.theme=ng,exports.useActiveWallet=function(){const{wallet:e}=jg();return{wallet:e}},exports.useCoinbaseOnramp=function(){const{wallet:e}=jg(),t=null==e?void 0:e.solanaAddress,n=null==e?void 0:e.ethereumAddress;return{getCoinbaseOnrampUrl:async(r,o="solana",s)=>{if(!e||!t||!n)throw new Error("Wallet not found");const a="solana"===o?t:n;return hf({sessionToken:await(null==e?void 0:e.fetchCoinbaseToken(a,o)),presetCryptoAmount:Number(r),redirectUrl:s||window.location.href})}}},exports.useConnect=function(){const{connect:e,disconnect:t,isConnecting:n}=jg();return{connect:e,disconnect:t,isConnecting:n}},exports.useLoginModal=Og,exports.useWallet=jg,exports.useWalletStatus=function(){const{error:e,session:t,isInitialized:n,wallet:r}=jg();return{isAuthenticated:null!==r,authenticated:null!==r,error:e,session:t,isInitialized:n,ready:n}};
|
|
295
|
+
`;async function $g(e){const t=e.toLowerCase(),n=r.v4(),o=await async function(e){const t=new TextEncoder,n=t.encode(e),r=await crypto.subtle.digest("SHA-256",n),o=Array.from(new Uint8Array(r));return btoa(String.fromCharCode(...o)).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}(n);return sessionStorage.setItem(`${t}_oauthCodeVerifier`,JSON.stringify({code_verifier:n,code_challenge:o,timestamp:Date.now()})),{codeVerifier:n,codeChallenge:o}}const Bg=()=>{if("undefined"!=typeof document&&document.getElementById("superstack-wallet-styles"))return;if("undefined"==typeof document)return;const e=document.createElement("link");e.id="superstack-wallet-fonts",e.rel="stylesheet",e.href="https://fonts.googleapis.com/css2?family=Montserrat:wght@300;400;500;600;700&display=swap",document.head.appendChild(e);const t=document.createElement("style");t.id="superstack-wallet-styles",t.textContent=`\n /* 只影响嵌入钱包模态框 */\n #embedded-wallet-modal {\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n z-index: 9999;\n display: flex;\n align-items: center;\n justify-content: center;\n background-color: rgba(0, 0, 0, 0.5);\n }\n \n /* 以下类选择器都只对SDK自己的元素生效 */\n .superstack-wallet-container {\n font-family: 'Montserrat', sans-serif;\n color: ${ng.colors.text.primary};\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n }\n \n /* 直接选择SDK组件,而不是使用通配符 */\n .superstack-wallet-container h1,\n .superstack-wallet-container h2,\n .superstack-wallet-container h3,\n .superstack-wallet-container h4,\n .superstack-wallet-container h5,\n .superstack-wallet-container h6 {\n font-family: 'Montserrat', sans-serif;\n font-weight: ${ng.typography.fontWeights.semibold};\n line-height: 1.2;\n margin-bottom: ${ng.spacing.md};\n }\n \n .superstack-wallet-container p {\n font-family: 'Montserrat', sans-serif;\n margin-bottom: ${ng.spacing.md};\n }\n \n /* 为SDK定义的按钮添加类名 */\n .superstack-wallet-btn {\n font-family: 'Montserrat', sans-serif;\n cursor: pointer;\n }\n \n /* 为SDK定义的输入域添加类名 */\n .superstack-wallet-input {\n font-family: 'Montserrat', sans-serif;\n }\n \n /* 模态内容应该有自己的样式,不影响外部 */\n #embedded-wallet-modal .modal-content {\n background-color: ${ng.colors.background.main};\n border-radius: ${ng.borderRadius.md};\n padding: ${ng.spacing.lg};\n box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);\n max-width: 480px;\n width: 100%;\n }\n `,document.head.appendChild(t)};var Cg=Object.freeze({__proto__:null,injectStyles:Bg,theme:ng});function Og({client:e,isOpen:t,onClose:n,onLogin:s,isLoading:a=!1}){const[i,c]=o.useState(""),[u,l]=o.useState(""),[d,f]=o.useState(!1),[h,p]=o.useState(!1),[g,b]=o.useState(["","","","","",""]),[y,w]=o.useState(!1),[v,x]=o.useState(!1),[E,P]=o.useState(!1),k=o.useMemo(()=>Array(6).fill(null).map(()=>o.createRef()),[]),A=e=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e),I=e=>/^\+[1-9]\d{1,3}\d{6,14}$/.test(e);return o.useEffect(()=>{g.forEach((e,t)=>{if(k[t]&&k[t].current){const n=k[t].current;n&&e&&(n.style.fontSize=ng.typography.fontSizes.xl)}})},[g,k]),{email:i,setEmail:c,emailSent:h,setEmailSent:p,sendingCode:y,setVerificationCode:b,verificationCode:g,verifyingCode:v,connectingPhantom:E,inputRefs:k,handleCodeChange:(e,t)=>{var n,r,o;if(t.length<=1){const r=[...g];r[e]=t,b(r),t&&e<5&&(null===(n=k[e+1].current)||void 0===n||n.focus())}else if(t.length>1){const e=t.replace(/\D/g,"").slice(0,6).split(""),n=[...Array(6).fill("")];e.forEach((e,t)=>{t<6&&(n[t]=e)}),b(n);const s=n.findIndex(e=>""===e);-1!==s?null===(r=k[s].current)||void 0===r||r.focus():n[5]&&(null===(o=k[5].current)||void 0===o||o.focus())}},handleKeyDown:(e,t)=>{var n;"Backspace"===t.key&&!g[e]&&e>0&&(null===(n=k[e-1].current)||void 0===n||n.focus())},handleContainerPaste:e=>{var t,n;e.preventDefault();const r=e.clipboardData.getData("text").replace(/\D/g,"").slice(0,6).split(""),o=[...Array(6).fill("")];r.forEach((e,t)=>{t<6&&(o[t]=e)}),b(o);const s=o.findIndex(e=>""===e);-1!==s?null===(t=k[s].current)||void 0===t||t.focus():o[5]&&(null===(n=k[5].current)||void 0===n||n.focus())},handleSendVerificationCode:async(t=i)=>{try{if(!A(t))return void alert("Please enter a valid email address");w(!0),await e.sendEmailVerificationCode(t),p(!0)}catch(e){alert("Failed to send verification code"),console.error("Failed to send verification code",e)}finally{w(!1)}},handleCodeSubmit:async(t=g.join(""),r=i)=>{try{if(6!==t.length)return void alert("Please enter a valid verification code");x(!0);const o=await e.verifyEmailVerificationCode({email:r,code:t});o&&(null==s||s(o),null==n||n())}catch(e){alert("Failed to verify code"),console.error("Failed to verify code",e)}finally{x(!1)}},handlePhoneCodeSubmit:async(t=g.join(""),r=u)=>{try{if(6!==t.length)return void alert("Please enter a valid verification code");x(!0);const o=await e.verifyPhoneVerificationCode({phone:r,code:t});o&&(null==s||s(o),null==n||n())}catch(e){alert("Failed to verify code"),console.error("Failed to verify code",e)}finally{x(!1)}},handleSendPhoneVerificationCode:async(t=u)=>{try{if(!I(t))return void alert("Please enter a valid phone number");await e.sendPhoneVerificationCode(t),f(!0)}catch(e){alert("Failed to send verification code"),console.error("Failed to send verification code",e)}finally{w(!1)}},handleGetChallenge:async(t,n)=>await e.getSignChallenge({method:null!=n?n:"phantom",id:t}),handleLoginWithChallenge:async(t,r)=>{try{const o=await e.loginWithChallenge(t,r);o&&(null==s||s(o),null==n||n())}catch(e){alert("Failed to login with challenge"),console.error("Failed to login with challenge",e)}finally{x(!1)}},phone:u,setPhone:l,phoneSent:d,setPhoneSent:f,onOauthLogin:async t=>{const n=function(e){const t=e.toLowerCase(),n=r.v4();return sessionStorage.setItem(`${t}_oauthState`,JSON.stringify({state:n,timestamp:Date.now()})),n}(t),{codeVerifier:o,codeChallenge:s}=await $g(t),a=await e.oauthInit({provider:t,redirect_uri:window.location.href,state:n,code_challenge:s}),{url:i,client_id:c}=a;if(!i&&!c)throw console.error("OAuth init failed."),new Error("init failed");const u={client_id:c,redirect_uri:i,state:n,code_challenge:s},l="google"===t?await async function(e){const t={response_type:"code",client_id:e.client_id,redirect_uri:e.redirect_uri,scope:["openid","email","profile"].join("%20"),code_challenge:e.code_challenge,code_challenge_method:"S256",state:e.state};return`https://accounts.google.com/o/oauth2/v2/auth?${m.stringify(t,{encode:!1})}`}(u):await async function(e){const t={response_type:"code",client_id:e.client_id,redirect_uri:e.redirect_uri,scope:["tweet.read","users.read"].join("%20"),code_challenge:e.code_challenge,code_challenge_method:"S256",state:e.state};return`https://twitter.com/i/oauth2/authorize?${m.stringify(t,{encode:!1})}`}(u);window.location.href=l},handlePhantomLogin:async()=>{try{P(!0);const t=await e.connectPhantom();t&&(null==s||s(t),null==n||n())}catch(e){console.error("Phantom login error:",e),alert("Failed to connect to Phantom wallet. Please make sure you have the Phantom extension installed.")}finally{P(!1)}},isOpen:t,onClose:n,onLogin:s,isLoading:a}}const Rg=({client:e,isOpen:t,onClose:n,onLogin:r,isLoading:o=!1,enableEmail:a=!0,enablePhone:i=!1,enableGoogle:c=!0,enableTwitter:u=!1,enablePhantom:l=!0})=>{const{email:d,setEmail:f,emailSent:h,sendingCode:m,setEmailSent:g,verifyingCode:b,verificationCode:y,connectingPhantom:w,inputRefs:v,handleCodeChange:x,handleKeyDown:E,handleContainerPaste:P,handleSendVerificationCode:k,handleCodeSubmit:A,onOauthLogin:I,handlePhantomLogin:N}=Og({client:e,isOpen:t,onClose:n,onLogin:r,isLoading:o});return t?p.default.createElement(og,null,p.default.createElement(sg,null,p.default.createElement(ag,null,p.default.createElement(ig,null,"Connect Wallet"),p.default.createElement(cg,{onClick:n},p.default.createElement(ug,{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},p.default.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})))),o?p.default.createElement(lg,null,p.default.createElement(dg,null,p.default.createElement(s.Loader2,{size:24})),p.default.createElement(fg,null,"Loading...")):p.default.createElement(p.default.Fragment,null,h?p.default.createElement(Eg,null,p.default.createElement("div",null,p.default.createElement(Pg,null,"Enter Verification Code"),p.default.createElement(kg,null,"We sent a verification code to ",d)),p.default.createElement(Ag,{onPaste:P},y.map((e,t)=>p.default.createElement(Ig,{key:t},p.default.createElement(Ng,{ref:v[t],type:"text",maxLength:1,value:e,onChange:e=>x(t,e.target.value),onKeyDown:e=>E(t,e),onPaste:e=>{0!==t&&(e.preventDefault(),P(e))}})))),p.default.createElement(mg,{onClick:()=>A(),disabled:6!==y.join("").length||b},b?"Verifying...":"Verify Code"),p.default.createElement(Sg,{onClick:()=>g(!1)},"Back to Email")):p.default.createElement(hg,null,a&&p.default.createElement(hg,null,p.default.createElement(pg,{type:"email",value:d,onChange:e=>f(e.target.value),placeholder:"Enter your email",disabled:m}),p.default.createElement(mg,{onClick:()=>k(),disabled:!d||m},m?"Sending...":"Send Verification Code")),(c||u||l)&&a&&p.default.createElement(gg,null,p.default.createElement(bg,null),p.default.createElement(yg,null,"Or continue with"),p.default.createElement(bg,null)),(c||u||l)&&p.default.createElement(p.default.Fragment,null,p.default.createElement(wg,null,c&&p.default.createElement(vg,{onClick:()=>I("google")},p.default.createElement(xg,null,p.default.createElement("img",{src:"https://cdn.jsdelivr.net/gh/devicons/devicon/icons/google/google-original.svg",alt:"Google",width:20,height:20})),"Google"),u&&p.default.createElement(vg,{onClick:()=>I("twitter")},p.default.createElement(xg,null,p.default.createElement("img",{src:"https://cdn.jsdelivr.net/gh/devicons/devicon/icons/twitter/twitter-original.svg",alt:"Twitter",width:20,height:20})),"X")),l&&p.default.createElement(vg,{onClick:N,disabled:w},p.default.createElement(xg,null,p.default.createElement("img",{src:"https://explorer-api.walletconnect.com/v3/logo/md/b6ec7b81-bb4f-427d-e290-7631e6e50d00?projectId=34357d3c125c2bcf2ce2bc3309d98715",alt:"Phantom",width:20,height:20})),w?"Connecting...":"Phantom")),!a&&!i&&!c&&!u&&!l&&p.default.createElement("div",{style:{textAlign:"center",padding:"20px",color:"#666"}},"No login methods are currently enabled."))),p.default.createElement(Tg,null,"By connecting your wallet, you agree to our Terms of Service and Privacy Policy"))):null};class zg{constructor(){this.container=null,this.root=null}createContainer(){if("undefined"==typeof document)return null;this.removeExistingContainer();const e=document.createElement("div");return e.id="embedded-wallet-modal",document.body.appendChild(e),e}removeExistingContainer(){if("undefined"==typeof document)return;const e=document.getElementById("embedded-wallet-modal");e&&e.parentNode&&e.parentNode.removeChild(e)}showLoginModal({client:e,isLoading:t=!1,onClose:n,onLogin:r,enableEmail:o=!0,enablePhone:s=!1,enableGoogle:a=!0,enableTwitter:i=!1,enablePhantom:c=!0}){return new Promise((u,l)=>{try{if("undefined"==typeof window)return void u();import("react-dom/client").then(({createRoot:l})=>{if(this.container=this.createContainer(),!this.container)return void u();this.root=l(this.container);const d=()=>{this.hideModal(),null==n||n()},f=e=>{this.hideModal(),null==r||r(e)};this.root&&this.root.render(p.default.createElement(Rg,{client:e,isOpen:!0,onClose:d,isLoading:t,onLogin:f,enableEmail:o,enablePhone:s,enableGoogle:a,enableTwitter:i,enablePhantom:c})),u()}).catch(e=>{console.error("Error importing createRoot:",e),l(e)})}catch(e){console.error("Error showing modal:",e),l(e)}})}hideModal(){this.root&&(this.root.unmount(),this.container&&this.container.parentNode&&(document.body.removeChild(this.container),this.container=null))}}const Mg={isAuthenticated:!1,isConnecting:!1,isInitialized:!1,walletInfo:null,wallet:null,session:null,error:null,enableEmail:!0,enablePhone:!1,enableGoogle:!0,enableTwitter:!1,enablePhantom:!0},_g=o.createContext({});function Fg(e,t){switch(t.type){case"SET_CONNECTING":return{...e,isConnecting:t.payload};case"SET_INITIALIZED":return{...e,isInitialized:t.payload};case"SET_SESSION":return{...e,isAuthenticated:!0,session:t.payload,error:null};case"SET_WALLET_INFO":return{...e,walletInfo:t.payload};case"SET_WALLET":return{...e,wallet:t.payload};case"SET_ERROR":return{...e,error:t.payload};case"RESET":return{...Mg,isInitialized:!0};default:return e}}function jg(){const e=o.useContext(_g);if(!e)throw new Error("useWallet must be used within a WalletProvider");return e}"undefined"!=typeof window&&Promise.resolve().then(function(){return Cg}).then(({injectStyles:e})=>{e()}),exports.Storage=w,exports.WalletClient=fh,exports.WalletProvider=function({children:e,config:t}){var n,r,s,a,i,c;const u=o.useRef(null);u.current||(u.current=new fh(t));const l=u.current,d=o.useRef(null!==(n=t.modalManager)&&void 0!==n?n:null),[f,h]=o.useReducer(Fg,{...Mg,enableEmail:null===(r=t.enableEmail)||void 0===r||r,enablePhone:null!==(s=t.enablePhone)&&void 0!==s&&s,enableGoogle:null===(a=t.enableGoogle)||void 0===a||a,enableTwitter:null!==(i=t.enableTwitter)&&void 0!==i&&i,enablePhantom:null===(c=t.enablePhantom)||void 0===c||c}),{walletInfo:m}=f,g=o.useRef(!1),b=o.useCallback(()=>(d.current||"undefined"==typeof window||(d.current=new zg),d.current),[]);o.useEffect(()=>{t.modalManager&&(d.current=t.modalManager)},[t.modalManager]),o.useEffect(()=>{!async function(){if(!(m||g.current||f.isInitialized)){g.current=!0;try{const e=await l.reconnect();e&&(h({type:"SET_WALLET_INFO",payload:e}),h({type:"SET_WALLET",payload:l}))}catch(e){console.error("Auto reconnect failed:",e)}finally{h({type:"SET_INITIALIZED",payload:!0})}}}()},[l]),o.useEffect(()=>{const e=async()=>{try{if(x.isConnecting)return;h({type:"SET_CONNECTING",payload:!0});const e=new URLSearchParams(window.location.search),t=e.get("wallet_oauth_provider"),n=e.get("wallet_oauth_state"),r=e.get("wallet_oauth_code");if(t&&n&&r){const e=function(e){const t=e.toLowerCase(),n=sessionStorage.getItem(`${t}_oauthCodeVerifier`);if(!n)return null;const r=JSON.parse(n);return sessionStorage.removeItem(`${t}_oauthCodeVerifier`),Date.now()-r.timestamp>6e5?null:{codeVerifier:r.code_verifier,codeChallenge:r.code_challenge}}(t);if(!e)throw new Error("No code verifier found");const{codeVerifier:o,codeChallenge:s}=e;let a;if("twitter"===t)a="TwitterOAuth";else{if("google"!==t)throw new Error("Unsupported provider");a="GoogleOAuth"}b().showLoginModal({client:l,isLoading:!0,enableEmail:f.enableEmail,enablePhone:f.enablePhone,enableGoogle:f.enableGoogle,enableTwitter:f.enableTwitter,enablePhantom:f.enablePhantom});const i=await l.oauthLogin(a,{state:n,code:r,code_verifier:o});if(i){h({type:"SET_WALLET_INFO",payload:i}),h({type:"SET_WALLET",payload:l});const e=new URL(window.location.href);e.searchParams.delete("wallet_oauth_provider"),e.searchParams.delete("wallet_oauth_state"),e.searchParams.delete("wallet_oauth_code"),history.replaceState(null,"",e.toString())}}}catch(e){console.log("oauth login error: ",e)}finally{h({type:"SET_CONNECTING",payload:!1}),await b().hideModal()}};return e(),window.addEventListener("popstate",e),()=>{window.removeEventListener("popstate",e)}},[]);const y=o.useCallback(async()=>{try{h({type:"SET_CONNECTING",payload:!0});b().showLoginModal({client:l,enableEmail:f.enableEmail,enablePhone:f.enablePhone,enableGoogle:f.enableGoogle,enableTwitter:f.enableTwitter,enablePhantom:f.enablePhantom,onClose:()=>{h({type:"SET_CONNECTING",payload:!1})},onLogin:e=>{h({type:"SET_CONNECTING",payload:!1}),h({type:"SET_WALLET_INFO",payload:e}),h({type:"SET_WALLET",payload:l})}})}catch(e){h({type:"SET_ERROR",payload:e instanceof Error?e.message:"Failed to connect"}),h({type:"SET_CONNECTING",payload:!1})}},[l]),v=o.useCallback(async()=>{await l.logout(),h({type:"RESET"})},[l]);o.useEffect(()=>{var e;"phantom"===w.getWalletType()&&l.getPhantomAdapter()&&(null===(e=l.getPhantomAdapter())||void 0===e||e.on("disconnect",()=>{v()}))},[l]);const x={...f,connect:y,disconnect:v};return p.default.createElement(_g.Provider,{value:x},e)},exports.injectStyles=Bg,exports.isVersionedTransaction=g,exports.theme=ng,exports.useActiveWallet=function(){const{wallet:e}=jg();return{wallet:e}},exports.useCoinbaseOnramp=function(){const{wallet:e}=jg(),t=null==e?void 0:e.solanaAddress,n=null==e?void 0:e.ethereumAddress;return{getCoinbaseOnrampUrl:async(r,o="solana",s)=>{if(!e||!t||!n)throw new Error("Wallet not found");const a="solana"===o?t:n;return hf({sessionToken:await(null==e?void 0:e.fetchCoinbaseToken(a,o)),presetCryptoAmount:Number(r),redirectUrl:s||window.location.href})}}},exports.useConnect=function(){const{connect:e,disconnect:t,isConnecting:n}=jg();return{connect:e,disconnect:t,isConnecting:n}},exports.useLoginModal=Og,exports.useWallet=jg,exports.useWalletStatus=function(){const{error:e,session:t,isInitialized:n,wallet:r}=jg();return{isAuthenticated:null!==r,authenticated:null!==r,error:e,session:t,isInitialized:n,ready:n}};
|
|
296
296
|
//# sourceMappingURL=index.cjs.map
|