@gardenfi/core 2.4.6-beta.2 → 2.4.6-beta.4
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/{ccip-7vWl1Beu.js → ccip-CM2FCFWE.js} +1 -1
- package/dist/{ccip-C0J0QEJ3.cjs → ccip-khJakyl9.cjs} +1 -1
- package/dist/{index-DQ_ZPlba.cjs → index-BDXehJkA.cjs} +3 -3
- package/dist/{index-CRkOwXPq.js → index-iqpfvx69.js} +3 -3
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/package.json +3 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { B as p, g as m, s as w, d as k, i as b, l as L, a as O, c as E, b as x, e as R, H as y, f as M } from "./index-
|
|
1
|
+
import { B as p, g as m, s as w, d as k, i as b, l as L, a as O, c as E, b as x, e as R, H as y, f as M } from "./index-iqpfvx69.js";
|
|
2
2
|
class S extends p {
|
|
3
3
|
constructor({ callbackSelector: r, cause: a, data: n, extraData: i, sender: f, urls: t }) {
|
|
4
4
|
var o;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-BDXehJkA.cjs");class w extends e.BaseError{constructor({callbackSelector:o,cause:a,data:c,extraData:u,sender:d,urls:r}){var n;super(a.shortMessage||"An error occurred while fetching for an offchain result.",{cause:a,metaMessages:[...a.metaMessages||[],(n=a.metaMessages)!=null&&n.length?"":[],"Offchain Gateway Call:",r&&[" Gateway URL(s):",...r.map(f=>` ${e.getUrl(f)}`)],` Sender: ${d}`,` Data: ${c}`,` Callback selector: ${o}`,` Extra data: ${u}`].flat(),name:"OffchainLookupError"})}}class k extends e.BaseError{constructor({result:o,url:a}){super("Offchain gateway response is malformed. Response data must be a hex value.",{metaMessages:[`Gateway URL: ${e.getUrl(a)}`,`Response: ${e.stringify(o)}`],name:"OffchainLookupResponseMalformedError"})}}class b extends e.BaseError{constructor({sender:o,to:a}){super("Reverted sender address does not match target contract address (`to`).",{metaMessages:[`Contract address: ${a}`,`OffchainLookup sender address: ${o}`],name:"OffchainLookupSenderMismatchError"})}}const L="0x556f1830",y={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 E(i,{blockNumber:o,blockTag:a,data:c,to:u}){const{args:d}=e.decodeErrorResult({data:c,abi:[y]}),[r,n,f,l,s]=d,{ccipRead:t}=i,h=t&&typeof(t==null?void 0:t.request)=="function"?t.request:m;try{if(!e.isAddressEqual(u,r))throw new b({sender:r,to:u});const p=n.includes(e.localBatchGatewayUrl)?await e.localBatchGatewayRequest({data:f,ccipRequest:h}):await h({data:f,sender:r,urls:n}),{data:g}=await e.call(i,{blockNumber:o,blockTag:a,data:e.concat([l,e.encodeAbiParameters([{type:"bytes"},{type:"bytes"}],[p,s])]),to:u});return g}catch(p){throw new w({callbackSelector:l,cause:p,data:c,extraData:s,sender:r,urls:n})}}async function m({data:i,sender:o,urls:a}){var u;let c=new Error("An unknown error occurred.");for(let d=0;d<a.length;d++){const r=a[d],n=r.includes("{data}")?"GET":"POST",f=n==="POST"?{data:i,sender:o}:void 0,l=n==="POST"?{"Content-Type":"application/json"}:{};try{const s=await fetch(r.replace("{sender}",o.toLowerCase()).replace("{data}",i),{body:JSON.stringify(f),headers:l,method:n});let t;if((u=s.headers.get("Content-Type"))!=null&&u.startsWith("application/json")?t=(await s.json()).data:t=await s.text(),!s.ok){c=new e.HttpRequestError({body:f,details:t!=null&&t.error?e.stringify(t.error):s.statusText,headers:s.headers,status:s.status,url:r});continue}if(!e.isHex(t)){c=new k({result:t,url:r});continue}return t}catch(s){c=new e.HttpRequestError({body:f,details:s.message,url:r})}}throw c}exports.ccipRequest=m;exports.offchainLookup=E;exports.offchainLookupAbiItem=y;exports.offchainLookupSignature=L;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";var z1=Object.defineProperty;var q1=(e,t,r)=>t in e?z1(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var Ph=(e,t,r)=>q1(e,typeof t!="symbol"?t+"":t,r);const be=require("@gardenfi/orderbook"),v=require("@gardenfi/utils"),Am=require("varuint-bitcoin"),V1=require("tiny-secp256k1"),pe=require("bitcoinjs-lib"),G1=require("bignumber.js"),Ua=require("ecpair"),it=require("starknet"),Oh=require("yup"),Bh=require("bip39"),W1=require("bip32"),sr=require("@coral-xyz/anchor"),K1=require("@solana/spl-token"),X1=require("@mysten/wallet-standard");function dc(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const Ch=dc(Am),ar=dc(V1),Se=dc(pe),Y1=dc(K1);var Ae=(e=>(e.Idle="Idle",e.Initiate="Initiate",e.Redeem="Redeem",e.Refund="Refund",e))(Ae||{});const Z1="1.0.8";let Kt=class ef extends Error{constructor(t,r={}){var o;const n=r.cause instanceof ef?r.cause.details:(o=r.cause)!=null&&o.message?r.cause.message:r.details,s=r.cause instanceof ef&&r.cause.docsPath||r.docsPath,i=[t||"An error occurred.","",...r.metaMessages?[...r.metaMessages,""]:[],...s?[`Docs: https://abitype.dev${s}`]:[],...n?[`Details: ${n}`]:[],`Version: abitype@${Z1}`].join(`
|
|
2
|
-
`);super(i),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"}),r.cause&&(this.cause=r.cause),this.details=n,this.docsPath=s,this.metaMessages=r.metaMessages,this.shortMessage=t}};function _n(e,t){const r=e.exec(t);return r==null?void 0:r.groups}const xm=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,Sm=/^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)?$/,_m=/^\(.+?\).*?$/,Rh=/^tuple(?<array>(\[(\d*)\])*)$/;function tf(e){let t=e.type;if(Rh.test(e.type)&&"components"in e){t="(";const r=e.components.length;for(let s=0;s<r;s++){const i=e.components[s];t+=tf(i),s<r-1&&(t+=", ")}const n=_n(Rh,e.type);return t+=`)${(n==null?void 0:n.array)??""}`,tf({...e,type:t})}return"indexed"in e&&e.indexed&&(t=`${t} indexed`),e.name?`${t} ${e.name}`:t}function Ni(e){let t="";const r=e.length;for(let n=0;n<r;n++){const s=e[n];t+=tf(s),n!==r-1&&(t+=", ")}return t}function Ja(e){var t;return e.type==="function"?`function ${e.name}(${Ni(e.inputs)})${e.stateMutability&&e.stateMutability!=="nonpayable"?` ${e.stateMutability}`:""}${(t=e.outputs)!=null&&t.length?` returns (${Ni(e.outputs)})`:""}`:e.type==="event"?`event ${e.name}(${Ni(e.inputs)})`:e.type==="error"?`error ${e.name}(${Ni(e.inputs)})`:e.type==="constructor"?`constructor(${Ni(e.inputs)})${e.stateMutability==="payable"?" payable":""}`:e.type==="fallback"?`fallback() external${e.stateMutability==="payable"?" payable":""}`:"receive() external payable"}const km=/^error (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/;function J1(e){return km.test(e)}function Q1(e){return _n(km,e)}const Tm=/^event (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/;function ev(e){return Tm.test(e)}function tv(e){return _n(Tm,e)}const Im=/^function (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)(?: (?<scope>external|public{1}))?(?: (?<stateMutability>pure|view|nonpayable|payable{1}))?(?: returns\s?\((?<returns>.*?)\))?$/;function rv(e){return Im.test(e)}function nv(e){return _n(Im,e)}const Pm=/^struct (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*) \{(?<properties>.*?)\}$/;function od(e){return Pm.test(e)}function sv(e){return _n(Pm,e)}const Om=/^constructor\((?<parameters>.*?)\)(?:\s(?<stateMutability>payable{1}))?$/;function iv(e){return Om.test(e)}function ov(e){return _n(Om,e)}const Bm=/^fallback\(\) external(?:\s(?<stateMutability>payable{1}))?$/;function av(e){return Bm.test(e)}function cv(e){return _n(Bm,e)}const uv=/^receive\(\) external payable$/;function lv(e){return uv.test(e)}const fv=new Set(["indexed"]),rf=new Set(["calldata","memory","storage"]);class dv extends Kt{constructor({signature:t}){super("Failed to parse ABI item.",{details:`parseAbiItem(${JSON.stringify(t,null,2)})`,docsPath:"/api/human#parseabiitem-1"}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidAbiItemError"})}}class hv extends Kt{constructor({type:t}){super("Unknown type.",{metaMessages:[`Type "${t}" is not a valid ABI type. Perhaps you forgot to include a struct signature?`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownTypeError"})}}class pv extends Kt{constructor({type:t}){super("Unknown type.",{metaMessages:[`Type "${t}" is not a valid ABI type.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownSolidityTypeError"})}}class yv extends Kt{constructor({param:t}){super("Invalid ABI parameter.",{details:t}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidParameterError"})}}class mv extends Kt{constructor({param:t,name:r}){super("Invalid ABI parameter.",{details:t,metaMessages:[`"${r}" 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 gv extends Kt{constructor({param:t,type:r,modifier:n}){super("Invalid ABI parameter.",{details:t,metaMessages:[`Modifier "${n}" not allowed${r?` in "${r}" type`:""}.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidModifierError"})}}class bv extends Kt{constructor({param:t,type:r,modifier:n}){super("Invalid ABI parameter.",{details:t,metaMessages:[`Modifier "${n}" not allowed${r?` in "${r}" 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 wv extends Kt{constructor({abiParameter:t}){super("Invalid ABI parameter.",{details:JSON.stringify(t,null,2),metaMessages:["ABI parameter type is invalid."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidAbiTypeParameterError"})}}class ki extends Kt{constructor({signature:t,type:r}){super(`Invalid ${r} signature.`,{details:t}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidSignatureError"})}}class vv extends Kt{constructor({signature:t}){super("Unknown signature.",{details:t}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownSignatureError"})}}class Ev extends Kt{constructor({signature:t}){super("Invalid struct signature.",{details:t,metaMessages:["No properties exist."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidStructSignatureError"})}}class Av extends Kt{constructor({type:t}){super("Circular reference detected.",{metaMessages:[`Struct "${t}" is a circular reference.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"CircularReferenceError"})}}class xv extends Kt{constructor({current:t,depth:r}){super("Unbalanced parentheses.",{metaMessages:[`"${t.trim()}" has too many ${r>0?"opening":"closing"} parentheses.`],details:`Depth "${r}"`}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidParenthesisError"})}}function Sv(e,t,r){let n="";if(r)for(const s of Object.entries(r)){if(!s)continue;let i="";for(const o of s[1])i+=`[${o.type}${o.name?`:${o.name}`:""}]`;n+=`(${s[0]}{${i}})`}return t?`${t}:${e}${n}`:e}const cu=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 nf(e,t={}){if(rv(e))return _v(e,t);if(ev(e))return kv(e,t);if(J1(e))return Tv(e,t);if(iv(e))return Iv(e,t);if(av(e))return Pv(e);if(lv(e))return{type:"receive",stateMutability:"payable"};throw new vv({signature:e})}function _v(e,t={}){const r=nv(e);if(!r)throw new ki({signature:e,type:"function"});const n=br(r.parameters),s=[],i=n.length;for(let a=0;a<i;a++)s.push(Ss(n[a],{modifiers:rf,structs:t,type:"function"}));const o=[];if(r.returns){const a=br(r.returns),c=a.length;for(let l=0;l<c;l++)o.push(Ss(a[l],{modifiers:rf,structs:t,type:"function"}))}return{name:r.name,type:"function",stateMutability:r.stateMutability??"nonpayable",inputs:s,outputs:o}}function kv(e,t={}){const r=tv(e);if(!r)throw new ki({signature:e,type:"event"});const n=br(r.parameters),s=[],i=n.length;for(let o=0;o<i;o++)s.push(Ss(n[o],{modifiers:fv,structs:t,type:"event"}));return{name:r.name,type:"event",inputs:s}}function Tv(e,t={}){const r=Q1(e);if(!r)throw new ki({signature:e,type:"error"});const n=br(r.parameters),s=[],i=n.length;for(let o=0;o<i;o++)s.push(Ss(n[o],{structs:t,type:"error"}));return{name:r.name,type:"error",inputs:s}}function Iv(e,t={}){const r=ov(e);if(!r)throw new ki({signature:e,type:"constructor"});const n=br(r.parameters),s=[],i=n.length;for(let o=0;o<i;o++)s.push(Ss(n[o],{structs:t,type:"constructor"}));return{type:"constructor",stateMutability:r.stateMutability??"nonpayable",inputs:s}}function Pv(e){const t=cv(e);if(!t)throw new ki({signature:e,type:"fallback"});return{type:"fallback",stateMutability:t.stateMutability??"nonpayable"}}const Ov=/^(?<type>[a-zA-Z$_][a-zA-Z0-9$_]*)(?<array>(?:\[\d*?\])+?)?(?:\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\s(?<name>[a-zA-Z$_][a-zA-Z0-9$_]*))?$/,Bv=/^\((?<type>.+?)\)(?<array>(?:\[\d*?\])+?)?(?:\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\s(?<name>[a-zA-Z$_][a-zA-Z0-9$_]*))?$/,Cv=/^u?int$/;function Ss(e,t){var f,p;const r=Sv(e,t==null?void 0:t.type,t==null?void 0:t.structs);if(cu.has(r))return cu.get(r);const n=_m.test(e),s=_n(n?Bv:Ov,e);if(!s)throw new yv({param:e});if(s.name&&$v(s.name))throw new mv({param:e,name:s.name});const i=s.name?{name:s.name}:{},o=s.modifier==="indexed"?{indexed:!0}:{},a=(t==null?void 0:t.structs)??{};let c,l={};if(n){c="tuple";const d=br(s.type),m=[],g=d.length;for(let w=0;w<g;w++)m.push(Ss(d[w],{structs:a}));l={components:m}}else if(s.type in a)c="tuple",l={components:a[s.type]};else if(Cv.test(s.type))c=`${s.type}256`;else if(c=s.type,(t==null?void 0:t.type)!=="struct"&&!Cm(c))throw new pv({type:c});if(s.modifier){if(!((p=(f=t==null?void 0:t.modifiers)==null?void 0:f.has)!=null&&p.call(f,s.modifier)))throw new gv({param:e,type:t==null?void 0:t.type,modifier:s.modifier});if(rf.has(s.modifier)&&!Nv(c,!!s.array))throw new bv({param:e,type:t==null?void 0:t.type,modifier:s.modifier})}const u={type:`${c}${s.array??""}`,...i,...o,...l};return cu.set(r,u),u}function br(e,t=[],r="",n=0){const s=e.trim().length;for(let i=0;i<s;i++){const o=e[i],a=e.slice(i+1);switch(o){case",":return n===0?br(a,[...t,r.trim()]):br(a,t,`${r}${o}`,n);case"(":return br(a,t,`${r}${o}`,n+1);case")":return br(a,t,`${r}${o}`,n-1);default:return br(a,t,`${r}${o}`,n)}}if(r==="")return t;if(n!==0)throw new xv({current:r,depth:n});return t.push(r.trim()),t}function Cm(e){return e==="address"||e==="bool"||e==="function"||e==="string"||xm.test(e)||Sm.test(e)}const Rv=/^(?: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 $v(e){return e==="address"||e==="bool"||e==="function"||e==="string"||e==="tuple"||xm.test(e)||Sm.test(e)||Rv.test(e)}function Nv(e,t){return t||e==="bytes"||e==="string"||e==="tuple"}function Rm(e){const t={},r=e.length;for(let o=0;o<r;o++){const a=e[o];if(!od(a))continue;const c=sv(a);if(!c)throw new ki({signature:a,type:"struct"});const l=c.properties.split(";"),u=[],f=l.length;for(let p=0;p<f;p++){const m=l[p].trim();if(!m)continue;const g=Ss(m,{type:"struct"});u.push(g)}if(!u.length)throw new Ev({signature:a});t[c.name]=u}const n={},s=Object.entries(t),i=s.length;for(let o=0;o<i;o++){const[a,c]=s[o];n[a]=$m(c,t)}return n}const Uv=/^(?<type>[a-zA-Z$_][a-zA-Z0-9$_]*)(?<array>(?:\[\d*?\])+?)?$/;function $m(e,t,r=new Set){const n=[],s=e.length;for(let i=0;i<s;i++){const o=e[i];if(_m.test(o.type))n.push(o);else{const c=_n(Uv,o.type);if(!(c!=null&&c.type))throw new wv({abiParameter:o});const{array:l,type:u}=c;if(u in t){if(r.has(u))throw new Av({type:u});n.push({...o,type:`tuple${l??""}`,components:$m(t[u]??[],t,new Set([...r,u]))})}else if(Cm(u))n.push(o);else throw new hv({type:u})}}return n}function Nm(e){const t=Rm(e),r=[],n=e.length;for(let s=0;s<n;s++){const i=e[s];od(i)||r.push(nf(i,t))}return r}function $h(e){let t;if(typeof e=="string")t=nf(e);else{const r=Rm(e),n=e.length;for(let s=0;s<n;s++){const i=e[s];if(!od(i)){t=nf(i,r);break}}}if(!t)throw new dv({signature:e});return t}function se(e,t,r){const n=e[t.name];if(typeof n=="function")return n;const s=e[r];return typeof s=="function"?s:i=>t(e,i)}function Ar(e,{includeName:t=!1}={}){if(e.type!=="function"&&e.type!=="event"&&e.type!=="error")throw new Xv(e.type);return`${e.name}(${hc(e.inputs,{includeName:t})})`}function hc(e,{includeName:t=!1}={}){return e?e.map(r=>Mv(r,{includeName:t})).join(t?", ":","):""}function Mv(e,{includeName:t}){return e.type.startsWith("tuple")?`(${hc(e.components,{includeName:t})})${e.type.slice(5)}`:e.type+(t&&e.name?` ${e.name}`:"")}function xr(e,{strict:t=!0}={}){return!e||typeof e!="string"?!1:t?/^0x[0-9a-fA-F]*$/.test(e):e.startsWith("0x")}function He(e){return xr(e,{strict:!1})?Math.ceil((e.length-2)/2):e.length}const Um="2.33.2";let Ui={getDocsUrl:({docsBaseUrl:e,docsPath:t="",docsSlug:r})=>t?`${e??"https://viem.sh"}${t}${r?`#${r}`:""}`:void 0,version:`viem@${Um}`},z=class sf extends Error{constructor(t,r={}){var a;const n=(()=>{var c;return r.cause instanceof sf?r.cause.details:(c=r.cause)!=null&&c.message?r.cause.message:r.details})(),s=r.cause instanceof sf&&r.cause.docsPath||r.docsPath,i=(a=Ui.getDocsUrl)==null?void 0:a.call(Ui,{...r,docsPath:s}),o=[t||"An error occurred.","",...r.metaMessages?[...r.metaMessages,""]:[],...i?[`Docs: ${i}`]:[],...n?[`Details: ${n}`]:[],...Ui.version?[`Version: ${Ui.version}`]:[]].join(`
|
|
2
|
+
`);super(i),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"}),r.cause&&(this.cause=r.cause),this.details=n,this.docsPath=s,this.metaMessages=r.metaMessages,this.shortMessage=t}};function _n(e,t){const r=e.exec(t);return r==null?void 0:r.groups}const xm=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,Sm=/^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)?$/,_m=/^\(.+?\).*?$/,Rh=/^tuple(?<array>(\[(\d*)\])*)$/;function tf(e){let t=e.type;if(Rh.test(e.type)&&"components"in e){t="(";const r=e.components.length;for(let s=0;s<r;s++){const i=e.components[s];t+=tf(i),s<r-1&&(t+=", ")}const n=_n(Rh,e.type);return t+=`)${(n==null?void 0:n.array)??""}`,tf({...e,type:t})}return"indexed"in e&&e.indexed&&(t=`${t} indexed`),e.name?`${t} ${e.name}`:t}function Ni(e){let t="";const r=e.length;for(let n=0;n<r;n++){const s=e[n];t+=tf(s),n!==r-1&&(t+=", ")}return t}function Ja(e){var t;return e.type==="function"?`function ${e.name}(${Ni(e.inputs)})${e.stateMutability&&e.stateMutability!=="nonpayable"?` ${e.stateMutability}`:""}${(t=e.outputs)!=null&&t.length?` returns (${Ni(e.outputs)})`:""}`:e.type==="event"?`event ${e.name}(${Ni(e.inputs)})`:e.type==="error"?`error ${e.name}(${Ni(e.inputs)})`:e.type==="constructor"?`constructor(${Ni(e.inputs)})${e.stateMutability==="payable"?" payable":""}`:e.type==="fallback"?`fallback() external${e.stateMutability==="payable"?" payable":""}`:"receive() external payable"}const km=/^error (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/;function J1(e){return km.test(e)}function Q1(e){return _n(km,e)}const Tm=/^event (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/;function ev(e){return Tm.test(e)}function tv(e){return _n(Tm,e)}const Im=/^function (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)(?: (?<scope>external|public{1}))?(?: (?<stateMutability>pure|view|nonpayable|payable{1}))?(?: returns\s?\((?<returns>.*?)\))?$/;function rv(e){return Im.test(e)}function nv(e){return _n(Im,e)}const Pm=/^struct (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*) \{(?<properties>.*?)\}$/;function od(e){return Pm.test(e)}function sv(e){return _n(Pm,e)}const Om=/^constructor\((?<parameters>.*?)\)(?:\s(?<stateMutability>payable{1}))?$/;function iv(e){return Om.test(e)}function ov(e){return _n(Om,e)}const Bm=/^fallback\(\) external(?:\s(?<stateMutability>payable{1}))?$/;function av(e){return Bm.test(e)}function cv(e){return _n(Bm,e)}const uv=/^receive\(\) external payable$/;function lv(e){return uv.test(e)}const fv=new Set(["indexed"]),rf=new Set(["calldata","memory","storage"]);class dv extends Kt{constructor({signature:t}){super("Failed to parse ABI item.",{details:`parseAbiItem(${JSON.stringify(t,null,2)})`,docsPath:"/api/human#parseabiitem-1"}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidAbiItemError"})}}class hv extends Kt{constructor({type:t}){super("Unknown type.",{metaMessages:[`Type "${t}" is not a valid ABI type. Perhaps you forgot to include a struct signature?`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownTypeError"})}}class pv extends Kt{constructor({type:t}){super("Unknown type.",{metaMessages:[`Type "${t}" is not a valid ABI type.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownSolidityTypeError"})}}class yv extends Kt{constructor({param:t}){super("Invalid ABI parameter.",{details:t}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidParameterError"})}}class mv extends Kt{constructor({param:t,name:r}){super("Invalid ABI parameter.",{details:t,metaMessages:[`"${r}" 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 gv extends Kt{constructor({param:t,type:r,modifier:n}){super("Invalid ABI parameter.",{details:t,metaMessages:[`Modifier "${n}" not allowed${r?` in "${r}" type`:""}.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidModifierError"})}}class bv extends Kt{constructor({param:t,type:r,modifier:n}){super("Invalid ABI parameter.",{details:t,metaMessages:[`Modifier "${n}" not allowed${r?` in "${r}" 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 wv extends Kt{constructor({abiParameter:t}){super("Invalid ABI parameter.",{details:JSON.stringify(t,null,2),metaMessages:["ABI parameter type is invalid."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidAbiTypeParameterError"})}}class ki extends Kt{constructor({signature:t,type:r}){super(`Invalid ${r} signature.`,{details:t}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidSignatureError"})}}class vv extends Kt{constructor({signature:t}){super("Unknown signature.",{details:t}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownSignatureError"})}}class Ev extends Kt{constructor({signature:t}){super("Invalid struct signature.",{details:t,metaMessages:["No properties exist."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidStructSignatureError"})}}class Av extends Kt{constructor({type:t}){super("Circular reference detected.",{metaMessages:[`Struct "${t}" is a circular reference.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"CircularReferenceError"})}}class xv extends Kt{constructor({current:t,depth:r}){super("Unbalanced parentheses.",{metaMessages:[`"${t.trim()}" has too many ${r>0?"opening":"closing"} parentheses.`],details:`Depth "${r}"`}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidParenthesisError"})}}function Sv(e,t,r){let n="";if(r)for(const s of Object.entries(r)){if(!s)continue;let i="";for(const o of s[1])i+=`[${o.type}${o.name?`:${o.name}`:""}]`;n+=`(${s[0]}{${i}})`}return t?`${t}:${e}${n}`:e}const cu=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 nf(e,t={}){if(rv(e))return _v(e,t);if(ev(e))return kv(e,t);if(J1(e))return Tv(e,t);if(iv(e))return Iv(e,t);if(av(e))return Pv(e);if(lv(e))return{type:"receive",stateMutability:"payable"};throw new vv({signature:e})}function _v(e,t={}){const r=nv(e);if(!r)throw new ki({signature:e,type:"function"});const n=br(r.parameters),s=[],i=n.length;for(let a=0;a<i;a++)s.push(Ss(n[a],{modifiers:rf,structs:t,type:"function"}));const o=[];if(r.returns){const a=br(r.returns),c=a.length;for(let l=0;l<c;l++)o.push(Ss(a[l],{modifiers:rf,structs:t,type:"function"}))}return{name:r.name,type:"function",stateMutability:r.stateMutability??"nonpayable",inputs:s,outputs:o}}function kv(e,t={}){const r=tv(e);if(!r)throw new ki({signature:e,type:"event"});const n=br(r.parameters),s=[],i=n.length;for(let o=0;o<i;o++)s.push(Ss(n[o],{modifiers:fv,structs:t,type:"event"}));return{name:r.name,type:"event",inputs:s}}function Tv(e,t={}){const r=Q1(e);if(!r)throw new ki({signature:e,type:"error"});const n=br(r.parameters),s=[],i=n.length;for(let o=0;o<i;o++)s.push(Ss(n[o],{structs:t,type:"error"}));return{name:r.name,type:"error",inputs:s}}function Iv(e,t={}){const r=ov(e);if(!r)throw new ki({signature:e,type:"constructor"});const n=br(r.parameters),s=[],i=n.length;for(let o=0;o<i;o++)s.push(Ss(n[o],{structs:t,type:"constructor"}));return{type:"constructor",stateMutability:r.stateMutability??"nonpayable",inputs:s}}function Pv(e){const t=cv(e);if(!t)throw new ki({signature:e,type:"fallback"});return{type:"fallback",stateMutability:t.stateMutability??"nonpayable"}}const Ov=/^(?<type>[a-zA-Z$_][a-zA-Z0-9$_]*)(?<array>(?:\[\d*?\])+?)?(?:\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\s(?<name>[a-zA-Z$_][a-zA-Z0-9$_]*))?$/,Bv=/^\((?<type>.+?)\)(?<array>(?:\[\d*?\])+?)?(?:\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\s(?<name>[a-zA-Z$_][a-zA-Z0-9$_]*))?$/,Cv=/^u?int$/;function Ss(e,t){var f,p;const r=Sv(e,t==null?void 0:t.type,t==null?void 0:t.structs);if(cu.has(r))return cu.get(r);const n=_m.test(e),s=_n(n?Bv:Ov,e);if(!s)throw new yv({param:e});if(s.name&&$v(s.name))throw new mv({param:e,name:s.name});const i=s.name?{name:s.name}:{},o=s.modifier==="indexed"?{indexed:!0}:{},a=(t==null?void 0:t.structs)??{};let c,l={};if(n){c="tuple";const d=br(s.type),m=[],g=d.length;for(let w=0;w<g;w++)m.push(Ss(d[w],{structs:a}));l={components:m}}else if(s.type in a)c="tuple",l={components:a[s.type]};else if(Cv.test(s.type))c=`${s.type}256`;else if(c=s.type,(t==null?void 0:t.type)!=="struct"&&!Cm(c))throw new pv({type:c});if(s.modifier){if(!((p=(f=t==null?void 0:t.modifiers)==null?void 0:f.has)!=null&&p.call(f,s.modifier)))throw new gv({param:e,type:t==null?void 0:t.type,modifier:s.modifier});if(rf.has(s.modifier)&&!Nv(c,!!s.array))throw new bv({param:e,type:t==null?void 0:t.type,modifier:s.modifier})}const u={type:`${c}${s.array??""}`,...i,...o,...l};return cu.set(r,u),u}function br(e,t=[],r="",n=0){const s=e.trim().length;for(let i=0;i<s;i++){const o=e[i],a=e.slice(i+1);switch(o){case",":return n===0?br(a,[...t,r.trim()]):br(a,t,`${r}${o}`,n);case"(":return br(a,t,`${r}${o}`,n+1);case")":return br(a,t,`${r}${o}`,n-1);default:return br(a,t,`${r}${o}`,n)}}if(r==="")return t;if(n!==0)throw new xv({current:r,depth:n});return t.push(r.trim()),t}function Cm(e){return e==="address"||e==="bool"||e==="function"||e==="string"||xm.test(e)||Sm.test(e)}const Rv=/^(?: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 $v(e){return e==="address"||e==="bool"||e==="function"||e==="string"||e==="tuple"||xm.test(e)||Sm.test(e)||Rv.test(e)}function Nv(e,t){return t||e==="bytes"||e==="string"||e==="tuple"}function Rm(e){const t={},r=e.length;for(let o=0;o<r;o++){const a=e[o];if(!od(a))continue;const c=sv(a);if(!c)throw new ki({signature:a,type:"struct"});const l=c.properties.split(";"),u=[],f=l.length;for(let p=0;p<f;p++){const m=l[p].trim();if(!m)continue;const g=Ss(m,{type:"struct"});u.push(g)}if(!u.length)throw new Ev({signature:a});t[c.name]=u}const n={},s=Object.entries(t),i=s.length;for(let o=0;o<i;o++){const[a,c]=s[o];n[a]=$m(c,t)}return n}const Uv=/^(?<type>[a-zA-Z$_][a-zA-Z0-9$_]*)(?<array>(?:\[\d*?\])+?)?$/;function $m(e,t,r=new Set){const n=[],s=e.length;for(let i=0;i<s;i++){const o=e[i];if(_m.test(o.type))n.push(o);else{const c=_n(Uv,o.type);if(!(c!=null&&c.type))throw new wv({abiParameter:o});const{array:l,type:u}=c;if(u in t){if(r.has(u))throw new Av({type:u});n.push({...o,type:`tuple${l??""}`,components:$m(t[u]??[],t,new Set([...r,u]))})}else if(Cm(u))n.push(o);else throw new hv({type:u})}}return n}function Nm(e){const t=Rm(e),r=[],n=e.length;for(let s=0;s<n;s++){const i=e[s];od(i)||r.push(nf(i,t))}return r}function $h(e){let t;if(typeof e=="string")t=nf(e);else{const r=Rm(e),n=e.length;for(let s=0;s<n;s++){const i=e[s];if(!od(i)){t=nf(i,r);break}}}if(!t)throw new dv({signature:e});return t}function se(e,t,r){const n=e[t.name];if(typeof n=="function")return n;const s=e[r];return typeof s=="function"?s:i=>t(e,i)}function Ar(e,{includeName:t=!1}={}){if(e.type!=="function"&&e.type!=="event"&&e.type!=="error")throw new Xv(e.type);return`${e.name}(${hc(e.inputs,{includeName:t})})`}function hc(e,{includeName:t=!1}={}){return e?e.map(r=>Mv(r,{includeName:t})).join(t?", ":","):""}function Mv(e,{includeName:t}){return e.type.startsWith("tuple")?`(${hc(e.components,{includeName:t})})${e.type.slice(5)}`:e.type+(t&&e.name?` ${e.name}`:"")}function xr(e,{strict:t=!0}={}){return!e||typeof e!="string"?!1:t?/^0x[0-9a-fA-F]*$/.test(e):e.startsWith("0x")}function He(e){return xr(e,{strict:!1})?Math.ceil((e.length-2)/2):e.length}const Um="2.33.3";let Ui={getDocsUrl:({docsBaseUrl:e,docsPath:t="",docsSlug:r})=>t?`${e??"https://viem.sh"}${t}${r?`#${r}`:""}`:void 0,version:`viem@${Um}`},z=class sf extends Error{constructor(t,r={}){var a;const n=(()=>{var c;return r.cause instanceof sf?r.cause.details:(c=r.cause)!=null&&c.message?r.cause.message:r.details})(),s=r.cause instanceof sf&&r.cause.docsPath||r.docsPath,i=(a=Ui.getDocsUrl)==null?void 0:a.call(Ui,{...r,docsPath:s}),o=[t||"An error occurred.","",...r.metaMessages?[...r.metaMessages,""]:[],...i?[`Docs: ${i}`]:[],...n?[`Details: ${n}`]:[],...Ui.version?[`Version: ${Ui.version}`]:[]].join(`
|
|
3
3
|
`);super(o,r.cause?{cause:r.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=n,this.docsPath=s,this.metaMessages=r.metaMessages,this.name=r.name??this.name,this.shortMessage=t,this.version=Um}walk(t){return Mm(this,t)}};function Mm(e,t){return t!=null&&t(e)?e:e&&typeof e=="object"&&"cause"in e&&e.cause!==void 0?Mm(e.cause,t):t?null:e}class Fv extends z{constructor({docsPath:t}){super(["A constructor was not found on the ABI.","Make sure you are using the correct ABI and that the constructor exists on it."].join(`
|
|
4
4
|
`),{docsPath:t,name:"AbiConstructorNotFoundError"})}}class Nh extends z{constructor({docsPath:t}){super(["Constructor arguments were provided (`args`), but a constructor parameters (`inputs`) were not found on the ABI.","Make sure you are using the correct ABI, and that the `inputs` attribute on the constructor exists."].join(`
|
|
5
5
|
`),{docsPath:t,name:"AbiConstructorParamsNotFoundError"})}}class Fm extends z{constructor({data:t,params:r,size:n}){super([`Data size of ${n} bytes is too small for given parameters.`].join(`
|
|
@@ -38,7 +38,7 @@ ${lE(d)}`),super(t.shortMessage,{cause:t,docsPath:n,metaMessages:[...t.metaMessa
|
|
|
38
38
|
`),{cause:t,metaMessages:["This error could arise when the account does not have enough funds to:"," - pay for the total gas fee,"," - pay for the value to send."," ","The cost of the transaction is calculated as `gas * gas fee + value`, where:"," - `gas` is the amount of gas needed for transaction to execute,"," - `gas fee` is the gas fee,"," - `value` is the amount of ether to send to the recipient."],name:"InsufficientFundsError"})}}Object.defineProperty(hf,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/insufficient funds|exceeds transaction sender account balance/});class pf extends z{constructor({cause:t,gas:r}={}){super(`The amount of gas ${r?`(${r}) `:""}provided for the transaction exceeds the limit allowed for the block.`,{cause:t,name:"IntrinsicGasTooHighError"})}}Object.defineProperty(pf,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too high|gas limit reached/});class yf extends z{constructor({cause:t,gas:r}={}){super(`The amount of gas ${r?`(${r}) `:""}provided for the transaction is too low.`,{cause:t,name:"IntrinsicGasTooLowError"})}}Object.defineProperty(yf,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too low/});class mf extends z{constructor({cause:t}){super("The transaction type is not supported for this chain.",{cause:t,name:"TransactionTypeNotSupportedError"})}}Object.defineProperty(mf,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/transaction type not valid/});class Uo extends z{constructor({cause:t,maxPriorityFeePerGas:r,maxFeePerGas:n}={}){super([`The provided tip (\`maxPriorityFeePerGas\`${r?` = ${Ut(r)} gwei`:""}) cannot be higher than the fee cap (\`maxFeePerGas\`${n?` = ${Ut(n)} gwei`:""}).`].join(`
|
|
39
39
|
`),{cause:t,name:"TipAboveFeeCapError"})}}Object.defineProperty(Uo,"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 ea extends z{constructor({cause:t}){super(`An error occurred while executing: ${t==null?void 0:t.shortMessage}`,{cause:t,name:"UnknownNodeError"})}}function Ac(e,t){const r=(e.details||"").toLowerCase(),n=e instanceof z?e.walk(s=>(s==null?void 0:s.code)===ii.code):e;return n instanceof z?new ii({cause:e,message:n.details}):ii.nodeMessage.test(r)?new ii({cause:e,message:e.details}):Ps.nodeMessage.test(r)?new Ps({cause:e,maxFeePerGas:t==null?void 0:t.maxFeePerGas}):uf.nodeMessage.test(r)?new uf({cause:e,maxFeePerGas:t==null?void 0:t.maxFeePerGas}):lf.nodeMessage.test(r)?new lf({cause:e,nonce:t==null?void 0:t.nonce}):ff.nodeMessage.test(r)?new ff({cause:e,nonce:t==null?void 0:t.nonce}):df.nodeMessage.test(r)?new df({cause:e,nonce:t==null?void 0:t.nonce}):hf.nodeMessage.test(r)?new hf({cause:e}):pf.nodeMessage.test(r)?new pf({cause:e,gas:t==null?void 0:t.gas}):yf.nodeMessage.test(r)?new yf({cause:e,gas:t==null?void 0:t.gas}):mf.nodeMessage.test(r)?new mf({cause:e}):Uo.nodeMessage.test(r)?new Uo({cause:e,maxFeePerGas:t==null?void 0:t.maxFeePerGas,maxPriorityFeePerGas:t==null?void 0:t.maxPriorityFeePerGas}):new ea({cause:e})}function OE(e,{docsPath:t,...r}){const n=(()=>{const s=Ac(e,r);return s instanceof ea?e:s})();return new PE(n,{docsPath:t,...r})}function xc(e,{format:t}){if(!t)return{};const r={};function n(i){const o=Object.keys(i);for(const a of o)a in e&&(r[a]=e[a]),i[a]&&typeof i[a]=="object"&&!Array.isArray(i[a])&&n(i[a])}const s=t(e||{});return n(s),r}function bd(e,t){return({exclude:r,format:n})=>({exclude:r,format:s=>{const i=t(s);if(r)for(const o of r)delete i[o];return{...i,...n(s)}},type:e})}const BE={legacy:"0x0",eip2930:"0x1",eip1559:"0x2",eip4844:"0x3",eip7702:"0x4"};function Pi(e){const t={};return typeof e.authorizationList<"u"&&(t.authorizationList=CE(e.authorizationList)),typeof e.accessList<"u"&&(t.accessList=e.accessList),typeof e.blobVersionedHashes<"u"&&(t.blobVersionedHashes=e.blobVersionedHashes),typeof e.blobs<"u"&&(typeof e.blobs[0]!="string"?t.blobs=e.blobs.map(r=>Je(r)):t.blobs=e.blobs),typeof e.data<"u"&&(t.data=e.data),typeof e.from<"u"&&(t.from=e.from),typeof e.gas<"u"&&(t.gas=X(e.gas)),typeof e.gasPrice<"u"&&(t.gasPrice=X(e.gasPrice)),typeof e.maxFeePerBlobGas<"u"&&(t.maxFeePerBlobGas=X(e.maxFeePerBlobGas)),typeof e.maxFeePerGas<"u"&&(t.maxFeePerGas=X(e.maxFeePerGas)),typeof e.maxPriorityFeePerGas<"u"&&(t.maxPriorityFeePerGas=X(e.maxPriorityFeePerGas)),typeof e.nonce<"u"&&(t.nonce=X(e.nonce)),typeof e.to<"u"&&(t.to=e.to),typeof e.type<"u"&&(t.type=BE[e.type]),typeof e.value<"u"&&(t.value=X(e.value)),t}function CE(e){return e.map(t=>({address:t.address,r:t.r?X(BigInt(t.r)):t.r,s:t.s?X(BigInt(t.s)):t.s,chainId:X(t.chainId),nonce:X(t.nonce),...typeof t.yParity<"u"?{yParity:X(t.yParity)}:{},...typeof t.v<"u"&&typeof t.yParity>"u"?{v:X(t.v)}:{}}))}function Jh(e){if(!(!e||e.length===0))return e.reduce((t,{slot:r,value:n})=>{if(r.length!==66)throw new Fh({size:r.length,targetSize:66,type:"hex"});if(n.length!==66)throw new Fh({size:n.length,targetSize:66,type:"hex"});return t[r]=n,t},{})}function RE(e){const{balance:t,nonce:r,state:n,stateDiff:s,code:i}=e,o={};if(i!==void 0&&(o.code=i),t!==void 0&&(o.balance=X(t)),r!==void 0&&(o.nonce=X(r)),n!==void 0&&(o.state=Jh(n)),s!==void 0){if(o.state)throw new uE;o.stateDiff=Jh(s)}return o}function wd(e){if(!e)return;const t={};for(const{address:r,...n}of e){if(!st(r,{strict:!1}))throw new Bt({address:r});if(t[r])throw new cE({address:r});t[r]=RE(n)}return t}const Sc=2n**256n-1n;function js(e){const{account:t,gasPrice:r,maxFeePerGas:n,maxPriorityFeePerGas:s,to:i}=e,o=t?Xe(t):void 0;if(o&&!st(o.address))throw new Bt({address:o.address});if(i&&!st(i))throw new Bt({address:i});if(typeof r<"u"&&(typeof n<"u"||typeof s<"u"))throw new fE;if(n&&n>Sc)throw new Ps({maxFeePerGas:n});if(s&&n&&s>n)throw new Uo({maxFeePerGas:n,maxPriorityFeePerGas:s})}class $E extends z{constructor(){super("`baseFeeMultiplier` must be greater than 1.",{name:"BaseFeeScalarError"})}}class vd extends z{constructor(){super("Chain does not support EIP-1559 fees.",{name:"Eip1559FeesNotSupportedError"})}}class NE extends z{constructor({maxPriorityFeePerGas:t}){super(`\`maxFeePerGas\` cannot be less than the \`maxPriorityFeePerGas\` (${Ut(t)} gwei).`,{name:"MaxFeePerGasTooLowError"})}}class T0 extends z{constructor({blockHash:t,blockNumber:r}){let n="Block";t&&(n=`Block at hash "${t}"`),r&&(n=`Block at number "${r}"`),super(`${n} could not be found.`,{name:"BlockNotFoundError"})}}const I0={"0x0":"legacy","0x1":"eip2930","0x2":"eip1559","0x3":"eip4844","0x4":"eip7702"};function _c(e){const t={...e,blockHash:e.blockHash?e.blockHash:null,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,chainId:e.chainId?ur(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?ur(e.nonce):void 0,to:e.to?e.to:null,transactionIndex:e.transactionIndex?Number(e.transactionIndex):null,type:e.type?I0[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=ME(e.authorizationList)),t.yParity=(()=>{if(e.yParity)return Number(e.yParity);if(typeof t.v=="bigint"){if(t.v===0n||t.v===27n)return 0;if(t.v===1n||t.v===28n)return 1;if(t.v>=35n)return t.v%2n===0n?1:0}})(),t.type==="legacy"&&(delete t.accessList,delete t.maxFeePerBlobGas,delete t.maxFeePerGas,delete t.maxPriorityFeePerGas,delete t.yParity),t.type==="eip2930"&&(delete t.maxFeePerBlobGas,delete t.maxFeePerGas,delete t.maxPriorityFeePerGas),t.type==="eip1559"&&delete t.maxFeePerBlobGas,t}const UE=bd("transaction",_c);function ME(e){return e.map(t=>({address:t.address,chainId:Number(t.chainId),nonce:Number(t.nonce),r:t.r,s:t.s,yParity:Number(t.yParity)}))}function Ed(e){const t=(e.transactions??[]).map(r=>typeof r=="string"?r:_c(r));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}}const FE=bd("block",Ed);async function qr(e,{blockHash:t,blockNumber:r,blockTag:n=e.experimental_blockTag??"latest",includeTransactions:s}={}){var l,u,f;const i=s??!1,o=r!==void 0?X(r):void 0;let a=null;if(t?a=await e.request({method:"eth_getBlockByHash",params:[t,i]},{dedupe:!0}):a=await e.request({method:"eth_getBlockByNumber",params:[o||n,i]},{dedupe:!!o}),!a)throw new T0({blockHash:t,blockNumber:r});return(((f=(u=(l=e.chain)==null?void 0:l.formatters)==null?void 0:u.block)==null?void 0:f.format)||Ed)(a)}async function Ad(e){const t=await e.request({method:"eth_gasPrice"});return BigInt(t)}async function jE(e,t){return P0(e,t)}async function P0(e,t){var i,o;const{block:r,chain:n=e.chain,request:s}=t||{};try{const a=((i=n==null?void 0:n.fees)==null?void 0:i.maxPriorityFeePerGas)??((o=n==null?void 0:n.fees)==null?void 0:o.defaultPriorityFee);if(typeof a=="function"){const l=r||await se(e,qr,"getBlock")({}),u=await a({block:l,client:e,request:s});if(u===null)throw new Error;return u}if(typeof a<"u")return a;const c=await e.request({method:"eth_maxPriorityFeePerGas"});return ot(c)}catch{const[a,c]=await Promise.all([r?Promise.resolve(r):se(e,qr,"getBlock")({}),se(e,Ad,"getGasPrice")({})]);if(typeof a.baseFeePerGas!="bigint")throw new vd;const l=c-a.baseFeePerGas;return l<0n?0n:l}}async function LE(e,t){return gf(e,t)}async function gf(e,t){var p,d;const{block:r,chain:n=e.chain,request:s,type:i="eip1559"}=t||{},o=await(async()=>{var m,g;return typeof((m=n==null?void 0:n.fees)==null?void 0:m.baseFeeMultiplier)=="function"?n.fees.baseFeeMultiplier({block:r,client:e,request:s}):((g=n==null?void 0:n.fees)==null?void 0:g.baseFeeMultiplier)??1.2})();if(o<1)throw new $E;const c=10**(((p=o.toString().split(".")[1])==null?void 0:p.length)??0),l=m=>m*BigInt(Math.ceil(o*c))/BigInt(c),u=r||await se(e,qr,"getBlock")({});if(typeof((d=n==null?void 0:n.fees)==null?void 0:d.estimateFeesPerGas)=="function"){const m=await n.fees.estimateFeesPerGas({block:r,client:e,multiply:l,request:s,type:i});if(m!==null)return m}if(i==="eip1559"){if(typeof u.baseFeePerGas!="bigint")throw new vd;const m=typeof(s==null?void 0:s.maxPriorityFeePerGas)=="bigint"?s.maxPriorityFeePerGas:await P0(e,{block:u,chain:n,request:s}),g=l(u.baseFeePerGas);return{maxFeePerGas:(s==null?void 0:s.maxFeePerGas)??g+m,maxPriorityFeePerGas:m}}return{gasPrice:(s==null?void 0:s.gasPrice)??l(await se(e,Ad,"getGasPrice")({}))}}async function xd(e,{address:t,blockTag:r="latest",blockNumber:n}){const s=await e.request({method:"eth_getTransactionCount",params:[t,typeof n=="bigint"?X(n):r]},{dedupe:!!n});return ur(s)}function Sd(e){const{kzg:t}=e,r=e.to??(typeof e.blobs[0]=="string"?"hex":"bytes"),n=typeof e.blobs[0]=="string"?e.blobs.map(i=>Sr(i)):e.blobs,s=[];for(const i of n)s.push(Uint8Array.from(t.blobToKzgCommitment(i)));return r==="bytes"?s:s.map(i=>Je(i))}function _d(e){const{kzg:t}=e,r=e.to??(typeof e.blobs[0]=="string"?"hex":"bytes"),n=typeof e.blobs[0]=="string"?e.blobs.map(o=>Sr(o)):e.blobs,s=typeof e.commitments[0]=="string"?e.commitments.map(o=>Sr(o)):e.commitments,i=[];for(let o=0;o<n.length;o++){const a=n[o],c=s[o];i.push(Uint8Array.from(t.computeBlobKzgProof(a,c)))}return r==="bytes"?i:i.map(o=>Je(o))}function DE(e,t,r,n){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,r,n);const s=BigInt(32),i=BigInt(4294967295),o=Number(r>>s&i),a=Number(r&i),c=n?4:0,l=n?0:4;e.setUint32(t+c,o,n),e.setUint32(t+l,a,n)}function HE(e,t,r){return e&t^~e&r}function zE(e,t,r){return e&t^e&r^t&r}let O0=class extends yc{constructor(t,r,n,s){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=r,this.padOffset=n,this.isLE=s,this.buffer=new Uint8Array(t),this.view=uu(this.buffer)}update(t){Jn(this),t=mn(t),lr(t);const{view:r,buffer:n,blockLen:s}=this,i=t.length;for(let o=0;o<i;){const a=Math.min(s-this.pos,i-o);if(a===s){const c=uu(t);for(;s<=i-o;o+=s)this.process(c,o);continue}n.set(t.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===s&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){Jn(this),cd(t,this),this.finished=!0;const{buffer:r,view:n,blockLen:s,isLE:i}=this;let{pos:o}=this;r[o++]=128,_r(this.buffer.subarray(o)),this.padOffset>s-o&&(this.process(n,0),o=0);for(let f=o;f<s;f++)r[f]=0;DE(n,s-8,BigInt(this.length*8),i),this.process(n,0);const a=uu(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=c/4,u=this.get();if(l>u.length)throw new Error("_sha2: outputLen bigger than state");for(let f=0;f<l;f++)a.setUint32(4*f,u[f],i)}digest(){const{buffer:t,outputLen:r}=this;this.digestInto(t);const n=t.slice(0,r);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:r,buffer:n,length:s,finished:i,destroyed:o,pos:a}=this;return t.destroyed=o,t.finished=i,t.length=s,t.pos=a,s%r&&t.buffer.set(n),t}clone(){return this._cloneInto()}};const Pn=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),On=Uint32Array.from([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]),qE=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]),Bn=new Uint32Array(64);let kd=class extends O0{constructor(t=32){super(64,t,8,!1),this.A=Pn[0]|0,this.B=Pn[1]|0,this.C=Pn[2]|0,this.D=Pn[3]|0,this.E=Pn[4]|0,this.F=Pn[5]|0,this.G=Pn[6]|0,this.H=Pn[7]|0}get(){const{A:t,B:r,C:n,D:s,E:i,F:o,G:a,H:c}=this;return[t,r,n,s,i,o,a,c]}set(t,r,n,s,i,o,a,c){this.A=t|0,this.B=r|0,this.C=n|0,this.D=s|0,this.E=i|0,this.F=o|0,this.G=a|0,this.H=c|0}process(t,r){for(let f=0;f<16;f++,r+=4)Bn[f]=t.getUint32(r,!1);for(let f=16;f<64;f++){const p=Bn[f-15],d=Bn[f-2],m=Br(p,7)^Br(p,18)^p>>>3,g=Br(d,17)^Br(d,19)^d>>>10;Bn[f]=g+Bn[f-7]+m+Bn[f-16]|0}let{A:n,B:s,C:i,D:o,E:a,F:c,G:l,H:u}=this;for(let f=0;f<64;f++){const p=Br(a,6)^Br(a,11)^Br(a,25),d=u+p+HE(a,c,l)+qE[f]+Bn[f]|0,g=(Br(n,2)^Br(n,13)^Br(n,22))+zE(n,s,i)|0;u=l,l=c,c=a,a=o+d|0,o=i,i=s,s=n,n=d+g|0}n=n+this.A|0,s=s+this.B|0,i=i+this.C|0,o=o+this.D|0,a=a+this.E|0,c=c+this.F|0,l=l+this.G|0,u=u+this.H|0,this.set(n,s,i,o,a,c,l,u)}roundClean(){_r(Bn)}destroy(){this.set(0,0,0,0,0,0,0,0),_r(this.buffer)}},B0=class extends kd{constructor(){super(28),this.A=On[0]|0,this.B=On[1]|0,this.C=On[2]|0,this.D=On[3]|0,this.E=On[4]|0,this.F=On[5]|0,this.G=On[6]|0,this.H=On[7]|0}};const C0=mc(()=>new kd),VE=mc(()=>new B0),GE=kd,R0=C0,WE=B0,KE=VE,XE=Object.freeze(Object.defineProperty({__proto__:null,SHA224:WE,SHA256:GE,sha224:KE,sha256:R0},Symbol.toStringTag,{value:"Module"}));function Ki(e,t){const r=t||"hex",n=R0(xr(e,{strict:!1})?Ii(e):e);return r==="bytes"?n:mt(n)}function YE(e){const{commitment:t,version:r=1}=e,n=e.to??(typeof t=="string"?"hex":"bytes"),s=Ki(t,"bytes");return s.set([r],0),n==="bytes"?s:Je(s)}function $0(e){const{commitments:t,version:r}=e,n=e.to??(typeof t[0]=="string"?"hex":"bytes"),s=[];for(const i of t)s.push(YE({commitment:i,to:n,version:r}));return s}const Qh=6,N0=32,Td=4096,U0=N0*Td,ep=U0*Qh-1-1*Td*Qh,M0=1;class ZE extends z{constructor({maxSize:t,size:r}){super("Blob size is too large.",{metaMessages:[`Max: ${t} bytes`,`Given: ${r} bytes`],name:"BlobSizeTooLargeError"})}}class F0 extends z{constructor(){super("Blob data must not be empty.",{name:"EmptyBlobError"})}}class JE extends z{constructor({hash:t,size:r}){super(`Versioned hash "${t}" size is invalid.`,{metaMessages:["Expected: 32",`Received: ${r}`],name:"InvalidVersionedHashSizeError"})}}class QE extends z{constructor({hash:t,version:r}){super(`Versioned hash "${t}" version is invalid.`,{metaMessages:[`Expected: ${M0}`,`Received: ${r}`],name:"InvalidVersionedHashVersionError"})}}function e6(e){const t=e.to??(typeof e.data=="string"?"hex":"bytes"),r=typeof e.data=="string"?Sr(e.data):e.data,n=He(r);if(!n)throw new F0;if(n>ep)throw new ZE({maxSize:ep,size:n});const s=[];let i=!0,o=0;for(;i;){const a=yd(new Uint8Array(U0));let c=0;for(;c<Td;){const l=r.slice(o,o+(N0-1));if(a.pushByte(0),a.pushBytes(l),l.length<31){a.pushByte(128),i=!1;break}c++,o+=31}s.push(a)}return t==="bytes"?s.map(a=>a.bytes):s.map(a=>Je(a.bytes))}function j0(e){const{data:t,kzg:r,to:n}=e,s=e.blobs??e6({data:t,to:n}),i=e.commitments??Sd({blobs:s,kzg:r,to:n}),o=e.proofs??_d({blobs:s,commitments:i,kzg:r,to:n}),a=[];for(let c=0;c<s.length;c++)a.push({blob:s[c],commitment:i[c],proof:o[c]});return a}function L0(e){if(e.type)return e.type;if(typeof e.authorizationList<"u")return"eip7702";if(typeof e.blobs<"u"||typeof e.blobVersionedHashes<"u"||typeof e.maxFeePerBlobGas<"u"||typeof e.sidecars<"u")return"eip4844";if(typeof e.maxFeePerGas<"u"||typeof e.maxPriorityFeePerGas<"u")return"eip1559";if(typeof e.gasPrice<"u")return typeof e.accessList<"u"?"eip2930":"legacy";throw new hE({transaction:e})}async function Oi(e){const t=await e.request({method:"eth_chainId"},{dedupe:!0});return ur(t)}const D0=["blobVersionedHashes","chainId","fees","gas","nonce","type"],tp=new Map;async function kc(e,t){const{account:r=e.account,blobs:n,chain:s,gas:i,kzg:o,nonce:a,nonceManager:c,parameters:l=D0,type:u}=t,f=r&&Xe(r),p={...t,...f?{from:f==null?void 0:f.address}:{}};let d;async function m(){return d||(d=await se(e,qr,"getBlock")({blockTag:"latest"}),d)}let g;async function w(){return g||(s?s.id:typeof t.chainId<"u"?t.chainId:(g=await se(e,Oi,"getChainId")({}),g))}if(l.includes("nonce")&&typeof a>"u"&&f)if(c){const A=await w();p.nonce=await c.consume({address:f.address,chainId:A,client:e})}else p.nonce=await se(e,xd,"getTransactionCount")({address:f.address,blockTag:"pending"});if((l.includes("blobVersionedHashes")||l.includes("sidecars"))&&n&&o){const A=Sd({blobs:n,kzg:o});if(l.includes("blobVersionedHashes")){const T=$0({commitments:A,to:"hex"});p.blobVersionedHashes=T}if(l.includes("sidecars")){const T=_d({blobs:n,commitments:A,kzg:o}),E=j0({blobs:n,commitments:A,proofs:T,to:"hex"});p.sidecars=E}}if(l.includes("chainId")&&(p.chainId=await w()),(l.includes("fees")||l.includes("type"))&&typeof u>"u")try{p.type=L0(p)}catch{let A=tp.get(e.uid);if(typeof A>"u"){const T=await m();A=typeof(T==null?void 0:T.baseFeePerGas)=="bigint",tp.set(e.uid,A)}p.type=A?"eip1559":"legacy"}if(l.includes("fees"))if(p.type!=="legacy"&&p.type!=="eip2930"){if(typeof p.maxFeePerGas>"u"||typeof p.maxPriorityFeePerGas>"u"){const A=await m(),{maxFeePerGas:T,maxPriorityFeePerGas:E}=await gf(e,{block:A,chain:s,request:p});if(typeof t.maxPriorityFeePerGas>"u"&&t.maxFeePerGas&&t.maxFeePerGas<E)throw new NE({maxPriorityFeePerGas:E});p.maxPriorityFeePerGas=E,p.maxFeePerGas=T}}else{if(typeof t.maxFeePerGas<"u"||typeof t.maxPriorityFeePerGas<"u")throw new vd;if(typeof t.gasPrice>"u"){const A=await m(),{gasPrice:T}=await gf(e,{block:A,chain:s,request:p,type:"legacy"});p.gasPrice=T}}return l.includes("gas")&&typeof i>"u"&&(p.gas=await se(e,Id,"estimateGas")({...p,account:f&&{address:f.address,type:"json-rpc"}})),js(p),delete p.parameters,p}async function H0(e,{address:t,blockNumber:r,blockTag:n=e.experimental_blockTag??"latest"}){const s=typeof r=="bigint"?X(r):void 0,i=await e.request({method:"eth_getBalance",params:[t,s||n]});return BigInt(i)}async function Id(e,t){var s,i,o;const{account:r=e.account}=t,n=r?Xe(r):void 0;try{let W=function(Q){const{block:re,request:D,rpcStateOverride:B}=Q;return e.request({method:"eth_estimateGas",params:B?[D,re??e.experimental_blockTag??"latest",B]:re?[D,re]:[D]})};const{accessList:a,authorizationList:c,blobs:l,blobVersionedHashes:u,blockNumber:f,blockTag:p,data:d,gas:m,gasPrice:g,maxFeePerBlobGas:w,maxFeePerGas:A,maxPriorityFeePerGas:T,nonce:E,value:S,stateOverride:I,...P}=await kc(e,{...t,parameters:(n==null?void 0:n.type)==="local"?void 0:["blobVersionedHashes"]}),j=(typeof f=="bigint"?X(f):void 0)||p,k=wd(I),F=await(async()=>{if(P.to)return P.to;if(c&&c.length>0)return await k0({authorization:c[0]}).catch(()=>{throw new z("`to` is required. Could not infer from `authorizationList`")})})();js(t);const R=(o=(i=(s=e.chain)==null?void 0:s.formatters)==null?void 0:i.transactionRequest)==null?void 0:o.format,H=(R||Pi)({...xc(P,{format:R}),from:n==null?void 0:n.address,accessList:a,authorizationList:c,blobs:l,blobVersionedHashes:u,data:d,gas:m,gasPrice:g,maxFeePerBlobGas:w,maxFeePerGas:A,maxPriorityFeePerGas:T,nonce:E,to:F,value:S});let Z=BigInt(await W({block:j,request:H,rpcStateOverride:k}));if(c){const Q=await H0(e,{address:H.from}),re=await Promise.all(c.map(async D=>{const{address:B}=D,V=await W({block:j,request:{authorizationList:void 0,data:d,from:n==null?void 0:n.address,to:B,value:X(Q)},rpcStateOverride:k}).catch(()=>100000n);return 2n*BigInt(V)}));Z+=re.reduce((D,B)=>D+B,0n)}return Z}catch(a){throw OE(a,{...t,account:n,chain:e.chain})}}async function z0(e,t){const{abi:r,address:n,args:s,functionName:i,dataSuffix:o,...a}=t,c=dr({abi:r,args:s,functionName:i});try{return await se(e,Id,"estimateGas")({data:`${c}${o?o.replace("0x",""):""}`,to:n,...a})}catch(l){const u=a.account?Xe(a.account):void 0;throw Is(l,{abi:r,address:n,args:s,docsPath:"/docs/contract/estimateContractGas",functionName:i,sender:u==null?void 0:u.address})}}function ta(e,t){if(!st(e,{strict:!1}))throw new Bt({address:e});if(!st(t,{strict:!1}))throw new Bt({address:t});return e.toLowerCase()===t.toLowerCase()}const rp="/docs/contract/decodeEventLog";function Pd(e){const{abi:t,data:r,strict:n,topics:s}=e,i=n??!0,[o,...a]=s;if(!o)throw new zv({docsPath:rp});const c=t.find(g=>g.type==="event"&&o===gc(Ar(g)));if(!(c&&"name"in c)||c.type!=="event")throw new Lm(o,{docsPath:rp});const{name:l,inputs:u}=c,f=u==null?void 0:u.some(g=>!("name"in g&&g.name)),p=f?[]:{},d=u.map((g,w)=>[g,w]).filter(([g])=>"indexed"in g&&g.indexed);for(let g=0;g<d.length;g++){const[w,A]=d[g],T=a[g];if(!T)throw new pc({abiItem:c,param:w});p[f?A:w.name||A]=t6({param:w,value:T})}const m=u.filter(g=>!("indexed"in g&&g.indexed));if(m.length>0){if(r&&r!=="0x")try{const g=Jo(m,r);if(g)if(f)for(let w=0;w<u.length;w++)p[w]=p[w]??g.shift();else for(let w=0;w<m.length;w++)p[m[w].name]=g[w]}catch(g){if(i)throw g instanceof Fm||g instanceof m0?new po({abiItem:c,data:r,params:m,size:He(r)}):g}else if(i)throw new po({abiItem:c,data:"0x",params:m,size:0})}return{eventName:l,args:Object.values(p).length>0?p:void 0}}function t6({param:e,value:t}){return e.type==="string"||e.type==="bytes"||e.type==="tuple"||e.type.match(/^(.*)\[(\d+)?\]$/)?t:(Jo([e],t)||[])[0]}function Od(e){const{abi:t,args:r,logs:n,strict:s=!0}=e,i=(()=>{if(e.eventName)return Array.isArray(e.eventName)?e.eventName:[e.eventName]})();return n.map(o=>{var a;try{const c=t.find(u=>u.type==="event"&&o.topics[0]===gc(u));if(!c)return null;const l=Pd({...o,abi:[c],strict:s});return i&&!i.includes(l.eventName)||!r6({args:l.args,inputs:c.inputs,matchArgs:r})?null:{...l,...o}}catch(c){let l,u;if(c instanceof Lm)return null;if(c instanceof po||c instanceof pc){if(s)return null;l=c.abiItem.name,u=(a=c.abiItem.inputs)==null?void 0:a.some(f=>!("name"in f&&f.name))}return{...o,args:u?[]:{},eventName:l}}}).filter(Boolean)}function r6(e){const{args:t,inputs:r,matchArgs:n}=e;if(!n)return!0;if(!t)return!1;function s(i,o,a){try{return i.type==="address"?ta(o,a):i.type==="string"||i.type==="bytes"?lt(Ii(o))===a:o===a}catch{return!1}}return Array.isArray(t)&&Array.isArray(n)?n.every((i,o)=>{if(i==null)return!0;const a=r[o];return a?(Array.isArray(i)?i:[i]).some(l=>s(a,l,t[o])):!1}):typeof t=="object"&&!Array.isArray(t)&&typeof n=="object"&&!Array.isArray(n)?Object.entries(n).every(([i,o])=>{if(o==null)return!0;const a=r.find(l=>l.name===i);return a?(Array.isArray(o)?o:[o]).some(l=>s(a,l,t[i])):!1}):!1}function wn(e,{args:t,eventName:r}={}){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,...r?{args:t,eventName:r}:{}}}async function Bd(e,{address:t,blockHash:r,fromBlock:n,toBlock:s,event:i,events:o,args:a,strict:c}={}){const l=c??!1,u=o??(i?[i]:void 0);let f=[];u&&(f=[u.flatMap(g=>Zo({abi:[g],eventName:g.name,args:o?void 0:a}))],i&&(f=f[0]));let p;r?p=await e.request({method:"eth_getLogs",params:[{address:t,topics:f,blockHash:r}]}):p=await e.request({method:"eth_getLogs",params:[{address:t,topics:f,fromBlock:typeof n=="bigint"?X(n):n,toBlock:typeof s=="bigint"?X(s):s}]});const d=p.map(m=>wn(m));return u?Od({abi:u,args:a,logs:d,strict:l}):d}async function Cd(e,t){const{abi:r,address:n,args:s,blockHash:i,eventName:o,fromBlock:a,toBlock:c,strict:l}=t,u=o?Fs({abi:r,name:o}):void 0,f=u?void 0:r.filter(p=>p.type==="event");return se(e,Bd,"getLogs")({address:n,args:s,blockHash:i,event:u,events:f,fromBlock:a,toBlock:c,strict:l})}const du="/docs/contract/decodeFunctionResult";function Ls(e){const{abi:t,args:r,functionName:n,data:s}=e;let i=t[0];if(n){const a=Fs({abi:t,args:r,name:n});if(!a)throw new yi(n,{docsPath:du});i=a}if(i.type!=="function")throw new yi(void 0,{docsPath:du});if(!i.outputs)throw new Dm(i.name,{docsPath:du});const o=Jo(i.outputs,s);if(o&&o.length>1)return o;if(o&&o.length===1)return o[0]}const n6="0.1.1";function s6(){return n6}class Fe extends Error{constructor(t,r={}){const n=(()=>{var c;if(r.cause instanceof Fe){if(r.cause.details)return r.cause.details;if(r.cause.shortMessage)return r.cause.shortMessage}return r.cause&&"details"in r.cause&&typeof r.cause.details=="string"?r.cause.details:(c=r.cause)!=null&&c.message?r.cause.message:r.details})(),s=r.cause instanceof Fe&&r.cause.docsPath||r.docsPath,o=`https://oxlib.sh${s??""}`,a=[t||"An error occurred.",...r.metaMessages?["",...r.metaMessages]:[],...n||s?["",n?`Details: ${n}`:void 0,s?`See: ${o}`:void 0]:[]].filter(c=>typeof c=="string").join(`
|
|
40
40
|
`);super(a,r.cause?{cause:r.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@${s6()}`}),this.cause=r.cause,this.details=n,this.docs=o,this.docsPath=s,this.shortMessage=t}walk(t){return q0(this,t)}}function q0(e,t){return t!=null&&t(e)?e:e&&typeof e=="object"&&"cause"in e&&e.cause?q0(e.cause,t):t?null:e}const i6="#__bigint";function o6(e,t,r){return JSON.stringify(e,(n,s)=>typeof s=="bigint"?s.toString()+i6:s,r)}function a6(e,t){if(sp(e)>t)throw new g6({givenSize:sp(e),maxSize:t})}const Jr={zero:48,nine:57,A:65,F:70,a:97,f:102};function np(e){if(e>=Jr.zero&&e<=Jr.nine)return e-Jr.zero;if(e>=Jr.A&&e<=Jr.F)return e-(Jr.A-10);if(e>=Jr.a&&e<=Jr.f)return e-(Jr.a-10)}function c6(e,t={}){const{dir:r,size:n=32}=t;if(n===0)return e;if(e.length>n)throw new b6({size:e.length,targetSize:n,type:"Bytes"});const s=new Uint8Array(n);for(let i=0;i<n;i++){const o=r==="right";s[o?i:n-i-1]=e[o?i:e.length-i-1]}return s}function Rd(e,t){if(fr(e)>t)throw new x6({givenSize:fr(e),maxSize:t})}function u6(e,t){if(typeof t=="number"&&t>0&&t>fr(e)-1)throw new X0({offset:t,position:"start",size:fr(e)})}function l6(e,t,r){if(typeof t=="number"&&typeof r=="number"&&fr(e)!==r-t)throw new X0({offset:r,position:"end",size:fr(e)})}function V0(e,t={}){const{dir:r,size:n=32}=t;if(n===0)return e;const s=e.replace("0x","");if(s.length>n*2)throw new S6({size:Math.ceil(s.length/2),targetSize:n,type:"Hex"});return`0x${s[r==="right"?"padEnd":"padStart"](n*2,"0")}`}const f6=new TextEncoder;function d6(e){return e instanceof Uint8Array?e:typeof e=="string"?p6(e):h6(e)}function h6(e){return e instanceof Uint8Array?e:new Uint8Array(e)}function p6(e,t={}){const{size:r}=t;let n=e;r&&(Rd(e,r),n=Bs(e,r));let s=n.slice(2);s.length%2&&(s=`0${s}`);const i=s.length/2,o=new Uint8Array(i);for(let a=0,c=0;a<i;a++){const l=np(s.charCodeAt(c++)),u=np(s.charCodeAt(c++));if(l===void 0||u===void 0)throw new Fe(`Invalid byte sequence ("${s[c-2]}${s[c-1]}" in "${s}").`);o[a]=l*16+u}return o}function y6(e,t={}){const{size:r}=t,n=f6.encode(e);return typeof r=="number"?(a6(n,r),m6(n,r)):n}function m6(e,t){return c6(e,{dir:"right",size:t})}function sp(e){return e.length}let g6=class extends Fe{constructor({givenSize:t,maxSize:r}){super(`Size cannot exceed \`${r}\` bytes. Given size: \`${t}\` bytes.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.SizeOverflowError"})}},b6=class extends Fe{constructor({size:t,targetSize:r,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (\`${t}\`) exceeds padding size (\`${r}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.SizeExceedsPaddingSizeError"})}};const w6=new TextEncoder,v6=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function E6(e,t={}){const{strict:r=!1}=t;if(!e)throw new ip(e);if(typeof e!="string")throw new ip(e);if(r&&!/^0x[0-9a-fA-F]*$/.test(e))throw new op(e);if(!e.startsWith("0x"))throw new op(e)}function Gr(...e){return`0x${e.reduce((t,r)=>t+r.replace("0x",""),"")}`}function G0(e,t={}){const r=`0x${Number(e)}`;return typeof t.size=="number"?(Rd(r,t.size),Os(r,t.size)):r}function W0(e,t={}){let r="";for(let s=0;s<e.length;s++)r+=v6[e[s]];const n=`0x${r}`;return typeof t.size=="number"?(Rd(n,t.size),Bs(n,t.size)):n}function It(e,t={}){const{signed:r,size:n}=t,s=BigInt(e);let i;n?r?i=(1n<<BigInt(n)*8n-1n)-1n:i=2n**(BigInt(n)*8n)-1n:typeof e=="number"&&(i=BigInt(Number.MAX_SAFE_INTEGER));const o=typeof i=="bigint"&&r?-i-1n:0;if(i&&s>i||s<o){const l=typeof e=="bigint"?"n":"";throw new K0({max:i?`${i}${l}`:void 0,min:`${o}${l}`,signed:r,size:n,value:`${e}${l}`})}const c=`0x${(r&&s<0?(1n<<BigInt(n*8))+BigInt(s):s).toString(16)}`;return n?Os(c,n):c}function $d(e,t={}){return W0(w6.encode(e),t)}function Os(e,t){return V0(e,{dir:"left",size:t})}function Bs(e,t){return V0(e,{dir:"right",size:t})}function Nd(e,t,r,n={}){const{strict:s}=n;u6(e,t);const i=`0x${e.replace("0x","").slice((t??0)*2,(r??e.length)*2)}`;return s&&l6(i,t,r),i}function fr(e){return Math.ceil((e.length-2)/2)}function A6(e,t={}){const{strict:r=!1}=t;try{return E6(e,{strict:r}),!0}catch{return!1}}class K0 extends Fe{constructor({max:t,min:r,signed:n,size:s,value:i}){super(`Number \`${i}\` is not in safe${s?` ${s*8}-bit`:""}${n?" signed":" unsigned"} integer range ${t?`(\`${r}\` to \`${t}\`)`:`(above \`${r}\`)`}`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.IntegerOutOfRangeError"})}}class ip extends Fe{constructor(t){super(`Value \`${typeof t=="object"?o6(t):t}\` of type \`${typeof t}\` is an invalid hex type.`,{metaMessages:['Hex types must be represented as `"0x${string}"`.']}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.InvalidHexTypeError"})}}class op extends Fe{constructor(t){super(`Value \`${t}\` is an invalid hex value.`,{metaMessages:['Hex values must start with `"0x"` and contain only hexadecimal characters (0-9, a-f, A-F).']}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.InvalidHexValueError"})}}class x6 extends Fe{constructor({givenSize:t,maxSize:r}){super(`Size cannot exceed \`${r}\` bytes. Given size: \`${t}\` bytes.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SizeOverflowError"})}}class X0 extends Fe{constructor({offset:t,position:r,size:n}){super(`Slice ${r==="start"?"starting":"ending"} at offset \`${t}\` is out-of-bounds (size: \`${n}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SliceOffsetOutOfBoundsError"})}}class S6 extends Fe{constructor({size:t,targetSize:r,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (\`${t}\`) exceeds padding size (\`${r}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SizeExceedsPaddingSizeError"})}}function _6(e){return{address:e.address,amount:It(e.amount),index:It(e.index),validatorIndex:It(e.validatorIndex)}}function Y0(e){return{...typeof e.baseFeePerGas=="bigint"&&{baseFeePerGas:It(e.baseFeePerGas)},...typeof e.blobBaseFee=="bigint"&&{blobBaseFee:It(e.blobBaseFee)},...typeof e.feeRecipient=="string"&&{feeRecipient:e.feeRecipient},...typeof e.gasLimit=="bigint"&&{gasLimit:It(e.gasLimit)},...typeof e.number=="bigint"&&{number:It(e.number)},...typeof e.prevRandao=="bigint"&&{prevRandao:It(e.prevRandao)},...typeof e.time=="bigint"&&{time:It(e.time)},...e.withdrawals&&{withdrawals:e.withdrawals.map(_6)}}}const bf=[{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"}],wf=[{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"}]}],Z0=[{inputs:[],name:"ResolverNotFound",type:"error"},{inputs:[],name:"ResolverWildcardNotSupported",type:"error"},{inputs:[],name:"ResolverNotContract",type:"error"},{inputs:[{name:"returnData",type:"bytes"}],name:"ResolverError",type:"error"},{inputs:[{components:[{name:"status",type:"uint16"},{name:"message",type:"string"}],name:"errors",type:"tuple[]"}],name:"HttpError",type:"error"}],J0=[...Z0,{name:"resolve",type:"function",stateMutability:"view",inputs:[{name:"name",type:"bytes"},{name:"data",type:"bytes"}],outputs:[{name:"",type:"bytes"},{name:"address",type:"address"}]},{name:"resolve",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"}]}],k6=[...Z0,{name:"reverse",type:"function",stateMutability:"view",inputs:[{type:"bytes",name:"reverseName"}],outputs:[{type:"string",name:"resolvedName"},{type:"address",name:"resolvedAddress"},{type:"address",name:"reverseResolver"},{type:"address",name:"resolver"}]},{name:"reverse",type:"function",stateMutability:"view",inputs:[{type:"bytes",name:"reverseName"},{type:"string[]",name:"gateways"}],outputs:[{type:"string",name:"resolvedName"},{type:"address",name:"resolvedAddress"},{type:"address",name:"reverseResolver"},{type:"address",name:"resolver"}]}],ap=[{name:"text",type:"function",stateMutability:"view",inputs:[{name:"name",type:"bytes32"},{name:"key",type:"string"}],outputs:[{name:"",type:"string"}]}],cp=[{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"}]}],up=[{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"}],T6="0x82ad56cb",Q0="0x608060405234801561001057600080fd5b5060405161018e38038061018e83398101604081905261002f91610124565b6000808351602085016000f59050803b61004857600080fd5b6000808351602085016000855af16040513d6000823e81610067573d81fd5b3d81f35b634e487b7160e01b600052604160045260246000fd5b600082601f83011261009257600080fd5b81516001600160401b038111156100ab576100ab61006b565b604051601f8201601f19908116603f011681016001600160401b03811182821017156100d9576100d961006b565b6040528181528382016020018510156100f157600080fd5b60005b82811015610110576020818601810151838301820152016100f4565b506000918101602001919091529392505050565b6000806040838503121561013757600080fd5b82516001600160401b0381111561014d57600080fd5b61015985828601610081565b602085015190935090506001600160401b0381111561017757600080fd5b61018385828601610081565b915050925092905056fe",I6="0x608060405234801561001057600080fd5b506040516102c03803806102c083398101604081905261002f916101e6565b836001600160a01b03163b6000036100e457600080836001600160a01b03168360405161005c9190610270565b6000604051808303816000865af19150503d8060008114610099576040519150601f19603f3d011682016040523d82523d6000602084013e61009e565b606091505b50915091508115806100b857506001600160a01b0386163b155b156100e1578060405163101bb98d60e01b81526004016100d8919061028c565b60405180910390fd5b50505b6000808451602086016000885af16040513d6000823e81610103573d81fd5b3d81f35b80516001600160a01b038116811461011e57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b8381101561015457818101518382015260200161013c565b50506000910152565b600082601f83011261016e57600080fd5b81516001600160401b0381111561018757610187610123565b604051601f8201601f19908116603f011681016001600160401b03811182821017156101b5576101b5610123565b6040528181528382016020018510156101cd57600080fd5b6101de826020830160208701610139565b949350505050565b600080600080608085870312156101fc57600080fd5b61020585610107565b60208601519094506001600160401b0381111561022157600080fd5b61022d8782880161015d565b93505061023c60408601610107565b60608601519092506001600160401b0381111561025857600080fd5b6102648782880161015d565b91505092959194509250565b60008251610282818460208701610139565b9190910192915050565b60208152600082518060208401526102ab816040850160208701610139565b601f01601f1916919091016040019291505056fe",P6="0x608060405234801561001057600080fd5b5060405161069438038061069483398101604081905261002f9161051e565b600061003c848484610048565b9050806000526001601ff35b60007f64926492649264926492649264926492649264926492649264926492649264926100748361040c565b036101e7576000606080848060200190518101906100929190610577565b60405192955090935091506000906001600160a01b038516906100b69085906105dd565b6000604051808303816000865af19150503d80600081146100f3576040519150601f19603f3d011682016040523d82523d6000602084013e6100f8565b606091505b50509050876001600160a01b03163b60000361016057806101605760405162461bcd60e51b815260206004820152601e60248201527f5369676e617475726556616c696461746f723a206465706c6f796d656e74000060448201526064015b60405180910390fd5b604051630b135d3f60e11b808252906001600160a01b038a1690631626ba7e90610190908b9087906004016105f9565b602060405180830381865afa1580156101ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101d19190610633565b6001600160e01b03191614945050505050610405565b6001600160a01b0384163b1561027a57604051630b135d3f60e11b808252906001600160a01b03861690631626ba7e9061022790879087906004016105f9565b602060405180830381865afa158015610244573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102689190610633565b6001600160e01b031916149050610405565b81516041146102df5760405162461bcd60e51b815260206004820152603a602482015260008051602061067483398151915260448201527f3a20696e76616c6964207369676e6174757265206c656e6774680000000000006064820152608401610157565b6102e7610425565b5060208201516040808401518451859392600091859190811061030c5761030c61065d565b016020015160f81c9050601b811480159061032b57508060ff16601c14155b1561038c5760405162461bcd60e51b815260206004820152603b602482015260008051602061067483398151915260448201527f3a20696e76616c6964207369676e617475726520762076616c756500000000006064820152608401610157565b60408051600081526020810180835289905260ff83169181019190915260608101849052608081018390526001600160a01b0389169060019060a0016020604051602081039080840390855afa1580156103ea573d6000803e3d6000fd5b505050602060405103516001600160a01b0316149450505050505b9392505050565b600060208251101561041d57600080fd5b508051015190565b60405180606001604052806003906020820280368337509192915050565b6001600160a01b038116811461045857600080fd5b50565b634e487b7160e01b600052604160045260246000fd5b60005b8381101561048c578181015183820152602001610474565b50506000910152565b600082601f8301126104a657600080fd5b81516001600160401b038111156104bf576104bf61045b565b604051601f8201601f19908116603f011681016001600160401b03811182821017156104ed576104ed61045b565b60405281815283820160200185101561050557600080fd5b610516826020830160208701610471565b949350505050565b60008060006060848603121561053357600080fd5b835161053e81610443565b6020850151604086015191945092506001600160401b0381111561056157600080fd5b61056d86828701610495565b9150509250925092565b60008060006060848603121561058c57600080fd5b835161059781610443565b60208501519093506001600160401b038111156105b357600080fd5b6105bf86828701610495565b604086015190935090506001600160401b0381111561056157600080fd5b600082516105ef818460208701610471565b9190910192915050565b828152604060208201526000825180604084015261061e816060850160208701610471565b601f01601f1916919091016060019392505050565b60006020828403121561064557600080fd5b81516001600160e01b03198116811461040557600080fd5b634e487b7160e01b600052603260045260246000fdfe5369676e617475726556616c696461746f72237265636f7665725369676e6572";class vf extends z{constructor({blockNumber:t,chain:r,contract:n}){super(`Chain "${r.name}" does not support contract "${n.name}".`,{metaMessages:["This could be due to any of the following:",...t&&n.blockCreated&&n.blockCreated>t?[`- The contract "${n.name}" was not deployed until block ${n.blockCreated} (current block ${t}).`]:[`- The chain does not have the contract "${n.name}" configured.`]],name:"ChainDoesNotSupportContract"})}}class O6 extends z{constructor({chain:t,currentChainId:r}){super(`The current chain of the wallet (id: ${r}) does not match the target chain for the transaction (id: ${t.id} – ${t.name}).`,{metaMessages:[`Current Chain ID: ${r}`,`Expected Chain ID: ${t.id} – ${t.name}`],name:"ChainMismatchError"})}}class B6 extends z{constructor(){super(["No chain was provided to the request.","Please provide a chain with the `chain` argument on the Action, or by supplying a `chain` to WalletClient."].join(`
|
|
41
|
-
`),{name:"ChainNotFoundError"})}}class eg extends z{constructor(){super("No chain was provided to the Client.",{name:"ClientChainNotConfiguredError"})}}class Tc extends z{constructor({chainId:t}){super(typeof t=="number"?`Chain ID "${t}" is invalid.`:"Chain ID is invalid.",{name:"InvalidChainIdError"})}}const hu="/docs/contract/encodeDeployData";function Ic(e){const{abi:t,args:r,bytecode:n}=e;if(!r||r.length===0)return n;const s=t.find(o=>"type"in o&&o.type==="constructor");if(!s)throw new Fv({docsPath:hu});if(!("inputs"in s))throw new Nh({docsPath:hu});if(!s.inputs||s.inputs.length===0)throw new Nh({docsPath:hu});const i=kn(s.inputs,r);return Tr([n,i])}function Bi({blockNumber:e,chain:t,contract:r}){var s;const n=(s=t==null?void 0:t.contracts)==null?void 0:s[r];if(!n)throw new vf({chain:t,contract:{name:r}});if(e&&n.blockCreated&&n.blockCreated>e)throw new vf({blockNumber:e,chain:t,contract:{name:r,blockCreated:n.blockCreated}});return n.address}function tg(e,{docsPath:t,...r}){const n=(()=>{const s=Ac(e,r);return s instanceof ea?e:s})();return new A0(n,{docsPath:t,...r})}function Ud(){let e=()=>{},t=()=>{};return{promise:new Promise((n,s)=>{e=n,t=s}),resolve:e,reject:t}}const pu=new Map;function rg({fn:e,id:t,shouldSplitBatch:r,wait:n=0,sort:s}){const i=async()=>{const u=c();o();const f=u.map(({args:p})=>p);f.length!==0&&e(f).then(p=>{s&&Array.isArray(p)&&p.sort(s);for(let d=0;d<u.length;d++){const{resolve:m}=u[d];m==null||m([p[d],p])}}).catch(p=>{for(let d=0;d<u.length;d++){const{reject:m}=u[d];m==null||m(p)}})},o=()=>pu.delete(t),a=()=>c().map(({args:u})=>u),c=()=>pu.get(t)||[],l=u=>pu.set(t,[...c(),u]);return{flush:o,async schedule(u){const{promise:f,resolve:p,reject:d}=Ud();return(r==null?void 0:r([...a(),u]))&&i(),c().length>0?(l({args:u,resolve:p,reject:d}),f):(l({args:u,resolve:p,reject:d}),setTimeout(i,n),f)}}}async function ra(e,t){var H,W,Z,Q;const{account:r=e.account,authorizationList:n,batch:s=!!((H=e.batch)!=null&&H.multicall),blockNumber:i,blockTag:o=e.experimental_blockTag??"latest",accessList:a,blobs:c,blockOverrides:l,code:u,data:f,factory:p,factoryData:d,gas:m,gasPrice:g,maxFeePerBlobGas:w,maxFeePerGas:A,maxPriorityFeePerGas:T,nonce:E,to:S,value:I,stateOverride:P,...$}=t,j=r?Xe(r):void 0;if(u&&(p||d))throw new z("Cannot provide both `code` & `factory`/`factoryData` as parameters.");if(u&&S)throw new z("Cannot provide both `code` & `to` as parameters.");const k=u&&f,F=p&&d&&S&&f,R=k||F,U=k?$6({code:u,data:f}):F?N6({data:f,factory:p,factoryData:d,to:S}):f;try{js(t);const D=(typeof i=="bigint"?X(i):void 0)||o,B=l?Y0(l):void 0,V=wd(P),K=(Q=(Z=(W=e.chain)==null?void 0:W.formatters)==null?void 0:Z.transactionRequest)==null?void 0:Q.format,N=(K||Pi)({...xc($,{format:K}),from:j==null?void 0:j.address,accessList:a,authorizationList:n,blobs:c,data:U,gas:m,gasPrice:g,maxFeePerBlobGas:w,maxFeePerGas:A,maxPriorityFeePerGas:T,nonce:E,to:R?void 0:S,value:I});if(s&&C6({request:N})&&!V&&!B)try{return await R6(e,{...N,blockNumber:i,blockTag:o})}catch(ne){if(!(ne instanceof eg)&&!(ne instanceof vf))throw ne}const L=(()=>{const ne=[N,D];return V&&B?[...ne,V,B]:V?[...ne,V]:B?[...ne,{},B]:ne})(),J=await e.request({method:"eth_call",params:L});return J==="0x"?{data:void 0}:{data:J}}catch(re){const D=U6(re),{offchainLookup:B,offchainLookupSignature:V}=await Promise.resolve().then(()=>require("./ccip-C0J0QEJ3.cjs"));if(e.ccipRead!==!1&&(D==null?void 0:D.slice(0,10))===V&&S)return{data:await B(e,{data:D,to:S})};throw R&&(D==null?void 0:D.slice(0,10))==="0x101bb98d"?new vE({factory:p}):tg(re,{...t,account:j,chain:e.chain})}}function C6({request:e}){const{data:t,to:r,...n}=e;return!(!t||t.startsWith(T6)||!r||Object.values(n).filter(s=>typeof s<"u").length>0)}async function R6(e,t){var g;const{batchSize:r=1024,wait:n=0}=typeof((g=e.batch)==null?void 0:g.multicall)=="object"?e.batch.multicall:{},{blockNumber:s,blockTag:i=e.experimental_blockTag??"latest",data:o,multicallAddress:a,to:c}=t;let l=a;if(!l){if(!e.chain)throw new eg;l=Bi({blockNumber:s,chain:e.chain,contract:"multicall3"})}const f=(typeof s=="bigint"?X(s):void 0)||i,{schedule:p}=rg({id:`${e.uid}.${f}`,wait:n,shouldSplitBatch(w){return w.reduce((T,{data:E})=>T+(E.length-2),0)>r*2},fn:async w=>{const A=w.map(S=>({allowFailure:!0,callData:S.data,target:S.to})),T=dr({abi:bf,args:[A],functionName:"aggregate3"}),E=await e.request({method:"eth_call",params:[{data:T,to:l},f]});return Ls({abi:bf,args:[A],functionName:"aggregate3",data:E||"0x"})}}),[{returnData:d,success:m}]=await p({data:o,to:c});if(!m)throw new Ec({data:d});return d==="0x"?{data:void 0}:{data:d}}function $6(e){const{code:t,data:r}=e;return Ic({abi:Nm(["constructor(bytes, bytes)"]),bytecode:Q0,args:[t,r]})}function N6(e){const{data:t,factory:r,factoryData:n,to:s}=e;return Ic({abi:Nm(["constructor(address, bytes, address, bytes)"]),bytecode:I6,args:[s,t,r,n]})}function U6(e){var r;if(!(e instanceof z))return;const t=e.walk();return typeof(t==null?void 0:t.data)=="object"?(r=t.data)==null?void 0:r.data:t.data}async function Wr(e,t){const{abi:r,address:n,args:s,functionName:i,...o}=t,a=dr({abi:r,args:s,functionName:i});try{const{data:c}=await se(e,ra,"call")({...o,data:a,to:n});return Ls({abi:r,args:s,functionName:i,data:c||"0x"})}catch(c){throw Is(c,{abi:r,address:n,args:s,docsPath:"/docs/contract/readContract",functionName:i})}}async function ng(e,t){const{abi:r,address:n,args:s,dataSuffix:i,functionName:o,...a}=t,c=a.account?Xe(a.account):e.account,l=dr({abi:r,args:s,functionName:o});try{const{data:u}=await se(e,ra,"call")({batch:!1,data:`${l}${i?i.replace("0x",""):""}`,to:n,...a,account:c}),f=Ls({abi:r,args:s,functionName:o,data:u||"0x"}),p=r.filter(d=>"name"in d&&d.name===t.functionName);return{result:f,request:{abi:p,address:n,args:s,dataSuffix:i,functionName:o,...a,account:c}}}catch(u){throw Is(u,{abi:r,address:n,args:s,docsPath:"/docs/contract/simulateContract",functionName:o,sender:c==null?void 0:c.address})}}const yu=new Map,lp=new Map;let M6=0;function vn(e,t,r){const n=++M6,s=()=>yu.get(e)||[],i=()=>{const u=s();yu.set(e,u.filter(f=>f.id!==n))},o=()=>{const u=s();if(!u.some(p=>p.id===n))return;const f=lp.get(e);if(u.length===1&&f){const p=f();p instanceof Promise&&p.catch(()=>{})}i()},a=s();if(yu.set(e,[...a,{id:n,fns:t}]),a&&a.length>0)return o;const c={};for(const u in t)c[u]=(...f)=>{var d,m;const p=s();if(p.length!==0)for(const g of p)(m=(d=g.fns)[u])==null||m.call(d,...f)};const l=r(c);return typeof l=="function"&&lp.set(e,l),o}async function Ef(e){return new Promise(t=>setTimeout(t,e))}function Ci(e,{emitOnBegin:t,initialWaitTime:r,interval:n}){let s=!0;const i=()=>s=!1;return(async()=>{let a;t&&(a=await e({unpoll:i}));const c=await(r==null?void 0:r(a))??n;await Ef(c);const l=async()=>{s&&(await e({unpoll:i}),await Ef(n),l())};l()})(),i}const F6=new Map,j6=new Map;function L6(e){const t=(s,i)=>({clear:()=>i.delete(s),get:()=>i.get(s),set:o=>i.set(s,o)}),r=t(e,F6),n=t(e,j6);return{clear:()=>{r.clear(),n.clear()},promise:r,response:n}}async function D6(e,{cacheKey:t,cacheTime:r=Number.POSITIVE_INFINITY}){const n=L6(t),s=n.response.get();if(s&&r>0&&new Date().getTime()-s.created.getTime()<r)return s.data;let i=n.promise.get();i||(i=e(),n.promise.set(i));try{const o=await i;return n.response.set({created:new Date,data:o}),o}finally{n.promise.clear()}}const H6=e=>`blockNumber.${e}`;async function na(e,{cacheTime:t=e.cacheTime}={}){const r=await D6(()=>e.request({method:"eth_blockNumber"}),{cacheKey:H6(e.uid),cacheTime:t});return BigInt(r)}async function Pc(e,{filter:t}){const r="strict"in t&&t.strict,n=await t.request({method:"eth_getFilterChanges",params:[t.id]});if(typeof n[0]=="string")return n;const s=n.map(i=>wn(i));return!("abi"in t)||!t.abi?s:Od({abi:t.abi,logs:s,strict:r})}async function Oc(e,{filter:t}){return t.request({method:"eth_uninstallFilter",params:[t.id]})}function sg(e,t){const{abi:r,address:n,args:s,batch:i=!0,eventName:o,fromBlock:a,onError:c,onLogs:l,poll:u,pollingInterval:f=e.pollingInterval,strict:p}=t;return(typeof u<"u"?u:typeof a=="bigint"?!0:!(e.transport.type==="webSocket"||e.transport.type==="ipc"||e.transport.type==="fallback"&&(e.transport.transports[0].config.type==="webSocket"||e.transport.transports[0].config.type==="ipc")))?(()=>{const w=p??!1,A=Ze(["watchContractEvent",n,s,i,e.uid,o,f,w,a]);return vn(A,{onLogs:l,onError:c},T=>{let E;a!==void 0&&(E=a-1n);let S,I=!1;const P=Ci(async()=>{var $;if(!I){try{S=await se(e,pd,"createContractEventFilter")({abi:r,address:n,args:s,eventName:o,strict:w,fromBlock:a})}catch{}I=!0;return}try{let j;if(S)j=await se(e,Pc,"getFilterChanges")({filter:S});else{const k=await se(e,na,"getBlockNumber")({});E&&E<k?j=await se(e,Cd,"getContractEvents")({abi:r,address:n,args:s,eventName:o,fromBlock:E+1n,toBlock:k,strict:w}):j=[],E=k}if(j.length===0)return;if(i)T.onLogs(j);else for(const k of j)T.onLogs([k])}catch(j){S&&j instanceof Ts&&(I=!1),($=T.onError)==null||$.call(T,j)}},{emitOnBegin:!0,interval:f});return async()=>{S&&await se(e,Oc,"uninstallFilter")({filter:S}),P()}})})():(()=>{const w=p??!1,A=Ze(["watchContractEvent",n,s,i,e.uid,o,f,w]);let T=!0,E=()=>T=!1;return vn(A,{onLogs:l,onError:c},S=>((async()=>{try{const I=(()=>{if(e.transport.type==="fallback"){const j=e.transport.transports.find(k=>k.config.type==="webSocket"||k.config.type==="ipc");return j?j.value:e.transport}return e.transport})(),P=o?Zo({abi:r,eventName:o,args:s}):[],{unsubscribe:$}=await I.subscribe({params:["logs",{address:n,topics:P}],onData(j){var F;if(!T)return;const k=j.result;try{const{eventName:R,args:U}=Pd({abi:r,data:k.data,topics:k.topics,strict:p}),H=wn(k,{args:U,eventName:R});S.onLogs([H])}catch(R){let U,H;if(R instanceof po||R instanceof pc){if(p)return;U=R.abiItem.name,H=(F=R.abiItem.inputs)==null?void 0:F.some(Z=>!("name"in Z&&Z.name))}const W=wn(k,{args:H?[]:{},eventName:U});S.onLogs([W])}},onError(j){var k;(k=S.onError)==null||k.call(S,j)}});E=$,T||E()}catch(I){c==null||c(I)}})(),()=>E()))})()}class Ds extends z{constructor({docsPath:t}={}){super(["Could not find an Account to execute with this Action.","Please provide an Account with the `account` argument on the Action, or by supplying an `account` to the Client."].join(`
|
|
41
|
+
`),{name:"ChainNotFoundError"})}}class eg extends z{constructor(){super("No chain was provided to the Client.",{name:"ClientChainNotConfiguredError"})}}class Tc extends z{constructor({chainId:t}){super(typeof t=="number"?`Chain ID "${t}" is invalid.`:"Chain ID is invalid.",{name:"InvalidChainIdError"})}}const hu="/docs/contract/encodeDeployData";function Ic(e){const{abi:t,args:r,bytecode:n}=e;if(!r||r.length===0)return n;const s=t.find(o=>"type"in o&&o.type==="constructor");if(!s)throw new Fv({docsPath:hu});if(!("inputs"in s))throw new Nh({docsPath:hu});if(!s.inputs||s.inputs.length===0)throw new Nh({docsPath:hu});const i=kn(s.inputs,r);return Tr([n,i])}function Bi({blockNumber:e,chain:t,contract:r}){var s;const n=(s=t==null?void 0:t.contracts)==null?void 0:s[r];if(!n)throw new vf({chain:t,contract:{name:r}});if(e&&n.blockCreated&&n.blockCreated>e)throw new vf({blockNumber:e,chain:t,contract:{name:r,blockCreated:n.blockCreated}});return n.address}function tg(e,{docsPath:t,...r}){const n=(()=>{const s=Ac(e,r);return s instanceof ea?e:s})();return new A0(n,{docsPath:t,...r})}function Ud(){let e=()=>{},t=()=>{};return{promise:new Promise((n,s)=>{e=n,t=s}),resolve:e,reject:t}}const pu=new Map;function rg({fn:e,id:t,shouldSplitBatch:r,wait:n=0,sort:s}){const i=async()=>{const u=c();o();const f=u.map(({args:p})=>p);f.length!==0&&e(f).then(p=>{s&&Array.isArray(p)&&p.sort(s);for(let d=0;d<u.length;d++){const{resolve:m}=u[d];m==null||m([p[d],p])}}).catch(p=>{for(let d=0;d<u.length;d++){const{reject:m}=u[d];m==null||m(p)}})},o=()=>pu.delete(t),a=()=>c().map(({args:u})=>u),c=()=>pu.get(t)||[],l=u=>pu.set(t,[...c(),u]);return{flush:o,async schedule(u){const{promise:f,resolve:p,reject:d}=Ud();return(r==null?void 0:r([...a(),u]))&&i(),c().length>0?(l({args:u,resolve:p,reject:d}),f):(l({args:u,resolve:p,reject:d}),setTimeout(i,n),f)}}}async function ra(e,t){var H,W,Z,Q;const{account:r=e.account,authorizationList:n,batch:s=!!((H=e.batch)!=null&&H.multicall),blockNumber:i,blockTag:o=e.experimental_blockTag??"latest",accessList:a,blobs:c,blockOverrides:l,code:u,data:f,factory:p,factoryData:d,gas:m,gasPrice:g,maxFeePerBlobGas:w,maxFeePerGas:A,maxPriorityFeePerGas:T,nonce:E,to:S,value:I,stateOverride:P,...$}=t,j=r?Xe(r):void 0;if(u&&(p||d))throw new z("Cannot provide both `code` & `factory`/`factoryData` as parameters.");if(u&&S)throw new z("Cannot provide both `code` & `to` as parameters.");const k=u&&f,F=p&&d&&S&&f,R=k||F,U=k?$6({code:u,data:f}):F?N6({data:f,factory:p,factoryData:d,to:S}):f;try{js(t);const D=(typeof i=="bigint"?X(i):void 0)||o,B=l?Y0(l):void 0,V=wd(P),K=(Q=(Z=(W=e.chain)==null?void 0:W.formatters)==null?void 0:Z.transactionRequest)==null?void 0:Q.format,N=(K||Pi)({...xc($,{format:K}),from:j==null?void 0:j.address,accessList:a,authorizationList:n,blobs:c,data:U,gas:m,gasPrice:g,maxFeePerBlobGas:w,maxFeePerGas:A,maxPriorityFeePerGas:T,nonce:E,to:R?void 0:S,value:I});if(s&&C6({request:N})&&!V&&!B)try{return await R6(e,{...N,blockNumber:i,blockTag:o})}catch(ne){if(!(ne instanceof eg)&&!(ne instanceof vf))throw ne}const L=(()=>{const ne=[N,D];return V&&B?[...ne,V,B]:V?[...ne,V]:B?[...ne,{},B]:ne})(),J=await e.request({method:"eth_call",params:L});return J==="0x"?{data:void 0}:{data:J}}catch(re){const D=U6(re),{offchainLookup:B,offchainLookupSignature:V}=await Promise.resolve().then(()=>require("./ccip-khJakyl9.cjs"));if(e.ccipRead!==!1&&(D==null?void 0:D.slice(0,10))===V&&S)return{data:await B(e,{data:D,to:S})};throw R&&(D==null?void 0:D.slice(0,10))==="0x101bb98d"?new vE({factory:p}):tg(re,{...t,account:j,chain:e.chain})}}function C6({request:e}){const{data:t,to:r,...n}=e;return!(!t||t.startsWith(T6)||!r||Object.values(n).filter(s=>typeof s<"u").length>0)}async function R6(e,t){var g;const{batchSize:r=1024,wait:n=0}=typeof((g=e.batch)==null?void 0:g.multicall)=="object"?e.batch.multicall:{},{blockNumber:s,blockTag:i=e.experimental_blockTag??"latest",data:o,multicallAddress:a,to:c}=t;let l=a;if(!l){if(!e.chain)throw new eg;l=Bi({blockNumber:s,chain:e.chain,contract:"multicall3"})}const f=(typeof s=="bigint"?X(s):void 0)||i,{schedule:p}=rg({id:`${e.uid}.${f}`,wait:n,shouldSplitBatch(w){return w.reduce((T,{data:E})=>T+(E.length-2),0)>r*2},fn:async w=>{const A=w.map(S=>({allowFailure:!0,callData:S.data,target:S.to})),T=dr({abi:bf,args:[A],functionName:"aggregate3"}),E=await e.request({method:"eth_call",params:[{data:T,to:l},f]});return Ls({abi:bf,args:[A],functionName:"aggregate3",data:E||"0x"})}}),[{returnData:d,success:m}]=await p({data:o,to:c});if(!m)throw new Ec({data:d});return d==="0x"?{data:void 0}:{data:d}}function $6(e){const{code:t,data:r}=e;return Ic({abi:Nm(["constructor(bytes, bytes)"]),bytecode:Q0,args:[t,r]})}function N6(e){const{data:t,factory:r,factoryData:n,to:s}=e;return Ic({abi:Nm(["constructor(address, bytes, address, bytes)"]),bytecode:I6,args:[s,t,r,n]})}function U6(e){var r;if(!(e instanceof z))return;const t=e.walk();return typeof(t==null?void 0:t.data)=="object"?(r=t.data)==null?void 0:r.data:t.data}async function Wr(e,t){const{abi:r,address:n,args:s,functionName:i,...o}=t,a=dr({abi:r,args:s,functionName:i});try{const{data:c}=await se(e,ra,"call")({...o,data:a,to:n});return Ls({abi:r,args:s,functionName:i,data:c||"0x"})}catch(c){throw Is(c,{abi:r,address:n,args:s,docsPath:"/docs/contract/readContract",functionName:i})}}async function ng(e,t){const{abi:r,address:n,args:s,dataSuffix:i,functionName:o,...a}=t,c=a.account?Xe(a.account):e.account,l=dr({abi:r,args:s,functionName:o});try{const{data:u}=await se(e,ra,"call")({batch:!1,data:`${l}${i?i.replace("0x",""):""}`,to:n,...a,account:c}),f=Ls({abi:r,args:s,functionName:o,data:u||"0x"}),p=r.filter(d=>"name"in d&&d.name===t.functionName);return{result:f,request:{abi:p,address:n,args:s,dataSuffix:i,functionName:o,...a,account:c}}}catch(u){throw Is(u,{abi:r,address:n,args:s,docsPath:"/docs/contract/simulateContract",functionName:o,sender:c==null?void 0:c.address})}}const yu=new Map,lp=new Map;let M6=0;function vn(e,t,r){const n=++M6,s=()=>yu.get(e)||[],i=()=>{const u=s();yu.set(e,u.filter(f=>f.id!==n))},o=()=>{const u=s();if(!u.some(p=>p.id===n))return;const f=lp.get(e);if(u.length===1&&f){const p=f();p instanceof Promise&&p.catch(()=>{})}i()},a=s();if(yu.set(e,[...a,{id:n,fns:t}]),a&&a.length>0)return o;const c={};for(const u in t)c[u]=(...f)=>{var d,m;const p=s();if(p.length!==0)for(const g of p)(m=(d=g.fns)[u])==null||m.call(d,...f)};const l=r(c);return typeof l=="function"&&lp.set(e,l),o}async function Ef(e){return new Promise(t=>setTimeout(t,e))}function Ci(e,{emitOnBegin:t,initialWaitTime:r,interval:n}){let s=!0;const i=()=>s=!1;return(async()=>{let a;t&&(a=await e({unpoll:i}));const c=await(r==null?void 0:r(a))??n;await Ef(c);const l=async()=>{s&&(await e({unpoll:i}),await Ef(n),l())};l()})(),i}const F6=new Map,j6=new Map;function L6(e){const t=(s,i)=>({clear:()=>i.delete(s),get:()=>i.get(s),set:o=>i.set(s,o)}),r=t(e,F6),n=t(e,j6);return{clear:()=>{r.clear(),n.clear()},promise:r,response:n}}async function D6(e,{cacheKey:t,cacheTime:r=Number.POSITIVE_INFINITY}){const n=L6(t),s=n.response.get();if(s&&r>0&&new Date().getTime()-s.created.getTime()<r)return s.data;let i=n.promise.get();i||(i=e(),n.promise.set(i));try{const o=await i;return n.response.set({created:new Date,data:o}),o}finally{n.promise.clear()}}const H6=e=>`blockNumber.${e}`;async function na(e,{cacheTime:t=e.cacheTime}={}){const r=await D6(()=>e.request({method:"eth_blockNumber"}),{cacheKey:H6(e.uid),cacheTime:t});return BigInt(r)}async function Pc(e,{filter:t}){const r="strict"in t&&t.strict,n=await t.request({method:"eth_getFilterChanges",params:[t.id]});if(typeof n[0]=="string")return n;const s=n.map(i=>wn(i));return!("abi"in t)||!t.abi?s:Od({abi:t.abi,logs:s,strict:r})}async function Oc(e,{filter:t}){return t.request({method:"eth_uninstallFilter",params:[t.id]})}function sg(e,t){const{abi:r,address:n,args:s,batch:i=!0,eventName:o,fromBlock:a,onError:c,onLogs:l,poll:u,pollingInterval:f=e.pollingInterval,strict:p}=t;return(typeof u<"u"?u:typeof a=="bigint"?!0:!(e.transport.type==="webSocket"||e.transport.type==="ipc"||e.transport.type==="fallback"&&(e.transport.transports[0].config.type==="webSocket"||e.transport.transports[0].config.type==="ipc")))?(()=>{const w=p??!1,A=Ze(["watchContractEvent",n,s,i,e.uid,o,f,w,a]);return vn(A,{onLogs:l,onError:c},T=>{let E;a!==void 0&&(E=a-1n);let S,I=!1;const P=Ci(async()=>{var $;if(!I){try{S=await se(e,pd,"createContractEventFilter")({abi:r,address:n,args:s,eventName:o,strict:w,fromBlock:a})}catch{}I=!0;return}try{let j;if(S)j=await se(e,Pc,"getFilterChanges")({filter:S});else{const k=await se(e,na,"getBlockNumber")({});E&&E<k?j=await se(e,Cd,"getContractEvents")({abi:r,address:n,args:s,eventName:o,fromBlock:E+1n,toBlock:k,strict:w}):j=[],E=k}if(j.length===0)return;if(i)T.onLogs(j);else for(const k of j)T.onLogs([k])}catch(j){S&&j instanceof Ts&&(I=!1),($=T.onError)==null||$.call(T,j)}},{emitOnBegin:!0,interval:f});return async()=>{S&&await se(e,Oc,"uninstallFilter")({filter:S}),P()}})})():(()=>{const w=p??!1,A=Ze(["watchContractEvent",n,s,i,e.uid,o,f,w]);let T=!0,E=()=>T=!1;return vn(A,{onLogs:l,onError:c},S=>((async()=>{try{const I=(()=>{if(e.transport.type==="fallback"){const j=e.transport.transports.find(k=>k.config.type==="webSocket"||k.config.type==="ipc");return j?j.value:e.transport}return e.transport})(),P=o?Zo({abi:r,eventName:o,args:s}):[],{unsubscribe:$}=await I.subscribe({params:["logs",{address:n,topics:P}],onData(j){var F;if(!T)return;const k=j.result;try{const{eventName:R,args:U}=Pd({abi:r,data:k.data,topics:k.topics,strict:p}),H=wn(k,{args:U,eventName:R});S.onLogs([H])}catch(R){let U,H;if(R instanceof po||R instanceof pc){if(p)return;U=R.abiItem.name,H=(F=R.abiItem.inputs)==null?void 0:F.some(Z=>!("name"in Z&&Z.name))}const W=wn(k,{args:H?[]:{},eventName:U});S.onLogs([W])}},onError(j){var k;(k=S.onError)==null||k.call(S,j)}});E=$,T||E()}catch(I){c==null||c(I)}})(),()=>E()))})()}class Ds extends z{constructor({docsPath:t}={}){super(["Could not find an Account to execute with this Action.","Please provide an Account with the `account` argument on the Action, or by supplying an `account` to the Client."].join(`
|
|
42
42
|
`),{docsPath:t,docsSlug:"account",name:"AccountNotFoundError"})}}class Ma extends z{constructor({docsPath:t,metaMessages:r,type:n}){super(`Account type "${n}" is not supported.`,{docsPath:t,metaMessages:r,name:"AccountTypeNotSupportedError"})}}function ig({chain:e,currentChainId:t}){if(!e)throw new B6;if(t!==e.id)throw new O6({chain:e,currentChainId:t})}function og(e,{docsPath:t,...r}){const n=(()=>{const s=Ac(e,r);return s instanceof ea?e:s})();return new yE(n,{docsPath:t,...r})}async function Md(e,{serializedTransaction:t}){return e.request({method:"eth_sendRawTransaction",params:[t]},{retryCount:0})}const mu=new bc(128);async function Bc(e,t){var T,E,S,I;const{account:r=e.account,chain:n=e.chain,accessList:s,authorizationList:i,blobs:o,data:a,gas:c,gasPrice:l,maxFeePerBlobGas:u,maxFeePerGas:f,maxPriorityFeePerGas:p,nonce:d,type:m,value:g,...w}=t;if(typeof r>"u")throw new Ds({docsPath:"/docs/actions/wallet/sendTransaction"});const A=r?Xe(r):null;try{js(t);const P=await(async()=>{if(t.to)return t.to;if(t.to!==null&&i&&i.length>0)return await k0({authorization:i[0]}).catch(()=>{throw new z("`to` is required. Could not infer from `authorizationList`.")})})();if((A==null?void 0:A.type)==="json-rpc"||A===null){let $;n!==null&&($=await se(e,Oi,"getChainId")({}),ig({currentChainId:$,chain:n}));const j=(S=(E=(T=e.chain)==null?void 0:T.formatters)==null?void 0:E.transactionRequest)==null?void 0:S.format,F=(j||Pi)({...xc(w,{format:j}),accessList:s,authorizationList:i,blobs:o,chainId:$,data:a,from:A==null?void 0:A.address,gas:c,gasPrice:l,maxFeePerBlobGas:u,maxFeePerGas:f,maxPriorityFeePerGas:p,nonce:d,to:P,type:m,value:g}),R=mu.get(e.uid),U=R?"wallet_sendTransaction":"eth_sendTransaction";try{return await e.request({method:U,params:[F]},{retryCount:0})}catch(H){if(R===!1)throw H;const W=H;if(W.name==="InvalidInputRpcError"||W.name==="InvalidParamsRpcError"||W.name==="MethodNotFoundRpcError"||W.name==="MethodNotSupportedRpcError")return await e.request({method:"wallet_sendTransaction",params:[F]},{retryCount:0}).then(Z=>(mu.set(e.uid,!0),Z)).catch(Z=>{const Q=Z;throw Q.name==="MethodNotFoundRpcError"||Q.name==="MethodNotSupportedRpcError"?(mu.set(e.uid,!1),W):Q});throw W}}if((A==null?void 0:A.type)==="local"){const $=await se(e,kc,"prepareTransactionRequest")({account:A,accessList:s,authorizationList:i,blobs:o,chain:n,data:a,gas:c,gasPrice:l,maxFeePerBlobGas:u,maxFeePerGas:f,maxPriorityFeePerGas:p,nonce:d,nonceManager:A.nonceManager,parameters:[...D0,"sidecars"],type:m,value:g,...w,to:P}),j=(I=n==null?void 0:n.serializers)==null?void 0:I.transaction,k=await A.signTransaction($,{serializer:j});return await se(e,Md,"sendRawTransaction")({serializedTransaction:k})}throw(A==null?void 0:A.type)==="smart"?new Ma({metaMessages:["Consider using the `sendUserOperation` Action instead."],docsPath:"/docs/actions/bundler/sendUserOperation",type:"smart"}):new Ma({docsPath:"/docs/actions/wallet/sendTransaction",type:A==null?void 0:A.type})}catch(P){throw P instanceof Ma?P:og(P,{...t,account:A,chain:t.chain||void 0})}}async function ag(e,t){const{abi:r,account:n=e.account,address:s,args:i,dataSuffix:o,functionName:a,...c}=t;if(typeof n>"u")throw new Ds({docsPath:"/docs/contract/writeContract"});const l=n?Xe(n):null,u=dr({abi:r,args:i,functionName:a});try{return await se(e,Bc,"sendTransaction")({data:`${u}${o?o.replace("0x",""):""}`,to:s,account:l,...c})}catch(f){throw Is(f,{abi:r,address:s,args:i,docsPath:"/docs/contract/writeContract",functionName:a,sender:l==null?void 0:l.address})}}function gu({abi:e,address:t,client:r}){const n=r,[s,i]=n?"public"in n&&"wallet"in n?[n.public,n.wallet]:"public"in n?[n.public,void 0]:"wallet"in n?[void 0,n.wallet]:[n,n]:[void 0,void 0],o=s!=null,a=i!=null,c={};let l=!1,u=!1,f=!1;for(const p of e)if(p.type==="function"?p.stateMutability==="view"||p.stateMutability==="pure"?l=!0:u=!0:p.type==="event"&&(f=!0),l&&u&&f)break;return o&&(l&&(c.read=new Proxy({},{get(p,d){return(...m)=>{const{args:g,options:w}=ya(m);return se(s,Wr,"readContract")({abi:e,address:t,functionName:d,args:g,...w})}}})),u&&(c.simulate=new Proxy({},{get(p,d){return(...m)=>{const{args:g,options:w}=ya(m);return se(s,ng,"simulateContract")({abi:e,address:t,functionName:d,args:g,...w})}}})),f&&(c.createEventFilter=new Proxy({},{get(p,d){return(...m)=>{const g=e.find(T=>T.type==="event"&&T.name===d),{args:w,options:A}=bu(m,g);return se(s,pd,"createContractEventFilter")({abi:e,address:t,eventName:d,args:w,...A})}}}),c.getEvents=new Proxy({},{get(p,d){return(...m)=>{const g=e.find(T=>T.type==="event"&&T.name===d),{args:w,options:A}=bu(m,g);return se(s,Cd,"getContractEvents")({abi:e,address:t,eventName:d,args:w,...A})}}}),c.watchEvent=new Proxy({},{get(p,d){return(...m)=>{const g=e.find(T=>T.type==="event"&&T.name===d),{args:w,options:A}=bu(m,g);return se(s,sg,"watchContractEvent")({abi:e,address:t,eventName:d,args:w,...A})}}}))),a&&u&&(c.write=new Proxy({},{get(p,d){return(...m)=>{const{args:g,options:w}=ya(m);return se(i,ag,"writeContract")({abi:e,address:t,functionName:d,args:g,...w})}}})),(o||a)&&u&&(c.estimateGas=new Proxy({},{get(p,d){return(...m)=>{const{args:g,options:w}=ya(m);return se(s??i,z0,"estimateContractGas")({abi:e,address:t,functionName:d,args:g,...w,account:w.account??i.account})}}})),c.address=t,c.abi=e,c}function ya(e){const t=e.length&&Array.isArray(e[0]),r=t?e[0]:[],n=(t?e[1]:e[0])??{};return{args:r,options:n}}function bu(e,t){let r=!1;Array.isArray(e[0])?r=!0:e.length===1?r=t.inputs.some(i=>i.indexed):e.length===2&&(r=!0);const n=r?e[0]:void 0,s=(r?e[1]:e[0])??{};return{args:n,options:s}}class z6 extends z{constructor(t){super(`Call bundle failed with status: ${t.statusCode}`,{name:"BundleFailedError"}),Object.defineProperty(this,"result",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.result=t}}function ec(e,{delay:t=100,retryCount:r=2,shouldRetry:n=()=>!0}={}){return new Promise((s,i)=>{const o=async({count:a=0}={})=>{const c=async({error:l})=>{const u=typeof t=="function"?t({count:a,error:l}):t;u&&await Ef(u),o({count:a+1})};try{const l=await e();s(l)}catch(l){if(a<r&&await n({count:a,error:l}))return c({error:l});i(l)}};o()})}const cg={"0x0":"reverted","0x1":"success"};function ug(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(r=>wn(r)):null,to:e.to?e.to:null,transactionIndex:e.transactionIndex?ur(e.transactionIndex):null,status:e.status?cg[e.status]:null,type:e.type?I0[e.type]||e.type:null};return e.blobGasPrice&&(t.blobGasPrice=BigInt(e.blobGasPrice)),e.blobGasUsed&&(t.blobGasUsed=BigInt(e.blobGasUsed)),t}const q6=bd("transactionReceipt",ug),lg="0x5792579257925792579257925792579257925792579257925792579257925792",fg=X(0,{size:32});async function V6(e,t){const{account:r=e.account,capabilities:n,chain:s=e.chain,experimental_fallback:i,experimental_fallbackDelay:o=32,forceAtomic:a=!1,id:c,version:l="2.0.0"}=t,u=r?Xe(r):null,f=t.calls.map(p=>{const d=p,m=d.abi?dr({abi:d.abi,functionName:d.functionName,args:d.args}):d.data;return{data:d.dataSuffix&&m?Vt([m,d.dataSuffix]):m,to:d.to,value:d.value?X(d.value):void 0}});try{const p=await e.request({method:"wallet_sendCalls",params:[{atomicRequired:a,calls:f,capabilities:n,chainId:X(s.id),from:u==null?void 0:u.address,id:c,version:l}]},{retryCount:0});return typeof p=="string"?{id:p}:p}catch(p){const d=p;if(i&&(d.name==="MethodNotFoundRpcError"||d.name==="MethodNotSupportedRpcError"||d.name==="UnknownRpcError"||d.details.toLowerCase().includes("does not exist / is not available")||d.details.toLowerCase().includes("missing or invalid. request()")||d.details.toLowerCase().includes("did not match any variant of untagged enum")||d.details.toLowerCase().includes("account upgraded to unsupported contract")||d.details.toLowerCase().includes("eip-7702 not supported")||d.details.toLowerCase().includes("unsupported wc_ method"))){if(n&&Object.values(n).some(T=>!T.optional)){const T="non-optional `capabilities` are not supported on fallback to `eth_sendTransaction`.";throw new bi(new z(T,{details:T}))}if(a&&f.length>1){const A="`forceAtomic` is not supported on fallback to `eth_sendTransaction`.";throw new wi(new z(A,{details:A}))}const m=[];for(const A of f){const T=Bc(e,{account:u,chain:s,data:A.data,to:A.to,value:A.value?ot(A.value):void 0});m.push(T),o>0&&await new Promise(E=>setTimeout(E,o))}const g=await Promise.allSettled(m);if(g.every(A=>A.status==="rejected"))throw g[0].reason;const w=g.map(A=>A.status==="fulfilled"?A.value:fg);return{id:Vt([...w,X(s.id,{size:32}),lg])}}throw og(p,{...t,account:u,chain:t.chain})}}async function dg(e,t){async function r(u){if(u.endsWith(lg.slice(2))){const p=cr(Qa(u,-64,-32)),d=Qa(u,0,-64).slice(2).match(/.{1,64}/g),m=await Promise.all(d.map(w=>fg.slice(2)!==w?e.request({method:"eth_getTransactionReceipt",params:[`0x${w}`]},{dedupe:!0}):void 0)),g=m.some(w=>w===null)?100:m.every(w=>(w==null?void 0:w.status)==="0x1")?200:m.every(w=>(w==null?void 0:w.status)==="0x0")?500:600;return{atomic:!1,chainId:ur(p),receipts:m.filter(Boolean),status:g,version:"2.0.0"}}return e.request({method:"wallet_getCallsStatus",params:[u]})}const{atomic:n=!1,chainId:s,receipts:i,version:o="2.0.0",...a}=await r(t.id),[c,l]=(()=>{const u=a.status;return u>=100&&u<200?["pending",u]:u>=200&&u<300?["success",u]:u>=300&&u<700?["failure",u]:u==="CONFIRMED"?["success",200]:u==="PENDING"?["pending",100]:[void 0,u]})();return{...a,atomic:n,chainId:s?ur(s):void 0,receipts:(i==null?void 0:i.map(u=>({...u,blockNumber:ot(u.blockNumber),gasUsed:ot(u.gasUsed),status:cg[u.status]})))??[],statusCode:l,status:c,version:o}}async function G6(e,t){const{id:r,pollingInterval:n=e.pollingInterval,status:s=({statusCode:g})=>g===200||g>=300,retryCount:i=4,retryDelay:o=({count:g})=>~~(1<<g)*200,timeout:a=6e4,throwOnFailure:c=!1}=t,l=Ze(["waitForCallsStatus",e.uid,r]),{promise:u,resolve:f,reject:p}=Ud();let d;const m=vn(l,{resolve:f,reject:p},g=>{const w=Ci(async()=>{const A=T=>{clearTimeout(d),w(),T(),m()};try{const T=await ec(async()=>{const E=await dg(e,{id:r});if(c&&E.status==="failure")throw new z6(E);return E},{retryCount:i,delay:o});if(!s(T))return;A(()=>g.resolve(T))}catch(T){A(()=>g.reject(T))}},{interval:n,emitOnBegin:!0});return w});return d=a?setTimeout(()=>{m(),clearTimeout(d),p(new W6({id:r}))},a):void 0,await u}class W6 extends z{constructor({id:t}){super(`Timed out while waiting for call bundle with id "${t}" to be confirmed.`,{name:"WaitForCallsStatusTimeoutError"})}}const Af=256;let ma=Af,ga;function hg(e=11){if(!ga||ma+e>Af*2){ga="",ma=0;for(let t=0;t<Af;t++)ga+=(256+Math.random()*256|0).toString(16).substring(1)}return ga.substring(ma,ma+++e)}function pg(e){const{batch:t,chain:r,ccipRead:n,key:s="base",name:i="Base Client",type:o="base"}=e,a=e.experimental_blockTag??(typeof(r==null?void 0:r.experimental_preconfirmationTime)=="number"?"pending":void 0),c=(r==null?void 0:r.blockTime)??12e3,l=Math.min(Math.max(Math.floor(c/2),500),4e3),u=e.pollingInterval??l,f=e.cacheTime??u,p=e.account?Xe(e.account):void 0,{config:d,request:m,value:g}=e.transport({chain:r,pollingInterval:u}),w={...d,...g},A={account:p,batch:t,cacheTime:f,ccipRead:n,chain:r,key:s,name:i,pollingInterval:u,request:m,transport:w,type:o,uid:hg(),...a?{experimental_blockTag:a}:{}};function T(E){return S=>{const I=S(E);for(const $ in A)delete I[$];const P={...E,...I};return Object.assign(P,{extend:T(P)})}}return Object.assign(A,{extend:T(A)})}const ba=new bc(8192);function K6(e,{enabled:t=!0,id:r}){if(!t||!r)return e();if(ba.get(r))return ba.get(r);const n=e().finally(()=>ba.delete(r));return ba.set(r,n),n}function X6(e,t={}){return async(r,n={})=>{var f;const{dedupe:s=!1,methods:i,retryDelay:o=150,retryCount:a=3,uid:c}={...t,...n},{method:l}=r;if((f=i==null?void 0:i.exclude)!=null&&f.includes(l))throw new ls(new Error("method not supported"),{method:l});if(i!=null&&i.include&&!i.include.includes(l))throw new ls(new Error("method not supported"),{method:l});const u=s?mi(`${c}.${Ze(r)}`):void 0;return K6(()=>ec(async()=>{try{return await e(r)}catch(p){const d=p;switch(d.code){case bo.code:throw new bo(d);case wo.code:throw new wo(d);case vo.code:throw new vo(d,{method:r.method});case Eo.code:throw new Eo(d);case ks.code:throw new ks(d);case Ts.code:throw new Ts(d);case Ao.code:throw new Ao(d);case xo.code:throw new xo(d);case So.code:throw new So(d);case ls.code:throw new ls(d,{method:r.method});case gi.code:throw new gi(d);case _o.code:throw new _o(d);case ui.code:throw new ui(d);case ko.code:throw new ko(d);case To.code:throw new To(d);case Io.code:throw new Io(d);case Po.code:throw new Po(d);case Oo.code:throw new Oo(d);case bi.code:throw new bi(d);case Bo.code:throw new Bo(d);case Co.code:throw new Co(d);case Ro.code:throw new Ro(d);case $o.code:throw new $o(d);case No.code:throw new No(d);case wi.code:throw new wi(d);case 5e3:throw new ui(d);default:throw p instanceof z?p:new AE(d)}}},{delay:({count:p,error:d})=>{var m;if(d&&d instanceof ci){const g=(m=d==null?void 0:d.headers)==null?void 0:m.get("Retry-After");if(g!=null&&g.match(/\d/))return Number.parseInt(g)*1e3}return~~(1<<p)*o},retryCount:a,shouldRetry:({error:p})=>Y6(p)}),{enabled:s,id:u})}}function Y6(e){return"code"in e&&typeof e.code=="number"?e.code===-1||e.code===gi.code||e.code===ks.code:e instanceof ci&&e.status?e.status===403||e.status===408||e.status===413||e.status===429||e.status===500||e.status===502||e.status===503||e.status===504:!0}function yg({key:e,methods:t,name:r,request:n,retryCount:s=3,retryDelay:i=150,timeout:o,type:a},c){const l=hg();return{config:{key:e,methods:t,name:r,request:n,retryCount:s,retryDelay:i,timeout:o,type:a},request:X6(n,{methods:t,retryCount:s,retryDelay:i,uid:l}),value:c}}function fp(e,t={}){const{key:r="custom",methods:n,name:s="Custom Provider",retryDelay:i}=t;return({retryCount:o})=>yg({key:r,methods:n,name:s,request:e.request.bind(e),retryCount:t.retryCount??o,retryDelay:i,type:"custom"})}class Z6 extends z{constructor(){super("No URL was provided to the Transport. Please provide a valid RPC URL to the Transport.",{docsPath:"/docs/clients/intro",name:"UrlRequiredError"})}}function J6(e,{errorInstance:t=new Error("timed out"),timeout:r,signal:n}){return new Promise((s,i)=>{(async()=>{let o;try{const a=new AbortController;r>0&&(o=setTimeout(()=>{n&&a.abort()},r)),s(await e({signal:(a==null?void 0:a.signal)||null}))}catch(a){(a==null?void 0:a.name)==="AbortError"&&i(t),i(a)}finally{clearTimeout(o)}})()})}function Q6(){return{current:0,take(){return this.current++},reset(){this.current=0}}}const dp=Q6();function eA(e,t={}){return{async request(r){var f;const{body:n,onRequest:s=t.onRequest,onResponse:i=t.onResponse,timeout:o=t.timeout??1e4}=r,a={...t.fetchOptions??{},...r.fetchOptions??{}},{headers:c,method:l,signal:u}=a;try{const p=await J6(async({signal:m})=>{const g={...a,body:Array.isArray(n)?Ze(n.map(E=>({jsonrpc:"2.0",id:E.id??dp.take(),...E}))):Ze({jsonrpc:"2.0",id:n.id??dp.take(),...n}),headers:{"Content-Type":"application/json",...c},method:l||"POST",signal:u||(o>0?m:null)},w=new Request(e,g),A=await(s==null?void 0:s(w,g))??{...g,url:e};return await fetch(A.url??e,A)},{errorInstance:new Yh({body:n,url:e}),timeout:o,signal:!0});i&&await i(p);let d;if((f=p.headers.get("Content-Type"))!=null&&f.startsWith("application/json"))d=await p.json();else{d=await p.text();try{d=JSON.parse(d||"{}")}catch(m){if(p.ok)throw m;d={error:d}}}if(!p.ok)throw new ci({body:n,details:Ze(d.error)||p.statusText,headers:p.headers,status:p.status,url:e});return d}catch(p){throw p instanceof ci||p instanceof Yh?p:new ci({body:n,cause:p,url:e})}}}}function mg(e,t={}){const{batch:r,fetchOptions:n,key:s="http",methods:i,name:o="HTTP JSON-RPC",onFetchRequest:a,onFetchResponse:c,retryDelay:l,raw:u}=t;return({chain:f,retryCount:p,timeout:d})=>{const{batchSize:m=1e3,wait:g=0}=typeof r=="object"?r:{},w=t.retryCount??p,A=d??t.timeout??1e4,T=f==null?void 0:f.rpcUrls.default.http[0];if(!T)throw new Z6;const E=eA(T,{fetchOptions:n,onRequest:a,onResponse:c,timeout:A});return yg({key:s,methods:i,name:o,async request({method:S,params:I}){const P={method:S,params:I},{schedule:$}=rg({id:T,wait:g,shouldSplitBatch(R){return R.length>m},fn:R=>E.request({body:R}),sort:(R,U)=>R.id-U.id}),j=async R=>r?$(R):[await E.request({body:R})],[{error:k,result:F}]=await j(P);if(u)return{error:k,result:F};if(k)throw new gd({body:P,error:k,url:T});return F},retryCount:w,retryDelay:l,timeout:A,type:"http"},{fetchOptions:n,url:T})}}function Fd(e,t){var n,s,i,o,a,c;if(!(e instanceof z))return!1;const r=e.walk(l=>l instanceof cf);return r instanceof cf?!!(((n=r.data)==null?void 0:n.errorName)==="ResolverNotFound"||((s=r.data)==null?void 0:s.errorName)==="ResolverWildcardNotSupported"||((i=r.data)==null?void 0:i.errorName)==="ResolverNotContract"||((o=r.data)==null?void 0:o.errorName)==="ResolverError"||((a=r.data)==null?void 0:a.errorName)==="HttpError"||(c=r.reason)!=null&&c.includes("Wildcard on non-extended resolvers is not supported")||t==="reverse"&&r.reason===p0[50]):!1}function tA(e){const{abi:t,data:r}=e,n=_s(r,0,4),s=t.find(i=>i.type==="function"&&n===Yo(Ar(i)));if(!s)throw new qv(n,{docsPath:"/docs/contract/decodeFunctionData"});return{functionName:s.name,args:"inputs"in s&&s.inputs&&s.inputs.length>0?Jo(s.inputs,_s(r,4)):void 0}}const wu="/docs/contract/encodeErrorResult";function hp(e){const{abi:t,errorName:r,args:n}=e;let s=t[0];if(r){const c=Fs({abi:t,args:n,name:r});if(!c)throw new Uh(r,{docsPath:wu});s=c}if(s.type!=="error")throw new Uh(void 0,{docsPath:wu});const i=Ar(s),o=Yo(i);let a="0x";if(n&&n.length>0){if(!s.inputs)throw new Hv(s.name,{docsPath:wu});a=kn(s.inputs,n)}return Tr([o,a])}const vu="/docs/contract/encodeFunctionResult";function rA(e){const{abi:t,functionName:r,result:n}=e;let s=t[0];if(r){const o=Fs({abi:t,name:r});if(!o)throw new yi(r,{docsPath:vu});s=o}if(s.type!=="function")throw new yi(void 0,{docsPath:vu});if(!s.outputs)throw new Dm(s.name,{docsPath:vu});const i=(()=>{if(s.outputs.length===0)return[];if(s.outputs.length===1)return[n];if(Array.isArray(n))return n;throw new Hm(n)})();return kn(s.outputs,i)}const Cc="x-batch-gateway:true";async function gg(e){const{data:t,ccipRequest:r}=e,{args:[n]}=tA({abi:wf,data:t}),s=[],i=[];return await Promise.all(n.map(async(o,a)=>{try{i[a]=o.urls.includes(Cc)?await gg({data:o.data,ccipRequest:r}):await r(o),s[a]=!1}catch(c){s[a]=!0,i[a]=nA(c)}})),rA({abi:wf,functionName:"query",result:[s,i]})}function nA(e){return e.name==="HttpRequestError"&&e.status?hp({abi:wf,errorName:"HttpError",args:[e.status,e.shortMessage]}):hp({abi:[y0],errorName:"Error",args:["shortMessage"in e?e.shortMessage:e.message]})}function bg(e){if(e.length!==66||e.indexOf("[")!==0||e.indexOf("]")!==65)return null;const t=`0x${e.slice(1,65)}`;return xr(t)?t:null}function Fa(e){let t=new Uint8Array(32).fill(0);if(!e)return Je(t);const r=e.split(".");for(let n=r.length-1;n>=0;n-=1){const s=bg(r[n]),i=s?Ii(s):lt(bs(r[n]),"bytes");t=lt(Vt([t,i]),"bytes")}return Je(t)}function sA(e){return`[${e.slice(2)}]`}function iA(e){const t=new Uint8Array(32).fill(0);return e?bg(e)||lt(bs(e)):Je(t)}function Rc(e){const t=e.replace(/^\.|\.$/gm,"");if(t.length===0)return new Uint8Array(1);const r=new Uint8Array(bs(t).byteLength+2);let n=0;const s=t.split(".");for(let i=0;i<s.length;i++){let o=bs(s[i]);o.byteLength>255&&(o=bs(sA(iA(s[i])))),r[n]=o.length,r.set(o,n+1),n+=o.length+1}return r.byteLength!==n+1?r.slice(0,n+1):r}async function oA(e,t){const{blockNumber:r,blockTag:n,coinType:s,name:i,gatewayUrls:o,strict:a}=t,{chain:c}=e,l=(()=>{if(t.universalResolverAddress)return t.universalResolverAddress;if(!c)throw new Error("client chain not configured. universalResolverAddress is required.");return Bi({blockNumber:r,chain:c,contract:"ensUniversalResolver"})})(),u=c==null?void 0:c.ensTlds;if(u&&!u.some(f=>i.endsWith(f)))return null;try{const f=dr({abi:cp,functionName:"addr",...s!=null?{args:[Fa(i),BigInt(s)]}:{args:[Fa(i)]}}),p={address:l,abi:J0,functionName:"resolve",args:[mt(Rc(i)),f,o??[Cc]],blockNumber:r,blockTag:n},m=await se(e,Wr,"readContract")(p);if(m[0]==="0x")return null;const g=Ls({abi:cp,args:s!=null?[Fa(i),BigInt(s)]:void 0,functionName:"addr",data:m[0]});return g==="0x"||cr(g)==="0x00"?null:g}catch(f){if(a)throw f;if(Fd(f,"resolve"))return null;throw f}}class aA extends z{constructor({data:t}){super("Unable to extract image from metadata. The metadata may be malformed or invalid.",{metaMessages:["- Metadata must be a JSON object with at least an `image`, `image_url` or `image_data` property.","",`Provided data: ${JSON.stringify(t)}`],name:"EnsAvatarInvalidMetadataError"})}}class Fi extends z{constructor({reason:t}){super(`ENS NFT avatar URI is invalid. ${t}`,{name:"EnsAvatarInvalidNftUriError"})}}class jd extends z{constructor({uri:t}){super(`Unable to resolve ENS avatar URI "${t}". The URI may be malformed, invalid, or does not respond with a valid image.`,{name:"EnsAvatarUriResolutionError"})}}class cA extends z{constructor({namespace:t}){super(`ENS NFT avatar namespace "${t}" is not supported. Must be "erc721" or "erc1155".`,{name:"EnsAvatarUnsupportedNamespaceError"})}}const uA=/(?<protocol>https?:\/\/[^\/]*|ipfs:\/|ipns:\/|ar:\/)?(?<root>\/)?(?<subpath>ipfs\/|ipns\/)?(?<target>[\w\-.]+)(?<subtarget>\/.*)?/,lA=/^(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>\/.*)?$/,fA=/^data:([a-zA-Z\-/+]*);base64,([^"].*)/,dA=/^data:([a-zA-Z\-/+]*)?(;[a-zA-Z0-9].*?)?(,)/;async function hA(e){try{const t=await fetch(e,{method:"HEAD"});if(t.status===200){const r=t.headers.get("content-type");return r==null?void 0:r.startsWith("image/")}return!1}catch(t){return typeof t=="object"&&typeof t.response<"u"||!globalThis.hasOwnProperty("Image")?!1:new Promise(r=>{const n=new Image;n.onload=()=>{r(!0)},n.onerror=()=>{r(!1)},n.src=e})}}function pp(e,t){return e?e.endsWith("/")?e.slice(0,-1):e:t}function wg({uri:e,gatewayUrls:t}){const r=fA.test(e);if(r)return{uri:e,isOnChain:!0,isEncoded:r};const n=pp(t==null?void 0:t.ipfs,"https://ipfs.io"),s=pp(t==null?void 0:t.arweave,"https://arweave.net"),i=e.match(uA),{protocol:o,subpath:a,target:c,subtarget:l=""}=(i==null?void 0:i.groups)||{},u=o==="ipns:/"||a==="ipns/",f=o==="ipfs:/"||a==="ipfs/"||lA.test(e);if(e.startsWith("http")&&!u&&!f){let d=e;return t!=null&&t.arweave&&(d=e.replace(/https:\/\/arweave.net/g,t==null?void 0:t.arweave)),{uri:d,isOnChain:!1,isEncoded:!1}}if((u||f)&&c)return{uri:`${n}/${u?"ipns":"ipfs"}/${c}${l}`,isOnChain:!1,isEncoded:!1};if(o==="ar:/"&&c)return{uri:`${s}/${c}${l||""}`,isOnChain:!1,isEncoded:!1};let p=e.replace(dA,"");if(p.startsWith("<svg")&&(p=`data:image/svg+xml;base64,${btoa(p)}`),p.startsWith("data:")||p.startsWith("{"))return{uri:p,isOnChain:!0,isEncoded:!1};throw new jd({uri:e})}function vg(e){if(typeof e!="object"||!("image"in e)&&!("image_url"in e)&&!("image_data"in e))throw new aA({data:e});return e.image||e.image_url||e.image_data}async function pA({gatewayUrls:e,uri:t}){try{const r=await fetch(t).then(s=>s.json());return await Ld({gatewayUrls:e,uri:vg(r)})}catch{throw new jd({uri:t})}}async function Ld({gatewayUrls:e,uri:t}){const{uri:r,isOnChain:n}=wg({uri:t,gatewayUrls:e});if(n||await hA(r))return r;throw new jd({uri:t})}function yA(e){let t=e;t.startsWith("did:nft:")&&(t=t.replace("did:nft:","").replace(/_/g,"/"));const[r,n,s]=t.split("/"),[i,o]=r.split(":"),[a,c]=n.split(":");if(!i||i.toLowerCase()!=="eip155")throw new Fi({reason:"Only EIP-155 supported"});if(!o)throw new Fi({reason:"Chain ID not found"});if(!c)throw new Fi({reason:"Contract address not found"});if(!s)throw new Fi({reason:"Token ID not found"});if(!a)throw new Fi({reason:"ERC namespace not found"});return{chainID:Number.parseInt(o),namespace:a.toLowerCase(),contractAddress:c,tokenID:s}}async function mA(e,{nft:t}){if(t.namespace==="erc721")return Wr(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(t.namespace==="erc1155")return Wr(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 cA({namespace:t.namespace})}async function gA(e,{gatewayUrls:t,record:r}){return/eip155:/i.test(r)?bA(e,{gatewayUrls:t,record:r}):Ld({uri:r,gatewayUrls:t})}async function bA(e,{gatewayUrls:t,record:r}){const n=yA(r),s=await mA(e,{nft:n}),{uri:i,isOnChain:o,isEncoded:a}=wg({uri:s,gatewayUrls:t});if(o&&(i.includes("data:application/json;base64,")||i.startsWith("{"))){const l=a?atob(i.replace("data:application/json;base64,","")):i,u=JSON.parse(l);return Ld({uri:vg(u),gatewayUrls:t})}let c=n.tokenID;return n.namespace==="erc1155"&&(c=c.replace("0x","").padStart(64,"0")),pA({gatewayUrls:t,uri:i.replace(/(?:0x)?{id}/,c)})}async function Eg(e,t){const{blockNumber:r,blockTag:n,key:s,name:i,gatewayUrls:o,strict:a}=t,{chain:c}=e,l=(()=>{if(t.universalResolverAddress)return t.universalResolverAddress;if(!c)throw new Error("client chain not configured. universalResolverAddress is required.");return Bi({blockNumber:r,chain:c,contract:"ensUniversalResolver"})})(),u=c==null?void 0:c.ensTlds;if(u&&!u.some(f=>i.endsWith(f)))return null;try{const f={address:l,abi:J0,functionName:"resolve",args:[mt(Rc(i)),dr({abi:ap,functionName:"text",args:[Fa(i),s]}),o??[Cc]],blockNumber:r,blockTag:n},d=await se(e,Wr,"readContract")(f);if(d[0]==="0x")return null;const m=Ls({abi:ap,functionName:"text",data:d[0]});return m===""?null:m}catch(f){if(a)throw f;if(Fd(f,"resolve"))return null;throw f}}async function wA(e,{blockNumber:t,blockTag:r,assetGatewayUrls:n,name:s,gatewayUrls:i,strict:o,universalResolverAddress:a}){const c=await se(e,Eg,"getEnsText")({blockNumber:t,blockTag:r,key:"avatar",name:s,universalResolverAddress:a,gatewayUrls:i,strict:o});if(!c)return null;try{return await gA(e,{record:c,gatewayUrls:n})}catch{return null}}async function vA(e,{address:t,blockNumber:r,blockTag:n,gatewayUrls:s,strict:i,universalResolverAddress:o}){let a=o;if(!a){if(!e.chain)throw new Error("client chain not configured. universalResolverAddress is required.");a=Bi({blockNumber:r,chain:e.chain,contract:"ensUniversalResolver"})}const c=`${t.toLowerCase().substring(2)}.addr.reverse`;try{const l={address:a,abi:k6,functionName:"reverse",args:[mt(Rc(c))],blockNumber:r,blockTag:n},u=se(e,Wr,"readContract"),[f,p]=s?await u({...l,args:[...l.args,s]}):await u(l);return t.toLowerCase()!==p.toLowerCase()?null:f}catch(l){if(i)throw l;if(Fd(l,"reverse"))return null;throw l}}async function EA(e,t){const{blockNumber:r,blockTag:n,name:s}=t,{chain:i}=e,o=(()=>{if(t.universalResolverAddress)return t.universalResolverAddress;if(!i)throw new Error("client chain not configured. universalResolverAddress is required.");return Bi({blockNumber:r,chain:i,contract:"ensUniversalResolver"})})(),a=i==null?void 0:i.ensTlds;if(a&&!a.some(l=>s.endsWith(l)))throw new Error(`${s} is not a valid ENS TLD (${a==null?void 0:a.join(", ")}) for chain "${i.name}" (id: ${i.id}).`);const[c]=await se(e,Wr,"readContract")({address:o,abi:[{inputs:[{type:"bytes"}],name:"findResolver",outputs:[{type:"address"},{type:"bytes32"}],stateMutability:"view",type:"function"}],functionName:"findResolver",args:[mt(Rc(s))],blockNumber:r,blockTag:n});return c}async function Ag(e,t){var w,A,T;const{account:r=e.account,blockNumber:n,blockTag:s="latest",blobs:i,data:o,gas:a,gasPrice:c,maxFeePerBlobGas:l,maxFeePerGas:u,maxPriorityFeePerGas:f,to:p,value:d,...m}=t,g=r?Xe(r):void 0;try{js(t);const S=(typeof n=="bigint"?X(n):void 0)||s,I=(T=(A=(w=e.chain)==null?void 0:w.formatters)==null?void 0:A.transactionRequest)==null?void 0:T.format,$=(I||Pi)({...xc(m,{format:I}),from:g==null?void 0:g.address,blobs:i,data:o,gas:a,gasPrice:c,maxFeePerBlobGas:l,maxFeePerGas:u,maxPriorityFeePerGas:f,to:p,value:d}),j=await e.request({method:"eth_createAccessList",params:[$,S]});return{accessList:j.accessList,gasUsed:BigInt(j.gasUsed)}}catch(E){throw tg(E,{...t,account:g,chain:e.chain})}}async function AA(e){const t=wc(e,{method:"eth_newBlockFilter"}),r=await e.request({method:"eth_newBlockFilter"});return{id:r,request:t(r),type:"block"}}async function xg(e,{address:t,args:r,event:n,events:s,fromBlock:i,strict:o,toBlock:a}={}){const c=s??(n?[n]:void 0),l=wc(e,{method:"eth_newFilter"});let u=[];c&&(u=[c.flatMap(d=>Zo({abi:[d],eventName:d.name,args:r}))],n&&(u=u[0]));const f=await e.request({method:"eth_newFilter",params:[{address:t,fromBlock:typeof i=="bigint"?X(i):i,toBlock:typeof a=="bigint"?X(a):a,...u.length?{topics:u}:{}}]});return{abi:c,args:r,eventName:n?n.name:void 0,fromBlock:i,id:f,request:l(f),strict:!!o,toBlock:a,type:"event"}}async function Sg(e){const t=wc(e,{method:"eth_newPendingTransactionFilter"}),r=await e.request({method:"eth_newPendingTransactionFilter"});return{id:r,request:t(r),type:"transaction"}}async function xA(e){const t=await e.request({method:"eth_blobBaseFee"});return BigInt(t)}async function SA(e,{blockHash:t,blockNumber:r,blockTag:n="latest"}={}){const s=r!==void 0?X(r):void 0;let i;return t?i=await e.request({method:"eth_getBlockTransactionCountByHash",params:[t]},{dedupe:!0}):i=await e.request({method:"eth_getBlockTransactionCountByNumber",params:[s||n]},{dedupe:!!s}),ur(i)}async function yp(e,{address:t,blockNumber:r,blockTag:n="latest"}){const s=r!==void 0?X(r):void 0,i=await e.request({method:"eth_getCode",params:[t,s||n]},{dedupe:!!s});if(i!=="0x")return i}class _A extends z{constructor({address:t}){super(`No EIP-712 domain found on contract "${t}".`,{metaMessages:["Ensure that:",`- The contract is deployed at the address "${t}".`,"- `eip712Domain()` function exists on the contract.","- `eip712Domain()` function matches signature to ERC-5267 specification."],name:"Eip712DomainNotFoundError"})}}async function kA(e,t){const{address:r,factory:n,factoryData:s}=t;try{const[i,o,a,c,l,u,f]=await se(e,Wr,"readContract")({abi:TA,address:r,functionName:"eip712Domain",factory:n,factoryData:s});return{domain:{name:o,version:a,chainId:Number(c),verifyingContract:l,salt:u},extensions:f,fields:i}}catch(i){const o=i;throw o.name==="ContractFunctionExecutionError"&&o.cause.name==="ContractFunctionZeroDataError"?new _A({address:r}):o}}const TA=[{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"}];function IA(e){var t;return{baseFeePerGas:e.baseFeePerGas.map(r=>BigInt(r)),gasUsedRatio:e.gasUsedRatio,oldestBlock:BigInt(e.oldestBlock),reward:(t=e.reward)==null?void 0:t.map(r=>r.map(n=>BigInt(n)))}}async function PA(e,{blockCount:t,blockNumber:r,blockTag:n="latest",rewardPercentiles:s}){const i=typeof r=="bigint"?X(r):void 0,o=await e.request({method:"eth_feeHistory",params:[X(t),i||n,s]},{dedupe:!!i});return IA(o)}async function OA(e,{filter:t}){const r=t.strict??!1,s=(await t.request({method:"eth_getFilterLogs",params:[t.id]})).map(i=>wn(i));return t.abi?Od({abi:t.abi,logs:s,strict:r}):s}function bt(e){return{formatters:void 0,fees:void 0,serializers:void 0,...e}}class BA extends z{constructor({domain:t}){super(`Invalid domain "${Ze(t)}".`,{metaMessages:["Must be a valid EIP-712 domain."]})}}class CA extends z{constructor({primaryType:t,types:r}){super(`Invalid primary type \`${t}\` must be one of \`${JSON.stringify(Object.keys(r))}\`.`,{docsPath:"/api/glossary/Errors#typeddatainvalidprimarytypeerror",metaMessages:["Check that the primary type is a key in `types`."]})}}class RA extends z{constructor({type:t}){super(`Struct type "${t}" is invalid.`,{metaMessages:["Struct type must not be a Solidity type."],name:"InvalidStructTypeError"})}}function $A(e){const{domain:t={},message:r,primaryType:n}=e,s={EIP712Domain:Og({domain:t}),...e.types};Pg({domain:t,message:r,primaryType:n,types:s});const i=["0x1901"];return t&&i.push(NA({domain:t,types:s})),n!=="EIP712Domain"&&i.push(_g({data:r,primaryType:n,types:s})),lt(Vt(i))}function NA({domain:e,types:t}){return _g({data:e,primaryType:"EIP712Domain",types:t})}function _g({data:e,primaryType:t,types:r}){const n=kg({data:e,primaryType:t,types:r});return lt(n)}function kg({data:e,primaryType:t,types:r}){const n=[{type:"bytes32"}],s=[UA({primaryType:t,types:r})];for(const i of r[t]){const[o,a]=Ig({types:r,name:i.name,type:i.type,value:e[i.name]});n.push(o),s.push(a)}return kn(n,s)}function UA({primaryType:e,types:t}){const r=mt(MA({primaryType:e,types:t}));return lt(r)}function MA({primaryType:e,types:t}){let r="";const n=Tg({primaryType:e,types:t});n.delete(e);const s=[e,...Array.from(n).sort()];for(const i of s)r+=`${i}(${t[i].map(({name:o,type:a})=>`${a} ${o}`).join(",")})`;return r}function Tg({primaryType:e,types:t},r=new Set){const n=e.match(/^\w*/u),s=n==null?void 0:n[0];if(r.has(s)||t[s]===void 0)return r;r.add(s);for(const i of t[s])Tg({primaryType:i.type,types:t},r);return r}function Ig({types:e,name:t,type:r,value:n}){if(e[r]!==void 0)return[{type:"bytes32"},lt(kg({data:n,primaryType:r,types:e}))];if(r==="bytes")return n=`0x${(n.length%2?"0":"")+n.slice(2)}`,[{type:"bytes32"},lt(n)];if(r==="string")return[{type:"bytes32"},lt(mt(n))];if(r.lastIndexOf("]")===r.length-1){const s=r.slice(0,r.lastIndexOf("[")),i=n.map(o=>Ig({name:t,type:s,types:e,value:o}));return[{type:"bytes32"},lt(kn(i.map(([o])=>o),i.map(([,o])=>o)))]}return[{type:r},n]}function FA(e){const{domain:t,message:r,primaryType:n,types:s}=e,i=(c,l)=>{const u={...l};for(const f of c){const{name:p,type:d}=f;d==="address"&&(u[p]=u[p].toLowerCase())}return u},o=s.EIP712Domain?t?i(s.EIP712Domain,t):{}:{},a=(()=>{if(n!=="EIP712Domain")return i(s[n],r)})();return Ze({domain:o,message:a,primaryType:n,types:s})}function Pg(e){const{domain:t,message:r,primaryType:n,types:s}=e,i=(o,a)=>{for(const c of o){const{name:l,type:u}=c,f=a[l],p=u.match(d0);if(p&&(typeof f=="number"||typeof f=="bigint")){const[g,w,A]=p;X(f,{signed:w==="int",size:Number.parseInt(A)/8})}if(u==="address"&&typeof f=="string"&&!st(f))throw new Bt({address:f});const d=u.match(M2);if(d){const[g,w]=d;if(w&&He(f)!==Number.parseInt(w))throw new Gv({expectedSize:Number.parseInt(w),givenSize:He(f)})}const m=s[u];m&&(jA(u),i(m,f))}};if(s.EIP712Domain&&t){if(typeof t!="object")throw new BA({domain:t});i(s.EIP712Domain,t)}if(n!=="EIP712Domain")if(s[n])i(s[n],r);else throw new CA({primaryType:n,types:s})}function Og({domain:e}){return[typeof(e==null?void 0:e.name)=="string"&&{name:"name",type:"string"},(e==null?void 0:e.version)&&{name:"version",type:"string"},(typeof(e==null?void 0:e.chainId)=="number"||typeof(e==null?void 0:e.chainId)=="bigint")&&{name:"chainId",type:"uint256"},(e==null?void 0:e.verifyingContract)&&{name:"verifyingContract",type:"address"},(e==null?void 0:e.salt)&&{name:"salt",type:"bytes32"}].filter(Boolean)}function jA(e){if(e==="address"||e==="bool"||e==="string"||e.startsWith("bytes")||e.startsWith("uint")||e.startsWith("int"))throw new RA({type:e})}function LA(e){const{authorizationList:t}=e;if(t)for(const r of t){const{chainId:n}=r,s=r.address;if(!st(s))throw new Bt({address:s});if(n<0)throw new Tc({chainId:n})}Dd(e)}function DA(e){const{blobVersionedHashes:t}=e;if(t){if(t.length===0)throw new F0;for(const r of t){const n=He(r),s=ur(_s(r,0,1));if(n!==32)throw new JE({hash:r,size:n});if(s!==M0)throw new QE({hash:r,version:s})}}Dd(e)}function Dd(e){const{chainId:t,maxPriorityFeePerGas:r,maxFeePerGas:n,to:s}=e;if(t<=0)throw new Tc({chainId:t});if(s&&!st(s))throw new Bt({address:s});if(n&&n>Sc)throw new Ps({maxFeePerGas:n});if(r&&n&&r>n)throw new Uo({maxFeePerGas:n,maxPriorityFeePerGas:r})}function HA(e){const{chainId:t,maxPriorityFeePerGas:r,gasPrice:n,maxFeePerGas:s,to:i}=e;if(t<=0)throw new Tc({chainId:t});if(i&&!st(i))throw new Bt({address:i});if(r||s)throw new z("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid EIP-2930 Transaction attribute.");if(n&&n>Sc)throw new Ps({maxFeePerGas:n})}function zA(e){const{chainId:t,maxPriorityFeePerGas:r,gasPrice:n,maxFeePerGas:s,to:i}=e;if(i&&!st(i))throw new Bt({address:i});if(typeof t<"u"&&t<=0)throw new Tc({chainId:t});if(r||s)throw new z("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid Legacy Transaction attribute.");if(n&&n>Sc)throw new Ps({maxFeePerGas:n})}function $c(e){if(!e||e.length===0)return[];const t=[];for(let r=0;r<e.length;r++){const{address:n,storageKeys:s}=e[r];for(let i=0;i<s.length;i++)if(s[i].length-2!==64)throw new pE({storageKey:s[i]});if(!st(n,{strict:!1}))throw new Bt({address:n});t.push([n,s])}return t}function qA(e,t){const r=L0(e);return r==="eip1559"?WA(e,t):r==="eip2930"?KA(e,t):r==="eip4844"?GA(e,t):r==="eip7702"?VA(e,t):XA(e,t)}function VA(e,t){const{authorizationList:r,chainId:n,gas:s,nonce:i,to:o,value:a,maxFeePerGas:c,maxPriorityFeePerGas:l,accessList:u,data:f}=e;LA(e);const p=$c(u),d=YA(r);return Tr(["0x04",Qn([X(n),i?X(i):"0x",l?X(l):"0x",c?X(c):"0x",s?X(s):"0x",o??"0x",a?X(a):"0x",f??"0x",p,d,...sa(e,t)])])}function GA(e,t){const{chainId:r,gas:n,nonce:s,to:i,value:o,maxFeePerBlobGas:a,maxFeePerGas:c,maxPriorityFeePerGas:l,accessList:u,data:f}=e;DA(e);let p=e.blobVersionedHashes,d=e.sidecars;if(e.blobs&&(typeof p>"u"||typeof d>"u")){const E=typeof e.blobs[0]=="string"?e.blobs:e.blobs.map(P=>Je(P)),S=e.kzg,I=Sd({blobs:E,kzg:S});if(typeof p>"u"&&(p=$0({commitments:I})),typeof d>"u"){const P=_d({blobs:E,commitments:I,kzg:S});d=j0({blobs:E,commitments:I,proofs:P})}}const m=$c(u),g=[X(r),s?X(s):"0x",l?X(l):"0x",c?X(c):"0x",n?X(n):"0x",i??"0x",o?X(o):"0x",f??"0x",m,a?X(a):"0x",p??[],...sa(e,t)],w=[],A=[],T=[];if(d)for(let E=0;E<d.length;E++){const{blob:S,commitment:I,proof:P}=d[E];w.push(S),A.push(I),T.push(P)}return Tr(["0x03",Qn(d?[g,w,A,T]:g)])}function WA(e,t){const{chainId:r,gas:n,nonce:s,to:i,value:o,maxFeePerGas:a,maxPriorityFeePerGas:c,accessList:l,data:u}=e;Dd(e);const f=$c(l),p=[X(r),s?X(s):"0x",c?X(c):"0x",a?X(a):"0x",n?X(n):"0x",i??"0x",o?X(o):"0x",u??"0x",f,...sa(e,t)];return Tr(["0x02",Qn(p)])}function KA(e,t){const{chainId:r,gas:n,data:s,nonce:i,to:o,value:a,accessList:c,gasPrice:l}=e;HA(e);const u=$c(c),f=[X(r),i?X(i):"0x",l?X(l):"0x",n?X(n):"0x",o??"0x",a?X(a):"0x",s??"0x",u,...sa(e,t)];return Tr(["0x01",Qn(f)])}function XA(e,t){const{chainId:r=0,gas:n,data:s,nonce:i,to:o,value:a,gasPrice:c}=e;zA(e);let l=[i?X(i):"0x",c?X(c):"0x",n?X(n):"0x",o??"0x",a?X(a):"0x",s??"0x"];if(t){const u=(()=>{if(t.v>=35n)return(t.v-35n)/2n>0?t.v:27n+(t.v===35n?0n:1n);if(r>0)return BigInt(r*2)+BigInt(35n+t.v-27n);const d=27n+(t.v===27n?0n:1n);if(t.v!==d)throw new dE({v:t.v});return d})(),f=cr(t.r),p=cr(t.s);l=[...l,X(u),f==="0x00"?"0x":f,p==="0x00"?"0x":p]}else r>0&&(l=[...l,X(r),"0x","0x"]);return Qn(l)}function sa(e,t){const r=t??e,{v:n,yParity:s}=r;if(typeof r.r>"u")return[];if(typeof r.s>"u")return[];if(typeof n>"u"&&typeof s>"u")return[];const i=cr(r.r),o=cr(r.s);return[typeof s=="number"?s?X(1):"0x":n===0n?"0x":n===1n?X(1):n===27n?"0x":X(1),i==="0x00"?"0x":i,o==="0x00"?"0x":o]}function YA(e){if(!e||e.length===0)return[];const t=[];for(const r of e){const{chainId:n,nonce:s,...i}=r,o=r.address;t.push([n?mt(n):"0x",o,s?mt(s):"0x",...sa({},i)])}return t}const ZA=Uint8Array.from([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),Bg=Uint8Array.from(new Array(16).fill(0).map((e,t)=>t)),JA=Bg.map(e=>(9*e+5)%16),Cg=(()=>{const r=[[Bg],[JA]];for(let n=0;n<4;n++)for(let s of r)s.push(s[n].map(i=>ZA[i]));return r})(),Rg=Cg[0],$g=Cg[1],Ng=[[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8],[12,13,11,15,6,9,9,7,12,15,11,13,7,8,7,7],[13,15,14,11,7,7,6,8,13,14,13,12,5,5,6,9],[14,11,12,14,8,6,5,5,15,12,15,14,9,9,8,6],[15,12,13,13,9,5,8,6,14,11,12,11,8,6,5,5]].map(e=>Uint8Array.from(e)),QA=Rg.map((e,t)=>e.map(r=>Ng[t][r])),ex=$g.map((e,t)=>e.map(r=>Ng[t][r])),tx=Uint32Array.from([0,1518500249,1859775393,2400959708,2840853838]),rx=Uint32Array.from([1352829926,1548603684,1836072691,2053994217,0]);function mp(e,t,r,n){return e===0?t^r^n:e===1?t&r|~t&n:e===2?(t|~r)^n:e===3?t&n|r&~n:t^(r|~n)}const wa=new Uint32Array(16);let Ug=class extends O0{constructor(){super(64,20,8,!0),this.h0=1732584193,this.h1=-271733879,this.h2=-1732584194,this.h3=271733878,this.h4=-1009589776}get(){const{h0:t,h1:r,h2:n,h3:s,h4:i}=this;return[t,r,n,s,i]}set(t,r,n,s,i){this.h0=t|0,this.h1=r|0,this.h2=n|0,this.h3=s|0,this.h4=i|0}process(t,r){for(let d=0;d<16;d++,r+=4)wa[d]=t.getUint32(r,!0);let n=this.h0|0,s=n,i=this.h1|0,o=i,a=this.h2|0,c=a,l=this.h3|0,u=l,f=this.h4|0,p=f;for(let d=0;d<5;d++){const m=4-d,g=tx[d],w=rx[d],A=Rg[d],T=$g[d],E=QA[d],S=ex[d];for(let I=0;I<16;I++){const P=pa(n+mp(d,i,a,l)+wa[A[I]]+g,E[I])+f|0;n=f,f=l,l=pa(a,10)|0,a=i,i=P}for(let I=0;I<16;I++){const P=pa(s+mp(m,o,c,u)+wa[T[I]]+w,S[I])+p|0;s=p,p=u,u=pa(c,10)|0,c=o,o=P}}this.set(this.h1+a+u|0,this.h2+l+p|0,this.h3+f+s|0,this.h4+n+o|0,this.h0+i+c|0)}roundClean(){_r(wa)}destroy(){this.destroyed=!0,_r(this.buffer),this.set(0,0,0,0,0)}};const nx=mc(()=>new Ug),sx=Ug,ix=nx,ox=Object.freeze(Object.defineProperty({__proto__:null,RIPEMD160:sx,ripemd160:ix},Symbol.toStringTag,{value:"Module"})),ax=`Ethereum Signed Message:
|
|
43
43
|
`;function cx(e){const t=typeof e=="string"?mi(e):typeof e.raw=="string"?e.raw:Je(e.raw),r=mi(`${ax}${He(t)}`);return Vt([r,t])}function Mg(e,t){return lt(cx(e),t)}const Fg="0x6492649264926492649264926492649264926492649264926492649264926492";function ux(e){return Qa(e,-32)===Fg}function lx(e){const{address:t,data:r,signature:n,to:s="hex"}=e,i=Tr([kn([{type:"address"},{type:"bytes"},{type:"bytes"}],[t,r,n]),Fg]);return s==="hex"?i:Sr(i)}function fx(e){return e.map(t=>({...t,value:BigInt(t.value)}))}function dx(e){return{...e,balance:e.balance?BigInt(e.balance):void 0,nonce:e.nonce?ur(e.nonce):void 0,storageProof:e.storageProof?fx(e.storageProof):void 0}}async function hx(e,{address:t,blockNumber:r,blockTag:n,storageKeys:s}){const i=n??"latest",o=r!==void 0?X(r):void 0,a=await e.request({method:"eth_getProof",params:[t,s,o||i]});return dx(a)}async function px(e,{address:t,blockNumber:r,blockTag:n="latest",slot:s}){const i=r!==void 0?X(r):void 0;return await e.request({method:"eth_getStorageAt",params:[t,s,i||n]})}async function Hd(e,{blockHash:t,blockNumber:r,blockTag:n,hash:s,index:i}){var u,f,p;const o=n||"latest",a=r!==void 0?X(r):void 0;let c=null;if(s?c=await e.request({method:"eth_getTransactionByHash",params:[s]},{dedupe:!0}):t?c=await e.request({method:"eth_getTransactionByBlockHashAndIndex",params:[t,X(i)]},{dedupe:!0}):c=await e.request({method:"eth_getTransactionByBlockNumberAndIndex",params:[a||o,X(i)]},{dedupe:!!a}),!c)throw new v0({blockHash:t,blockNumber:r,blockTag:o,hash:s,index:i});return(((p=(f=(u=e.chain)==null?void 0:u.formatters)==null?void 0:f.transaction)==null?void 0:p.format)||_c)(c)}async function yx(e,{hash:t,transactionReceipt:r}){const[n,s]=await Promise.all([se(e,na,"getBlockNumber")({}),t?se(e,Hd,"getTransaction")({hash:t}):void 0]),i=(r==null?void 0:r.blockNumber)||(s==null?void 0:s.blockNumber);return i?n-i+1n:0n}async function ja(e,{hash:t}){var s,i,o;const r=await e.request({method:"eth_getTransactionReceipt",params:[t]},{dedupe:!0});if(!r)throw new E0({hash:t});return(((o=(i=(s=e.chain)==null?void 0:s.formatters)==null?void 0:i.transactionReceipt)==null?void 0:o.format)||ug)(r)}async function mx(e,t){var A;const{account:r,allowFailure:n=!0,batchSize:s,blockNumber:i,blockTag:o,multicallAddress:a,stateOverride:c}=t,l=t.contracts,u=s??(typeof((A=e.batch)==null?void 0:A.multicall)=="object"&&e.batch.multicall.batchSize||1024);let f=a;if(!f){if(!e.chain)throw new Error("client chain not configured. multicallAddress is required.");f=Bi({blockNumber:i,chain:e.chain,contract:"multicall3"})}const p=[[]];let d=0,m=0;for(let T=0;T<l.length;T++){const{abi:E,address:S,args:I,functionName:P}=l[T];try{const $=dr({abi:E,args:I,functionName:P});m+=($.length-2)/2,u>0&&m>u&&p[d].length>0&&(d++,m=($.length-2)/2,p[d]=[]),p[d]=[...p[d],{allowFailure:!0,callData:$,target:S}]}catch($){const j=Is($,{abi:E,address:S,args:I,docsPath:"/docs/contract/multicall",functionName:P,sender:r});if(!n)throw j;p[d]=[...p[d],{allowFailure:!0,callData:"0x",target:S}]}}const g=await Promise.allSettled(p.map(T=>se(e,Wr,"readContract")({abi:bf,account:r,address:f,args:[T],blockNumber:i,blockTag:o,functionName:"aggregate3",stateOverride:c}))),w=[];for(let T=0;T<g.length;T++){const E=g[T];if(E.status==="rejected"){if(!n)throw E.reason;for(let I=0;I<p[T].length;I++)w.push({status:"failure",error:E.reason,result:void 0});continue}const S=E.value;for(let I=0;I<S.length;I++){const{returnData:P,success:$}=S[I],{callData:j}=p[T][I],{abi:k,address:F,functionName:R,args:U}=l[w.length];try{if(j==="0x")throw new Ko;if(!$)throw new Ec({data:P});const H=Ls({abi:k,args:U,data:P,functionName:R});w.push(n?{result:H,status:"success"}:H)}catch(H){const W=Is(H,{abi:k,address:F,args:U,docsPath:"/docs/contract/multicall",functionName:R});if(!n)throw W;w.push({error:W,result:void 0,status:"failure"})}}}if(w.length!==l.length)throw new z("multicall results mismatch");return w}async function xf(e,t){const{blockNumber:r,blockTag:n=e.experimental_blockTag??"latest",blocks:s,returnFullTransactions:i,traceTransfers:o,validation:a}=t;try{const c=[];for(const p of s){const d=p.blockOverrides?Y0(p.blockOverrides):void 0,m=p.calls.map(w=>{const A=w,T=A.account?Xe(A.account):void 0,E=A.abi?dr(A):A.data,S={...A,data:A.dataSuffix?Vt([E||"0x",A.dataSuffix]):E,from:A.from??(T==null?void 0:T.address)};return js(S),Pi(S)}),g=p.stateOverrides?wd(p.stateOverrides):void 0;c.push({blockOverrides:d,calls:m,stateOverrides:g})}const u=(typeof r=="bigint"?X(r):void 0)||n;return(await e.request({method:"eth_simulateV1",params:[{blockStateCalls:c,returnFullTransactions:i,traceTransfers:o,validation:a},u]})).map((p,d)=>({...Ed(p),calls:p.calls.map((m,g)=>{var F,R;const{abi:w,args:A,functionName:T,to:E}=s[d].calls[g],S=((F=m.error)==null?void 0:F.data)??m.returnData,I=BigInt(m.gasUsed),P=(R=m.logs)==null?void 0:R.map(U=>wn(U)),$=m.status==="0x1"?"success":"failure",j=w&&$==="success"&&S!=="0x"?Ls({abi:w,data:S,functionName:T}):null,k=(()=>{var H;if($==="success")return;let U;if(((H=m.error)==null?void 0:H.data)==="0x"?U=new Ko:m.error&&(U=new Ec(m.error)),!!U)return Is(U,{abi:w??[],address:E??"0x",args:A,functionName:T??"<unknown>"})})();return{data:S,gasUsed:I,logs:P,status:$,...$==="success"?{result:j}:{error:k}}})}))}catch(c){const l=c,u=Ac(l,{});throw u instanceof ea?l:u}}function jg(e,t={}){const{as:r=typeof e=="string"?"Hex":"Bytes"}=t,n=o0(d6(e));return r==="Bytes"?n:W0(n)}class gx extends Map{constructor(t){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=t}get(t){const r=super.get(t);return super.has(t)&&r!==void 0&&(this.delete(t),super.set(t,r)),r}set(t,r){if(super.set(t,r),this.maxSize&&this.size>this.maxSize){const n=this.keys().next().value;n&&this.delete(n)}return this}}const bx={checksum:new gx(8192)},Eu=bx.checksum,wx=/^0x[a-fA-F0-9]{40}$/;function Nc(e,t={}){const{strict:r=!0}=t;if(!wx.test(e))throw new gp({address:e,cause:new Ex});if(r){if(e.toLowerCase()===e)return;if(vx(e)!==e)throw new gp({address:e,cause:new Ax})}}function vx(e){if(Eu.has(e))return Eu.get(e);Nc(e,{strict:!1});const t=e.substring(2).toLowerCase(),r=jg(y6(t),{as:"Bytes"}),n=t.split("");for(let i=0;i<40;i+=2)r[i>>1]>>4>=8&&n[i]&&(n[i]=n[i].toUpperCase()),(r[i>>1]&15)>=8&&n[i+1]&&(n[i+1]=n[i+1].toUpperCase());const s=`0x${n.join("")}`;return Eu.set(e,s),s}function Sf(e,t={}){const{strict:r=!0}=t??{};try{return Nc(e,{strict:r}),!0}catch{return!1}}class gp extends Fe{constructor({address:t,cause:r}){super(`Address "${t}" is invalid.`,{cause:r}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidAddressError"})}}class Ex extends Fe{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 Ax extends Fe{constructor(){super("Address does not match its checksum counterpart."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidChecksumError"})}}function _f(e){let t=!0,r="",n=0,s="",i=!1;for(let o=0;o<e.length;o++){const a=e[o];if(["(",")",","].includes(a)&&(t=!0),a==="("&&n++,a===")"&&n--,!!t){if(n===0){if(a===" "&&["event","function","error",""].includes(s))s="";else if(s+=a,a===")"){i=!0;break}continue}if(a===" "){e[o-1]!==","&&r!==","&&r!==",("&&(r="",t=!1);continue}s+=a,r+=a}}if(!i)throw new Fe("Unable to normalize signature.");return s}function kf(e,t){const r=typeof e,n=t.type;switch(n){case"address":return Sf(e,{strict:!1});case"bool":return r==="boolean";case"function":return r==="string";case"string":return r==="string";default:return n==="tuple"&&"components"in t?Object.values(t.components).every((s,i)=>kf(Object.values(e)[i],s)):/^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(n)?r==="number"||r==="bigint":/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/.test(n)?r==="string"||e instanceof Uint8Array:/[a-z]+[1-9]{0,3}(\[[0-9]{0,}\])+$/.test(n)?Array.isArray(e)&&e.every(s=>kf(s,{...t,type:n.replace(/(\[[0-9]{0,}\])$/,"")})):!1}}function Lg(e,t,r){for(const n in e){const s=e[n],i=t[n];if(s.type==="tuple"&&i.type==="tuple"&&"components"in s&&"components"in i)return Lg(s.components,i.components,r[n]);const o=[s.type,i.type];if(o.includes("address")&&o.includes("bytes20")?!0:o.includes("address")&&o.includes("string")?Sf(r[n],{strict:!1}):o.includes("address")&&o.includes("bytes")?Sf(r[n],{strict:!1}):!1)return o}}function Dg(e,t={}){const{prepare:r=!0}=t,n=Array.isArray(e)||typeof e=="string"?$h(e):e;return{...n,...r?{hash:oi(n)}:{}}}function xx(e,t,r){const{args:n=[],prepare:s=!0}=r??{},i=A6(t,{strict:!1}),o=e.filter(l=>i?l.type==="function"||l.type==="error"?Hg(l)===Nd(t,0,4):l.type==="event"?oi(l)===t:!1:"name"in l&&l.name===t);if(o.length===0)throw new Tf({name:t});if(o.length===1)return{...o[0],...s?{hash:oi(o[0])}:{}};let a;for(const l of o){if(!("inputs"in l))continue;if(!n||n.length===0){if(!l.inputs||l.inputs.length===0)return{...l,...s?{hash:oi(l)}:{}};continue}if(!l.inputs||l.inputs.length===0||l.inputs.length!==n.length)continue;if(n.every((f,p)=>{const d="inputs"in l&&l.inputs[p];return d?kf(f,d):!1})){if(a&&"inputs"in a&&a.inputs){const f=Lg(l.inputs,a.inputs,n);if(f)throw new _x({abiItem:l,type:f[0]},{abiItem:a,type:f[1]})}a=l}}const c=(()=>{if(a)return a;const[l,...u]=o;return{...l,overloads:u}})();if(!c)throw new Tf({name:t});return{...c,...s?{hash:oi(c)}:{}}}function Hg(e){return Nd(oi(e),0,4)}function Sx(e){const t=typeof e=="string"?e:Ja(e);return _f(t)}function oi(e){return typeof e!="string"&&"hash"in e&&e.hash?e.hash:jg($d(Sx(e)))}class _x extends Fe{constructor(t,r){super("Found ambiguous types in overloaded ABI Items.",{metaMessages:[`\`${t.type}\` in \`${_f(Ja(t.abiItem))}\`, and`,`\`${r.type}\` in \`${_f(Ja(r.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 Tf extends Fe{constructor({name:t,data:r,type:n="item"}){const s=t?` with name "${t}"`:r?` with data "${r}"`:"";super(`ABI ${n}${s} not found.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiItem.NotFoundError"})}}const kx=/^(.*)\[([0-9]*)\]$/,Tx=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,zg=/^(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 Ix({checksumAddress:e,parameters:t,values:r}){const n=[];for(let s=0;s<t.length;s++)n.push(zd({checksumAddress:e,parameter:t[s],value:r[s]}));return n}function zd({checksumAddress:e=!1,parameter:t,value:r}){const n=t,s=Ux(n.type);if(s){const[i,o]=s;return Ox(r,{checksumAddress:e,length:i,parameter:{...n,type:o}})}if(n.type==="tuple")return Nx(r,{checksumAddress:e,parameter:n});if(n.type==="address")return Px(r,{checksum:e});if(n.type==="bool")return Cx(r);if(n.type.startsWith("uint")||n.type.startsWith("int")){const i=n.type.startsWith("int"),[,,o="256"]=zg.exec(n.type)??[];return Rx(r,{signed:i,size:Number(o)})}if(n.type.startsWith("bytes"))return Bx(r,{type:n.type});if(n.type==="string")return $x(r);throw new Wg(n.type)}function qd(e){let t=0;for(let i=0;i<e.length;i++){const{dynamic:o,encoded:a}=e[i];o?t+=32:t+=fr(a)}const r=[],n=[];let s=0;for(let i=0;i<e.length;i++){const{dynamic:o,encoded:a}=e[i];o?(r.push(It(t+s,{size:32})),n.push(a),s+=fr(a)):r.push(a)}return Gr(...r,...n)}function Px(e,t){const{checksum:r=!1}=t;return Nc(e,{strict:r}),{dynamic:!1,encoded:Os(e.toLowerCase())}}function Ox(e,t){const{checksumAddress:r,length:n,parameter:s}=t,i=n===null;if(!Array.isArray(e))throw new Fx(e);if(!i&&e.length!==n)throw new Mx({expectedLength:n,givenLength:e.length,type:`${s.type}[${n}]`});let o=!1;const a=[];for(let c=0;c<e.length;c++){const l=zd({checksumAddress:r,parameter:s,value:e[c]});l.dynamic&&(o=!0),a.push(l)}if(i||o){const c=qd(a);if(i){const l=It(a.length,{size:32});return{dynamic:!0,encoded:a.length>0?Gr(l,c):l}}if(o)return{dynamic:!0,encoded:c}}return{dynamic:!1,encoded:Gr(...a.map(({encoded:c})=>c))}}function Bx(e,{type:t}){const[,r]=t.split("bytes"),n=fr(e);if(!r){let s=e;return n%32!==0&&(s=Bs(s,Math.ceil((e.length-2)/2/32)*32)),{dynamic:!0,encoded:Gr(Os(It(n,{size:32})),s)}}if(n!==Number.parseInt(r))throw new Vg({expectedSize:Number.parseInt(r),value:e});return{dynamic:!1,encoded:Bs(e)}}function Cx(e){if(typeof e!="boolean")throw new Fe(`Invalid boolean value: "${e}" (type: ${typeof e}). Expected: \`true\` or \`false\`.`);return{dynamic:!1,encoded:Os(G0(e))}}function Rx(e,{signed:t,size:r}){if(typeof r=="number"){const n=2n**(BigInt(r)-(t?1n:0n))-1n,s=t?-n-1n:0n;if(e>n||e<s)throw new K0({max:n.toString(),min:s.toString(),signed:t,size:r/8,value:e.toString()})}return{dynamic:!1,encoded:It(e,{size:32,signed:t})}}function $x(e){const t=$d(e),r=Math.ceil(fr(t)/32),n=[];for(let s=0;s<r;s++)n.push(Bs(Nd(t,s*32,(s+1)*32)));return{dynamic:!0,encoded:Gr(Bs(It(fr(t),{size:32})),...n)}}function Nx(e,t){const{checksumAddress:r,parameter:n}=t;let s=!1;const i=[];for(let o=0;o<n.components.length;o++){const a=n.components[o],c=Array.isArray(e)?o:a.name,l=zd({checksumAddress:r,parameter:a,value:e[c]});i.push(l),l.dynamic&&(s=!0)}return{dynamic:s,encoded:s?qd(i):Gr(...i.map(({encoded:o})=>o))}}function Ux(e){const t=e.match(/^(.*)\[(\d+)?\]$/);return t?[t[2]?Number(t[2]):null,t[1]]:void 0}function qg(e,t,r){const{checksumAddress:n=!1}={};if(e.length!==t.length)throw new Gg({expectedLength:e.length,givenLength:t.length});const s=Ix({checksumAddress:n,parameters:e,values:t}),i=qd(s);return i.length===0?"0x":i}function If(e,t){if(e.length!==t.length)throw new Gg({expectedLength:e.length,givenLength:t.length});const r=[];for(let n=0;n<e.length;n++){const s=e[n],i=t[n];r.push(If.encode(s,i))}return Gr(...r)}(function(e){function t(r,n,s=!1){if(r==="address"){const c=n;return Nc(c),Os(c.toLowerCase(),s?32:0)}if(r==="string")return $d(n);if(r==="bytes")return n;if(r==="bool")return Os(G0(n),s?32:1);const i=r.match(zg);if(i){const[c,l,u="256"]=i,f=Number.parseInt(u)/8;return It(n,{size:s?32:f,signed:l==="int"})}const o=r.match(Tx);if(o){const[c,l]=o;if(Number.parseInt(l)!==(n.length-2)/2)throw new Vg({expectedSize:Number.parseInt(l),value:n});return Bs(n,s?32:0)}const a=r.match(kx);if(a&&Array.isArray(n)){const[c,l]=a,u=[];for(let f=0;f<n.length;f++)u.push(t(l,n[f],!0));return u.length===0?"0x":Gr(...u)}throw new Wg(r)}e.encode=t})(If||(If={}));class Mx extends Fe{constructor({expectedLength:t,givenLength:r,type:n}){super(`Array length mismatch for type \`${n}\`. Expected: \`${t}\`. Given: \`${r}\`.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.ArrayLengthMismatchError"})}}class Vg extends Fe{constructor({expectedSize:t,value:r}){super(`Size of bytes "${r}" (bytes${fr(r)}) does not match expected size (bytes${t}).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.BytesSizeMismatchError"})}}class Gg extends Fe{constructor({expectedLength:t,givenLength:r}){super(["ABI encoding parameters/values length mismatch.",`Expected length (parameters): ${t}`,`Given length (values): ${r}`].join(`
|
|
44
44
|
`)),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.LengthMismatchError"})}}class Fx extends Fe{constructor(t){super(`Value \`${t}\` is not a valid array.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.InvalidArrayError"})}}class Wg extends Fe{constructor(t){super(`Type \`${t}\` is not a valid ABI Type.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.InvalidTypeError"})}}function jx(e,t){var s;const{bytecode:r,args:n}=t;return Gr(r,(s=e.inputs)!=null&&s.length&&(n!=null&&n.length)?qg(e.inputs,n):"0x")}function Lx(e){return Dg(e)}function Dx(e,...t){const{overloads:r}=e,n=r?Hx([e,...r],e.name,{args:t[0]}):e,s=zx(n),i=t.length>0?qg(n.inputs,t[0]):void 0;return i?Gr(s,i):s}function Ks(e,t={}){return Dg(e,t)}function Hx(e,t,r){const n=xx(e,t,r);if(n.type!=="function")throw new Tf({name:t,type:"function"});return n}function zx(e){return Hg(e)}const qx="0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",Cr="0x0000000000000000000000000000000000000000",Vx="0x6080604052348015600e575f80fd5b5061016d8061001c5f395ff3fe608060405234801561000f575f80fd5b5060043610610029575f3560e01c8063f8b2cb4f1461002d575b5f80fd5b610047600480360381019061004291906100db565b61005d565b604051610054919061011e565b60405180910390f35b5f8173ffffffffffffffffffffffffffffffffffffffff16319050919050565b5f80fd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6100aa82610081565b9050919050565b6100ba816100a0565b81146100c4575f80fd5b50565b5f813590506100d5816100b1565b92915050565b5f602082840312156100f0576100ef61007d565b5b5f6100fd848285016100c7565b91505092915050565b5f819050919050565b61011881610106565b82525050565b5f6020820190506101315f83018461010f565b9291505056fea26469706673582212203b9fe929fe995c7cf9887f0bdba8a36dd78e8b73f149b17d2d9ad7cd09d2dc6264736f6c634300081a0033";async function Gx(e,t){const{blockNumber:r,blockTag:n,calls:s,stateOverrides:i,traceAssetChanges:o,traceTransfers:a,validation:c}=t,l=t.account?Xe(t.account):void 0;if(o&&!l)throw new z("`account` is required when `traceAssetChanges` is true");const u=l?jx(Lx("constructor(bytes, bytes)"),{bytecode:Q0,args:[Vx,Dx(Ks("function getBalance(address)"),[l.address])]}):void 0,f=o?await Promise.all(t.calls.map(async D=>{if(!D.data&&!D.abi)return;const{accessList:B}=await Ag(e,{account:l.address,...D,data:D.abi?dr(D):D.data});return B.map(({address:V,storageKeys:K})=>K.length>0?V:null)})).then(D=>D.flat().filter(Boolean)):[],p=await xf(e,{blockNumber:r,blockTag:n,blocks:[...o?[{calls:[{data:u}],stateOverrides:i},{calls:f.map((D,B)=>({abi:[Ks("function balanceOf(address) returns (uint256)")],functionName:"balanceOf",args:[l.address],to:D,from:Cr,nonce:B})),stateOverrides:[{address:Cr,nonce:0}]}]:[],{calls:[...s,{}].map(D=>({...D,from:l==null?void 0:l.address})),stateOverrides:i},...o?[{calls:[{data:u}]},{calls:f.map((D,B)=>({abi:[Ks("function balanceOf(address) returns (uint256)")],functionName:"balanceOf",args:[l.address],to:D,from:Cr,nonce:B})),stateOverrides:[{address:Cr,nonce:0}]},{calls:f.map((D,B)=>({to:D,abi:[Ks("function decimals() returns (uint256)")],functionName:"decimals",from:Cr,nonce:B})),stateOverrides:[{address:Cr,nonce:0}]},{calls:f.map((D,B)=>({to:D,abi:[Ks("function tokenURI(uint256) returns (string)")],functionName:"tokenURI",args:[0n],from:Cr,nonce:B})),stateOverrides:[{address:Cr,nonce:0}]},{calls:f.map((D,B)=>({to:D,abi:[Ks("function symbol() returns (string)")],functionName:"symbol",from:Cr,nonce:B})),stateOverrides:[{address:Cr,nonce:0}]}]:[]],traceTransfers:a,validation:c}),d=o?p[2]:p[0],[m,g,,w,A,T,E,S]=o?p:[],{calls:I,...P}=d,$=I.slice(0,-1)??[],j=(m==null?void 0:m.calls)??[],k=(g==null?void 0:g.calls)??[],F=[...j,...k].map(D=>D.status==="success"?ot(D.data):null),R=(w==null?void 0:w.calls)??[],U=(A==null?void 0:A.calls)??[],H=[...R,...U].map(D=>D.status==="success"?ot(D.data):null),W=((T==null?void 0:T.calls)??[]).map(D=>D.status==="success"?D.result:null),Z=((S==null?void 0:S.calls)??[]).map(D=>D.status==="success"?D.result:null),Q=((E==null?void 0:E.calls)??[]).map(D=>D.status==="success"?D.result:null),re=[];for(const[D,B]of H.entries()){const V=F[D];if(typeof B!="bigint"||typeof V!="bigint")continue;const K=W[D-1],O=Z[D-1],N=Q[D-1],L=D===0?{address:qx,decimals:18,symbol:"ETH"}:{address:f[D-1],decimals:N||K?Number(K??1):void 0,symbol:O??void 0};re.some(J=>J.token.address===L.address)||re.push({token:L,value:{pre:V,post:B,diff:B-V}})}return{assetChanges:re,block:P,results:$}}class Kg extends yc{constructor(t,r){super(),this.finished=!1,this.destroyed=!1,m2(t);const n=mn(r);if(this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const s=this.blockLen,i=new Uint8Array(s);i.set(n.length>s?t.create().update(n).digest():n);for(let o=0;o<i.length;o++)i[o]^=54;this.iHash.update(i),this.oHash=t.create();for(let o=0;o<i.length;o++)i[o]^=106;this.oHash.update(i),_r(i)}update(t){return Jn(this),this.iHash.update(t),this}digestInto(t){Jn(this),lr(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));const{oHash:r,iHash:n,finished:s,destroyed:i,blockLen:o,outputLen:a}=this;return t=t,t.finished=s,t.destroyed=i,t.blockLen=o,t.outputLen=a,t.oHash=r._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const Xg=(e,t,r)=>new Kg(e,t).update(r).digest();Xg.create=(e,t)=>new Kg(e,t);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Vd=BigInt(0),Pf=BigInt(1);function tc(e,t){if(typeof t!="boolean")throw new Error(e+" boolean expected, got "+t)}function va(e){const t=e.toString(16);return t.length&1?"0"+t:t}function Yg(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);return e===""?Vd:BigInt("0x"+e)}function Uc(e){return Yg(mo(e))}function Zg(e){return lr(e),Yg(mo(Uint8Array.from(e).reverse()))}function Gd(e,t){return ud(e.toString(16).padStart(t*2,"0"))}function Jg(e,t){return Gd(e,t).reverse()}function Qt(e,t,r){let n;if(typeof t=="string")try{n=ud(t)}catch(i){throw new Error(e+" must be hex string or Uint8Array, cause: "+i)}else if(ad(t))n=Uint8Array.from(t);else throw new Error(e+" must be hex string or Uint8Array");const s=n.length;if(typeof r=="number"&&s!==r)throw new Error(e+" of length "+r+" expected, got "+s);return n}const Au=e=>typeof e=="bigint"&&Vd<=e;function Wx(e,t,r){return Au(e)&&Au(t)&&Au(r)&&t<=e&&e<r}function Kx(e,t,r,n){if(!Wx(t,r,n))throw new Error("expected valid "+e+": "+r+" <= n < "+n+", got "+t)}function Xx(e){let t;for(t=0;e>Vd;e>>=Pf,t+=1);return t}const Mc=e=>(Pf<<BigInt(e))-Pf;function Yx(e,t,r){if(typeof e!="number"||e<2)throw new Error("hashLen must be a number");if(typeof t!="number"||t<2)throw new Error("qByteLen must be a number");if(typeof r!="function")throw new Error("hmacFn must be a function");const n=d=>new Uint8Array(d),s=d=>Uint8Array.of(d);let i=n(e),o=n(e),a=0;const c=()=>{i.fill(1),o.fill(0),a=0},l=(...d)=>r(o,i,...d),u=(d=n(0))=>{o=l(s(0),d),i=l(),d.length!==0&&(o=l(s(1),d),i=l())},f=()=>{if(a++>=1e3)throw new Error("drbg: tried 1000 values");let d=0;const m=[];for(;d<t;){i=l();const g=i.slice();m.push(g),d+=i.length}return us(...m)};return(d,m)=>{c(),u(d);let g;for(;!(g=m(f()));)u();return c(),g}}function Wd(e,t,r={}){if(!e||typeof e!="object")throw new Error("expected valid options object");function n(s,i,o){const a=e[s];if(o&&a===void 0)return;const c=typeof a;if(c!==i||a===null)throw new Error(`param "${s}" is invalid: expected ${i}, got ${c}`)}Object.entries(t).forEach(([s,i])=>n(s,i,!1)),Object.entries(r).forEach(([s,i])=>n(s,i,!0))}function bp(e){const t=new WeakMap;return(r,...n)=>{const s=t.get(r);if(s!==void 0)return s;const i=e(r,...n);return t.set(r,i),i}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Nt=BigInt(0),Ot=BigInt(1),fs=BigInt(2),Zx=BigInt(3),Qg=BigInt(4),eb=BigInt(5),tb=BigInt(8);function rr(e,t){const r=e%t;return r>=Nt?r:t+r}function Zt(e,t,r){let n=e;for(;t-- >Nt;)n*=n,n%=r;return n}function wp(e,t){if(e===Nt)throw new Error("invert: expected non-zero number");if(t<=Nt)throw new Error("invert: expected positive modulus, got "+t);let r=rr(e,t),n=t,s=Nt,i=Ot;for(;r!==Nt;){const a=n/r,c=n%r,l=s-i*a;n=r,r=c,s=i,i=l}if(n!==Ot)throw new Error("invert: does not exist");return rr(s,t)}function rb(e,t){const r=(e.ORDER+Ot)/Qg,n=e.pow(t,r);if(!e.eql(e.sqr(n),t))throw new Error("Cannot find square root");return n}function Jx(e,t){const r=(e.ORDER-eb)/tb,n=e.mul(t,fs),s=e.pow(n,r),i=e.mul(t,s),o=e.mul(e.mul(i,fs),s),a=e.mul(i,e.sub(o,e.ONE));if(!e.eql(e.sqr(a),t))throw new Error("Cannot find square root");return a}function Qx(e){if(e<BigInt(3))throw new Error("sqrt is not defined for small field");let t=e-Ot,r=0;for(;t%fs===Nt;)t/=fs,r++;let n=fs;const s=Fc(e);for(;vp(s,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(r===1)return rb;let i=s.pow(n,t);const o=(t+Ot)/fs;return function(c,l){if(c.is0(l))return l;if(vp(c,l)!==1)throw new Error("Cannot find square root");let u=r,f=c.mul(c.ONE,i),p=c.pow(l,t),d=c.pow(l,o);for(;!c.eql(p,c.ONE);){if(c.is0(p))return c.ZERO;let m=1,g=c.sqr(p);for(;!c.eql(g,c.ONE);)if(m++,g=c.sqr(g),m===u)throw new Error("Cannot find square root");const w=Ot<<BigInt(u-m-1),A=c.pow(f,w);u=m,f=c.sqr(A),p=c.mul(p,f),d=c.mul(d,A)}return d}}function eS(e){return e%Qg===Zx?rb:e%tb===eb?Jx:Qx(e)}const tS=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function rS(e){const t={ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"},r=tS.reduce((n,s)=>(n[s]="function",n),t);return Wd(e,r),e}function nS(e,t,r){if(r<Nt)throw new Error("invalid exponent, negatives unsupported");if(r===Nt)return e.ONE;if(r===Ot)return t;let n=e.ONE,s=t;for(;r>Nt;)r&Ot&&(n=e.mul(n,s)),s=e.sqr(s),r>>=Ot;return n}function nb(e,t,r=!1){const n=new Array(t.length).fill(r?e.ZERO:void 0),s=t.reduce((o,a,c)=>e.is0(a)?o:(n[c]=o,e.mul(o,a)),e.ONE),i=e.inv(s);return t.reduceRight((o,a,c)=>e.is0(a)?o:(n[c]=e.mul(o,n[c]),e.mul(o,a)),i),n}function vp(e,t){const r=(e.ORDER-Ot)/fs,n=e.pow(t,r),s=e.eql(n,e.ONE),i=e.eql(n,e.ZERO),o=e.eql(n,e.neg(e.ONE));if(!s&&!i&&!o)throw new Error("invalid Legendre symbol result");return s?1:i?0:-1}function sS(e,t){t!==void 0&&Zn(t);const r=t!==void 0?t:e.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}function Fc(e,t,r=!1,n={}){if(e<=Nt)throw new Error("invalid field: expected ORDER > 0, got "+e);let s,i;if(typeof t=="object"&&t!=null){if(n.sqrt||r)throw new Error("cannot specify opts in two arguments");const u=t;u.BITS&&(s=u.BITS),u.sqrt&&(i=u.sqrt),typeof u.isLE=="boolean"&&(r=u.isLE)}else typeof t=="number"&&(s=t),n.sqrt&&(i=n.sqrt);const{nBitLength:o,nByteLength:a}=sS(e,s);if(a>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let c;const l=Object.freeze({ORDER:e,isLE:r,BITS:o,BYTES:a,MASK:Mc(o),ZERO:Nt,ONE:Ot,create:u=>rr(u,e),isValid:u=>{if(typeof u!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof u);return Nt<=u&&u<e},is0:u=>u===Nt,isValidNot0:u=>!l.is0(u)&&l.isValid(u),isOdd:u=>(u&Ot)===Ot,neg:u=>rr(-u,e),eql:(u,f)=>u===f,sqr:u=>rr(u*u,e),add:(u,f)=>rr(u+f,e),sub:(u,f)=>rr(u-f,e),mul:(u,f)=>rr(u*f,e),pow:(u,f)=>nS(l,u,f),div:(u,f)=>rr(u*wp(f,e),e),sqrN:u=>u*u,addN:(u,f)=>u+f,subN:(u,f)=>u-f,mulN:(u,f)=>u*f,inv:u=>wp(u,e),sqrt:i||(u=>(c||(c=eS(e)),c(l,u))),toBytes:u=>r?Jg(u,a):Gd(u,a),fromBytes:u=>{if(u.length!==a)throw new Error("Field.fromBytes: expected "+a+" bytes, got "+u.length);return r?Zg(u):Uc(u)},invertBatch:u=>nb(l,u),cmov:(u,f,p)=>p?f:u});return Object.freeze(l)}function sb(e){if(typeof e!="bigint")throw new Error("field order must be bigint");const t=e.toString(2).length;return Math.ceil(t/8)}function ib(e){const t=sb(e);return t+Math.ceil(t/2)}function iS(e,t,r=!1){const n=e.length,s=sb(t),i=ib(t);if(n<16||n<i||n>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+n);const o=r?Zg(e):Uc(e),a=rr(o,t-Ot)+Ot;return r?Jg(a,s):Gd(a,s)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const vi=BigInt(0),ds=BigInt(1);function to(e,t){const r=t.negate();return e?r:t}function oS(e,t,r){const n=o=>o.pz,s=nb(e.Fp,r.map(n));return r.map((o,a)=>o.toAffine(s[a])).map(e.fromAffine)}function ob(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function xu(e,t){ob(e,t);const r=Math.ceil(t/e)+1,n=2**(e-1),s=2**e,i=Mc(e),o=BigInt(e);return{windows:r,windowSize:n,mask:i,maxNumber:s,shiftBy:o}}function Ep(e,t,r){const{windowSize:n,mask:s,maxNumber:i,shiftBy:o}=r;let a=Number(e&s),c=e>>o;a>n&&(a-=i,c+=ds);const l=t*n,u=l+Math.abs(a)-1,f=a===0,p=a<0,d=t%2!==0;return{nextN:c,offset:u,isZero:f,isNeg:p,isNegF:d,offsetF:l}}function aS(e,t){if(!Array.isArray(e))throw new Error("array expected");e.forEach((r,n)=>{if(!(r instanceof t))throw new Error("invalid point at index "+n)})}function cS(e,t){if(!Array.isArray(e))throw new Error("array of scalars expected");e.forEach((r,n)=>{if(!t.isValid(r))throw new Error("invalid scalar at index "+n)})}const Su=new WeakMap,ab=new WeakMap;function _u(e){return ab.get(e)||1}function Ap(e){if(e!==vi)throw new Error("invalid wNAF")}function uS(e,t){return{constTimeNegate:to,hasPrecomputes(r){return _u(r)!==1},unsafeLadder(r,n,s=e.ZERO){let i=r;for(;n>vi;)n&ds&&(s=s.add(i)),i=i.double(),n>>=ds;return s},precomputeWindow(r,n){const{windows:s,windowSize:i}=xu(n,t),o=[];let a=r,c=a;for(let l=0;l<s;l++){c=a,o.push(c);for(let u=1;u<i;u++)c=c.add(a),o.push(c);a=c.double()}return o},wNAF(r,n,s){let i=e.ZERO,o=e.BASE;const a=xu(r,t);for(let c=0;c<a.windows;c++){const{nextN:l,offset:u,isZero:f,isNeg:p,isNegF:d,offsetF:m}=Ep(s,c,a);s=l,f?o=o.add(to(d,n[m])):i=i.add(to(p,n[u]))}return Ap(s),{p:i,f:o}},wNAFUnsafe(r,n,s,i=e.ZERO){const o=xu(r,t);for(let a=0;a<o.windows&&s!==vi;a++){const{nextN:c,offset:l,isZero:u,isNeg:f}=Ep(s,a,o);if(s=c,!u){const p=n[l];i=i.add(f?p.negate():p)}}return Ap(s),i},getPrecomputes(r,n,s){let i=Su.get(n);return i||(i=this.precomputeWindow(n,r),r!==1&&(typeof s=="function"&&(i=s(i)),Su.set(n,i))),i},wNAFCached(r,n,s){const i=_u(r);return this.wNAF(i,this.getPrecomputes(i,r,s),n)},wNAFCachedUnsafe(r,n,s,i){const o=_u(r);return o===1?this.unsafeLadder(r,n,i):this.wNAFUnsafe(o,this.getPrecomputes(o,r,s),n,i)},setWindowSize(r,n){ob(n,t),ab.set(r,n),Su.delete(r)}}}function lS(e,t,r,n){let s=t,i=e.ZERO,o=e.ZERO;for(;r>vi||n>vi;)r&ds&&(i=i.add(s)),n&ds&&(o=o.add(s)),s=s.double(),r>>=ds,n>>=ds;return{p1:i,p2:o}}function fS(e,t,r,n){aS(r,e),cS(n,t);const s=r.length,i=n.length;if(s!==i)throw new Error("arrays of points and scalars must have equal length");const o=e.ZERO,a=Xx(BigInt(s));let c=1;a>12?c=a-3:a>4?c=a-2:a>0&&(c=2);const l=Mc(c),u=new Array(Number(l)+1).fill(o),f=Math.floor((t.BITS-1)/c)*c;let p=o;for(let d=f;d>=0;d-=c){u.fill(o);for(let g=0;g<i;g++){const w=n[g],A=Number(w>>BigInt(d)&l);u[A]=u[A].add(r[g])}let m=o;for(let g=u.length-1,w=o;g>0;g--)w=w.add(u[g]),m=m.add(w);if(p=p.add(m),d!==0)for(let g=0;g<c;g++)p=p.double()}return p}function xp(e,t){if(t){if(t.ORDER!==e)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return rS(t),t}else return Fc(e)}function dS(e,t,r={}){if(!t||typeof t!="object")throw new Error(`expected valid ${e} CURVE object`);for(const a of["p","n","h"]){const c=t[a];if(!(typeof c=="bigint"&&c>vi))throw new Error(`CURVE.${a} must be positive bigint`)}const n=xp(t.p,r.Fp),s=xp(t.n,r.Fn),o=["Gx","Gy","a","b"];for(const a of o)if(!n.isValid(t[a]))throw new Error(`CURVE.${a} must be valid field element of CURVE.Fp`);return{Fp:n,Fn:s}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Sp(e){e.lowS!==void 0&&tc("lowS",e.lowS),e.prehash!==void 0&&tc("prehash",e.prehash)}class hS extends Error{constructor(t=""){super(t)}}const un={Err:hS,_tlv:{encode:(e,t)=>{const{Err:r}=un;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(t.length&1)throw new r("tlv.encode: unpadded data");const n=t.length/2,s=va(n);if(s.length/2&128)throw new r("tlv.encode: long form length too big");const i=n>127?va(s.length/2|128):"";return va(e)+i+s+t},decode(e,t){const{Err:r}=un;let n=0;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(t.length<2||t[n++]!==e)throw new r("tlv.decode: wrong tlv");const s=t[n++],i=!!(s&128);let o=0;if(!i)o=s;else{const c=s&127;if(!c)throw new r("tlv.decode(long): indefinite length not supported");if(c>4)throw new r("tlv.decode(long): byte length is too big");const l=t.subarray(n,n+c);if(l.length!==c)throw new r("tlv.decode: length bytes not complete");if(l[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(const u of l)o=o<<8|u;if(n+=c,o<128)throw new r("tlv.decode(long): not minimal encoding")}const a=t.subarray(n,n+o);if(a.length!==o)throw new r("tlv.decode: wrong value length");return{v:a,l:t.subarray(n+o)}}},_int:{encode(e){const{Err:t}=un;if(e<ro)throw new t("integer: negative integers are not allowed");let r=va(e);if(Number.parseInt(r[0],16)&8&&(r="00"+r),r.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return r},decode(e){const{Err:t}=un;if(e[0]&128)throw new t("invalid signature integer: negative");if(e[0]===0&&!(e[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return Uc(e)}},toSig(e){const{Err:t,_int:r,_tlv:n}=un,s=Qt("signature",e),{v:i,l:o}=n.decode(48,s);if(o.length)throw new t("invalid signature: left bytes after parsing");const{v:a,l:c}=n.decode(2,i),{v:l,l:u}=n.decode(2,c);if(u.length)throw new t("invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(l)}},hexFromSig(e){const{_tlv:t,_int:r}=un,n=t.encode(2,r.encode(e.r)),s=t.encode(2,r.encode(e.s)),i=n+s;return t.encode(48,i)}},ro=BigInt(0),no=BigInt(1),pS=BigInt(2),Ea=BigInt(3),yS=BigInt(4);function mS(e,t,r){function n(s){const i=e.sqr(s),o=e.mul(i,s);return e.add(e.add(o,e.mul(s,t)),r)}return n}function cb(e,t,r){const{BYTES:n}=e;function s(i){let o;if(typeof i=="bigint")o=i;else{let a=Qt("private key",i);if(t){if(!t.includes(a.length*2))throw new Error("invalid private key");const c=new Uint8Array(n);c.set(a,c.length-a.length),a=c}try{o=e.fromBytes(a)}catch{throw new Error(`invalid private key: expected ui8a of size ${n}, got ${typeof i}`)}}if(r&&(o=e.create(o)),!e.isValidNot0(o))throw new Error("invalid private key: out of range [1..N-1]");return o}return s}function gS(e,t={}){const{Fp:r,Fn:n}=dS("weierstrass",e,t),{h:s,n:i}=e;Wd(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",wrapPrivateKey:"boolean"});const{endo:o}=t;if(o&&(!r.is0(e.a)||typeof o.beta!="bigint"||typeof o.splitScalar!="function"))throw new Error('invalid endo: expected "beta": bigint and "splitScalar": function');function a(){if(!r.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function c(j,k,F){const{x:R,y:U}=k.toAffine(),H=r.toBytes(R);if(tc("isCompressed",F),F){a();const W=!r.isOdd(U);return us(ub(W),H)}else return us(Uint8Array.of(4),H,r.toBytes(U))}function l(j){lr(j);const k=r.BYTES,F=k+1,R=2*k+1,U=j.length,H=j[0],W=j.subarray(1);if(U===F&&(H===2||H===3)){const Z=r.fromBytes(W);if(!r.isValid(Z))throw new Error("bad point: is not on curve, wrong x");const Q=p(Z);let re;try{re=r.sqrt(Q)}catch(V){const K=V instanceof Error?": "+V.message:"";throw new Error("bad point: is not on curve, sqrt error"+K)}a();const D=r.isOdd(re);return(H&1)===1!==D&&(re=r.neg(re)),{x:Z,y:re}}else if(U===R&&H===4){const Z=r.fromBytes(W.subarray(k*0,k*1)),Q=r.fromBytes(W.subarray(k*1,k*2));if(!d(Z,Q))throw new Error("bad point: is not on curve");return{x:Z,y:Q}}else throw new Error(`bad point: got length ${U}, expected compressed=${F} or uncompressed=${R}`)}const u=t.toBytes||c,f=t.fromBytes||l,p=mS(r,e.a,e.b);function d(j,k){const F=r.sqr(k),R=p(j);return r.eql(F,R)}if(!d(e.Gx,e.Gy))throw new Error("bad curve params: generator point");const m=r.mul(r.pow(e.a,Ea),yS),g=r.mul(r.sqr(e.b),BigInt(27));if(r.is0(r.add(m,g)))throw new Error("bad curve params: a or b");function w(j,k,F=!1){if(!r.isValid(k)||F&&r.is0(k))throw new Error(`bad point coordinate ${j}`);return k}function A(j){if(!(j instanceof I))throw new Error("ProjectivePoint expected")}const T=bp((j,k)=>{const{px:F,py:R,pz:U}=j;if(r.eql(U,r.ONE))return{x:F,y:R};const H=j.is0();k==null&&(k=H?r.ONE:r.inv(U));const W=r.mul(F,k),Z=r.mul(R,k),Q=r.mul(U,k);if(H)return{x:r.ZERO,y:r.ZERO};if(!r.eql(Q,r.ONE))throw new Error("invZ was invalid");return{x:W,y:Z}}),E=bp(j=>{if(j.is0()){if(t.allowInfinityPoint&&!r.is0(j.py))return;throw new Error("bad point: ZERO")}const{x:k,y:F}=j.toAffine();if(!r.isValid(k)||!r.isValid(F))throw new Error("bad point: x or y not field elements");if(!d(k,F))throw new Error("bad point: equation left != right");if(!j.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function S(j,k,F,R,U){return F=new I(r.mul(F.px,j),F.py,F.pz),k=to(R,k),F=to(U,F),k.add(F)}class I{constructor(k,F,R){this.px=w("x",k),this.py=w("y",F,!0),this.pz=w("z",R),Object.freeze(this)}static fromAffine(k){const{x:F,y:R}=k||{};if(!k||!r.isValid(F)||!r.isValid(R))throw new Error("invalid affine point");if(k instanceof I)throw new Error("projective point not allowed");return r.is0(F)&&r.is0(R)?I.ZERO:new I(F,R,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(k){return oS(I,"pz",k)}static fromBytes(k){return lr(k),I.fromHex(k)}static fromHex(k){const F=I.fromAffine(f(Qt("pointHex",k)));return F.assertValidity(),F}static fromPrivateKey(k){const F=cb(n,t.allowedPrivateKeyLengths,t.wrapPrivateKey);return I.BASE.multiply(F(k))}static msm(k,F){return fS(I,n,k,F)}precompute(k=8,F=!0){return $.setWindowSize(this,k),F||this.multiply(Ea),this}_setWindowSize(k){this.precompute(k)}assertValidity(){E(this)}hasEvenY(){const{y:k}=this.toAffine();if(!r.isOdd)throw new Error("Field doesn't support isOdd");return!r.isOdd(k)}equals(k){A(k);const{px:F,py:R,pz:U}=this,{px:H,py:W,pz:Z}=k,Q=r.eql(r.mul(F,Z),r.mul(H,U)),re=r.eql(r.mul(R,Z),r.mul(W,U));return Q&&re}negate(){return new I(this.px,r.neg(this.py),this.pz)}double(){const{a:k,b:F}=e,R=r.mul(F,Ea),{px:U,py:H,pz:W}=this;let Z=r.ZERO,Q=r.ZERO,re=r.ZERO,D=r.mul(U,U),B=r.mul(H,H),V=r.mul(W,W),K=r.mul(U,H);return K=r.add(K,K),re=r.mul(U,W),re=r.add(re,re),Z=r.mul(k,re),Q=r.mul(R,V),Q=r.add(Z,Q),Z=r.sub(B,Q),Q=r.add(B,Q),Q=r.mul(Z,Q),Z=r.mul(K,Z),re=r.mul(R,re),V=r.mul(k,V),K=r.sub(D,V),K=r.mul(k,K),K=r.add(K,re),re=r.add(D,D),D=r.add(re,D),D=r.add(D,V),D=r.mul(D,K),Q=r.add(Q,D),V=r.mul(H,W),V=r.add(V,V),D=r.mul(V,K),Z=r.sub(Z,D),re=r.mul(V,B),re=r.add(re,re),re=r.add(re,re),new I(Z,Q,re)}add(k){A(k);const{px:F,py:R,pz:U}=this,{px:H,py:W,pz:Z}=k;let Q=r.ZERO,re=r.ZERO,D=r.ZERO;const B=e.a,V=r.mul(e.b,Ea);let K=r.mul(F,H),O=r.mul(R,W),N=r.mul(U,Z),L=r.add(F,R),J=r.add(H,W);L=r.mul(L,J),J=r.add(K,O),L=r.sub(L,J),J=r.add(F,U);let ne=r.add(H,Z);return J=r.mul(J,ne),ne=r.add(K,N),J=r.sub(J,ne),ne=r.add(R,U),Q=r.add(W,Z),ne=r.mul(ne,Q),Q=r.add(O,N),ne=r.sub(ne,Q),D=r.mul(B,J),Q=r.mul(V,N),D=r.add(Q,D),Q=r.sub(O,D),D=r.add(O,D),re=r.mul(Q,D),O=r.add(K,K),O=r.add(O,K),N=r.mul(B,N),J=r.mul(V,J),O=r.add(O,N),N=r.sub(K,N),N=r.mul(B,N),J=r.add(J,N),K=r.mul(O,J),re=r.add(re,K),K=r.mul(ne,J),Q=r.mul(L,Q),Q=r.sub(Q,K),K=r.mul(L,O),D=r.mul(ne,D),D=r.add(D,K),new I(Q,re,D)}subtract(k){return this.add(k.negate())}is0(){return this.equals(I.ZERO)}multiply(k){const{endo:F}=t;if(!n.isValidNot0(k))throw new Error("invalid scalar: out of range");let R,U;const H=W=>$.wNAFCached(this,W,I.normalizeZ);if(F){const{k1neg:W,k1:Z,k2neg:Q,k2:re}=F.splitScalar(k),{p:D,f:B}=H(Z),{p:V,f:K}=H(re);U=B.add(K),R=S(F.beta,D,V,W,Q)}else{const{p:W,f:Z}=H(k);R=W,U=Z}return I.normalizeZ([R,U])[0]}multiplyUnsafe(k){const{endo:F}=t,R=this;if(!n.isValid(k))throw new Error("invalid scalar: out of range");if(k===ro||R.is0())return I.ZERO;if(k===no)return R;if($.hasPrecomputes(this))return this.multiply(k);if(F){const{k1neg:U,k1:H,k2neg:W,k2:Z}=F.splitScalar(k),{p1:Q,p2:re}=lS(I,R,H,Z);return S(F.beta,Q,re,U,W)}else return $.wNAFCachedUnsafe(R,k)}multiplyAndAddUnsafe(k,F,R){const U=this.multiplyUnsafe(F).add(k.multiplyUnsafe(R));return U.is0()?void 0:U}toAffine(k){return T(this,k)}isTorsionFree(){const{isTorsionFree:k}=t;return s===no?!0:k?k(I,this):$.wNAFCachedUnsafe(this,i).is0()}clearCofactor(){const{clearCofactor:k}=t;return s===no?this:k?k(I,this):this.multiplyUnsafe(s)}toBytes(k=!0){return tc("isCompressed",k),this.assertValidity(),u(I,this,k)}toRawBytes(k=!0){return this.toBytes(k)}toHex(k=!0){return mo(this.toBytes(k))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}I.BASE=new I(e.Gx,e.Gy,r.ONE),I.ZERO=new I(r.ZERO,r.ONE,r.ZERO),I.Fp=r,I.Fn=n;const P=n.BITS,$=uS(I,t.endo?Math.ceil(P/2):P);return I}function ub(e){return Uint8Array.of(e?2:3)}function bS(e,t,r={}){Wd(t,{hash:"function"},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});const n=t.randomBytes||E2,s=t.hmac||((R,...U)=>Xg(t.hash,R,us(...U))),{Fp:i,Fn:o}=e,{ORDER:a,BITS:c}=o;function l(R){const U=a>>no;return R>U}function u(R){return l(R)?o.neg(R):R}function f(R,U){if(!o.isValidNot0(U))throw new Error(`invalid signature ${R}: out of range 1..CURVE.n`)}class p{constructor(U,H,W){f("r",U),f("s",H),this.r=U,this.s=H,W!=null&&(this.recovery=W),Object.freeze(this)}static fromCompact(U){const H=o.BYTES,W=Qt("compactSignature",U,H*2);return new p(o.fromBytes(W.subarray(0,H)),o.fromBytes(W.subarray(H,H*2)))}static fromDER(U){const{r:H,s:W}=un.toSig(Qt("DER",U));return new p(H,W)}assertValidity(){}addRecoveryBit(U){return new p(this.r,this.s,U)}recoverPublicKey(U){const H=i.ORDER,{r:W,s:Z,recovery:Q}=this;if(Q==null||![0,1,2,3].includes(Q))throw new Error("recovery id invalid");if(a*pS<H&&Q>1)throw new Error("recovery id is ambiguous for h>1 curve");const D=Q===2||Q===3?W+a:W;if(!i.isValid(D))throw new Error("recovery id 2 or 3 invalid");const B=i.toBytes(D),V=e.fromHex(us(ub((Q&1)===0),B)),K=o.inv(D),O=E(Qt("msgHash",U)),N=o.create(-O*K),L=o.create(Z*K),J=e.BASE.multiplyUnsafe(N).add(V.multiplyUnsafe(L));if(J.is0())throw new Error("point at infinify");return J.assertValidity(),J}hasHighS(){return l(this.s)}normalizeS(){return this.hasHighS()?new p(this.r,o.neg(this.s),this.recovery):this}toBytes(U){if(U==="compact")return us(o.toBytes(this.r),o.toBytes(this.s));if(U==="der")return ud(un.hexFromSig(this));throw new Error("invalid format")}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return mo(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return mo(this.toBytes("compact"))}}const d=cb(o,r.allowedPrivateKeyLengths,r.wrapPrivateKey),m={isValidPrivateKey(R){try{return d(R),!0}catch{return!1}},normPrivateKeyToScalar:d,randomPrivateKey:()=>{const R=a;return iS(n(ib(R)),R)},precompute(R=8,U=e.BASE){return U.precompute(R,!1)}};function g(R,U=!0){return e.fromPrivateKey(R).toBytes(U)}function w(R){if(typeof R=="bigint")return!1;if(R instanceof e)return!0;const H=Qt("key",R).length,W=i.BYTES,Z=W+1,Q=2*W+1;if(!(r.allowedPrivateKeyLengths||o.BYTES===Z))return H===Z||H===Q}function A(R,U,H=!0){if(w(R)===!0)throw new Error("first arg must be private key");if(w(U)===!1)throw new Error("second arg must be public key");return e.fromHex(U).multiply(d(R)).toBytes(H)}const T=t.bits2int||function(R){if(R.length>8192)throw new Error("input is too large");const U=Uc(R),H=R.length*8-c;return H>0?U>>BigInt(H):U},E=t.bits2int_modN||function(R){return o.create(T(R))},S=Mc(c);function I(R){return Kx("num < 2^"+c,R,ro,S),o.toBytes(R)}function P(R,U,H=$){if(["recovered","canonical"].some(L=>L in H))throw new Error("sign() legacy options not supported");const{hash:W}=t;let{lowS:Z,prehash:Q,extraEntropy:re}=H;Z==null&&(Z=!0),R=Qt("msgHash",R),Sp(H),Q&&(R=Qt("prehashed msgHash",W(R)));const D=E(R),B=d(U),V=[I(B),I(D)];if(re!=null&&re!==!1){const L=re===!0?n(i.BYTES):re;V.push(Qt("extraEntropy",L))}const K=us(...V),O=D;function N(L){const J=T(L);if(!o.isValidNot0(J))return;const ne=o.inv(J),fe=e.BASE.multiply(J).toAffine(),ce=o.create(fe.x);if(ce===ro)return;const oe=o.create(ne*o.create(O+ce*B));if(oe===ro)return;let ie=(fe.x===ce?0:2)|Number(fe.y&no),he=oe;return Z&&l(oe)&&(he=u(oe),ie^=1),new p(ce,he,ie)}return{seed:K,k2sig:N}}const $={lowS:t.lowS,prehash:!1},j={lowS:t.lowS,prehash:!1};function k(R,U,H=$){const{seed:W,k2sig:Z}=P(R,U,H);return Yx(t.hash.outputLen,o.BYTES,s)(W,Z)}e.BASE.precompute(8);function F(R,U,H,W=j){const Z=R;U=Qt("msgHash",U),H=Qt("publicKey",H),Sp(W);const{lowS:Q,prehash:re,format:D}=W;if("strict"in W)throw new Error("options.strict was renamed to lowS");if(D!==void 0&&!["compact","der","js"].includes(D))throw new Error('format must be "compact", "der" or "js"');const B=typeof Z=="string"||ad(Z),V=!B&&!D&&typeof Z=="object"&&Z!==null&&typeof Z.r=="bigint"&&typeof Z.s=="bigint";if(!B&&!V)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let K,O;try{if(V)if(D===void 0||D==="js")K=new p(Z.r,Z.s);else throw new Error("invalid format");if(B){try{D!=="compact"&&(K=p.fromDER(Z))}catch(he){if(!(he instanceof un.Err))throw he}!K&&D!=="der"&&(K=p.fromCompact(Z))}O=e.fromHex(H)}catch{return!1}if(!K||Q&&K.hasHighS())return!1;re&&(U=t.hash(U));const{r:N,s:L}=K,J=E(U),ne=o.inv(L),fe=o.create(J*ne),ce=o.create(N*ne),oe=e.BASE.multiplyUnsafe(fe).add(O.multiplyUnsafe(ce));return oe.is0()?!1:o.create(oe.x)===N}return Object.freeze({getPublicKey:g,getSharedSecret:A,sign:k,verify:F,utils:m,Point:e,Signature:p})}function wS(e){const t={a:e.a,b:e.b,p:e.Fp.ORDER,n:e.n,h:e.h,Gx:e.Gx,Gy:e.Gy},r=e.Fp,n=Fc(t.n,e.nBitLength),s={Fp:r,Fn:n,allowedPrivateKeyLengths:e.allowedPrivateKeyLengths,allowInfinityPoint:e.allowInfinityPoint,endo:e.endo,wrapPrivateKey:e.wrapPrivateKey,isTorsionFree:e.isTorsionFree,clearCofactor:e.clearCofactor,fromBytes:e.fromBytes,toBytes:e.toBytes};return{CURVE:t,curveOpts:s}}function vS(e){const{CURVE:t,curveOpts:r}=wS(e),n={hash:e.hash,hmac:e.hmac,randomBytes:e.randomBytes,lowS:e.lowS,bits2int:e.bits2int,bits2int_modN:e.bits2int_modN};return{CURVE:t,curveOpts:r,ecdsaOpts:n}}function ES(e,t){return Object.assign({},t,{ProjectivePoint:t.Point,CURVE:e})}function AS(e){const{CURVE:t,curveOpts:r,ecdsaOpts:n}=vS(e),s=gS(t,r),i=bS(s,n,r);return ES(e,i)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function xS(e,t){const r=n=>AS({...e,hash:n});return{...r(t),create:r}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const rc={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")};BigInt(0);const SS=BigInt(1),Of=BigInt(2),_p=(e,t)=>(e+t/Of)/t;function _S(e){const t=rc.p,r=BigInt(3),n=BigInt(6),s=BigInt(11),i=BigInt(22),o=BigInt(23),a=BigInt(44),c=BigInt(88),l=e*e*e%t,u=l*l*e%t,f=Zt(u,r,t)*u%t,p=Zt(f,r,t)*u%t,d=Zt(p,Of,t)*l%t,m=Zt(d,s,t)*d%t,g=Zt(m,i,t)*m%t,w=Zt(g,a,t)*g%t,A=Zt(w,c,t)*w%t,T=Zt(A,a,t)*g%t,E=Zt(T,r,t)*u%t,S=Zt(E,o,t)*m%t,I=Zt(S,n,t)*l%t,P=Zt(I,Of,t);if(!Bf.eql(Bf.sqr(P),e))throw new Error("Cannot find square root");return P}const Bf=Fc(rc.p,void 0,void 0,{sqrt:_S}),lb=xS({...rc,Fp:Bf,lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{const t=rc.n,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-SS*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),s=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=r,o=BigInt("0x100000000000000000000000000000000"),a=_p(i*e,t),c=_p(-n*e,t);let l=rr(e-a*r-c*s,t),u=rr(-a*n-c*i,t);const f=l>o,p=u>o;if(f&&(l=t-l),p&&(u=t-u),l>o||u>o)throw new Error("splitScalar: Endomorphism failed, k="+e);return{k1neg:f,k1:l,k2neg:p,k2:u}}}},C0),kS=Object.freeze(Object.defineProperty({__proto__:null,secp256k1:lb},Symbol.toStringTag,{value:"Module"}));function TS({r:e,s:t,to:r="hex",v:n,yParity:s}){const i=(()=>{if(s===0||s===1)return s;if(n&&(n===27n||n===28n||n>=35n))return n%2n===0n?1:0;throw new Error("Invalid `v` or `yParity` value")})(),o=`0x${new lb.Signature(ot(e),ot(t)).toCompactHex()}${i===0?"1b":"1c"}`;return r==="hex"?o:Sr(o)}async function Kd(e,t){var f,p,d;const{address:r,factory:n,factoryData:s,hash:i,signature:o,universalSignatureVerifierAddress:a=(d=(p=(f=e.chain)==null?void 0:f.contracts)==null?void 0:p.universalSignatureVerifier)==null?void 0:d.address,...c}=t,l=xr(o)?o:typeof o=="object"&&"r"in o&&"s"in o?TS(o):Je(o),u=await(async()=>!n&&!s||ux(l)?l:lx({address:n,data:s,signature:l}))();try{const m=a?{to:a,data:dr({abi:up,functionName:"isValidSig",args:[r,i,u]}),...c}:{data:Ic({abi:up,args:[r,i,u],bytecode:P6}),...c},{data:g}=await se(e,ra,"call")(m);return t2(g??"0x0")}catch(m){try{if(ta(c0(r),await x0({hash:i,signature:o})))return!0}catch{}if(m instanceof A0)return!1;throw m}}async function IS(e,{address:t,message:r,factory:n,factoryData:s,signature:i,...o}){const a=Mg(r);return Kd(e,{address:t,factory:n,factoryData:s,hash:a,signature:i,...o})}async function PS(e,t){const{address:r,factory:n,factoryData:s,signature:i,message:o,primaryType:a,types:c,domain:l,...u}=t,f=$A({message:o,primaryType:a,types:c,domain:l});return Kd(e,{address:r,factory:n,factoryData:s,hash:f,signature:i,...u})}function fb(e,{emitOnBegin:t=!1,emitMissed:r=!1,onBlockNumber:n,onError:s,poll:i,pollingInterval:o=e.pollingInterval}){const a=typeof i<"u"?i:!(e.transport.type==="webSocket"||e.transport.type==="ipc"||e.transport.type==="fallback"&&(e.transport.transports[0].config.type==="webSocket"||e.transport.transports[0].config.type==="ipc"));let c;return a?(()=>{const f=Ze(["watchBlockNumber",e.uid,t,r,o]);return vn(f,{onBlockNumber:n,onError:s},p=>Ci(async()=>{var d;try{const m=await se(e,na,"getBlockNumber")({cacheTime:0});if(c){if(m===c)return;if(m-c>1&&r)for(let g=c+1n;g<m;g++)p.onBlockNumber(g,c),c=g}(!c||m>c)&&(p.onBlockNumber(m,c),c=m)}catch(m){(d=p.onError)==null||d.call(p,m)}},{emitOnBegin:t,interval:o}))})():(()=>{const f=Ze(["watchBlockNumber",e.uid,t,r]);return vn(f,{onBlockNumber:n,onError:s},p=>{let d=!0,m=()=>d=!1;return(async()=>{try{const g=(()=>{if(e.transport.type==="fallback"){const A=e.transport.transports.find(T=>T.config.type==="webSocket"||T.config.type==="ipc");return A?A.value:e.transport}return e.transport})(),{unsubscribe:w}=await g.subscribe({params:["newHeads"],onData(A){var E;if(!d)return;const T=ot((E=A.result)==null?void 0:E.number);p.onBlockNumber(T,c),c=T},onError(A){var T;(T=p.onError)==null||T.call(p,A)}});m=w,d||m()}catch(g){s==null||s(g)}})(),()=>m()})})()}async function OS(e,t){const{checkReplacement:r=!0,confirmations:n=1,hash:s,onReplaced:i,retryCount:o=6,retryDelay:a=({count:I})=>~~(1<<I)*200,timeout:c=18e4}=t,l=Ze(["waitForTransactionReceipt",e.uid,s]),u=(()=>{var I;return t.pollingInterval?t.pollingInterval:(I=e.chain)!=null&&I.experimental_preconfirmationTime?e.chain.experimental_preconfirmationTime:e.pollingInterval})();let f,p,d,m=!1,g,w;const{promise:A,resolve:T,reject:E}=Ud(),S=c?setTimeout(()=>{w(),g(),E(new mE({hash:s}))},c):void 0;return g=vn(l,{onReplaced:i,resolve:T,reject:E},async I=>{if(d=await se(e,ja,"getTransactionReceipt")({hash:s}).catch(()=>{}),d&&n<=1){clearTimeout(S),I.resolve(d),g();return}w=se(e,fb,"watchBlockNumber")({emitMissed:!0,emitOnBegin:!0,poll:!0,pollingInterval:u,async onBlockNumber(P){const $=k=>{clearTimeout(S),w(),k(),g()};let j=P;if(!m)try{if(d){if(n>1&&(!d.blockNumber||j-d.blockNumber+1n<n))return;$(()=>I.resolve(d));return}if(r&&!f&&(m=!0,await ec(async()=>{f=await se(e,Hd,"getTransaction")({hash:s}),f.blockNumber&&(j=f.blockNumber)},{delay:a,retryCount:o}),m=!1),d=await se(e,ja,"getTransactionReceipt")({hash:s}),n>1&&(!d.blockNumber||j-d.blockNumber+1n<n))return;$(()=>I.resolve(d))}catch(k){if(k instanceof v0||k instanceof E0){if(!f){m=!1;return}try{p=f,m=!0;const F=await ec(()=>se(e,qr,"getBlock")({blockNumber:j,includeTransactions:!0}),{delay:a,retryCount:o,shouldRetry:({error:H})=>H instanceof T0});m=!1;const R=F.transactions.find(({from:H,nonce:W})=>H===p.from&&W===p.nonce);if(!R||(d=await se(e,ja,"getTransactionReceipt")({hash:R.hash}),n>1&&(!d.blockNumber||j-d.blockNumber+1n<n)))return;let U="replaced";R.to===p.to&&R.value===p.value&&R.input===p.input?U="repriced":R.from===R.to&&R.value===0n&&(U="cancelled"),$(()=>{var H;(H=I.onReplaced)==null||H.call(I,{reason:U,replacedTransaction:p,transaction:R,transactionReceipt:d}),I.resolve(d)})}catch(F){$(()=>I.reject(F))}}else $(()=>I.reject(k))}}})}),A}function BS(e,{blockTag:t=e.experimental_blockTag??"latest",emitMissed:r=!1,emitOnBegin:n=!1,onBlock:s,onError:i,includeTransactions:o,poll:a,pollingInterval:c=e.pollingInterval}){const l=typeof a<"u"?a:!(e.transport.type==="webSocket"||e.transport.type==="ipc"||e.transport.type==="fallback"&&(e.transport.transports[0].config.type==="webSocket"||e.transport.transports[0].config.type==="ipc")),u=o??!1;let f;return l?(()=>{const m=Ze(["watchBlocks",e.uid,t,r,n,u,c]);return vn(m,{onBlock:s,onError:i},g=>Ci(async()=>{var w;try{const A=await se(e,qr,"getBlock")({blockTag:t,includeTransactions:u});if(A.number!==null&&(f==null?void 0:f.number)!=null){if(A.number===f.number)return;if(A.number-f.number>1&&r)for(let T=(f==null?void 0:f.number)+1n;T<A.number;T++){const E=await se(e,qr,"getBlock")({blockNumber:T,includeTransactions:u});g.onBlock(E,f),f=E}}((f==null?void 0:f.number)==null||t==="pending"&&(A==null?void 0:A.number)==null||A.number!==null&&A.number>f.number)&&(g.onBlock(A,f),f=A)}catch(A){(w=g.onError)==null||w.call(g,A)}},{emitOnBegin:n,interval:c}))})():(()=>{let m=!0,g=!0,w=()=>m=!1;return(async()=>{try{n&&se(e,qr,"getBlock")({blockTag:t,includeTransactions:u}).then(E=>{m&&g&&(s(E,void 0),g=!1)}).catch(i);const A=(()=>{if(e.transport.type==="fallback"){const E=e.transport.transports.find(S=>S.config.type==="webSocket"||S.config.type==="ipc");return E?E.value:e.transport}return e.transport})(),{unsubscribe:T}=await A.subscribe({params:["newHeads"],async onData(E){var I;if(!m)return;const S=await se(e,qr,"getBlock")({blockNumber:(I=E.result)==null?void 0:I.number,includeTransactions:u}).catch(()=>{});m&&(s(S,f),g=!1,f=S)},onError(E){i==null||i(E)}});w=T,m||w()}catch(A){i==null||i(A)}})(),()=>w()})()}function CS(e,{address:t,args:r,batch:n=!0,event:s,events:i,fromBlock:o,onError:a,onLogs:c,poll:l,pollingInterval:u=e.pollingInterval,strict:f}){const p=typeof l<"u"?l:typeof o=="bigint"?!0:!(e.transport.type==="webSocket"||e.transport.type==="ipc"||e.transport.type==="fallback"&&(e.transport.transports[0].config.type==="webSocket"||e.transport.transports[0].config.type==="ipc")),d=f??!1;return p?(()=>{const w=Ze(["watchEvent",t,r,n,e.uid,s,u,o]);return vn(w,{onLogs:c,onError:a},A=>{let T;o!==void 0&&(T=o-1n);let E,S=!1;const I=Ci(async()=>{var P;if(!S){try{E=await se(e,xg,"createEventFilter")({address:t,args:r,event:s,events:i,strict:d,fromBlock:o})}catch{}S=!0;return}try{let $;if(E)$=await se(e,Pc,"getFilterChanges")({filter:E});else{const j=await se(e,na,"getBlockNumber")({});T&&T!==j?$=await se(e,Bd,"getLogs")({address:t,args:r,event:s,events:i,fromBlock:T+1n,toBlock:j}):$=[],T=j}if($.length===0)return;if(n)A.onLogs($);else for(const j of $)A.onLogs([j])}catch($){E&&$ instanceof Ts&&(S=!1),(P=A.onError)==null||P.call(A,$)}},{emitOnBegin:!0,interval:u});return async()=>{E&&await se(e,Oc,"uninstallFilter")({filter:E}),I()}})})():(()=>{let w=!0,A=()=>w=!1;return(async()=>{try{const T=(()=>{if(e.transport.type==="fallback"){const P=e.transport.transports.find($=>$.config.type==="webSocket"||$.config.type==="ipc");return P?P.value:e.transport}return e.transport})(),E=i??(s?[s]:void 0);let S=[];E&&(S=[E.flatMap($=>Zo({abi:[$],eventName:$.name,args:r}))],s&&(S=S[0]));const{unsubscribe:I}=await T.subscribe({params:["logs",{address:t,topics:S}],onData(P){var j;if(!w)return;const $=P.result;try{const{eventName:k,args:F}=Pd({abi:E??[],data:$.data,topics:$.topics,strict:d}),R=wn($,{args:F,eventName:k});c([R])}catch(k){let F,R;if(k instanceof po||k instanceof pc){if(f)return;F=k.abiItem.name,R=(j=k.abiItem.inputs)==null?void 0:j.some(H=>!("name"in H&&H.name))}const U=wn($,{args:R?[]:{},eventName:F});c([U])}},onError(P){a==null||a(P)}});A=I,w||A()}catch(T){a==null||a(T)}})(),()=>A()})()}function RS(e,{batch:t=!0,onError:r,onTransactions:n,poll:s,pollingInterval:i=e.pollingInterval}){return(typeof s<"u"?s:e.transport.type!=="webSocket"&&e.transport.type!=="ipc")?(()=>{const l=Ze(["watchPendingTransactions",e.uid,t,i]);return vn(l,{onTransactions:n,onError:r},u=>{let f;const p=Ci(async()=>{var d;try{if(!f)try{f=await se(e,Sg,"createPendingTransactionFilter")({});return}catch(g){throw p(),g}const m=await se(e,Pc,"getFilterChanges")({filter:f});if(m.length===0)return;if(t)u.onTransactions(m);else for(const g of m)u.onTransactions([g])}catch(m){(d=u.onError)==null||d.call(u,m)}},{emitOnBegin:!0,interval:i});return async()=>{f&&await se(e,Oc,"uninstallFilter")({filter:f}),p()}})})():(()=>{let l=!0,u=()=>l=!1;return(async()=>{try{const{unsubscribe:f}=await e.transport.subscribe({params:["newPendingTransactions"],onData(p){if(!l)return;const d=p.result;n([d])},onError(p){r==null||r(p)}});u=f,l||u()}catch(f){r==null||r(f)}})(),()=>u()})()}function $S(e){var f,p,d;const{scheme:t,statement:r,...n}=((f=e.match(NS))==null?void 0:f.groups)??{},{chainId:s,expirationTime:i,issuedAt:o,notBefore:a,requestId:c,...l}=((p=e.match(US))==null?void 0:p.groups)??{},u=(d=e.split("Resources:")[1])==null?void 0:d.split(`
|
|
@@ -96,7 +96,7 @@ ${lE(d)}`),super(t.shortMessage,{cause:t,docsPath:n,metaMessages:[...t.metaMessa
|
|
|
96
96
|
`))):oe=O.stylize("[Circular]","special")),$(ce)){if(fe&&ne.match(/^\d+$/))return oe;ce=JSON.stringify(""+ne),ce.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(ce=ce.slice(1,-1),ce=O.stylize(ce,"name")):(ce=ce.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),ce=O.stylize(ce,"string"))}return ce+": "+oe}function g(O,N,L){var J=O.reduce(function(ne,fe){return fe.indexOf(`
|
|
97
97
|
`)>=0,ne+fe.replace(/\u001b\[\d\d?m/g,"").length+1},0);return J>60?L[0]+(N===""?"":N+`
|
|
98
98
|
`)+" "+O.join(`,
|
|
99
|
-
`)+" "+L[1]:L[0]+N+" "+O.join(", ")+" "+L[1]}e.types=YI();function w(O){return Array.isArray(O)}e.isArray=w;function A(O){return typeof O=="boolean"}e.isBoolean=A;function T(O){return O===null}e.isNull=T;function E(O){return O==null}e.isNullOrUndefined=E;function S(O){return typeof O=="number"}e.isNumber=S;function I(O){return typeof O=="string"}e.isString=I;function P(O){return typeof O=="symbol"}e.isSymbol=P;function $(O){return O===void 0}e.isUndefined=$;function j(O){return k(O)&&W(O)==="[object RegExp]"}e.isRegExp=j,e.types.isRegExp=j;function k(O){return typeof O=="object"&&O!==null}e.isObject=k;function F(O){return k(O)&&W(O)==="[object Date]"}e.isDate=F,e.types.isDate=F;function R(O){return k(O)&&(W(O)==="[object Error]"||O instanceof Error)}e.isError=R,e.types.isNativeError=R;function U(O){return typeof O=="function"}e.isFunction=U;function H(O){return O===null||typeof O=="boolean"||typeof O=="number"||typeof O=="string"||typeof O=="symbol"||typeof O>"u"}e.isPrimitive=H,e.isBuffer=ZI();function W(O){return Object.prototype.toString.call(O)}function Z(O){return O<10?"0"+O.toString(10):O.toString(10)}var Q=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function re(){var O=new Date,N=[Z(O.getHours()),Z(O.getMinutes()),Z(O.getSeconds())].join(":");return[O.getDate(),Q[O.getMonth()],N].join(" ")}e.log=function(){console.log("%s - %s",re(),e.format.apply(e,arguments))},e.inherits=JI(),e._extend=function(O,N){if(!N||!k(N))return O;for(var L=Object.keys(N),J=L.length;J--;)O[L[J]]=N[L[J]];return O};function D(O,N){return Object.prototype.hasOwnProperty.call(O,N)}var B=typeof Symbol<"u"?Symbol("util.promisify.custom"):void 0;e.promisify=function(N){if(typeof N!="function")throw new TypeError('The "original" argument must be of type Function');if(B&&N[B]){var L=N[B];if(typeof L!="function")throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(L,B,{value:L,enumerable:!1,writable:!1,configurable:!0}),L}function L(){for(var J,ne,fe=new Promise(function(ie,he){J=ie,ne=he}),ce=[],oe=0;oe<arguments.length;oe++)ce.push(arguments[oe]);ce.push(function(ie,he){ie?ne(ie):J(he)});try{N.apply(this,ce)}catch(ie){ne(ie)}return fe}return Object.setPrototypeOf(L,Object.getPrototypeOf(N)),B&&Object.defineProperty(L,B,{value:L,enumerable:!1,writable:!1,configurable:!0}),Object.defineProperties(L,t(N))},e.promisify.custom=B;function V(O,N){if(!O){var L=new Error("Promise was rejected with a falsy value");L.reason=O,O=L}return N(O)}function K(O){if(typeof O!="function")throw new TypeError('The "original" argument must be of type Function');function N(){for(var L=[],J=0;J<arguments.length;J++)L.push(arguments[J]);var ne=L.pop();if(typeof ne!="function")throw new TypeError("The last argument must be of type Function");var fe=this,ce=function(){return ne.apply(fe,arguments)};O.apply(this,L).then(function(oe){process.nextTick(ce.bind(null,null,oe))},function(oe){process.nextTick(V.bind(null,oe,ce))})}return Object.setPrototypeOf(N,Object.getPrototypeOf(O)),Object.defineProperties(N,t(O)),N}e.callbackify=K}(zu)),zu}Object.defineProperty(Yc,"__esModule",{value:!0});Yc.decode=QI;Yc.encode=eP;const gw=$s;function QI(e){return(gw.isBrowser?new TextDecoder("utf-8"):new(mw()).TextDecoder("utf-8")).decode(e)}function eP(e){return(gw.isBrowser?new TextEncoder:new(mw()).TextEncoder("utf-8")).encode(e)}var Qc={},qf={exports:{}};/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */(function(e,t){var r=Hs,n=r.Buffer;function s(o,a){for(var c in o)a[c]=o[c]}n.from&&n.alloc&&n.allocUnsafe&&n.allocUnsafeSlow?e.exports=r:(s(r,t),t.Buffer=i);function i(o,a,c){return n(o,a,c)}i.prototype=Object.create(n.prototype),s(n,i),i.from=function(o,a,c){if(typeof o=="number")throw new TypeError("Argument must not be a number");return n(o,a,c)},i.alloc=function(o,a,c){if(typeof o!="number")throw new TypeError("Argument must be a number");var l=n(o);return a!==void 0?typeof c=="string"?l.fill(a,c):l.fill(a):l.fill(0),l},i.allocUnsafe=function(o){if(typeof o!="number")throw new TypeError("Argument must be a number");return n(o)},i.allocUnsafeSlow=function(o){if(typeof o!="number")throw new TypeError("Argument must be a number");return r.SlowBuffer(o)}})(qf,qf.exports);var tP=qf.exports,Ca=tP.Buffer;function rP(e){if(e.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),r=0;r<t.length;r++)t[r]=255;for(var n=0;n<e.length;n++){var s=e.charAt(n),i=s.charCodeAt(0);if(t[i]!==255)throw new TypeError(s+" is ambiguous");t[i]=n}var o=e.length,a=e.charAt(0),c=Math.log(o)/Math.log(256),l=Math.log(256)/Math.log(o);function u(d){if((Array.isArray(d)||d instanceof Uint8Array)&&(d=Ca.from(d)),!Ca.isBuffer(d))throw new TypeError("Expected Buffer");if(d.length===0)return"";for(var m=0,g=0,w=0,A=d.length;w!==A&&d[w]===0;)w++,m++;for(var T=(A-w)*l+1>>>0,E=new Uint8Array(T);w!==A;){for(var S=d[w],I=0,P=T-1;(S!==0||I<g)&&P!==-1;P--,I++)S+=256*E[P]>>>0,E[P]=S%o>>>0,S=S/o>>>0;if(S!==0)throw new Error("Non-zero carry");g=I,w++}for(var $=T-g;$!==T&&E[$]===0;)$++;for(var j=a.repeat(m);$<T;++$)j+=e.charAt(E[$]);return j}function f(d){if(typeof d!="string")throw new TypeError("Expected String");if(d.length===0)return Ca.alloc(0);for(var m=0,g=0,w=0;d[m]===a;)g++,m++;for(var A=(d.length-m)*c+1>>>0,T=new Uint8Array(A);m<d.length;){var E=d.charCodeAt(m);if(E>255)return;var S=t[E];if(S===255)return;for(var I=0,P=A-1;(S!==0||I<w)&&P!==-1;P--,I++)S+=o*T[P]>>>0,T[P]=S%256>>>0,S=S/256>>>0;if(S!==0)throw new Error("Non-zero carry");w=I,m++}for(var $=A-w;$!==A&&T[$]===0;)$++;var j=Ca.allocUnsafe(g+(A-$));j.fill(0,0,g);for(var k=g;$!==A;)j[k++]=T[$++];return j}function p(d){var m=f(d);if(m)return m;throw new Error("Non-base"+o+" character")}return{encode:u,decodeUnsafe:f,decode:p}}var nP=rP,sP=nP,iP="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",oP=sP(iP),aP=Kr&&Kr.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Qc,"__esModule",{value:!0});Qc.encode=cP;Qc.decode=uP;const bw=aP(oP);function cP(e){return bw.default.encode(e)}function uP(e){return bw.default.decode(e)}var eu={};Object.defineProperty(eu,"__esModule",{value:!0});eu.encode=fP;eu.decode=dP;const lP=Hs;function fP(e){return e.toString("base64")}function dP(e){return lP.Buffer.from(e,"base64")}var hP=Kr&&Kr.__createBinding||(Object.create?function(e,t,r,n){n===void 0&&(n=r);var s=Object.getOwnPropertyDescriptor(t,r);(!s||("get"in s?!t.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,s)}:function(e,t,r,n){n===void 0&&(n=r),e[n]=t[r]}),pP=Kr&&Kr.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),tu=Kr&&Kr.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)r!=="default"&&Object.prototype.hasOwnProperty.call(e,r)&&hP(t,e,r);return pP(t,e),t};Object.defineProperty(hn,"__esModule",{value:!0});hn.base64=hn.bs58=hn.utf8=ww=hn.hex=void 0;var ww=hn.hex=tu(Xc);hn.utf8=tu(Yc);hn.bs58=tu(Qc);hn.base64=tu(eu);class Wn{constructor(t,r,n,s,i){try{this.swapId=Array.from(Buffer.from(t,"hex")),this.secretHash=Array.from(Buffer.from(n,"hex"))}catch(o){throw new Error("Error decoding swapId or secretHash",{cause:o})}if(this.secretHash.length!=32||this.swapId.length!=32)throw new Error("swapId or secretHash must be exactly 32 bits in size");try{this.redeemer=new sr.web3.PublicKey(r)}catch(o){throw new Error("Error decoding redeemer. Ensure it is a valid base58 encoded",{cause:o})}try{this.amount=new sr.BN(s.toString(10),10),this.expiresIn=new sr.BN(i)}catch(o){throw new Error("Error decoding amount. Invalid value for amount",{cause:o})}if(!(Number.isInteger(i)&&i>0))throw new Error("expiresIn must be a positive integer.")}static from(t){let r;if(t.source_swap.chain.includes("solana"))r=t.source_swap;else if(t.destination_swap.chain.includes("solana"))r=t.destination_swap;else throw new Error("Expected source_swap or destination_swap to be one of 'solana', 'solana_localnet', 'solana_devnet'");const{swap_id:n,redeemer:s,secret_hash:i,timelock:o}=r,a=BigInt(r.amount);return new Wn(n,s,i,a,o)}}function vw(e){let t;try{t=[...ww.decode(e)]}catch(r){throw new Error("Error decoding secret. Ensure it is a hex string",{cause:r})}if(t.length!=32)throw new Error("Invalid Secret size. Expected 32 bytes, got "+t.length);return t}class Ew{constructor(t,r,n,s){if(this.provider=t,this.url=r,!t)throw new Error("Provider is required");if(!r)throw new Error("Endpoint URL is required");if(!n)throw new Error("Relayer address is required");try{this.relayer=new sr.web3.PublicKey(n)}catch(a){throw new Error("Error decoding relayer public key. Ensure it is base58 encoded.",{cause:a})}const i=s.spl?{...ty,metadata:{...ty.metadata??{}},address:s.spl}:void 0,o=s.native?{...zf,metadata:{...zf.metadata??{}},address:s.native}:void 0;try{this.splProgram=i?new sr.Program(i,this.provider):void 0,this.nativeProgram=o?new sr.Program(o,this.provider):void 0}catch(a){throw new Error("Error creating Program instances. Ensure the IDLs and provider are correct.",{cause:a})}}get htlcActorAddress(){if(!this.provider.publicKey)throw new Error("No provider public key found");return this.provider.publicKey.toBase58()}isNativeToken(t){return be.isSolanaNativeToken(t.source_swap.chain,t.source_swap.token_address)}async sendSplViaRelayer(t,r){try{t.recentBlockhash=(await this.provider.connection.getLatestBlockhash()).blockhash,t.feePayer=this.relayer;const s=(await this.provider.wallet.signTransaction(t)).serialize({requireAllSignatures:!1}).toString("base64"),i=await v.Fetcher.post(this.url.endpoint("/initiate"),{body:JSON.stringify({order_id:r,serialized_tx:s}),headers:{"Content-Type":"application/json"}});return i.error||!i.result?v.Err(`Error from Relayer: ${i.error}`):await Tu(this.provider.connection,i.result)?v.Ok(i.result):v.Err("Relayer: Failed to Initiate swap, confirmation timed out")}catch(n){return v.Err(`Failed to send SPL transaction: ${n instanceof Error?n.message:String(n)}`)}}async initiateViaHTLC(t,r){if(!r)return v.Err("Order is required");try{const n=await this.provider.sendAndConfirm(t);return n?await Tu(this.provider.connection,n)?v.Ok(n):v.Err("HTLC: Failed to Initiate swap, confirmation timed out"):v.Err("Failed to initiate HTLC transaction")}catch(n){return v.Err(`Error initiating swap: ${n instanceof Error?n.message:String(n)}`)}}createSwapPDA(t,r){const n=[Buffer.from("swap_account"),this.provider.publicKey.toBuffer(),t];return sr.web3.PublicKey.findProgramAddressSync(n,r)[0]}async initiateSplSwap(t){if(!this.splProgram)return v.Err("SPL program is not initialized");try{const{redeemer:r,secretHash:n,amount:s,expiresIn:i}=Wn.from(t),o=this.splProgram.methods.initiate(i,r,n,s,null),a=new sr.web3.PublicKey(t.source_swap.token_address),c={initiator:this.provider.publicKey,mint:a,initiatorTokenAccount:Y1.getAssociatedTokenAddressSync(a,this.provider.publicKey),sponsor:this.relayer},l=await o.accounts(c).transaction();return this.sendSplViaRelayer(l,t.create_order.create_id)}catch(r){return v.Err(`Error initiating SPL swap: ${r instanceof Error?r.message:String(r)}`)}}async initiateNativeSwap(t){if(!this.nativeProgram)return v.Err("Native program is not initialized");try{const{redeemer:r,secretHash:n,amount:s,expiresIn:i}=Wn.from(t),o=await this.nativeProgram.methods.initiate(s,i,r,n).accounts({initiator:this.provider.publicKey}).transaction();return this.initiateViaHTLC(o,t)}catch(r){return v.Err(`Error initiating native swap: ${r instanceof Error?r.message:String(r)}`)}}async initiate(t){if(!t)return v.Err("Order is required");try{return this.isNativeToken(t)?this.nativeProgram?await this.initiateNativeSwap(t):v.Err("Native program is not initialized"):this.splProgram?await this.initiateSplSwap(t):v.Err("SPL program is not initialized")}catch(r){return v.Err(`Error initiating swap: ${r instanceof Error?r.message:String(r)}`)}}async redeem(t,r){try{const n=vw(r),s={order_id:t.create_order.create_id,secret:Buffer.from(n).toString("hex")},i=await v.Fetcher.post(this.url.endpoint("redeem"),{body:JSON.stringify(s),headers:{"Content-Type":"application/json"}});if(i.error)return v.Err(`Redeem: Error from relayer: ${i.error}`);if(!i.result)return v.Err("Redeem: No transaction hash returned from relayer");const o=i.result;return await Tu(this.provider.connection,o)?v.Ok(o):v.Err("Redeem: Timed out waiting for confirmation")}catch(n){return console.error("Redeem: Caught exception:",n),v.Err(`Error redeeming: ${n instanceof Error?n.message:String(n)}`)}}async refund(){return v.Err("Refund is automatically handled by the relayer.")}}const Aw="1.37.1",yP="1.54.0",mP={"-32700":"ParseError","-32701":"OversizedRequest","-32702":"OversizedResponse","-32600":"InvalidRequest","-32601":"MethodNotFound","-32602":"InvalidParams","-32603":"InternalError","-32604":"ServerBusy","-32000":"CallExecutionFailed","-32001":"UnknownError","-32003":"SubscriptionClosed","-32004":"SubscriptionClosedWithError","-32005":"BatchesNotSupported","-32006":"TooManySubscriptions","-32050":"TransientError","-32002":"TransactionExecutionClientError"};class xw extends Error{}class Sw extends xw{constructor(t,r){super(t),this.code=r,this.type=mP[r]??"ServerError"}}class gP extends xw{constructor(t,r,n){super(t),this.status=r,this.statusText=n}}var _w=e=>{throw TypeError(e)},ph=(e,t,r)=>t.has(e)||_w("Cannot "+r),Ue=(e,t,r)=>(ph(e,t,"read from private field"),r?r.call(e):t.get(e)),is=(e,t,r)=>t.has(e)?_w("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),pi=(e,t,r,n)=>(ph(e,t,"write to private field"),t.set(e,r),r),kw=(e,t,r)=>(ph(e,t,"access private method"),r),bP=(e,t,r,n)=>({set _(s){pi(e,t,s)},get _(){return Ue(e,t,n)}}),Ln,uo,ln,ps,Ho,ys,ic,Tw,Iw;function wP(e){const t=new URL(e);return t.protocol=t.protocol.replace("http","ws"),t.toString()}const vP={WebSocketConstructor:typeof WebSocket<"u"?WebSocket:void 0,callTimeout:3e4,reconnectTimeout:3e3,maxReconnects:5};class EP{constructor(t,r={}){if(is(this,ic),is(this,Ln,0),is(this,uo,0),is(this,ln,null),is(this,ps,null),is(this,Ho,new Set),is(this,ys,new Map),this.endpoint=t,this.options={...vP,...r},!this.options.WebSocketConstructor)throw new Error("Missing WebSocket constructor");this.endpoint.startsWith("http")&&(this.endpoint=wP(this.endpoint))}async makeRequest(t,r,n){const s=await kw(this,ic,Tw).call(this);return new Promise((i,o)=>{pi(this,Ln,Ue(this,Ln)+1),Ue(this,ys).set(Ue(this,Ln),{resolve:i,reject:o,timeout:setTimeout(()=>{Ue(this,ys).delete(Ue(this,Ln)),o(new Error(`Request timeout: ${t}`))},this.options.callTimeout)}),n==null||n.addEventListener("abort",()=>{Ue(this,ys).delete(Ue(this,Ln)),o(n.reason)}),s.send(JSON.stringify({jsonrpc:"2.0",id:Ue(this,Ln),method:t,params:r}))}).then(({error:i,result:o})=>{if(i)throw new Sw(i.message,i.code);return o})}async subscribe(t){const r=new AP(t);return Ue(this,Ho).add(r),await r.subscribe(this),()=>r.unsubscribe(this)}}Ln=new WeakMap;uo=new WeakMap;ln=new WeakMap;ps=new WeakMap;Ho=new WeakMap;ys=new WeakMap;ic=new WeakSet;Tw=function(){return Ue(this,ps)?Ue(this,ps):(pi(this,ps,new Promise(e=>{var t;(t=Ue(this,ln))==null||t.close(),pi(this,ln,new this.options.WebSocketConstructor(this.endpoint)),Ue(this,ln).addEventListener("open",()=>{pi(this,uo,0),e(Ue(this,ln))}),Ue(this,ln).addEventListener("close",()=>{bP(this,uo)._++,Ue(this,uo)<=this.options.maxReconnects&&setTimeout(()=>{kw(this,ic,Iw).call(this)},this.options.reconnectTimeout)}),Ue(this,ln).addEventListener("message",({data:r})=>{let n;try{n=JSON.parse(r)}catch(s){console.error(new Error(`Failed to parse RPC message: ${r}`,{cause:s}));return}if("id"in n&&n.id!=null&&Ue(this,ys).has(n.id)){const{resolve:s,timeout:i}=Ue(this,ys).get(n.id);clearTimeout(i),s(n)}else if("params"in n){const{params:s}=n;Ue(this,Ho).forEach(i=>{i.subscriptionId===s.subscription&&s.subscription===i.subscriptionId&&i.onMessage(s.result)})}})})),Ue(this,ps))};Iw=async function(){var e;return(e=Ue(this,ln))==null||e.close(),pi(this,ps,null),Promise.allSettled([...Ue(this,Ho)].map(t=>t.subscribe(this)))};class AP{constructor(t){this.subscriptionId=null,this.subscribed=!1,this.input=t}onMessage(t){this.subscribed&&this.input.onMessage(t)}async unsubscribe(t){const{subscriptionId:r}=this;return this.subscribed=!1,r==null?!1:(this.subscriptionId=null,t.makeRequest(this.input.unsubscribe,[r]))}async subscribe(t){this.subscriptionId=null,this.subscribed=!0;const r=await t.makeRequest(this.input.method,this.input.params,this.input.signal);this.subscribed&&(this.subscriptionId=r)}}var Pw=e=>{throw TypeError(e)},yh=(e,t,r)=>t.has(e)||Pw("Cannot "+r),nr=(e,t,r)=>(yh(e,t,"read from private field"),r?r.call(e):t.get(e)),Ra=(e,t,r)=>t.has(e)?Pw("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),Vf=(e,t,r,n)=>(yh(e,t,"write to private field"),t.set(e,r),r),xP=(e,t,r)=>(yh(e,t,"access private method"),r),Qi,yr,lo,Gf,Ow;class SP{constructor(t){Ra(this,Gf),Ra(this,Qi,0),Ra(this,yr),Ra(this,lo),Vf(this,yr,t)}fetch(t,r){const n=nr(this,yr).fetch??fetch;if(!n)throw new Error("The current environment does not support fetch, you can provide a fetch implementation in the options for SuiHTTPTransport.");return n(t,r)}async request(t){var s,i;Vf(this,Qi,nr(this,Qi)+1);const r=await this.fetch(((s=nr(this,yr).rpc)==null?void 0:s.url)??nr(this,yr).url,{method:"POST",signal:t.signal,headers:{"Content-Type":"application/json","Client-Sdk-Type":"typescript","Client-Sdk-Version":Aw,"Client-Target-Api-Version":yP,"Client-Request-Method":t.method,...(i=nr(this,yr).rpc)==null?void 0:i.headers},body:JSON.stringify({jsonrpc:"2.0",id:nr(this,Qi),method:t.method,params:t.params})});if(!r.ok)throw new gP(`Unexpected status code: ${r.status}`,r.status,r.statusText);const n=await r.json();if("error"in n&&n.error!=null)throw new Sw(n.error.message,n.error.code);return n.result}async subscribe(t){const r=await xP(this,Gf,Ow).call(this).subscribe(t);return t.signal&&(t.signal.throwIfAborted(),t.signal.addEventListener("abort",()=>{r()})),async()=>!!await r()}}Qi=new WeakMap;yr=new WeakMap;lo=new WeakMap;Gf=new WeakSet;Ow=function(){var e;if(!nr(this,lo)){const t=nr(this,yr).WebSocketConstructor??WebSocket;if(!t)throw new Error("The current environment does not support WebSocket, you can provide a WebSocketConstructor in the options for SuiHTTPTransport.");Vf(this,lo,new EP(((e=nr(this,yr).websocket)==null?void 0:e.url)??nr(this,yr).url,{WebSocketConstructor:t,...nr(this,yr).websocket}))}return nr(this,lo)};function _P(e){switch(e){case"mainnet":return"https://fullnode.mainnet.sui.io:443";case"testnet":return"https://fullnode.testnet.sui.io:443";case"devnet":return"https://fullnode.devnet.sui.io:443";case"localnet":return"http://127.0.0.1:9000";default:throw new Error(`Unknown network: ${e}`)}}/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function kP(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Bw(e,t){return Array.isArray(t)?t.length===0?!0:e?t.every(r=>typeof r=="string"):t.every(r=>Number.isSafeInteger(r)):!1}function Wf(e,t){if(typeof t!="string")throw new Error(`${e}: string expected`);return!0}function Cw(e){if(!Number.isSafeInteger(e))throw new Error(`invalid integer: ${e}`)}function Kf(e){if(!Array.isArray(e))throw new Error("array expected")}function Rw(e,t){if(!Bw(!0,t))throw new Error(`${e}: array of strings expected`)}function TP(e,t){if(!Bw(!1,t))throw new Error(`${e}: array of numbers expected`)}function IP(...e){const t=i=>i,r=(i,o)=>a=>i(o(a)),n=e.map(i=>i.encode).reduceRight(r,t),s=e.map(i=>i.decode).reduce(r,t);return{encode:n,decode:s}}function PP(e){const t=typeof e=="string"?e.split(""):e,r=t.length;Rw("alphabet",t);const n=new Map(t.map((s,i)=>[s,i]));return{encode:s=>(Kf(s),s.map(i=>{if(!Number.isSafeInteger(i)||i<0||i>=r)throw new Error(`alphabet.encode: digit index outside alphabet "${i}". Allowed: ${e}`);return t[i]})),decode:s=>(Kf(s),s.map(i=>{Wf("alphabet.decode",i);const o=n.get(i);if(o===void 0)throw new Error(`Unknown letter: "${i}". Allowed: ${e}`);return o}))}}function OP(e=""){return Wf("join",e),{encode:t=>(Rw("join.decode",t),t.join(e)),decode:t=>(Wf("join.decode",t),t.split(e))}}function sm(e,t,r){if(t<2)throw new Error(`convertRadix: invalid from=${t}, base cannot be less than 2`);if(r<2)throw new Error(`convertRadix: invalid to=${r}, base cannot be less than 2`);if(Kf(e),!e.length)return[];let n=0;const s=[],i=Array.from(e,a=>{if(Cw(a),a<0||a>=t)throw new Error(`invalid integer: ${a}`);return a}),o=i.length;for(;;){let a=0,c=!0;for(let l=n;l<o;l++){const u=i[l],f=t*a,p=f+u;if(!Number.isSafeInteger(p)||f/t!==a||p-u!==f)throw new Error("convertRadix: carry overflow");const d=p/r;a=p%r;const m=Math.floor(d);if(i[l]=m,!Number.isSafeInteger(m)||m*r+a!==p)throw new Error("convertRadix: carry overflow");if(c)m?c=!1:n=l;else continue}if(s.push(a),c)break}for(let a=0;a<e.length-1&&e[a]===0;a++)s.push(0);return s.reverse()}function BP(e){Cw(e);const t=2**8;return{encode:r=>{if(!kP(r))throw new Error("radix.encode input should be Uint8Array");return sm(Array.from(r),t,e)},decode:r=>(TP("radix.decode",r),Uint8Array.from(sm(r,e,t)))}}const CP=e=>IP(BP(58),PP(e),OP("")),$w=CP("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),ru=e=>$w.encode(e),zo=e=>$w.decode(e);function zt(e){return Uint8Array.from(atob(e),t=>t.charCodeAt(0))}const zl=8192;function yt(e){if(e.length<zl)return btoa(String.fromCharCode(...e));let t="";for(var r=0;r<e.length;r+=zl){const n=e.slice(r,r+zl);t+=String.fromCharCode(...n)}return btoa(t)}function Nw(e){var s;const t=e.startsWith("0x")?e.slice(2):e,r=t.length%2===0?t:`0${t}`,n=((s=r.match(/[0-9a-fA-F]{2}/g))==null?void 0:s.map(i=>parseInt(i,16)))??[];if(n.length!==r.length/2)throw new Error(`Invalid hex string ${e}`);return Uint8Array.from(n)}function Si(e){return e.reduce((t,r)=>t+r.toString(16).padStart(2,"0"),"")}function nu(e,t){return Array.from({length:Math.ceil(e.length/t)},(r,n)=>e.slice(n*t,(n+1)*t))}class Uw{constructor(t,r){if(typeof t!="function")throw new TypeError(`DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but got: ${t}.`);this._batchLoadFn=t,this._maxBatchSize=UP(r),this._batchScheduleFn=MP(r),this._cacheKeyFn=FP(r),this._cacheMap=jP(r),this._batch=null,this.name=LP(r)}load(t){if(t==null)throw new TypeError(`The loader.load() function must be called with a value, but got: ${String(t)}.`);const r=$P(this),n=this._cacheMap;let s;if(n){s=this._cacheKeyFn(t);const o=n.get(s);if(o){const a=r.cacheHits||(r.cacheHits=[]);return new Promise(c=>{a.push(()=>{c(o)})})}}r.keys.push(t);const i=new Promise((o,a)=>{r.callbacks.push({resolve:o,reject:a})});return n&&n.set(s,i),i}loadMany(t){if(!Mw(t))throw new TypeError(`The loader.loadMany() function must be called with Array<key>, but got: ${t}.`);const r=[];for(let n=0;n<t.length;n++)r.push(this.load(t[n]).catch(s=>s));return Promise.all(r)}clear(t){const r=this._cacheMap;if(r){const n=this._cacheKeyFn(t);r.delete(n)}return this}clearAll(){const t=this._cacheMap;return t&&t.clear(),this}prime(t,r){const n=this._cacheMap;if(n){const s=this._cacheKeyFn(t);if(n.get(s)===void 0){let i;r instanceof Error?(i=Promise.reject(r),i.catch(()=>{})):i=Promise.resolve(r),n.set(s,i)}}return this}}const RP=typeof process=="object"&&typeof process.nextTick=="function"?function(e){ql||(ql=Promise.resolve()),ql.then(()=>{process.nextTick(e)})}:typeof setImmediate=="function"?function(e){setImmediate(e)}:function(e){setTimeout(e)};let ql;function $P(e){const t=e._batch;if(t!==null&&!t.hasDispatched&&t.keys.length<e._maxBatchSize)return t;const r={hasDispatched:!1,keys:[],callbacks:[]};return e._batch=r,e._batchScheduleFn(()=>{NP(e,r)}),r}function NP(e,t){if(t.hasDispatched=!0,t.keys.length===0){Xf(t);return}let r;try{r=e._batchLoadFn(t.keys)}catch(n){return Vl(e,t,new TypeError(`DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function errored synchronously: ${String(n)}.`))}if(!r||typeof r.then!="function")return Vl(e,t,new TypeError(`DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function did not return a Promise: ${String(r)}.`));Promise.resolve(r).then(n=>{if(!Mw(n))throw new TypeError(`DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function did not return a Promise of an Array: ${String(n)}.`);if(n.length!==t.keys.length)throw new TypeError(`DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function did not return a Promise of an Array of the same length as the Array of keys.
|
|
99
|
+
`)+" "+L[1]:L[0]+N+" "+O.join(", ")+" "+L[1]}e.types=YI();function w(O){return Array.isArray(O)}e.isArray=w;function A(O){return typeof O=="boolean"}e.isBoolean=A;function T(O){return O===null}e.isNull=T;function E(O){return O==null}e.isNullOrUndefined=E;function S(O){return typeof O=="number"}e.isNumber=S;function I(O){return typeof O=="string"}e.isString=I;function P(O){return typeof O=="symbol"}e.isSymbol=P;function $(O){return O===void 0}e.isUndefined=$;function j(O){return k(O)&&W(O)==="[object RegExp]"}e.isRegExp=j,e.types.isRegExp=j;function k(O){return typeof O=="object"&&O!==null}e.isObject=k;function F(O){return k(O)&&W(O)==="[object Date]"}e.isDate=F,e.types.isDate=F;function R(O){return k(O)&&(W(O)==="[object Error]"||O instanceof Error)}e.isError=R,e.types.isNativeError=R;function U(O){return typeof O=="function"}e.isFunction=U;function H(O){return O===null||typeof O=="boolean"||typeof O=="number"||typeof O=="string"||typeof O=="symbol"||typeof O>"u"}e.isPrimitive=H,e.isBuffer=ZI();function W(O){return Object.prototype.toString.call(O)}function Z(O){return O<10?"0"+O.toString(10):O.toString(10)}var Q=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function re(){var O=new Date,N=[Z(O.getHours()),Z(O.getMinutes()),Z(O.getSeconds())].join(":");return[O.getDate(),Q[O.getMonth()],N].join(" ")}e.log=function(){console.log("%s - %s",re(),e.format.apply(e,arguments))},e.inherits=JI(),e._extend=function(O,N){if(!N||!k(N))return O;for(var L=Object.keys(N),J=L.length;J--;)O[L[J]]=N[L[J]];return O};function D(O,N){return Object.prototype.hasOwnProperty.call(O,N)}var B=typeof Symbol<"u"?Symbol("util.promisify.custom"):void 0;e.promisify=function(N){if(typeof N!="function")throw new TypeError('The "original" argument must be of type Function');if(B&&N[B]){var L=N[B];if(typeof L!="function")throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(L,B,{value:L,enumerable:!1,writable:!1,configurable:!0}),L}function L(){for(var J,ne,fe=new Promise(function(ie,he){J=ie,ne=he}),ce=[],oe=0;oe<arguments.length;oe++)ce.push(arguments[oe]);ce.push(function(ie,he){ie?ne(ie):J(he)});try{N.apply(this,ce)}catch(ie){ne(ie)}return fe}return Object.setPrototypeOf(L,Object.getPrototypeOf(N)),B&&Object.defineProperty(L,B,{value:L,enumerable:!1,writable:!1,configurable:!0}),Object.defineProperties(L,t(N))},e.promisify.custom=B;function V(O,N){if(!O){var L=new Error("Promise was rejected with a falsy value");L.reason=O,O=L}return N(O)}function K(O){if(typeof O!="function")throw new TypeError('The "original" argument must be of type Function');function N(){for(var L=[],J=0;J<arguments.length;J++)L.push(arguments[J]);var ne=L.pop();if(typeof ne!="function")throw new TypeError("The last argument must be of type Function");var fe=this,ce=function(){return ne.apply(fe,arguments)};O.apply(this,L).then(function(oe){process.nextTick(ce.bind(null,null,oe))},function(oe){process.nextTick(V.bind(null,oe,ce))})}return Object.setPrototypeOf(N,Object.getPrototypeOf(O)),Object.defineProperties(N,t(O)),N}e.callbackify=K}(zu)),zu}Object.defineProperty(Yc,"__esModule",{value:!0});Yc.decode=QI;Yc.encode=eP;const gw=$s;function QI(e){return(gw.isBrowser?new TextDecoder("utf-8"):new(mw()).TextDecoder("utf-8")).decode(e)}function eP(e){return(gw.isBrowser?new TextEncoder:new(mw()).TextEncoder("utf-8")).encode(e)}var Qc={},qf={exports:{}};/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */(function(e,t){var r=Hs,n=r.Buffer;function s(o,a){for(var c in o)a[c]=o[c]}n.from&&n.alloc&&n.allocUnsafe&&n.allocUnsafeSlow?e.exports=r:(s(r,t),t.Buffer=i);function i(o,a,c){return n(o,a,c)}i.prototype=Object.create(n.prototype),s(n,i),i.from=function(o,a,c){if(typeof o=="number")throw new TypeError("Argument must not be a number");return n(o,a,c)},i.alloc=function(o,a,c){if(typeof o!="number")throw new TypeError("Argument must be a number");var l=n(o);return a!==void 0?typeof c=="string"?l.fill(a,c):l.fill(a):l.fill(0),l},i.allocUnsafe=function(o){if(typeof o!="number")throw new TypeError("Argument must be a number");return n(o)},i.allocUnsafeSlow=function(o){if(typeof o!="number")throw new TypeError("Argument must be a number");return r.SlowBuffer(o)}})(qf,qf.exports);var tP=qf.exports,Ca=tP.Buffer;function rP(e){if(e.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),r=0;r<t.length;r++)t[r]=255;for(var n=0;n<e.length;n++){var s=e.charAt(n),i=s.charCodeAt(0);if(t[i]!==255)throw new TypeError(s+" is ambiguous");t[i]=n}var o=e.length,a=e.charAt(0),c=Math.log(o)/Math.log(256),l=Math.log(256)/Math.log(o);function u(d){if((Array.isArray(d)||d instanceof Uint8Array)&&(d=Ca.from(d)),!Ca.isBuffer(d))throw new TypeError("Expected Buffer");if(d.length===0)return"";for(var m=0,g=0,w=0,A=d.length;w!==A&&d[w]===0;)w++,m++;for(var T=(A-w)*l+1>>>0,E=new Uint8Array(T);w!==A;){for(var S=d[w],I=0,P=T-1;(S!==0||I<g)&&P!==-1;P--,I++)S+=256*E[P]>>>0,E[P]=S%o>>>0,S=S/o>>>0;if(S!==0)throw new Error("Non-zero carry");g=I,w++}for(var $=T-g;$!==T&&E[$]===0;)$++;for(var j=a.repeat(m);$<T;++$)j+=e.charAt(E[$]);return j}function f(d){if(typeof d!="string")throw new TypeError("Expected String");if(d.length===0)return Ca.alloc(0);for(var m=0,g=0,w=0;d[m]===a;)g++,m++;for(var A=(d.length-m)*c+1>>>0,T=new Uint8Array(A);m<d.length;){var E=d.charCodeAt(m);if(E>255)return;var S=t[E];if(S===255)return;for(var I=0,P=A-1;(S!==0||I<w)&&P!==-1;P--,I++)S+=o*T[P]>>>0,T[P]=S%256>>>0,S=S/256>>>0;if(S!==0)throw new Error("Non-zero carry");w=I,m++}for(var $=A-w;$!==A&&T[$]===0;)$++;var j=Ca.allocUnsafe(g+(A-$));j.fill(0,0,g);for(var k=g;$!==A;)j[k++]=T[$++];return j}function p(d){var m=f(d);if(m)return m;throw new Error("Non-base"+o+" character")}return{encode:u,decodeUnsafe:f,decode:p}}var nP=rP,sP=nP,iP="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",oP=sP(iP),aP=Kr&&Kr.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Qc,"__esModule",{value:!0});Qc.encode=cP;Qc.decode=uP;const bw=aP(oP);function cP(e){return bw.default.encode(e)}function uP(e){return bw.default.decode(e)}var eu={};Object.defineProperty(eu,"__esModule",{value:!0});eu.encode=fP;eu.decode=dP;const lP=Hs;function fP(e){return e.toString("base64")}function dP(e){return lP.Buffer.from(e,"base64")}var hP=Kr&&Kr.__createBinding||(Object.create?function(e,t,r,n){n===void 0&&(n=r);var s=Object.getOwnPropertyDescriptor(t,r);(!s||("get"in s?!t.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,s)}:function(e,t,r,n){n===void 0&&(n=r),e[n]=t[r]}),pP=Kr&&Kr.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),tu=Kr&&Kr.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)r!=="default"&&Object.prototype.hasOwnProperty.call(e,r)&&hP(t,e,r);return pP(t,e),t};Object.defineProperty(hn,"__esModule",{value:!0});hn.base64=hn.bs58=hn.utf8=ww=hn.hex=void 0;var ww=hn.hex=tu(Xc);hn.utf8=tu(Yc);hn.bs58=tu(Qc);hn.base64=tu(eu);class Wn{constructor(t,r,n,s,i){try{this.swapId=Array.from(Buffer.from(t,"hex")),this.secretHash=Array.from(Buffer.from(n,"hex"))}catch(o){throw new Error("Error decoding swapId or secretHash",{cause:o})}if(this.secretHash.length!=32||this.swapId.length!=32)throw new Error("swapId or secretHash must be exactly 32 bits in size");try{this.redeemer=new sr.web3.PublicKey(r)}catch(o){throw new Error("Error decoding redeemer. Ensure it is a valid base58 encoded",{cause:o})}try{this.amount=new sr.BN(s.toString(10),10),this.expiresIn=new sr.BN(i)}catch(o){throw new Error("Error decoding amount. Invalid value for amount",{cause:o})}if(!(Number.isInteger(i)&&i>0))throw new Error("expiresIn must be a positive integer.")}static from(t){let r;if(t.source_swap.chain.includes("solana"))r=t.source_swap;else if(t.destination_swap.chain.includes("solana"))r=t.destination_swap;else throw new Error("Expected source_swap or destination_swap to be one of 'solana', 'solana_localnet', 'solana_devnet'");const{swap_id:n,redeemer:s,secret_hash:i,timelock:o}=r,a=BigInt(r.amount);return new Wn(n,s,i,a,o)}}function vw(e){let t;try{t=[...ww.decode(e)]}catch(r){throw new Error("Error decoding secret. Ensure it is a hex string",{cause:r})}if(t.length!=32)throw new Error("Invalid Secret size. Expected 32 bytes, got "+t.length);return t}class Ew{constructor(t,r,n,s){if(this.provider=t,this.url=r,!t)throw new Error("Provider is required");if(!r)throw new Error("Endpoint URL is required");if(!n)throw new Error("Relayer address is required");try{this.relayer=new sr.web3.PublicKey(n)}catch(a){throw new Error("Error decoding relayer public key. Ensure it is base58 encoded.",{cause:a})}const i=s.spl?{...ty,metadata:{...ty.metadata??{}},address:s.spl}:void 0,o=s.native?{...zf,metadata:{...zf.metadata??{}},address:s.native}:void 0;try{this.splProgram=i?new sr.Program(i,this.provider):void 0,this.nativeProgram=o?new sr.Program(o,this.provider):void 0}catch(a){throw new Error("Error creating Program instances. Ensure the IDLs and provider are correct.",{cause:a})}}get htlcActorAddress(){if(!this.provider.publicKey)throw new Error("No provider public key found");return this.provider.publicKey.toBase58()}isNativeToken(t){return be.isSolanaNativeToken(t.source_swap.chain,t.source_swap.token_address)}async sendSplViaRelayer(t,r){try{t.recentBlockhash=(await this.provider.connection.getLatestBlockhash()).blockhash,t.feePayer=this.relayer;const s=(await this.provider.wallet.signTransaction(t)).serialize({requireAllSignatures:!1}).toString("base64"),i=await v.Fetcher.post(this.url.endpoint("/initiate"),{body:JSON.stringify({order_id:r,serialized_tx:s}),headers:{"Content-Type":"application/json"}});return i.error||!i.result?v.Err(`Error from Relayer: ${i.error}`):await Tu(this.provider.connection,i.result)?v.Ok(i.result):v.Err("Relayer: Failed to Initiate swap, confirmation timed out")}catch(n){return v.Err(`Failed to send SPL transaction: ${n instanceof Error?n.message:String(n)}`)}}async initiateViaHTLC(t,r){if(!r)return v.Err("Order is required");try{const n=await this.provider.sendAndConfirm(t);return n?await Tu(this.provider.connection,n)?v.Ok(n):v.Err("HTLC: Failed to Initiate swap, confirmation timed out"):v.Err("Failed to initiate HTLC transaction")}catch(n){return v.Err(`Error initiating swap: ${n instanceof Error?n.message:String(n)}`)}}createSwapPDA(t,r){const n=[Buffer.from("swap_account"),this.provider.publicKey.toBuffer(),t];return sr.web3.PublicKey.findProgramAddressSync(n,r)[0]}async initiateSplSwap(t){if(!this.splProgram)return v.Err("SPL program is not initialized");try{const{redeemer:r,secretHash:n,amount:s,expiresIn:i}=Wn.from(t),o=this.splProgram.methods.initiate(i,r,n,s,null),a=new sr.web3.PublicKey(t.source_swap.token_address),c={initiator:this.provider.publicKey,mint:a,initiatorTokenAccount:Y1.getAssociatedTokenAddressSync(a,this.provider.publicKey),sponsor:this.relayer},l=await o.accounts(c).transaction();return this.sendSplViaRelayer(l,t.create_order.create_id)}catch(r){return v.Err(`Error initiating SPL swap: ${r instanceof Error?r.message:String(r)}`)}}async initiateNativeSwap(t){if(!this.nativeProgram)return v.Err("Native program is not initialized");try{const{redeemer:r,secretHash:n,amount:s,expiresIn:i}=Wn.from(t),o=await this.nativeProgram.methods.initiate(s,i,r,n).accounts({initiator:this.provider.publicKey}).transaction();return this.initiateViaHTLC(o,t)}catch(r){return v.Err(`Error initiating native swap: ${r instanceof Error?r.message:String(r)}`)}}async initiate(t){if(!t)return v.Err("Order is required");try{return this.isNativeToken(t)?this.nativeProgram?await this.initiateNativeSwap(t):v.Err("Native program is not initialized"):this.splProgram?await this.initiateSplSwap(t):v.Err("SPL program is not initialized")}catch(r){return v.Err(`Error initiating swap: ${r instanceof Error?r.message:String(r)}`)}}async redeem(t,r){try{const n=vw(r),s={order_id:t.create_order.create_id,secret:Buffer.from(n).toString("hex")},i=await v.Fetcher.post(this.url.endpoint("redeem"),{body:JSON.stringify(s),headers:{"Content-Type":"application/json"}});if(i.error)return v.Err(`Redeem: Error from relayer: ${i.error}`);if(!i.result)return v.Err("Redeem: No transaction hash returned from relayer");const o=i.result;return await Tu(this.provider.connection,o)?v.Ok(o):v.Err("Redeem: Timed out waiting for confirmation")}catch(n){return console.error("Redeem: Caught exception:",n),v.Err(`Error redeeming: ${n instanceof Error?n.message:String(n)}`)}}async refund(){return v.Err("Refund is automatically handled by the relayer.")}}const Aw="1.37.2",yP="1.55.0",mP={"-32700":"ParseError","-32701":"OversizedRequest","-32702":"OversizedResponse","-32600":"InvalidRequest","-32601":"MethodNotFound","-32602":"InvalidParams","-32603":"InternalError","-32604":"ServerBusy","-32000":"CallExecutionFailed","-32001":"UnknownError","-32003":"SubscriptionClosed","-32004":"SubscriptionClosedWithError","-32005":"BatchesNotSupported","-32006":"TooManySubscriptions","-32050":"TransientError","-32002":"TransactionExecutionClientError"};class xw extends Error{}class Sw extends xw{constructor(t,r){super(t),this.code=r,this.type=mP[r]??"ServerError"}}class gP extends xw{constructor(t,r,n){super(t),this.status=r,this.statusText=n}}var _w=e=>{throw TypeError(e)},ph=(e,t,r)=>t.has(e)||_w("Cannot "+r),Ue=(e,t,r)=>(ph(e,t,"read from private field"),r?r.call(e):t.get(e)),is=(e,t,r)=>t.has(e)?_w("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),pi=(e,t,r,n)=>(ph(e,t,"write to private field"),t.set(e,r),r),kw=(e,t,r)=>(ph(e,t,"access private method"),r),bP=(e,t,r,n)=>({set _(s){pi(e,t,s)},get _(){return Ue(e,t,n)}}),Ln,uo,ln,ps,Ho,ys,ic,Tw,Iw;function wP(e){const t=new URL(e);return t.protocol=t.protocol.replace("http","ws"),t.toString()}const vP={WebSocketConstructor:typeof WebSocket<"u"?WebSocket:void 0,callTimeout:3e4,reconnectTimeout:3e3,maxReconnects:5};class EP{constructor(t,r={}){if(is(this,ic),is(this,Ln,0),is(this,uo,0),is(this,ln,null),is(this,ps,null),is(this,Ho,new Set),is(this,ys,new Map),this.endpoint=t,this.options={...vP,...r},!this.options.WebSocketConstructor)throw new Error("Missing WebSocket constructor");this.endpoint.startsWith("http")&&(this.endpoint=wP(this.endpoint))}async makeRequest(t,r,n){const s=await kw(this,ic,Tw).call(this);return new Promise((i,o)=>{pi(this,Ln,Ue(this,Ln)+1),Ue(this,ys).set(Ue(this,Ln),{resolve:i,reject:o,timeout:setTimeout(()=>{Ue(this,ys).delete(Ue(this,Ln)),o(new Error(`Request timeout: ${t}`))},this.options.callTimeout)}),n==null||n.addEventListener("abort",()=>{Ue(this,ys).delete(Ue(this,Ln)),o(n.reason)}),s.send(JSON.stringify({jsonrpc:"2.0",id:Ue(this,Ln),method:t,params:r}))}).then(({error:i,result:o})=>{if(i)throw new Sw(i.message,i.code);return o})}async subscribe(t){const r=new AP(t);return Ue(this,Ho).add(r),await r.subscribe(this),()=>r.unsubscribe(this)}}Ln=new WeakMap;uo=new WeakMap;ln=new WeakMap;ps=new WeakMap;Ho=new WeakMap;ys=new WeakMap;ic=new WeakSet;Tw=function(){return Ue(this,ps)?Ue(this,ps):(pi(this,ps,new Promise(e=>{var t;(t=Ue(this,ln))==null||t.close(),pi(this,ln,new this.options.WebSocketConstructor(this.endpoint)),Ue(this,ln).addEventListener("open",()=>{pi(this,uo,0),e(Ue(this,ln))}),Ue(this,ln).addEventListener("close",()=>{bP(this,uo)._++,Ue(this,uo)<=this.options.maxReconnects&&setTimeout(()=>{kw(this,ic,Iw).call(this)},this.options.reconnectTimeout)}),Ue(this,ln).addEventListener("message",({data:r})=>{let n;try{n=JSON.parse(r)}catch(s){console.error(new Error(`Failed to parse RPC message: ${r}`,{cause:s}));return}if("id"in n&&n.id!=null&&Ue(this,ys).has(n.id)){const{resolve:s,timeout:i}=Ue(this,ys).get(n.id);clearTimeout(i),s(n)}else if("params"in n){const{params:s}=n;Ue(this,Ho).forEach(i=>{i.subscriptionId===s.subscription&&s.subscription===i.subscriptionId&&i.onMessage(s.result)})}})})),Ue(this,ps))};Iw=async function(){var e;return(e=Ue(this,ln))==null||e.close(),pi(this,ps,null),Promise.allSettled([...Ue(this,Ho)].map(t=>t.subscribe(this)))};class AP{constructor(t){this.subscriptionId=null,this.subscribed=!1,this.input=t}onMessage(t){this.subscribed&&this.input.onMessage(t)}async unsubscribe(t){const{subscriptionId:r}=this;return this.subscribed=!1,r==null?!1:(this.subscriptionId=null,t.makeRequest(this.input.unsubscribe,[r]))}async subscribe(t){this.subscriptionId=null,this.subscribed=!0;const r=await t.makeRequest(this.input.method,this.input.params,this.input.signal);this.subscribed&&(this.subscriptionId=r)}}var Pw=e=>{throw TypeError(e)},yh=(e,t,r)=>t.has(e)||Pw("Cannot "+r),nr=(e,t,r)=>(yh(e,t,"read from private field"),r?r.call(e):t.get(e)),Ra=(e,t,r)=>t.has(e)?Pw("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),Vf=(e,t,r,n)=>(yh(e,t,"write to private field"),t.set(e,r),r),xP=(e,t,r)=>(yh(e,t,"access private method"),r),Qi,yr,lo,Gf,Ow;class SP{constructor(t){Ra(this,Gf),Ra(this,Qi,0),Ra(this,yr),Ra(this,lo),Vf(this,yr,t)}fetch(t,r){const n=nr(this,yr).fetch??fetch;if(!n)throw new Error("The current environment does not support fetch, you can provide a fetch implementation in the options for SuiHTTPTransport.");return n(t,r)}async request(t){var s,i;Vf(this,Qi,nr(this,Qi)+1);const r=await this.fetch(((s=nr(this,yr).rpc)==null?void 0:s.url)??nr(this,yr).url,{method:"POST",signal:t.signal,headers:{"Content-Type":"application/json","Client-Sdk-Type":"typescript","Client-Sdk-Version":Aw,"Client-Target-Api-Version":yP,"Client-Request-Method":t.method,...(i=nr(this,yr).rpc)==null?void 0:i.headers},body:JSON.stringify({jsonrpc:"2.0",id:nr(this,Qi),method:t.method,params:t.params})});if(!r.ok)throw new gP(`Unexpected status code: ${r.status}`,r.status,r.statusText);const n=await r.json();if("error"in n&&n.error!=null)throw new Sw(n.error.message,n.error.code);return n.result}async subscribe(t){const r=await xP(this,Gf,Ow).call(this).subscribe(t);return t.signal&&(t.signal.throwIfAborted(),t.signal.addEventListener("abort",()=>{r()})),async()=>!!await r()}}Qi=new WeakMap;yr=new WeakMap;lo=new WeakMap;Gf=new WeakSet;Ow=function(){var e;if(!nr(this,lo)){const t=nr(this,yr).WebSocketConstructor??WebSocket;if(!t)throw new Error("The current environment does not support WebSocket, you can provide a WebSocketConstructor in the options for SuiHTTPTransport.");Vf(this,lo,new EP(((e=nr(this,yr).websocket)==null?void 0:e.url)??nr(this,yr).url,{WebSocketConstructor:t,...nr(this,yr).websocket}))}return nr(this,lo)};function _P(e){switch(e){case"mainnet":return"https://fullnode.mainnet.sui.io:443";case"testnet":return"https://fullnode.testnet.sui.io:443";case"devnet":return"https://fullnode.devnet.sui.io:443";case"localnet":return"http://127.0.0.1:9000";default:throw new Error(`Unknown network: ${e}`)}}/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */function kP(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function Bw(e,t){return Array.isArray(t)?t.length===0?!0:e?t.every(r=>typeof r=="string"):t.every(r=>Number.isSafeInteger(r)):!1}function Wf(e,t){if(typeof t!="string")throw new Error(`${e}: string expected`);return!0}function Cw(e){if(!Number.isSafeInteger(e))throw new Error(`invalid integer: ${e}`)}function Kf(e){if(!Array.isArray(e))throw new Error("array expected")}function Rw(e,t){if(!Bw(!0,t))throw new Error(`${e}: array of strings expected`)}function TP(e,t){if(!Bw(!1,t))throw new Error(`${e}: array of numbers expected`)}function IP(...e){const t=i=>i,r=(i,o)=>a=>i(o(a)),n=e.map(i=>i.encode).reduceRight(r,t),s=e.map(i=>i.decode).reduce(r,t);return{encode:n,decode:s}}function PP(e){const t=typeof e=="string"?e.split(""):e,r=t.length;Rw("alphabet",t);const n=new Map(t.map((s,i)=>[s,i]));return{encode:s=>(Kf(s),s.map(i=>{if(!Number.isSafeInteger(i)||i<0||i>=r)throw new Error(`alphabet.encode: digit index outside alphabet "${i}". Allowed: ${e}`);return t[i]})),decode:s=>(Kf(s),s.map(i=>{Wf("alphabet.decode",i);const o=n.get(i);if(o===void 0)throw new Error(`Unknown letter: "${i}". Allowed: ${e}`);return o}))}}function OP(e=""){return Wf("join",e),{encode:t=>(Rw("join.decode",t),t.join(e)),decode:t=>(Wf("join.decode",t),t.split(e))}}function sm(e,t,r){if(t<2)throw new Error(`convertRadix: invalid from=${t}, base cannot be less than 2`);if(r<2)throw new Error(`convertRadix: invalid to=${r}, base cannot be less than 2`);if(Kf(e),!e.length)return[];let n=0;const s=[],i=Array.from(e,a=>{if(Cw(a),a<0||a>=t)throw new Error(`invalid integer: ${a}`);return a}),o=i.length;for(;;){let a=0,c=!0;for(let l=n;l<o;l++){const u=i[l],f=t*a,p=f+u;if(!Number.isSafeInteger(p)||f/t!==a||p-u!==f)throw new Error("convertRadix: carry overflow");const d=p/r;a=p%r;const m=Math.floor(d);if(i[l]=m,!Number.isSafeInteger(m)||m*r+a!==p)throw new Error("convertRadix: carry overflow");if(c)m?c=!1:n=l;else continue}if(s.push(a),c)break}for(let a=0;a<e.length-1&&e[a]===0;a++)s.push(0);return s.reverse()}function BP(e){Cw(e);const t=2**8;return{encode:r=>{if(!kP(r))throw new Error("radix.encode input should be Uint8Array");return sm(Array.from(r),t,e)},decode:r=>(TP("radix.decode",r),Uint8Array.from(sm(r,e,t)))}}const CP=e=>IP(BP(58),PP(e),OP("")),$w=CP("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),ru=e=>$w.encode(e),zo=e=>$w.decode(e);function zt(e){return Uint8Array.from(atob(e),t=>t.charCodeAt(0))}const zl=8192;function yt(e){if(e.length<zl)return btoa(String.fromCharCode(...e));let t="";for(var r=0;r<e.length;r+=zl){const n=e.slice(r,r+zl);t+=String.fromCharCode(...n)}return btoa(t)}function Nw(e){var s;const t=e.startsWith("0x")?e.slice(2):e,r=t.length%2===0?t:`0${t}`,n=((s=r.match(/[0-9a-fA-F]{2}/g))==null?void 0:s.map(i=>parseInt(i,16)))??[];if(n.length!==r.length/2)throw new Error(`Invalid hex string ${e}`);return Uint8Array.from(n)}function Si(e){return e.reduce((t,r)=>t+r.toString(16).padStart(2,"0"),"")}function nu(e,t){return Array.from({length:Math.ceil(e.length/t)},(r,n)=>e.slice(n*t,(n+1)*t))}class Uw{constructor(t,r){if(typeof t!="function")throw new TypeError(`DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but got: ${t}.`);this._batchLoadFn=t,this._maxBatchSize=UP(r),this._batchScheduleFn=MP(r),this._cacheKeyFn=FP(r),this._cacheMap=jP(r),this._batch=null,this.name=LP(r)}load(t){if(t==null)throw new TypeError(`The loader.load() function must be called with a value, but got: ${String(t)}.`);const r=$P(this),n=this._cacheMap;let s;if(n){s=this._cacheKeyFn(t);const o=n.get(s);if(o){const a=r.cacheHits||(r.cacheHits=[]);return new Promise(c=>{a.push(()=>{c(o)})})}}r.keys.push(t);const i=new Promise((o,a)=>{r.callbacks.push({resolve:o,reject:a})});return n&&n.set(s,i),i}loadMany(t){if(!Mw(t))throw new TypeError(`The loader.loadMany() function must be called with Array<key>, but got: ${t}.`);const r=[];for(let n=0;n<t.length;n++)r.push(this.load(t[n]).catch(s=>s));return Promise.all(r)}clear(t){const r=this._cacheMap;if(r){const n=this._cacheKeyFn(t);r.delete(n)}return this}clearAll(){const t=this._cacheMap;return t&&t.clear(),this}prime(t,r){const n=this._cacheMap;if(n){const s=this._cacheKeyFn(t);if(n.get(s)===void 0){let i;r instanceof Error?(i=Promise.reject(r),i.catch(()=>{})):i=Promise.resolve(r),n.set(s,i)}}return this}}const RP=typeof process=="object"&&typeof process.nextTick=="function"?function(e){ql||(ql=Promise.resolve()),ql.then(()=>{process.nextTick(e)})}:typeof setImmediate=="function"?function(e){setImmediate(e)}:function(e){setTimeout(e)};let ql;function $P(e){const t=e._batch;if(t!==null&&!t.hasDispatched&&t.keys.length<e._maxBatchSize)return t;const r={hasDispatched:!1,keys:[],callbacks:[]};return e._batch=r,e._batchScheduleFn(()=>{NP(e,r)}),r}function NP(e,t){if(t.hasDispatched=!0,t.keys.length===0){Xf(t);return}let r;try{r=e._batchLoadFn(t.keys)}catch(n){return Vl(e,t,new TypeError(`DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function errored synchronously: ${String(n)}.`))}if(!r||typeof r.then!="function")return Vl(e,t,new TypeError(`DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function did not return a Promise: ${String(r)}.`));Promise.resolve(r).then(n=>{if(!Mw(n))throw new TypeError(`DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function did not return a Promise of an Array: ${String(n)}.`);if(n.length!==t.keys.length)throw new TypeError(`DataLoader must be constructed with a function which accepts Array<key> and returns Promise<Array<value>>, but the function did not return a Promise of an Array of the same length as the Array of keys.
|
|
100
100
|
|
|
101
101
|
Keys:
|
|
102
102
|
${String(t.keys)}
|
|
@@ -663,7 +663,7 @@ function Zr(e, { strict: t = !0 } = {}) {
|
|
|
663
663
|
function De(e) {
|
|
664
664
|
return Zr(e, { strict: !1 }) ? Math.ceil((e.length - 2) / 2) : e.length;
|
|
665
665
|
}
|
|
666
|
-
const n0 = "2.33.
|
|
666
|
+
const n0 = "2.33.3";
|
|
667
667
|
let Vi = {
|
|
668
668
|
getDocsUrl: ({ docsBaseUrl: e, docsPath: t = "", docsSlug: r }) => t ? `${e ?? "https://viem.sh"}${t}${r ? `#${r}` : ""}` : void 0,
|
|
669
669
|
version: `viem@${n0}`
|
|
@@ -5346,7 +5346,7 @@ async function Fc(e, t) {
|
|
|
5346
5346
|
});
|
|
5347
5347
|
return J === "0x" ? { data: void 0 } : { data: J };
|
|
5348
5348
|
} catch (re) {
|
|
5349
|
-
const D = oA(re), { offchainLookup: O, offchainLookupSignature: q } = await import("./ccip-
|
|
5349
|
+
const D = oA(re), { offchainLookup: O, offchainLookupSignature: q } = await import("./ccip-CM2FCFWE.js");
|
|
5350
5350
|
if (e.ccipRead !== !1 && (D == null ? void 0 : D.slice(0, 10)) === q && S)
|
|
5351
5351
|
return { data: await O(e, { data: D, to: S }) };
|
|
5352
5352
|
throw C && (D == null ? void 0 : D.slice(0, 10)) === "0x101bb98d" ? new VE({ factory: p }) : Eg(re, {
|
|
@@ -24281,7 +24281,7 @@ class XP {
|
|
|
24281
24281
|
return F("Refund is automatically handled by the relayer.");
|
|
24282
24282
|
}
|
|
24283
24283
|
}
|
|
24284
|
-
const Bw = "1.37.
|
|
24284
|
+
const Bw = "1.37.2", YP = "1.55.0", ZP = {
|
|
24285
24285
|
"-32700": "ParseError",
|
|
24286
24286
|
"-32701": "OversizedRequest",
|
|
24287
24287
|
"-32702": "OversizedResponse",
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-BDXehJkA.cjs");exports.API=e.API;exports.BitcoinNetwork=e.BitcoinNetwork;exports.BitcoinProvider=e.BitcoinProvider;exports.BitcoinWallet=e.BitcoinWallet;exports.BlockNumberFetcher=e.BlockNumberFetcher;exports.EvmRelay=e.EvmRelay;exports.Garden=e.Garden;exports.OrderActions=e.OrderActions;exports.OrderStatus=e.OrderStatus;exports.ParseOrderStatus=e.ParseOrderStatus;exports.ParseSwapStatus=e.ParseSwapStatus;exports.Quote=e.Quote;exports.STARKNET_CONFIG=e.STARKNET_CONFIG;exports.SecretManager=e.SecretManager;exports.SolanaHTLC=e.SolanaHTLC;exports.SolanaRelay=e.SolanaRelay;exports.SolanaRelayerAddress=e.SolanaRelayerAddress;exports.StarknetHTLC=e.StarknetHTLC;exports.StarknetRelay=e.StarknetRelay;exports.SwapStatus=e.SwapStatus;exports.botanix=e.botanixMainnet;exports.checkStarknetAlloance=e.checkAllowance;exports.checkStarknetAllowanceAndApprove=e.checkAllowanceAndApprove;exports.constructOrderPair=e.constructOrderPair;exports.evmToViemChainMap=e.evmToViemChainMap;exports.filterDeadlineExpiredOrders=e.filterDeadlineExpiredOrders;exports.hyperliquid=e.hyperliquid;exports.hyperliquidTestnet=e.hyperliquidTestnet;exports.isExpired=e.isExpired;exports.isOrderExpired=e.isOrderExpired;exports.isStarknetAllowanceSufficient=e.isAllowanceSufficient;exports.parseAction=e.parseAction;exports.parseActionFromStatus=e.parseActionFromStatus;exports.resolveApiConfig=e.resolveApiConfig;exports.solanaProgramAddress=e.solanaProgramAddress;exports.switchOrAddNetwork=e.switchOrAddNetwork;exports.toXOnly=e.toXOnly;exports.validateBTCAddress=e.validateBTCAddress;
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { U as e, N as r, R as t, T as i, m as n, E as o, G as d, O as l, n as c, P as S, q as A, Q as p, V as u, w as k, k as O, j as h, W as m, h as w, S as y, o as T, M as v, z as C, x as P, A as x, I as E, u as N, L as R, K as f, r as B, t as F, y as g, p as q, v as G, F as I, X as L, J as M, D as b, C as D } from "./index-
|
|
1
|
+
import { U as e, N as r, R as t, T as i, m as n, E as o, G as d, O as l, n as c, P as S, q as A, Q as p, V as u, w as k, k as O, j as h, W as m, h as w, S as y, o as T, M as v, z as C, x as P, A as x, I as E, u as N, L as R, K as f, r as B, t as F, y as g, p as q, v as G, F as I, X as L, J as M, D as b, C as D } from "./index-iqpfvx69.js";
|
|
2
2
|
export {
|
|
3
3
|
e as API,
|
|
4
4
|
r as BitcoinNetwork,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gardenfi/core",
|
|
3
|
-
"version": "2.4.6-beta.
|
|
3
|
+
"version": "2.4.6-beta.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "vite build",
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@coral-xyz/anchor": "^0.31.1",
|
|
31
|
-
"@gardenfi/orderbook": "2.4.6-beta.
|
|
32
|
-
"@gardenfi/utils": "2.4.6
|
|
31
|
+
"@gardenfi/orderbook": "2.4.6-beta.4",
|
|
32
|
+
"@gardenfi/utils": "2.4.6",
|
|
33
33
|
"@mysten/signers": "^0.3.4",
|
|
34
34
|
"@mysten/sui": "^1.37.1",
|
|
35
35
|
"@mysten/wallet-standard": "^0.16.9",
|