@gardenfi/core 3.0.3 → 3.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{ccip-7c-UACTE.cjs → ccip-CDLid_2f.cjs} +1 -1
- package/dist/{ccip-DLgqhLjs.js → ccip-DJsqgvYa.js} +1 -1
- package/dist/{index-C_LKWqCF.js → index-DnqAlC96.js} +4 -4
- package/dist/{index-BjIPz_mR.cjs → index-Dr2UWku_.cjs} +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/package.json +2 -2
|
@@ -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-Dr2UWku_.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,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-DnqAlC96.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;
|
|
@@ -5370,7 +5370,7 @@ async function cu(t, e) {
|
|
|
5370
5370
|
});
|
|
5371
5371
|
return ne === "0x" ? { data: void 0 } : { data: ne };
|
|
5372
5372
|
} catch (te) {
|
|
5373
|
-
const G = j8(te), { offchainLookup: I, offchainLookupSignature: j } = await import("./ccip-
|
|
5373
|
+
const G = j8(te), { offchainLookup: I, offchainLookupSignature: j } = await import("./ccip-DJsqgvYa.js");
|
|
5374
5374
|
if (t.ccipRead !== !1 && (G == null ? void 0 : G.slice(0, 10)) === j && g)
|
|
5375
5375
|
return { data: await I(t, { data: G, to: g }) };
|
|
5376
5376
|
throw M && (G == null ? void 0 : G.slice(0, 10)) === "0x101bb98d" ? new wE({ factory: p }) : xg(te, {
|
|
@@ -20010,7 +20010,7 @@ const rI = /* @__PURE__ */ wt({
|
|
|
20010
20010
|
}
|
|
20011
20011
|
}
|
|
20012
20012
|
}, gI = {
|
|
20013
|
-
id:
|
|
20013
|
+
id: 8150,
|
|
20014
20014
|
name: "Alpen Network",
|
|
20015
20015
|
nativeCurrency: {
|
|
20016
20016
|
name: "Signet bitcoin",
|
|
@@ -20020,12 +20020,12 @@ const rI = /* @__PURE__ */ wt({
|
|
|
20020
20020
|
blockExplorers: {
|
|
20021
20021
|
default: {
|
|
20022
20022
|
name: "Alpen Explorer",
|
|
20023
|
-
url: "https://explorer.testnet.alpenlabs.io"
|
|
20023
|
+
url: "https://explorer.pectra-testnet.alpenlabs.io"
|
|
20024
20024
|
}
|
|
20025
20025
|
},
|
|
20026
20026
|
rpcUrls: {
|
|
20027
20027
|
default: {
|
|
20028
|
-
http: ["https://rpc.testnet.alpenlabs.io
|
|
20028
|
+
http: ["https://rpc.pectra-testnet.alpenlabs.io"]
|
|
20029
20029
|
}
|
|
20030
20030
|
}
|
|
20031
20031
|
}, wI = {
|
|
@@ -38,7 +38,7 @@ ${B5(d)}`),super(e.shortMessage,{cause:e,docsPath:n,metaMessages:[...e.metaMessa
|
|
|
38
38
|
`),{cause:e,metaMessages:["This error could arise when the account does not have enough funds to:"," - pay for the total gas fee,"," - pay for the value to send."," ","The cost of the transaction is calculated as `gas * gas fee + value`, where:"," - `gas` is the amount of gas needed for transaction to execute,"," - `gas fee` is the gas fee,"," - `value` is the amount of ether to send to the recipient."],name:"InsufficientFundsError"})}}Object.defineProperty(Fl,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/insufficient funds|exceeds transaction sender account balance/});class jl extends L{constructor({cause:e,gas:r}={}){super(`The amount of gas ${r?`(${r}) `:""}provided for the transaction exceeds the limit allowed for the block.`,{cause:e,name:"IntrinsicGasTooHighError"})}}Object.defineProperty(jl,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too high|gas limit reached/});class Ll extends L{constructor({cause:e,gas:r}={}){super(`The amount of gas ${r?`(${r}) `:""}provided for the transaction is too low.`,{cause:e,name:"IntrinsicGasTooLowError"})}}Object.defineProperty(Ll,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/intrinsic gas too low/});class Hl extends L{constructor({cause:e}){super("The transaction type is not supported for this chain.",{cause:e,name:"TransactionTypeNotSupportedError"})}}Object.defineProperty(Hl,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/transaction type not valid/});class Zo extends L{constructor({cause:e,maxPriorityFeePerGas:r,maxFeePerGas:n}={}){super([`The provided tip (\`maxPriorityFeePerGas\`${r?` = ${jt(r)} gwei`:""}) cannot be higher than the fee cap (\`maxFeePerGas\`${n?` = ${jt(n)} gwei`:""}).`].join(`
|
|
39
39
|
`),{cause:e,name:"TipAboveFeeCapError"})}}Object.defineProperty(Zo,"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 ba extends L{constructor({cause:e}){super(`An error occurred while executing: ${e==null?void 0:e.shortMessage}`,{cause:e,name:"UnknownNodeError"})}}function Dc(t,e){const r=(t.details||"").toLowerCase(),n=t instanceof L?t.walk(s=>(s==null?void 0:s.code)===mi.code):t;return n instanceof L?new mi({cause:t,message:n.details}):mi.nodeMessage.test(r)?new mi({cause:t,message:t.details}):js.nodeMessage.test(r)?new js({cause:t,maxFeePerGas:e==null?void 0:e.maxFeePerGas}):Rl.nodeMessage.test(r)?new Rl({cause:t,maxFeePerGas:e==null?void 0:e.maxFeePerGas}):Nl.nodeMessage.test(r)?new Nl({cause:t,nonce:e==null?void 0:e.nonce}):Ul.nodeMessage.test(r)?new Ul({cause:t,nonce:e==null?void 0:e.nonce}):Ml.nodeMessage.test(r)?new Ml({cause:t,nonce:e==null?void 0:e.nonce}):Fl.nodeMessage.test(r)?new Fl({cause:t}):jl.nodeMessage.test(r)?new jl({cause:t,gas:e==null?void 0:e.gas}):Ll.nodeMessage.test(r)?new Ll({cause:t,gas:e==null?void 0:e.gas}):Hl.nodeMessage.test(r)?new Hl({cause:t}):Zo.nodeMessage.test(r)?new Zo({cause:t,maxFeePerGas:e==null?void 0:e.maxFeePerGas,maxPriorityFeePerGas:e==null?void 0:e.maxPriorityFeePerGas}):new ba({cause:t})}function Y5(t,{docsPath:e,...r}){const n=(()=>{const s=Dc(t,r);return s instanceof ba?t:s})();return new Z5(n,{docsPath:e,...r})}function zc(t,{format:e}){if(!e)return{};const r={};function n(i){const o=Object.keys(i);for(const a of o)a in t&&(r[a]=t[a]),i[a]&&typeof i[a]=="object"&&!Array.isArray(i[a])&&n(i[a])}const s=e(t||{});return n(s),r}function Kd(t,e){return({exclude:r,format:n})=>({exclude:r,format:s=>{const i=e(s);if(r)for(const o of r)delete i[o];return{...i,...n(s)}},type:t})}const X5={legacy:"0x0",eip2930:"0x1",eip1559:"0x2",eip4844:"0x3",eip7702:"0x4"};function Vi(t){const e={};return typeof t.authorizationList<"u"&&(e.authorizationList=J5(t.authorizationList)),typeof t.accessList<"u"&&(e.accessList=t.accessList),typeof t.blobVersionedHashes<"u"&&(e.blobVersionedHashes=t.blobVersionedHashes),typeof t.blobs<"u"&&(typeof t.blobs[0]!="string"?e.blobs=t.blobs.map(r=>et(r)):e.blobs=t.blobs),typeof t.data<"u"&&(e.data=t.data),typeof t.from<"u"&&(e.from=t.from),typeof t.gas<"u"&&(e.gas=Z(t.gas)),typeof t.gasPrice<"u"&&(e.gasPrice=Z(t.gasPrice)),typeof t.maxFeePerBlobGas<"u"&&(e.maxFeePerBlobGas=Z(t.maxFeePerBlobGas)),typeof t.maxFeePerGas<"u"&&(e.maxFeePerGas=Z(t.maxFeePerGas)),typeof t.maxPriorityFeePerGas<"u"&&(e.maxPriorityFeePerGas=Z(t.maxPriorityFeePerGas)),typeof t.nonce<"u"&&(e.nonce=Z(t.nonce)),typeof t.to<"u"&&(e.to=t.to),typeof t.type<"u"&&(e.type=X5[t.type]),typeof t.value<"u"&&(e.value=Z(t.value)),e}function J5(t){return t.map(e=>({address:e.address,r:e.r?Z(BigInt(e.r)):e.r,s:e.s?Z(BigInt(e.s)):e.s,chainId:Z(e.chainId),nonce:Z(e.nonce),...typeof e.yParity<"u"?{yParity:Z(e.yParity)}:{},...typeof e.v<"u"&&typeof e.yParity>"u"?{v:Z(e.v)}:{}}))}function Np(t){if(!(!t||t.length===0))return t.reduce((e,{slot:r,value:n})=>{if(r.length!==66)throw new Ap({size:r.length,targetSize:66,type:"hex"});if(n.length!==66)throw new Ap({size:n.length,targetSize:66,type:"hex"});return e[r]=n,e},{})}function Q5(t){const{balance:e,nonce:r,state:n,stateDiff:s,code:i}=t,o={};if(i!==void 0&&(o.code=i),e!==void 0&&(o.balance=Z(e)),r!==void 0&&(o.nonce=Z(r)),n!==void 0&&(o.state=Np(n)),s!==void 0){if(o.state)throw new O5;o.stateDiff=Np(s)}return o}function Zd(t){if(!t)return;const e={};for(const{address:r,...n}of t){if(!at(r,{strict:!1}))throw new $t({address:r});if(e[r])throw new I5({address:r});e[r]=Q5(n)}return e}const Vc=2n**256n-1n;function Ys(t){const{account:e,gasPrice:r,maxFeePerGas:n,maxPriorityFeePerGas:s,to:i}=t,o=e?Ze(e):void 0;if(o&&!at(o.address))throw new $t({address:o.address});if(i&&!at(i))throw new $t({address:i});if(typeof r<"u"&&(typeof n<"u"||typeof s<"u"))throw new C5;if(n&&n>Vc)throw new js({maxFeePerGas:n});if(s&&n&&s>n)throw new Zo({maxFeePerGas:n,maxPriorityFeePerGas:s})}class eE extends L{constructor(){super("`baseFeeMultiplier` must be greater than 1.",{name:"BaseFeeScalarError"})}}class Yd extends L{constructor(){super("Chain does not support EIP-1559 fees.",{name:"Eip1559FeesNotSupportedError"})}}class tE extends L{constructor({maxPriorityFeePerGas:e}){super(`\`maxFeePerGas\` cannot be less than the \`maxPriorityFeePerGas\` (${jt(e)} gwei).`,{name:"MaxFeePerGasTooLowError"})}}class vb extends L{constructor({blockHash:e,blockNumber:r}){let n="Block";e&&(n=`Block at hash "${e}"`),r&&(n=`Block at number "${r}"`),super(`${n} could not be found.`,{name:"BlockNotFoundError"})}}const Eb={"0x0":"legacy","0x1":"eip2930","0x2":"eip1559","0x3":"eip4844","0x4":"eip7702"};function qc(t){const e={...t,blockHash:t.blockHash?t.blockHash:null,blockNumber:t.blockNumber?BigInt(t.blockNumber):null,chainId:t.chainId?lr(t.chainId):void 0,gas:t.gas?BigInt(t.gas):void 0,gasPrice:t.gasPrice?BigInt(t.gasPrice):void 0,maxFeePerBlobGas:t.maxFeePerBlobGas?BigInt(t.maxFeePerBlobGas):void 0,maxFeePerGas:t.maxFeePerGas?BigInt(t.maxFeePerGas):void 0,maxPriorityFeePerGas:t.maxPriorityFeePerGas?BigInt(t.maxPriorityFeePerGas):void 0,nonce:t.nonce?lr(t.nonce):void 0,to:t.to?t.to:null,transactionIndex:t.transactionIndex?Number(t.transactionIndex):null,type:t.type?Eb[t.type]:void 0,typeHex:t.type?t.type:void 0,value:t.value?BigInt(t.value):void 0,v:t.v?BigInt(t.v):void 0};return t.authorizationList&&(e.authorizationList=nE(t.authorizationList)),e.yParity=(()=>{if(t.yParity)return Number(t.yParity);if(typeof e.v=="bigint"){if(e.v===0n||e.v===27n)return 0;if(e.v===1n||e.v===28n)return 1;if(e.v>=35n)return e.v%2n===0n?1:0}})(),e.type==="legacy"&&(delete e.accessList,delete e.maxFeePerBlobGas,delete e.maxFeePerGas,delete e.maxPriorityFeePerGas,delete e.yParity),e.type==="eip2930"&&(delete e.maxFeePerBlobGas,delete e.maxFeePerGas,delete e.maxPriorityFeePerGas),e.type==="eip1559"&&delete e.maxFeePerBlobGas,e}const rE=Kd("transaction",qc);function nE(t){return t.map(e=>({address:e.address,chainId:Number(e.chainId),nonce:Number(e.nonce),r:e.r,s:e.s,yParity:Number(e.yParity)}))}function Xd(t){const e=(t.transactions??[]).map(r=>typeof r=="string"?r:qc(r));return{...t,baseFeePerGas:t.baseFeePerGas?BigInt(t.baseFeePerGas):null,blobGasUsed:t.blobGasUsed?BigInt(t.blobGasUsed):void 0,difficulty:t.difficulty?BigInt(t.difficulty):void 0,excessBlobGas:t.excessBlobGas?BigInt(t.excessBlobGas):void 0,gasLimit:t.gasLimit?BigInt(t.gasLimit):void 0,gasUsed:t.gasUsed?BigInt(t.gasUsed):void 0,hash:t.hash?t.hash:null,logsBloom:t.logsBloom?t.logsBloom:null,nonce:t.nonce?t.nonce:null,number:t.number?BigInt(t.number):null,size:t.size?BigInt(t.size):void 0,timestamp:t.timestamp?BigInt(t.timestamp):void 0,transactions:e,totalDifficulty:t.totalDifficulty?BigInt(t.totalDifficulty):null}}const sE=Kd("block",Xd);async function Zr(t,{blockHash:e,blockNumber:r,blockTag:n=t.experimental_blockTag??"latest",includeTransactions:s}={}){var u,f,l;const i=s??!1,o=r!==void 0?Z(r):void 0;let a=null;if(e?a=await t.request({method:"eth_getBlockByHash",params:[e,i]},{dedupe:!0}):a=await t.request({method:"eth_getBlockByNumber",params:[o||n,i]},{dedupe:!!o}),!a)throw new vb({blockHash:e,blockNumber:r});return(((l=(f=(u=t.chain)==null?void 0:u.formatters)==null?void 0:f.block)==null?void 0:l.format)||Xd)(a)}async function Jd(t){const e=await t.request({method:"eth_gasPrice"});return BigInt(e)}async function iE(t,e){return Ab(t,e)}async function Ab(t,e){var i,o;const{block:r,chain:n=t.chain,request:s}=e||{};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 u=r||await se(t,Zr,"getBlock")({}),f=await a({block:u,client:t,request:s});if(f===null)throw new Error;return f}if(typeof a<"u")return a;const c=await t.request({method:"eth_maxPriorityFeePerGas"});return ut(c)}catch{const[a,c]=await Promise.all([r?Promise.resolve(r):se(t,Zr,"getBlock")({}),se(t,Jd,"getGasPrice")({})]);if(typeof a.baseFeePerGas!="bigint")throw new Yd;const u=c-a.baseFeePerGas;return u<0n?0n:u}}async function oE(t,e){return Dl(t,e)}async function Dl(t,e){var p,d;const{block:r,chain:n=t.chain,request:s,type:i="eip1559"}=e||{},o=await(async()=>{var m,b;return typeof((m=n==null?void 0:n.fees)==null?void 0:m.baseFeeMultiplier)=="function"?n.fees.baseFeeMultiplier({block:r,client:t,request:s}):((b=n==null?void 0:n.fees)==null?void 0:b.baseFeeMultiplier)??1.2})();if(o<1)throw new eE;const c=10**(((p=o.toString().split(".")[1])==null?void 0:p.length)??0),u=m=>m*BigInt(Math.ceil(o*c))/BigInt(c),f=r||await se(t,Zr,"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:t,multiply:u,request:s,type:i});if(m!==null)return m}if(i==="eip1559"){if(typeof f.baseFeePerGas!="bigint")throw new Yd;const m=typeof(s==null?void 0:s.maxPriorityFeePerGas)=="bigint"?s.maxPriorityFeePerGas:await Ab(t,{block:f,chain:n,request:s}),b=u(f.baseFeePerGas);return{maxFeePerGas:(s==null?void 0:s.maxFeePerGas)??b+m,maxPriorityFeePerGas:m}}return{gasPrice:(s==null?void 0:s.gasPrice)??u(await se(t,Jd,"getGasPrice")({}))}}async function Qd(t,{address:e,blockTag:r="latest",blockNumber:n}){const s=await t.request({method:"eth_getTransactionCount",params:[e,typeof n=="bigint"?Z(n):r]},{dedupe:!!n});return lr(s)}function eh(t){const{kzg:e}=t,r=t.to??(typeof t.blobs[0]=="string"?"hex":"bytes"),n=typeof t.blobs[0]=="string"?t.blobs.map(i=>Jr(i)):t.blobs,s=[];for(const i of n)s.push(Uint8Array.from(e.blobToKzgCommitment(i)));return r==="bytes"?s:s.map(i=>et(i))}function th(t){const{kzg:e}=t,r=t.to??(typeof t.blobs[0]=="string"?"hex":"bytes"),n=typeof t.blobs[0]=="string"?t.blobs.map(o=>Jr(o)):t.blobs,s=typeof t.commitments[0]=="string"?t.commitments.map(o=>Jr(o)):t.commitments,i=[];for(let o=0;o<n.length;o++){const a=n[o],c=s[o];i.push(Uint8Array.from(e.computeBlobKzgProof(a,c)))}return r==="bytes"?i:i.map(o=>et(o))}function aE(t,e,r,n){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,r,n);const s=BigInt(32),i=BigInt(4294967295),o=Number(r>>s&i),a=Number(r&i),c=n?4:0,u=n?0:4;t.setUint32(e+c,o,n),t.setUint32(e+u,a,n)}function cE(t,e,r){return t&e^~t&r}function uE(t,e,r){return t&e^t&r^e&r}let Sb=class extends Nc{constructor(e,r,n,s){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=r,this.padOffset=n,this.isLE=s,this.buffer=new Uint8Array(e),this.view=Iu(this.buffer)}update(e){os(this),e=En(e),is(e);const{view:r,buffer:n,blockLen:s}=this,i=e.length;for(let o=0;o<i;){const a=Math.min(s-this.pos,i-o);if(a===s){const c=Iu(e);for(;s<=i-o;o+=s)this.process(c,o);continue}n.set(e.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===s&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){os(this),Md(e,this),this.finished=!0;const{buffer:r,view:n,blockLen:s,isLE:i}=this;let{pos:o}=this;r[o++]=128,Pr(this.buffer.subarray(o)),this.padOffset>s-o&&(this.process(n,0),o=0);for(let l=o;l<s;l++)r[l]=0;aE(n,s-8,BigInt(this.length*8),i),this.process(n,0);const a=Iu(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const u=c/4,f=this.get();if(u>f.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<u;l++)a.setUint32(4*l,f[l],i)}digest(){const{buffer:e,outputLen:r}=this;this.digestInto(e);const n=e.slice(0,r);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:r,buffer:n,length:s,finished:i,destroyed:o,pos:a}=this;return e.destroyed=o,e.finished=i,e.length=s,e.pos=a,s%r&&e.buffer.set(n),e}clone(){return this._cloneInto()}};const Un=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Mn=Uint32Array.from([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]),fE=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]),Fn=new Uint32Array(64);let rh=class extends Sb{constructor(e=32){super(64,e,8,!1),this.A=Un[0]|0,this.B=Un[1]|0,this.C=Un[2]|0,this.D=Un[3]|0,this.E=Un[4]|0,this.F=Un[5]|0,this.G=Un[6]|0,this.H=Un[7]|0}get(){const{A:e,B:r,C:n,D:s,E:i,F:o,G:a,H:c}=this;return[e,r,n,s,i,o,a,c]}set(e,r,n,s,i,o,a,c){this.A=e|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(e,r){for(let l=0;l<16;l++,r+=4)Fn[l]=e.getUint32(r,!1);for(let l=16;l<64;l++){const p=Fn[l-15],d=Fn[l-2],m=Ur(p,7)^Ur(p,18)^p>>>3,b=Ur(d,17)^Ur(d,19)^d>>>10;Fn[l]=b+Fn[l-7]+m+Fn[l-16]|0}let{A:n,B:s,C:i,D:o,E:a,F:c,G:u,H:f}=this;for(let l=0;l<64;l++){const p=Ur(a,6)^Ur(a,11)^Ur(a,25),d=f+p+cE(a,c,u)+fE[l]+Fn[l]|0,b=(Ur(n,2)^Ur(n,13)^Ur(n,22))+uE(n,s,i)|0;f=u,u=c,c=a,a=o+d|0,o=i,i=s,s=n,n=d+b|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,u=u+this.G|0,f=f+this.H|0,this.set(n,s,i,o,a,c,u,f)}roundClean(){Pr(Fn)}destroy(){this.set(0,0,0,0,0,0,0,0),Pr(this.buffer)}},xb=class extends rh{constructor(){super(28),this.A=Mn[0]|0,this.B=Mn[1]|0,this.C=Mn[2]|0,this.D=Mn[3]|0,this.E=Mn[4]|0,this.F=Mn[5]|0,this.G=Mn[6]|0,this.H=Mn[7]|0}};const kb=Uc(()=>new rh),lE=Uc(()=>new xb),dE=rh,Tb=kb,hE=xb,pE=lE,yE=Object.freeze(Object.defineProperty({__proto__:null,SHA224:hE,SHA256:dE,sha224:pE,sha256:Tb},Symbol.toStringTag,{value:"Module"}));function ho(t,e){const r=e||"hex",n=Tb(_r(t,{strict:!1})?zi(t):t);return r==="bytes"?n:Bt(n)}function mE(t){const{commitment:e,version:r=1}=t,n=t.to??(typeof e=="string"?"hex":"bytes"),s=ho(e,"bytes");return s.set([r],0),n==="bytes"?s:et(s)}function _b(t){const{commitments:e,version:r}=t,n=t.to??(typeof e[0]=="string"?"hex":"bytes"),s=[];for(const i of e)s.push(mE({commitment:i,to:n,version:r}));return s}const Up=6,Pb=32,nh=4096,Ib=Pb*nh,Mp=Ib*Up-1-1*nh*Up,Ob=1;class bE extends L{constructor({maxSize:e,size:r}){super("Blob size is too large.",{metaMessages:[`Max: ${e} bytes`,`Given: ${r} bytes`],name:"BlobSizeTooLargeError"})}}class Bb extends L{constructor(){super("Blob data must not be empty.",{name:"EmptyBlobError"})}}class gE extends L{constructor({hash:e,size:r}){super(`Versioned hash "${e}" size is invalid.`,{metaMessages:["Expected: 32",`Received: ${r}`],name:"InvalidVersionedHashSizeError"})}}class wE extends L{constructor({hash:e,version:r}){super(`Versioned hash "${e}" version is invalid.`,{metaMessages:[`Expected: ${Ob}`,`Received: ${r}`],name:"InvalidVersionedHashVersionError"})}}function vE(t){const e=t.to??(typeof t.data=="string"?"hex":"bytes"),r=typeof t.data=="string"?Jr(t.data):t.data,n=De(r);if(!n)throw new Bb;if(n>Mp)throw new bE({maxSize:Mp,size:n});const s=[];let i=!0,o=0;for(;i;){const a=Vd(new Uint8Array(Ib));let c=0;for(;c<nh;){const u=r.slice(o,o+(Pb-1));if(a.pushByte(0),a.pushBytes(u),u.length<31){a.pushByte(128),i=!1;break}c++,o+=31}s.push(a)}return e==="bytes"?s.map(a=>a.bytes):s.map(a=>et(a.bytes))}function Cb(t){const{data:e,kzg:r,to:n}=t,s=t.blobs??vE({data:e,to:n}),i=t.commitments??eh({blobs:s,kzg:r,to:n}),o=t.proofs??th({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 $b(t){if(t.type)return t.type;if(typeof t.authorizationList<"u")return"eip7702";if(typeof t.blobs<"u"||typeof t.blobVersionedHashes<"u"||typeof t.maxFeePerBlobGas<"u"||typeof t.sidecars<"u")return"eip4844";if(typeof t.maxFeePerGas<"u"||typeof t.maxPriorityFeePerGas<"u")return"eip1559";if(typeof t.gasPrice<"u")return typeof t.accessList<"u"?"eip2930":"legacy";throw new R5({transaction:t})}async function qi(t){const e=await t.request({method:"eth_chainId"},{dedupe:!0});return lr(e)}const Rb=["blobVersionedHashes","chainId","fees","gas","nonce","type"],Fp=new Map;async function Gc(t,e){const{account:r=t.account,blobs:n,chain:s,gas:i,kzg:o,nonce:a,nonceManager:c,parameters:u=Rb,type:f}=e,l=r&&Ze(r),p={...e,...l?{from:l==null?void 0:l.address}:{}};let d;async function m(){return d||(d=await se(t,Zr,"getBlock")({blockTag:"latest"}),d)}let b;async function E(){return b||(s?s.id:typeof e.chainId<"u"?e.chainId:(b=await se(t,qi,"getChainId")({}),b))}if(u.includes("nonce")&&typeof a>"u"&&l)if(c){const S=await E();p.nonce=await c.consume({address:l.address,chainId:S,client:t})}else p.nonce=await se(t,Qd,"getTransactionCount")({address:l.address,blockTag:"pending"});if((u.includes("blobVersionedHashes")||u.includes("sidecars"))&&n&&o){const S=eh({blobs:n,kzg:o});if(u.includes("blobVersionedHashes")){const P=_b({commitments:S,to:"hex"});p.blobVersionedHashes=P}if(u.includes("sidecars")){const P=th({blobs:n,commitments:S,kzg:o}),A=Cb({blobs:n,commitments:S,proofs:P,to:"hex"});p.sidecars=A}}if(u.includes("chainId")&&(p.chainId=await E()),(u.includes("fees")||u.includes("type"))&&typeof f>"u")try{p.type=$b(p)}catch{let S=Fp.get(t.uid);if(typeof S>"u"){const P=await m();S=typeof(P==null?void 0:P.baseFeePerGas)=="bigint",Fp.set(t.uid,S)}p.type=S?"eip1559":"legacy"}if(u.includes("fees"))if(p.type!=="legacy"&&p.type!=="eip2930"){if(typeof p.maxFeePerGas>"u"||typeof p.maxPriorityFeePerGas>"u"){const S=await m(),{maxFeePerGas:P,maxPriorityFeePerGas:A}=await Dl(t,{block:S,chain:s,request:p});if(typeof e.maxPriorityFeePerGas>"u"&&e.maxFeePerGas&&e.maxFeePerGas<A)throw new tE({maxPriorityFeePerGas:A});p.maxPriorityFeePerGas=A,p.maxFeePerGas=P}}else{if(typeof e.maxFeePerGas<"u"||typeof e.maxPriorityFeePerGas<"u")throw new Yd;if(typeof e.gasPrice>"u"){const S=await m(),{gasPrice:P}=await Dl(t,{block:S,chain:s,request:p,type:"legacy"});p.gasPrice=P}}return u.includes("gas")&&typeof i>"u"&&(p.gas=await se(t,sh,"estimateGas")({...p,account:l&&{address:l.address,type:"json-rpc"}})),Ys(p),delete p.parameters,p}async function sh(t,e){var s,i,o;const{account:r=t.account}=e,n=r?Ze(r):void 0;try{const{accessList:a,authorizationList:c,blobs:u,blobVersionedHashes:f,blockNumber:l,blockTag:p,data:d,gas:m,gasPrice:b,maxFeePerBlobGas:E,maxFeePerGas:S,maxPriorityFeePerGas:P,nonce:A,value:w,stateOverride:k,...T}=await Gc(t,{...e,parameters:(n==null?void 0:n.type)==="local"?void 0:["blobVersionedHashes"]}),N=(typeof l=="bigint"?Z(l):void 0)||p,$=Zd(k),H=await(async()=>{if(T.to)return T.to;if(c&&c.length>0)return await Wd({authorization:c[0]}).catch(()=>{throw new L("`to` is required. Could not infer from `authorizationList`")})})();Ys(e);const M=(o=(i=(s=t.chain)==null?void 0:s.formatters)==null?void 0:i.transactionRequest)==null?void 0:o.format,G=(M||Vi)({...zc(T,{format:M}),from:n==null?void 0:n.address,accessList:a,authorizationList:c,blobs:u,blobVersionedHashes:f,data:d,gas:m,gasPrice:b,maxFeePerBlobGas:E,maxFeePerGas:S,maxPriorityFeePerGas:P,nonce:A,to:H,value:w});return BigInt(await t.request({method:"eth_estimateGas",params:$?[G,N??t.experimental_blockTag??"latest",$]:N?[G,N]:[G]}))}catch(a){throw Y5(a,{...e,account:n,chain:t.chain})}}async function Nb(t,e){const{abi:r,address:n,args:s,functionName:i,dataSuffix:o,...a}=e,c=Xt({abi:r,args:s,functionName:i});try{return await se(t,sh,"estimateGas")({data:`${c}${o?o.replace("0x",""):""}`,to:n,...a})}catch(u){const f=a.account?Ze(a.account):void 0;throw Fs(u,{abi:r,address:n,args:s,docsPath:"/docs/contract/estimateContractGas",functionName:i,sender:f==null?void 0:f.address})}}function Gi(t,e){if(!at(t,{strict:!1}))throw new $t({address:t});if(!at(e,{strict:!1}))throw new $t({address:e});return t.toLowerCase()===e.toLowerCase()}const jp="/docs/contract/decodeEventLog";function ih(t){const{abi:e,data:r,strict:n,topics:s}=t,i=n??!0,[o,...a]=s;if(!o)throw new cv({docsPath:jp});const c=e.find(b=>b.type==="event"&&o===Mc(Tr(b)));if(!(c&&"name"in c)||c.type!=="event")throw new Um(o,{docsPath:jp});const{name:u,inputs:f}=c,l=f==null?void 0:f.some(b=>!("name"in b&&b.name)),p=l?[]:{},d=f.map((b,E)=>[b,E]).filter(([b])=>"indexed"in b&&b.indexed);for(let b=0;b<d.length;b++){const[E,S]=d[b],P=a[b];if(!P)throw new Rc({abiItem:c,param:E});p[l?S:E.name||S]=EE({param:E,value:P})}const m=f.filter(b=>!("indexed"in b&&b.indexed));if(m.length>0){if(r&&r!=="0x")try{const b=ya(m,r);if(b)if(l)for(let E=0;E<f.length;E++)p[E]=p[E]??b.shift();else for(let E=0;E<m.length;E++)p[m[E].name]=b[E]}catch(b){if(i)throw b instanceof Rm||b instanceof ub?new Po({abiItem:c,data:r,params:m,size:De(r)}):b}else if(i)throw new Po({abiItem:c,data:"0x",params:m,size:0})}return{eventName:u,args:Object.values(p).length>0?p:void 0}}function EE({param:t,value:e}){return t.type==="string"||t.type==="bytes"||t.type==="tuple"||t.type.match(/^(.*)\[(\d+)?\]$/)?e:(ya([t],e)||[])[0]}function oh(t){const{abi:e,args:r,logs:n,strict:s=!0}=t,i=(()=>{if(t.eventName)return Array.isArray(t.eventName)?t.eventName:[t.eventName]})();return n.map(o=>{var a;try{const c=e.find(f=>f.type==="event"&&o.topics[0]===Mc(f));if(!c)return null;const u=ih({...o,abi:[c],strict:s});return i&&!i.includes(u.eventName)||!AE({args:u.args,inputs:c.inputs,matchArgs:r})?null:{...u,...o}}catch(c){let u,f;if(c instanceof Um)return null;if(c instanceof Po||c instanceof Rc){if(s)return null;u=c.abiItem.name,f=(a=c.abiItem.inputs)==null?void 0:a.some(l=>!("name"in l&&l.name))}return{...o,args:f?[]:{},eventName:u}}}).filter(Boolean)}function AE(t){const{args:e,inputs:r,matchArgs:n}=t;if(!n)return!0;if(!e)return!1;function s(i,o,a){try{return i.type==="address"?Gi(o,a):i.type==="string"||i.type==="bytes"?ht(zi(o))===a:o===a}catch{return!1}}return Array.isArray(e)&&Array.isArray(n)?n.every((i,o)=>{if(i==null)return!0;const a=r[o];return a?(Array.isArray(i)?i:[i]).some(u=>s(a,u,e[o])):!1}):typeof e=="object"&&!Array.isArray(e)&&typeof n=="object"&&!Array.isArray(n)?Object.entries(n).every(([i,o])=>{if(o==null)return!0;const a=r.find(u=>u.name===i);return a?(Array.isArray(o)?o:[o]).some(u=>s(a,u,e[i])):!1}):!1}function kn(t,{args:e,eventName:r}={}){return{...t,blockHash:t.blockHash?t.blockHash:null,blockNumber:t.blockNumber?BigInt(t.blockNumber):null,logIndex:t.logIndex?Number(t.logIndex):null,transactionHash:t.transactionHash?t.transactionHash:null,transactionIndex:t.transactionIndex?Number(t.transactionIndex):null,...r?{args:e,eventName:r}:{}}}async function ah(t,{address:e,blockHash:r,fromBlock:n,toBlock:s,event:i,events:o,args:a,strict:c}={}){const u=c??!1,f=o??(i?[i]:void 0);let l=[];f&&(l=[f.flatMap(b=>pa({abi:[b],eventName:b.name,args:o?void 0:a}))],i&&(l=l[0]));let p;r?p=await t.request({method:"eth_getLogs",params:[{address:e,topics:l,blockHash:r}]}):p=await t.request({method:"eth_getLogs",params:[{address:e,topics:l,fromBlock:typeof n=="bigint"?Z(n):n,toBlock:typeof s=="bigint"?Z(s):s}]});const d=p.map(m=>kn(m));return f?oh({abi:f,args:a,logs:d,strict:u}):d}async function ch(t,e){const{abi:r,address:n,args:s,blockHash:i,eventName:o,fromBlock:a,toBlock:c,strict:u}=e,f=o?Zs({abi:r,name:o}):void 0,l=f?void 0:r.filter(p=>p.type==="event");return se(t,ah,"getLogs")({address:n,args:s,blockHash:i,event:f,events:l,fromBlock:a,toBlock:c,strict:u})}const Cu="/docs/contract/decodeFunctionResult";function Xs(t){const{abi:e,args:r,functionName:n,data:s}=t;let i=e[0];if(n){const a=Zs({abi:e,args:r,name:n});if(!a)throw new Oi(n,{docsPath:Cu});i=a}if(i.type!=="function")throw new Oi(void 0,{docsPath:Cu});if(!i.outputs)throw new Mm(i.name,{docsPath:Cu});const o=ya(i.outputs,s);if(o&&o.length>1)return o;if(o&&o.length===1)return o[0]}const SE="0.1.1";function xE(){return SE}let ve=class zl extends Error{constructor(e,r={}){const n=(()=>{var c;if(r.cause instanceof zl){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 zl&&r.cause.docsPath||r.docsPath,o=`https://oxlib.sh${s??""}`,a=[e||"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@${xE()}`}),this.cause=r.cause,this.details=n,this.docs=o,this.docsPath=s,this.shortMessage=e}walk(e){return Ub(this,e)}};function Ub(t,e){return e!=null&&e(t)?t:t&&typeof t=="object"&&"cause"in t&&t.cause?Ub(t.cause,e):e?null:t}function ga(t,e){if(bi(t)>e)throw new HE({givenSize:bi(t),maxSize:e})}const rn={zero:48,nine:57,A:65,F:70,a:97,f:102};function Lp(t){if(t>=rn.zero&&t<=rn.nine)return t-rn.zero;if(t>=rn.A&&t<=rn.F)return t-(rn.A-10);if(t>=rn.a&&t<=rn.f)return t-(rn.a-10)}function kE(t,e={}){const{dir:r,size:n=32}=e;if(n===0)return t;if(t.length>n)throw new DE({size:t.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]=t[o?i:t.length-i-1]}return s}function Mb(t,e={}){const{dir:r="left"}=e;let n=t,s=0;for(let i=0;i<n.length-1&&n[r==="left"?i:n.length-i-1].toString()==="0";i++)s++;return n=r==="left"?n.slice(s):n.slice(0,n.length-s),n}function Wc(t,e){if(Kt(t)>e)throw new KE({givenSize:Kt(t),maxSize:e})}function TE(t,e){if(typeof e=="number"&&e>0&&e>Kt(t)-1)throw new Gb({offset:e,position:"start",size:Kt(t)})}function _E(t,e,r){if(typeof e=="number"&&typeof r=="number"&&Kt(t)!==r-e)throw new Gb({offset:r,position:"end",size:Kt(t)})}function Fb(t,e={}){const{dir:r,size:n=32}=e;if(n===0)return t;const s=t.replace("0x","");if(s.length>n*2)throw new ZE({size:Math.ceil(s.length/2),targetSize:n,type:"Hex"});return`0x${s[r==="right"?"padEnd":"padStart"](n*2,"0")}`}const PE="#__bigint";function jb(t,e,r){return JSON.stringify(t,(n,s)=>typeof s=="bigint"?s.toString()+PE:s,r)}const IE=new TextDecoder,OE=new TextEncoder;function BE(t){return t instanceof Uint8Array?t:typeof t=="string"?Lb(t):CE(t)}function CE(t){return t instanceof Uint8Array?t:new Uint8Array(t)}function Lb(t,e={}){const{size:r}=e;let n=t;r&&(Wc(t,r),n=Hs(t,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 u=Lp(s.charCodeAt(c++)),f=Lp(s.charCodeAt(c++));if(u===void 0||f===void 0)throw new ve(`Invalid byte sequence ("${s[c-2]}${s[c-1]}" in "${s}").`);o[a]=u*16+f}return o}function $E(t,e={}){const{size:r}=e,n=OE.encode(t);return typeof r=="number"?(ga(n,r),RE(n,r)):n}function RE(t,e){return kE(t,{dir:"right",size:e})}function bi(t){return t.length}function NE(t,e,r,n={}){const{strict:s}=n;return t.slice(e,r)}function UE(t,e={}){const{size:r}=e;typeof r<"u"&&ga(t,r);const n=Or(t,e);return zb(n,e)}function ME(t,e={}){const{size:r}=e;let n=t;if(typeof r<"u"&&(ga(n,r),n=Hb(n)),n.length>1||n[0]>1)throw new LE(n);return!!n[0]}function Sn(t,e={}){const{size:r}=e;typeof r<"u"&&ga(t,r);const n=Or(t,e);return Vb(n,e)}function FE(t,e={}){const{size:r}=e;let n=t;return typeof r<"u"&&(ga(n,r),n=jE(n)),IE.decode(n)}function Hb(t){return Mb(t,{dir:"left"})}function jE(t){return Mb(t,{dir:"right"})}class LE extends ve{constructor(e){super(`Bytes value \`${e}\` is not a valid boolean.`,{metaMessages:["The bytes array must contain a single byte of either a `0` or `1` value."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.InvalidBytesBooleanError"})}}let HE=class extends ve{constructor({givenSize:e,maxSize:r}){super(`Size cannot exceed \`${r}\` bytes. Given size: \`${e}\` bytes.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.SizeOverflowError"})}},DE=class extends ve{constructor({size:e,targetSize:r,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (\`${e}\`) exceeds padding size (\`${r}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.SizeExceedsPaddingSizeError"})}};const zE=new TextEncoder,VE=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function qE(t,e={}){const{strict:r=!1}=e;if(!t)throw new Hp(t);if(typeof t!="string")throw new Hp(t);if(r&&!/^0x[0-9a-fA-F]*$/.test(t))throw new Dp(t);if(!t.startsWith("0x"))throw new Dp(t)}function Ir(...t){return`0x${t.reduce((e,r)=>e+r.replace("0x",""),"")}`}function GE(t){return t instanceof Uint8Array?Or(t):Array.isArray(t)?Or(new Uint8Array(t)):t}function Db(t,e={}){const r=`0x${Number(t)}`;return typeof e.size=="number"?(Wc(r,e.size),Ls(r,e.size)):r}function Or(t,e={}){let r="";for(let s=0;s<t.length;s++)r+=VE[t[s]];const n=`0x${r}`;return typeof e.size=="number"?(Wc(n,e.size),Hs(n,e.size)):n}function It(t,e={}){const{signed:r,size:n}=e,s=BigInt(t);let i;n?r?i=(1n<<BigInt(n)*8n-1n)-1n:i=2n**(BigInt(n)*8n)-1n:typeof t=="number"&&(i=BigInt(Number.MAX_SAFE_INTEGER));const o=typeof i=="bigint"&&r?-i-1n:0;if(i&&s>i||s<o){const u=typeof t=="bigint"?"n":"";throw new qb({max:i?`${i}${u}`:void 0,min:`${o}${u}`,signed:r,size:n,value:`${t}${u}`})}const c=`0x${(r&&s<0?(1n<<BigInt(n*8))+BigInt(s):s).toString(16)}`;return n?Ls(c,n):c}function uh(t,e={}){return Or(zE.encode(t),e)}function Ls(t,e){return Fb(t,{dir:"left",size:e})}function Hs(t,e){return Fb(t,{dir:"right",size:e})}function Yr(t,e,r,n={}){const{strict:s}=n;TE(t,e);const i=`0x${t.replace("0x","").slice((e??0)*2,(r??t.length)*2)}`;return s&&_E(i,e,r),i}function Kt(t){return Math.ceil((t.length-2)/2)}function zb(t,e={}){const{signed:r}=e;e.size&&Wc(t,e.size);const n=BigInt(t);if(!r)return n;const s=(t.length-2)/2,i=(1n<<BigInt(s)*8n)-1n,o=i>>1n;return n<=o?n:n-i-1n}function Vb(t,e={}){const{signed:r,size:n}=e;return Number(!r&&!n?t:zb(t,e))}function WE(t,e={}){const{strict:r=!1}=e;try{return qE(t,{strict:r}),!0}catch{return!1}}class qb extends ve{constructor({max:e,min:r,signed:n,size:s,value:i}){super(`Number \`${i}\` is not in safe${s?` ${s*8}-bit`:""}${n?" signed":" unsigned"} integer range ${e?`(\`${r}\` to \`${e}\`)`:`(above \`${r}\`)`}`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.IntegerOutOfRangeError"})}}class Hp extends ve{constructor(e){super(`Value \`${typeof e=="object"?jb(e):e}\` of type \`${typeof e}\` is an invalid hex type.`,{metaMessages:['Hex types must be represented as `"0x${string}"`.']}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.InvalidHexTypeError"})}}class Dp extends ve{constructor(e){super(`Value \`${e}\` is an invalid hex value.`,{metaMessages:['Hex values must start with `"0x"` and contain only hexadecimal characters (0-9, a-f, A-F).']}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.InvalidHexValueError"})}}class KE extends ve{constructor({givenSize:e,maxSize:r}){super(`Size cannot exceed \`${r}\` bytes. Given size: \`${e}\` bytes.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SizeOverflowError"})}}class Gb extends ve{constructor({offset:e,position:r,size:n}){super(`Slice ${r==="start"?"starting":"ending"} at offset \`${e}\` is out-of-bounds (size: \`${n}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SliceOffsetOutOfBoundsError"})}}class ZE extends ve{constructor({size:e,targetSize:r,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (\`${e}\`) exceeds padding size (\`${r}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SizeExceedsPaddingSizeError"})}}function YE(t){return{address:t.address,amount:It(t.amount),index:It(t.index),validatorIndex:It(t.validatorIndex)}}function Wb(t){return{...typeof t.baseFeePerGas=="bigint"&&{baseFeePerGas:It(t.baseFeePerGas)},...typeof t.blobBaseFee=="bigint"&&{blobBaseFee:It(t.blobBaseFee)},...typeof t.feeRecipient=="string"&&{feeRecipient:t.feeRecipient},...typeof t.gasLimit=="bigint"&&{gasLimit:It(t.gasLimit)},...typeof t.number=="bigint"&&{number:It(t.number)},...typeof t.prevRandao=="bigint"&&{prevRandao:It(t.prevRandao)},...typeof t.time=="bigint"&&{time:It(t.time)},...t.withdrawals&&{withdrawals:t.withdrawals.map(YE)}}}const gc=[{inputs:[{components:[{name:"target",type:"address"},{name:"allowFailure",type:"bool"},{name:"callData",type:"bytes"}],name:"calls",type:"tuple[]"}],name:"aggregate3",outputs:[{components:[{name:"success",type:"bool"},{name:"returnData",type:"bytes"}],name:"returnData",type:"tuple[]"}],stateMutability:"view",type:"function"},{inputs:[],name:"getCurrentBlockTimestamp",outputs:[{internalType:"uint256",name:"timestamp",type:"uint256"}],stateMutability:"view",type:"function"}],Vl=[{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"}]}],Kb=[{inputs:[{name:"dns",type:"bytes"}],name:"DNSDecodingFailed",type:"error"},{inputs:[{name:"ens",type:"string"}],name:"DNSEncodingFailed",type:"error"},{inputs:[],name:"EmptyAddress",type:"error"},{inputs:[{name:"status",type:"uint16"},{name:"message",type:"string"}],name:"HttpError",type:"error"},{inputs:[],name:"InvalidBatchGatewayResponse",type:"error"},{inputs:[{name:"errorData",type:"bytes"}],name:"ResolverError",type:"error"},{inputs:[{name:"name",type:"bytes"},{name:"resolver",type:"address"}],name:"ResolverNotContract",type:"error"},{inputs:[{name:"name",type:"bytes"}],name:"ResolverNotFound",type:"error"},{inputs:[{name:"primary",type:"string"},{name:"primaryAddress",type:"bytes"}],name:"ReverseAddressMismatch",type:"error"},{inputs:[{internalType:"bytes4",name:"selector",type:"bytes4"}],name:"UnsupportedResolverProfile",type:"error"}],Zb=[...Kb,{name:"resolveWithGateways",type:"function",stateMutability:"view",inputs:[{name:"name",type:"bytes"},{name:"data",type:"bytes"},{name:"gateways",type:"string[]"}],outputs:[{name:"",type:"bytes"},{name:"address",type:"address"}]}],XE=[...Kb,{name:"reverseWithGateways",type:"function",stateMutability:"view",inputs:[{type:"bytes",name:"reverseName"},{type:"uint256",name:"coinType"},{type:"string[]",name:"gateways"}],outputs:[{type:"string",name:"resolvedName"},{type:"address",name:"resolver"},{type:"address",name:"reverseResolver"}]}],zp=[{name:"text",type:"function",stateMutability:"view",inputs:[{name:"name",type:"bytes32"},{name:"key",type:"string"}],outputs:[{name:"",type:"string"}]}],Vp=[{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"}]}],Yb=[{name:"isValidSignature",type:"function",stateMutability:"view",inputs:[{name:"hash",type:"bytes32"},{name:"signature",type:"bytes"}],outputs:[{name:"",type:"bytes4"}]}],qp=[{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"}],JE="0x82ad56cb",Xb="0x608060405234801561001057600080fd5b5060405161018e38038061018e83398101604081905261002f91610124565b6000808351602085016000f59050803b61004857600080fd5b6000808351602085016000855af16040513d6000823e81610067573d81fd5b3d81f35b634e487b7160e01b600052604160045260246000fd5b600082601f83011261009257600080fd5b81516001600160401b038111156100ab576100ab61006b565b604051601f8201601f19908116603f011681016001600160401b03811182821017156100d9576100d961006b565b6040528181528382016020018510156100f157600080fd5b60005b82811015610110576020818601810151838301820152016100f4565b506000918101602001919091529392505050565b6000806040838503121561013757600080fd5b82516001600160401b0381111561014d57600080fd5b61015985828601610081565b602085015190935090506001600160401b0381111561017757600080fd5b61018385828601610081565b915050925092905056fe",QE="0x608060405234801561001057600080fd5b506040516102c03803806102c083398101604081905261002f916101e6565b836001600160a01b03163b6000036100e457600080836001600160a01b03168360405161005c9190610270565b6000604051808303816000865af19150503d8060008114610099576040519150601f19603f3d011682016040523d82523d6000602084013e61009e565b606091505b50915091508115806100b857506001600160a01b0386163b155b156100e1578060405163101bb98d60e01b81526004016100d8919061028c565b60405180910390fd5b50505b6000808451602086016000885af16040513d6000823e81610103573d81fd5b3d81f35b80516001600160a01b038116811461011e57600080fd5b919050565b634e487b7160e01b600052604160045260246000fd5b60005b8381101561015457818101518382015260200161013c565b50506000910152565b600082601f83011261016e57600080fd5b81516001600160401b0381111561018757610187610123565b604051601f8201601f19908116603f011681016001600160401b03811182821017156101b5576101b5610123565b6040528181528382016020018510156101cd57600080fd5b6101de826020830160208701610139565b949350505050565b600080600080608085870312156101fc57600080fd5b61020585610107565b60208601519094506001600160401b0381111561022157600080fd5b61022d8782880161015d565b93505061023c60408601610107565b60608601519092506001600160401b0381111561025857600080fd5b6102648782880161015d565b91505092959194509250565b60008251610282818460208701610139565b9190910192915050565b60208152600082518060208401526102ab816040850160208701610139565b601f01601f1916919091016040019291505056fe",eA="0x608060405234801561001057600080fd5b5060405161069438038061069483398101604081905261002f9161051e565b600061003c848484610048565b9050806000526001601ff35b60007f64926492649264926492649264926492649264926492649264926492649264926100748361040c565b036101e7576000606080848060200190518101906100929190610577565b60405192955090935091506000906001600160a01b038516906100b69085906105dd565b6000604051808303816000865af19150503d80600081146100f3576040519150601f19603f3d011682016040523d82523d6000602084013e6100f8565b606091505b50509050876001600160a01b03163b60000361016057806101605760405162461bcd60e51b815260206004820152601e60248201527f5369676e617475726556616c696461746f723a206465706c6f796d656e74000060448201526064015b60405180910390fd5b604051630b135d3f60e11b808252906001600160a01b038a1690631626ba7e90610190908b9087906004016105f9565b602060405180830381865afa1580156101ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101d19190610633565b6001600160e01b03191614945050505050610405565b6001600160a01b0384163b1561027a57604051630b135d3f60e11b808252906001600160a01b03861690631626ba7e9061022790879087906004016105f9565b602060405180830381865afa158015610244573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102689190610633565b6001600160e01b031916149050610405565b81516041146102df5760405162461bcd60e51b815260206004820152603a602482015260008051602061067483398151915260448201527f3a20696e76616c6964207369676e6174757265206c656e6774680000000000006064820152608401610157565b6102e7610425565b5060208201516040808401518451859392600091859190811061030c5761030c61065d565b016020015160f81c9050601b811480159061032b57508060ff16601c14155b1561038c5760405162461bcd60e51b815260206004820152603b602482015260008051602061067483398151915260448201527f3a20696e76616c6964207369676e617475726520762076616c756500000000006064820152608401610157565b60408051600081526020810180835289905260ff83169181019190915260608101849052608081018390526001600160a01b0389169060019060a0016020604051602081039080840390855afa1580156103ea573d6000803e3d6000fd5b505050602060405103516001600160a01b0316149450505050505b9392505050565b600060208251101561041d57600080fd5b508051015190565b60405180606001604052806003906020820280368337509192915050565b6001600160a01b038116811461045857600080fd5b50565b634e487b7160e01b600052604160045260246000fd5b60005b8381101561048c578181015183820152602001610474565b50506000910152565b600082601f8301126104a657600080fd5b81516001600160401b038111156104bf576104bf61045b565b604051601f8201601f19908116603f011681016001600160401b03811182821017156104ed576104ed61045b565b60405281815283820160200185101561050557600080fd5b610516826020830160208701610471565b949350505050565b60008060006060848603121561053357600080fd5b835161053e81610443565b6020850151604086015191945092506001600160401b0381111561056157600080fd5b61056d86828701610495565b9150509250925092565b60008060006060848603121561058c57600080fd5b835161059781610443565b60208501519093506001600160401b038111156105b357600080fd5b6105bf86828701610495565b604086015190935090506001600160401b0381111561056157600080fd5b600082516105ef818460208701610471565b9190910192915050565b828152604060208201526000825180604084015261061e816060850160208701610471565b601f01601f1916919091016060019392505050565b60006020828403121561064557600080fd5b81516001600160e01b03198116811461040557600080fd5b634e487b7160e01b600052603260045260246000fdfe5369676e617475726556616c696461746f72237265636f7665725369676e6572",fh="0x608060405234801561001057600080fd5b506115b9806100206000396000f3fe6080604052600436106100f35760003560e01c80634d2301cc1161008a578063a8b0574e11610059578063a8b0574e14610325578063bce38bd714610350578063c3077fa914610380578063ee82ac5e146103b2576100f3565b80634d2301cc1461026257806372425d9d1461029f57806382ad56cb146102ca57806386d516e8146102fa576100f3565b80633408e470116100c65780633408e470146101af578063399542e9146101da5780633e64a6961461020c57806342cbb15c14610237576100f3565b80630f28c97d146100f8578063174dea7114610123578063252dba421461015357806327e86d6e14610184575b600080fd5b34801561010457600080fd5b5061010d6103ef565b60405161011a9190610c0a565b60405180910390f35b61013d60048036038101906101389190610c94565b6103f7565b60405161014a9190610e94565b60405180910390f35b61016d60048036038101906101689190610f0c565b610615565b60405161017b92919061101b565b60405180910390f35b34801561019057600080fd5b506101996107ab565b6040516101a69190611064565b60405180910390f35b3480156101bb57600080fd5b506101c46107b7565b6040516101d19190610c0a565b60405180910390f35b6101f460048036038101906101ef91906110ab565b6107bf565b6040516102039392919061110b565b60405180910390f35b34801561021857600080fd5b506102216107e1565b60405161022e9190610c0a565b60405180910390f35b34801561024357600080fd5b5061024c6107e9565b6040516102599190610c0a565b60405180910390f35b34801561026e57600080fd5b50610289600480360381019061028491906111a7565b6107f1565b6040516102969190610c0a565b60405180910390f35b3480156102ab57600080fd5b506102b4610812565b6040516102c19190610c0a565b60405180910390f35b6102e460048036038101906102df919061122a565b61081a565b6040516102f19190610e94565b60405180910390f35b34801561030657600080fd5b5061030f6109e4565b60405161031c9190610c0a565b60405180910390f35b34801561033157600080fd5b5061033a6109ec565b6040516103479190611286565b60405180910390f35b61036a600480360381019061036591906110ab565b6109f4565b6040516103779190610e94565b60405180910390f35b61039a60048036038101906103959190610f0c565b610ba6565b6040516103a99392919061110b565b60405180910390f35b3480156103be57600080fd5b506103d960048036038101906103d491906112cd565b610bca565b6040516103e69190611064565b60405180910390f35b600042905090565b60606000808484905090508067ffffffffffffffff81111561041c5761041b6112fa565b5b60405190808252806020026020018201604052801561045557816020015b610442610bd5565b81526020019060019003908161043a5790505b5092503660005b828110156105c957600085828151811061047957610478611329565b5b6020026020010151905087878381811061049657610495611329565b5b90506020028101906104a89190611367565b925060008360400135905080860195508360000160208101906104cb91906111a7565b73ffffffffffffffffffffffffffffffffffffffff16818580606001906104f2919061138f565b604051610500929190611431565b60006040518083038185875af1925050503d806000811461053d576040519150601f19603f3d011682016040523d82523d6000602084013e610542565b606091505b5083600001846020018290528215151515815250505081516020850135176105bc577f08c379a000000000000000000000000000000000000000000000000000000000600052602060045260176024527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060445260846000fd5b826001019250505061045c565b5082341461060c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610603906114a7565b60405180910390fd5b50505092915050565b6000606043915060008484905090508067ffffffffffffffff81111561063e5761063d6112fa565b5b60405190808252806020026020018201604052801561067157816020015b606081526020019060019003908161065c5790505b5091503660005b828110156107a157600087878381811061069557610694611329565b5b90506020028101906106a791906114c7565b92508260000160208101906106bc91906111a7565b73ffffffffffffffffffffffffffffffffffffffff168380602001906106e2919061138f565b6040516106f0929190611431565b6000604051808303816000865af19150503d806000811461072d576040519150601f19603f3d011682016040523d82523d6000602084013e610732565b606091505b5086848151811061074657610745611329565b5b60200260200101819052819250505080610795576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161078c9061153b565b60405180910390fd5b81600101915050610678565b5050509250929050565b60006001430340905090565b600046905090565b6000806060439250434091506107d68686866109f4565b905093509350939050565b600048905090565b600043905090565b60008173ffffffffffffffffffffffffffffffffffffffff16319050919050565b600044905090565b606060008383905090508067ffffffffffffffff81111561083e5761083d6112fa565b5b60405190808252806020026020018201604052801561087757816020015b610864610bd5565b81526020019060019003908161085c5790505b5091503660005b828110156109db57600084828151811061089b5761089a611329565b5b602002602001015190508686838181106108b8576108b7611329565b5b90506020028101906108ca919061155b565b92508260000160208101906108df91906111a7565b73ffffffffffffffffffffffffffffffffffffffff16838060400190610905919061138f565b604051610913929190611431565b6000604051808303816000865af19150503d8060008114610950576040519150601f19603f3d011682016040523d82523d6000602084013e610955565b606091505b5082600001836020018290528215151515815250505080516020840135176109cf577f08c379a000000000000000000000000000000000000000000000000000000000600052602060045260176024527f4d756c746963616c6c333a2063616c6c206661696c656400000000000000000060445260646000fd5b8160010191505061087e565b50505092915050565b600045905090565b600041905090565b606060008383905090508067ffffffffffffffff811115610a1857610a176112fa565b5b604051908082528060200260200182016040528015610a5157816020015b610a3e610bd5565b815260200190600190039081610a365790505b5091503660005b82811015610b9c576000848281518110610a7557610a74611329565b5b60200260200101519050868683818110610a9257610a91611329565b5b9050602002810190610aa491906114c7565b9250826000016020810190610ab991906111a7565b73ffffffffffffffffffffffffffffffffffffffff16838060200190610adf919061138f565b604051610aed929190611431565b6000604051808303816000865af19150503d8060008114610b2a576040519150601f19603f3d011682016040523d82523d6000602084013e610b2f565b606091505b508260000183602001829052821515151581525050508715610b90578060000151610b8f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b869061153b565b60405180910390fd5b5b81600101915050610a58565b5050509392505050565b6000806060610bb7600186866107bf565b8093508194508295505050509250925092565b600081409050919050565b6040518060400160405280600015158152602001606081525090565b6000819050919050565b610c0481610bf1565b82525050565b6000602082019050610c1f6000830184610bfb565b92915050565b600080fd5b600080fd5b600080fd5b600080fd5b600080fd5b60008083601f840112610c5457610c53610c2f565b5b8235905067ffffffffffffffff811115610c7157610c70610c34565b5b602083019150836020820283011115610c8d57610c8c610c39565b5b9250929050565b60008060208385031215610cab57610caa610c25565b5b600083013567ffffffffffffffff811115610cc957610cc8610c2a565b5b610cd585828601610c3e565b92509250509250929050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b60008115159050919050565b610d2281610d0d565b82525050565b600081519050919050565b600082825260208201905092915050565b60005b83811015610d62578082015181840152602081019050610d47565b83811115610d71576000848401525b50505050565b6000601f19601f8301169050919050565b6000610d9382610d28565b610d9d8185610d33565b9350610dad818560208601610d44565b610db681610d77565b840191505092915050565b6000604083016000830151610dd96000860182610d19565b5060208301518482036020860152610df18282610d88565b9150508091505092915050565b6000610e0a8383610dc1565b905092915050565b6000602082019050919050565b6000610e2a82610ce1565b610e348185610cec565b935083602082028501610e4685610cfd565b8060005b85811015610e825784840389528151610e638582610dfe565b9450610e6e83610e12565b925060208a01995050600181019050610e4a565b50829750879550505050505092915050565b60006020820190508181036000830152610eae8184610e1f565b905092915050565b60008083601f840112610ecc57610ecb610c2f565b5b8235905067ffffffffffffffff811115610ee957610ee8610c34565b5b602083019150836020820283011115610f0557610f04610c39565b5b9250929050565b60008060208385031215610f2357610f22610c25565b5b600083013567ffffffffffffffff811115610f4157610f40610c2a565b5b610f4d85828601610eb6565b92509250509250929050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b6000610f918383610d88565b905092915050565b6000602082019050919050565b6000610fb182610f59565b610fbb8185610f64565b935083602082028501610fcd85610f75565b8060005b858110156110095784840389528151610fea8582610f85565b9450610ff583610f99565b925060208a01995050600181019050610fd1565b50829750879550505050505092915050565b60006040820190506110306000830185610bfb565b81810360208301526110428184610fa6565b90509392505050565b6000819050919050565b61105e8161104b565b82525050565b60006020820190506110796000830184611055565b92915050565b61108881610d0d565b811461109357600080fd5b50565b6000813590506110a58161107f565b92915050565b6000806000604084860312156110c4576110c3610c25565b5b60006110d286828701611096565b935050602084013567ffffffffffffffff8111156110f3576110f2610c2a565b5b6110ff86828701610eb6565b92509250509250925092565b60006060820190506111206000830186610bfb565b61112d6020830185611055565b818103604083015261113f8184610e1f565b9050949350505050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061117482611149565b9050919050565b61118481611169565b811461118f57600080fd5b50565b6000813590506111a18161117b565b92915050565b6000602082840312156111bd576111bc610c25565b5b60006111cb84828501611192565b91505092915050565b60008083601f8401126111ea576111e9610c2f565b5b8235905067ffffffffffffffff81111561120757611206610c34565b5b60208301915083602082028301111561122357611222610c39565b5b9250929050565b6000806020838503121561124157611240610c25565b5b600083013567ffffffffffffffff81111561125f5761125e610c2a565b5b61126b858286016111d4565b92509250509250929050565b61128081611169565b82525050565b600060208201905061129b6000830184611277565b92915050565b6112aa81610bf1565b81146112b557600080fd5b50565b6000813590506112c7816112a1565b92915050565b6000602082840312156112e3576112e2610c25565b5b60006112f1848285016112b8565b91505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600080fd5b600080fd5b600080fd5b60008235600160800383360303811261138357611382611358565b5b80830191505092915050565b600080833560016020038436030381126113ac576113ab611358565b5b80840192508235915067ffffffffffffffff8211156113ce576113cd61135d565b5b6020830192506001820236038313156113ea576113e9611362565b5b509250929050565b600081905092915050565b82818337600083830152505050565b600061141883856113f2565b93506114258385846113fd565b82840190509392505050565b600061143e82848661140c565b91508190509392505050565b600082825260208201905092915050565b7f4d756c746963616c6c333a2076616c7565206d69736d61746368000000000000600082015250565b6000611491601a8361144a565b915061149c8261145b565b602082019050919050565b600060208201905081810360008301526114c081611484565b9050919050565b6000823560016040038336030381126114e3576114e2611358565b5b80830191505092915050565b7f4d756c746963616c6c333a2063616c6c206661696c6564000000000000000000600082015250565b600061152560178361144a565b9150611530826114ef565b602082019050919050565b6000602082019050818103600083015261155481611518565b9050919050565b60008235600160600383360303811261157757611576611358565b5b8083019150509291505056fea264697066735822122020c1bc9aacf8e4a6507193432a895a8e77094f45a1395583f07b24e860ef06cd64736f6c634300080c0033";class ql extends L{constructor({blockNumber:e,chain:r,contract:n}){super(`Chain "${r.name}" does not support contract "${n.name}".`,{metaMessages:["This could be due to any of the following:",...e&&n.blockCreated&&n.blockCreated>e?[`- The contract "${n.name}" was not deployed until block ${n.blockCreated} (current block ${e}).`]:[`- The chain does not have the contract "${n.name}" configured.`]],name:"ChainDoesNotSupportContract"})}}class tA extends L{constructor({chain:e,currentChainId:r}){super(`The current chain of the wallet (id: ${r}) does not match the target chain for the transaction (id: ${e.id} – ${e.name}).`,{metaMessages:[`Current Chain ID: ${r}`,`Expected Chain ID: ${e.id} – ${e.name}`],name:"ChainMismatchError"})}}class rA extends L{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 Jb extends L{constructor(){super("No chain was provided to the Client.",{name:"ClientChainNotConfiguredError"})}}class Kc extends L{constructor({chainId:e}){super(typeof e=="number"?`Chain ID "${e}" is invalid.`:"Chain ID is invalid.",{name:"InvalidChainIdError"})}}const $u="/docs/contract/encodeDeployData";function Zc(t){const{abi:e,args:r,bytecode:n}=t;if(!r||r.length===0)return n;const s=e.find(o=>"type"in o&&o.type==="constructor");if(!s)throw new nv({docsPath:$u});if(!("inputs"in s))throw new wp({docsPath:$u});if(!s.inputs||s.inputs.length===0)throw new wp({docsPath:$u});const i=fs(s.inputs,r);return Cr([n,i])}function Wi({blockNumber:t,chain:e,contract:r}){var s;const n=(s=e==null?void 0:e.contracts)==null?void 0:s[r];if(!n)throw new ql({chain:e,contract:{name:r}});if(t&&n.blockCreated&&n.blockCreated>t)throw new ql({blockNumber:t,chain:e,contract:{name:r,blockCreated:n.blockCreated}});return n.address}function Qb(t,{docsPath:e,...r}){const n=(()=>{const s=Dc(t,r);return s instanceof ba?t:s})();return new yb(n,{docsPath:e,...r})}function lh(){let t=()=>{},e=()=>{};return{promise:new Promise((n,s)=>{t=n,e=s}),resolve:t,reject:e}}const Ru=new Map;function eg({fn:t,id:e,shouldSplitBatch:r,wait:n=0,sort:s}){const i=async()=>{const f=c();o();const l=f.map(({args:p})=>p);l.length!==0&&t(l).then(p=>{s&&Array.isArray(p)&&p.sort(s);for(let d=0;d<f.length;d++){const{resolve:m}=f[d];m==null||m([p[d],p])}}).catch(p=>{for(let d=0;d<f.length;d++){const{reject:m}=f[d];m==null||m(p)}})},o=()=>Ru.delete(e),a=()=>c().map(({args:f})=>f),c=()=>Ru.get(e)||[],u=f=>Ru.set(e,[...c(),f]);return{flush:o,async schedule(f){const{promise:l,resolve:p,reject:d}=lh();return(r==null?void 0:r([...a(),f]))&&i(),c().length>0?(u({args:f,resolve:p,reject:d}),l):(u({args:f,resolve:p,reject:d}),setTimeout(i,n),l)}}}async function wa(t,e){var G,Q,W,K;const{account:r=t.account,authorizationList:n,batch:s=!!((G=t.batch)!=null&&G.multicall),blockNumber:i,blockTag:o=t.experimental_blockTag??"latest",accessList:a,blobs:c,blockOverrides:u,code:f,data:l,factory:p,factoryData:d,gas:m,gasPrice:b,maxFeePerBlobGas:E,maxFeePerGas:S,maxPriorityFeePerGas:P,nonce:A,to:w,value:k,stateOverride:T,...B}=e,N=r?Ze(r):void 0;if(f&&(p||d))throw new L("Cannot provide both `code` & `factory`/`factoryData` as parameters.");if(f&&w)throw new L("Cannot provide both `code` & `to` as parameters.");const $=f&&l,H=p&&d&&w&&l,M=$||H,V=$?tg({code:f,data:l}):H?iA({data:l,factory:p,factoryData:d,to:w}):l;try{Ys(e);const q=(typeof i=="bigint"?Z(i):void 0)||o,I=u?Wb(u):void 0,j=Zd(T),J=(K=(W=(Q=t.chain)==null?void 0:Q.formatters)==null?void 0:W.transactionRequest)==null?void 0:K.format,R=(J||Vi)({...zc(B,{format:J}),from:N==null?void 0:N.address,accessList:a,authorizationList:n,blobs:c,data:V,gas:m,gasPrice:b,maxFeePerBlobGas:E,maxFeePerGas:S,maxPriorityFeePerGas:P,nonce:A,to:M?void 0:w,value:k});if(s&&nA({request:R})&&!j&&!I)try{return await sA(t,{...R,blockNumber:i,blockTag:o})}catch(ae){if(!(ae instanceof Jb)&&!(ae instanceof ql))throw ae}const F=(()=>{const ae=[R,q];return j&&I?[...ae,j,I]:j?[...ae,j]:I?[...ae,{},I]:ae})(),ne=await t.request({method:"eth_call",params:F});return ne==="0x"?{data:void 0}:{data:ne}}catch(re){const q=oA(re),{offchainLookup:I,offchainLookupSignature:j}=await Promise.resolve().then(()=>require("./ccip-7c-UACTE.cjs"));if(t.ccipRead!==!1&&(q==null?void 0:q.slice(0,10))===j&&w)return{data:await I(t,{data:q,to:w})};throw M&&(q==null?void 0:q.slice(0,10))==="0x101bb98d"?new L5({factory:p}):Qb(re,{...e,account:N,chain:t.chain})}}function nA({request:t}){const{data:e,to:r,...n}=t;return!(!e||e.startsWith(JE)||!r||Object.values(n).filter(s=>typeof s<"u").length>0)}async function sA(t,e){var b;const{batchSize:r=1024,deployless:n=!1,wait:s=0}=typeof((b=t.batch)==null?void 0:b.multicall)=="object"?t.batch.multicall:{},{blockNumber:i,blockTag:o=t.experimental_blockTag??"latest",data:a,to:c}=e,u=(()=>{if(n)return null;if(e.multicallAddress)return e.multicallAddress;if(t.chain)return Wi({blockNumber:i,chain:t.chain,contract:"multicall3"});throw new Jb})(),l=(typeof i=="bigint"?Z(i):void 0)||o,{schedule:p}=eg({id:`${t.uid}.${l}`,wait:s,shouldSplitBatch(E){return E.reduce((P,{data:A})=>P+(A.length-2),0)>r*2},fn:async E=>{const S=E.map(w=>({allowFailure:!0,callData:w.data,target:w.to})),P=Xt({abi:gc,args:[S],functionName:"aggregate3"}),A=await t.request({method:"eth_call",params:[{...u===null?{data:tg({code:fh,data:P})}:{to:u,data:P}},l]});return Xs({abi:gc,args:[S],functionName:"aggregate3",data:A||"0x"})}}),[{returnData:d,success:m}]=await p({data:a,to:c});if(!m)throw new Hc({data:d});return d==="0x"?{data:void 0}:{data:d}}function tg(t){const{code:e,data:r}=t;return Zc({abi:Bm(["constructor(bytes, bytes)"]),bytecode:Xb,args:[e,r]})}function iA(t){const{data:e,factory:r,factoryData:n,to:s}=t;return Zc({abi:Bm(["constructor(address, bytes, address, bytes)"]),bytecode:QE,args:[s,e,r,n]})}function oA(t){var r;if(!(t instanceof L))return;const e=t.walk();return typeof(e==null?void 0:e.data)=="object"?(r=e.data)==null?void 0:r.data:e.data}async function dr(t,e){const{abi:r,address:n,args:s,functionName:i,...o}=e,a=Xt({abi:r,args:s,functionName:i});try{const{data:c}=await se(t,wa,"call")({...o,data:a,to:n});return Xs({abi:r,args:s,functionName:i,data:c||"0x"})}catch(c){throw Fs(c,{abi:r,address:n,args:s,docsPath:"/docs/contract/readContract",functionName:i})}}async function rg(t,e){const{abi:r,address:n,args:s,dataSuffix:i,functionName:o,...a}=e,c=a.account?Ze(a.account):t.account,u=Xt({abi:r,args:s,functionName:o});try{const{data:f}=await se(t,wa,"call")({batch:!1,data:`${u}${i?i.replace("0x",""):""}`,to:n,...a,account:c}),l=Xs({abi:r,args:s,functionName:o,data:f||"0x"}),p=r.filter(d=>"name"in d&&d.name===e.functionName);return{result:l,request:{abi:p,address:n,args:s,dataSuffix:i,functionName:o,...a,account:c}}}catch(f){throw Fs(f,{abi:r,address:n,args:s,docsPath:"/docs/contract/simulateContract",functionName:o,sender:c==null?void 0:c.address})}}const Nu=new Map,Gp=new Map;let aA=0;function Tn(t,e,r){const n=++aA,s=()=>Nu.get(t)||[],i=()=>{const f=s();Nu.set(t,f.filter(l=>l.id!==n))},o=()=>{const f=s();if(!f.some(p=>p.id===n))return;const l=Gp.get(t);if(f.length===1&&l){const p=l();p instanceof Promise&&p.catch(()=>{})}i()},a=s();if(Nu.set(t,[...a,{id:n,fns:e}]),a&&a.length>0)return o;const c={};for(const f in e)c[f]=(...l)=>{var d,m;const p=s();if(p.length!==0)for(const b of p)(m=(d=b.fns)[f])==null||m.call(d,...l)};const u=r(c);return typeof u=="function"&&Gp.set(t,u),o}async function Gl(t){return new Promise(e=>setTimeout(e,t))}function Ki(t,{emitOnBegin:e,initialWaitTime:r,interval:n}){let s=!0;const i=()=>s=!1;return(async()=>{let a;e&&(a=await t({unpoll:i}));const c=await(r==null?void 0:r(a))??n;await Gl(c);const u=async()=>{s&&(await t({unpoll:i}),await Gl(n),u())};u()})(),i}const cA=new Map,uA=new Map;function fA(t){const e=(s,i)=>({clear:()=>i.delete(s),get:()=>i.get(s),set:o=>i.set(s,o)}),r=e(t,cA),n=e(t,uA);return{clear:()=>{r.clear(),n.clear()},promise:r,response:n}}async function lA(t,{cacheKey:e,cacheTime:r=Number.POSITIVE_INFINITY}){const n=fA(e),s=n.response.get();if(s&&r>0&&Date.now()-s.created.getTime()<r)return s.data;let i=n.promise.get();i||(i=t(),n.promise.set(i));try{const o=await i;return n.response.set({created:new Date,data:o}),o}finally{n.promise.clear()}}const dA=t=>`blockNumber.${t}`;async function va(t,{cacheTime:e=t.cacheTime}={}){const r=await lA(()=>t.request({method:"eth_blockNumber"}),{cacheKey:dA(t.uid),cacheTime:e});return BigInt(r)}async function Yc(t,{filter:e}){const r="strict"in e&&e.strict,n=await e.request({method:"eth_getFilterChanges",params:[e.id]});if(typeof n[0]=="string")return n;const s=n.map(i=>kn(i));return!("abi"in e)||!e.abi?s:oh({abi:e.abi,logs:s,strict:r})}async function Xc(t,{filter:e}){return e.request({method:"eth_uninstallFilter",params:[e.id]})}function ng(t,e){const{abi:r,address:n,args:s,batch:i=!0,eventName:o,fromBlock:a,onError:c,onLogs:u,poll:f,pollingInterval:l=t.pollingInterval,strict:p}=e;return(typeof f<"u"?f:typeof a=="bigint"?!0:!(t.transport.type==="webSocket"||t.transport.type==="ipc"||t.transport.type==="fallback"&&(t.transport.transports[0].config.type==="webSocket"||t.transport.transports[0].config.type==="ipc")))?(()=>{const E=p??!1,S=Qe(["watchContractEvent",n,s,i,t.uid,o,l,E,a]);return Tn(S,{onLogs:u,onError:c},P=>{let A;a!==void 0&&(A=a-1n);let w,k=!1;const T=Ki(async()=>{var B;if(!k){try{w=await se(t,zd,"createContractEventFilter")({abi:r,address:n,args:s,eventName:o,strict:E,fromBlock:a})}catch{}k=!0;return}try{let N;if(w)N=await se(t,Yc,"getFilterChanges")({filter:w});else{const $=await se(t,va,"getBlockNumber")({});A&&A<$?N=await se(t,ch,"getContractEvents")({abi:r,address:n,args:s,eventName:o,fromBlock:A+1n,toBlock:$,strict:E}):N=[],A=$}if(N.length===0)return;if(i)P.onLogs(N);else for(const $ of N)P.onLogs([$])}catch(N){w&&N instanceof Ms&&(k=!1),(B=P.onError)==null||B.call(P,N)}},{emitOnBegin:!0,interval:l});return async()=>{w&&await se(t,Xc,"uninstallFilter")({filter:w}),T()}})})():(()=>{const E=p??!1,S=Qe(["watchContractEvent",n,s,i,t.uid,o,l,E]);let P=!0,A=()=>P=!1;return Tn(S,{onLogs:u,onError:c},w=>((async()=>{try{const k=(()=>{if(t.transport.type==="fallback"){const N=t.transport.transports.find($=>$.config.type==="webSocket"||$.config.type==="ipc");return N?N.value:t.transport}return t.transport})(),T=o?pa({abi:r,eventName:o,args:s}):[],{unsubscribe:B}=await k.subscribe({params:["logs",{address:n,topics:T}],onData(N){var H;if(!P)return;const $=N.result;try{const{eventName:M,args:V}=ih({abi:r,data:$.data,topics:$.topics,strict:p}),G=kn($,{args:V,eventName:M});w.onLogs([G])}catch(M){let V,G;if(M instanceof Po||M instanceof Rc){if(p)return;V=M.abiItem.name,G=(H=M.abiItem.inputs)==null?void 0:H.some(W=>!("name"in W&&W.name))}const Q=kn($,{args:G?[]:{},eventName:V});w.onLogs([Q])}},onError(N){var $;($=w.onError)==null||$.call(w,N)}});A=B,P||A()}catch(k){c==null||c(k)}})(),()=>A()))})()}class Js extends L{constructor({docsPath:e}={}){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 Jb extends L{constructor(){super("No chain was provided to the Client.",{name:"ClientChainNotConfiguredError"})}}class Kc extends L{constructor({chainId:e}){super(typeof e=="number"?`Chain ID "${e}" is invalid.`:"Chain ID is invalid.",{name:"InvalidChainIdError"})}}const $u="/docs/contract/encodeDeployData";function Zc(t){const{abi:e,args:r,bytecode:n}=t;if(!r||r.length===0)return n;const s=e.find(o=>"type"in o&&o.type==="constructor");if(!s)throw new nv({docsPath:$u});if(!("inputs"in s))throw new wp({docsPath:$u});if(!s.inputs||s.inputs.length===0)throw new wp({docsPath:$u});const i=fs(s.inputs,r);return Cr([n,i])}function Wi({blockNumber:t,chain:e,contract:r}){var s;const n=(s=e==null?void 0:e.contracts)==null?void 0:s[r];if(!n)throw new ql({chain:e,contract:{name:r}});if(t&&n.blockCreated&&n.blockCreated>t)throw new ql({blockNumber:t,chain:e,contract:{name:r,blockCreated:n.blockCreated}});return n.address}function Qb(t,{docsPath:e,...r}){const n=(()=>{const s=Dc(t,r);return s instanceof ba?t:s})();return new yb(n,{docsPath:e,...r})}function lh(){let t=()=>{},e=()=>{};return{promise:new Promise((n,s)=>{t=n,e=s}),resolve:t,reject:e}}const Ru=new Map;function eg({fn:t,id:e,shouldSplitBatch:r,wait:n=0,sort:s}){const i=async()=>{const f=c();o();const l=f.map(({args:p})=>p);l.length!==0&&t(l).then(p=>{s&&Array.isArray(p)&&p.sort(s);for(let d=0;d<f.length;d++){const{resolve:m}=f[d];m==null||m([p[d],p])}}).catch(p=>{for(let d=0;d<f.length;d++){const{reject:m}=f[d];m==null||m(p)}})},o=()=>Ru.delete(e),a=()=>c().map(({args:f})=>f),c=()=>Ru.get(e)||[],u=f=>Ru.set(e,[...c(),f]);return{flush:o,async schedule(f){const{promise:l,resolve:p,reject:d}=lh();return(r==null?void 0:r([...a(),f]))&&i(),c().length>0?(u({args:f,resolve:p,reject:d}),l):(u({args:f,resolve:p,reject:d}),setTimeout(i,n),l)}}}async function wa(t,e){var G,Q,W,K;const{account:r=t.account,authorizationList:n,batch:s=!!((G=t.batch)!=null&&G.multicall),blockNumber:i,blockTag:o=t.experimental_blockTag??"latest",accessList:a,blobs:c,blockOverrides:u,code:f,data:l,factory:p,factoryData:d,gas:m,gasPrice:b,maxFeePerBlobGas:E,maxFeePerGas:S,maxPriorityFeePerGas:P,nonce:A,to:w,value:k,stateOverride:T,...B}=e,N=r?Ze(r):void 0;if(f&&(p||d))throw new L("Cannot provide both `code` & `factory`/`factoryData` as parameters.");if(f&&w)throw new L("Cannot provide both `code` & `to` as parameters.");const $=f&&l,H=p&&d&&w&&l,M=$||H,V=$?tg({code:f,data:l}):H?iA({data:l,factory:p,factoryData:d,to:w}):l;try{Ys(e);const q=(typeof i=="bigint"?Z(i):void 0)||o,I=u?Wb(u):void 0,j=Zd(T),J=(K=(W=(Q=t.chain)==null?void 0:Q.formatters)==null?void 0:W.transactionRequest)==null?void 0:K.format,R=(J||Vi)({...zc(B,{format:J}),from:N==null?void 0:N.address,accessList:a,authorizationList:n,blobs:c,data:V,gas:m,gasPrice:b,maxFeePerBlobGas:E,maxFeePerGas:S,maxPriorityFeePerGas:P,nonce:A,to:M?void 0:w,value:k});if(s&&nA({request:R})&&!j&&!I)try{return await sA(t,{...R,blockNumber:i,blockTag:o})}catch(ae){if(!(ae instanceof Jb)&&!(ae instanceof ql))throw ae}const F=(()=>{const ae=[R,q];return j&&I?[...ae,j,I]:j?[...ae,j]:I?[...ae,{},I]:ae})(),ne=await t.request({method:"eth_call",params:F});return ne==="0x"?{data:void 0}:{data:ne}}catch(re){const q=oA(re),{offchainLookup:I,offchainLookupSignature:j}=await Promise.resolve().then(()=>require("./ccip-CDLid_2f.cjs"));if(t.ccipRead!==!1&&(q==null?void 0:q.slice(0,10))===j&&w)return{data:await I(t,{data:q,to:w})};throw M&&(q==null?void 0:q.slice(0,10))==="0x101bb98d"?new L5({factory:p}):Qb(re,{...e,account:N,chain:t.chain})}}function nA({request:t}){const{data:e,to:r,...n}=t;return!(!e||e.startsWith(JE)||!r||Object.values(n).filter(s=>typeof s<"u").length>0)}async function sA(t,e){var b;const{batchSize:r=1024,deployless:n=!1,wait:s=0}=typeof((b=t.batch)==null?void 0:b.multicall)=="object"?t.batch.multicall:{},{blockNumber:i,blockTag:o=t.experimental_blockTag??"latest",data:a,to:c}=e,u=(()=>{if(n)return null;if(e.multicallAddress)return e.multicallAddress;if(t.chain)return Wi({blockNumber:i,chain:t.chain,contract:"multicall3"});throw new Jb})(),l=(typeof i=="bigint"?Z(i):void 0)||o,{schedule:p}=eg({id:`${t.uid}.${l}`,wait:s,shouldSplitBatch(E){return E.reduce((P,{data:A})=>P+(A.length-2),0)>r*2},fn:async E=>{const S=E.map(w=>({allowFailure:!0,callData:w.data,target:w.to})),P=Xt({abi:gc,args:[S],functionName:"aggregate3"}),A=await t.request({method:"eth_call",params:[{...u===null?{data:tg({code:fh,data:P})}:{to:u,data:P}},l]});return Xs({abi:gc,args:[S],functionName:"aggregate3",data:A||"0x"})}}),[{returnData:d,success:m}]=await p({data:a,to:c});if(!m)throw new Hc({data:d});return d==="0x"?{data:void 0}:{data:d}}function tg(t){const{code:e,data:r}=t;return Zc({abi:Bm(["constructor(bytes, bytes)"]),bytecode:Xb,args:[e,r]})}function iA(t){const{data:e,factory:r,factoryData:n,to:s}=t;return Zc({abi:Bm(["constructor(address, bytes, address, bytes)"]),bytecode:QE,args:[s,e,r,n]})}function oA(t){var r;if(!(t instanceof L))return;const e=t.walk();return typeof(e==null?void 0:e.data)=="object"?(r=e.data)==null?void 0:r.data:e.data}async function dr(t,e){const{abi:r,address:n,args:s,functionName:i,...o}=e,a=Xt({abi:r,args:s,functionName:i});try{const{data:c}=await se(t,wa,"call")({...o,data:a,to:n});return Xs({abi:r,args:s,functionName:i,data:c||"0x"})}catch(c){throw Fs(c,{abi:r,address:n,args:s,docsPath:"/docs/contract/readContract",functionName:i})}}async function rg(t,e){const{abi:r,address:n,args:s,dataSuffix:i,functionName:o,...a}=e,c=a.account?Ze(a.account):t.account,u=Xt({abi:r,args:s,functionName:o});try{const{data:f}=await se(t,wa,"call")({batch:!1,data:`${u}${i?i.replace("0x",""):""}`,to:n,...a,account:c}),l=Xs({abi:r,args:s,functionName:o,data:f||"0x"}),p=r.filter(d=>"name"in d&&d.name===e.functionName);return{result:l,request:{abi:p,address:n,args:s,dataSuffix:i,functionName:o,...a,account:c}}}catch(f){throw Fs(f,{abi:r,address:n,args:s,docsPath:"/docs/contract/simulateContract",functionName:o,sender:c==null?void 0:c.address})}}const Nu=new Map,Gp=new Map;let aA=0;function Tn(t,e,r){const n=++aA,s=()=>Nu.get(t)||[],i=()=>{const f=s();Nu.set(t,f.filter(l=>l.id!==n))},o=()=>{const f=s();if(!f.some(p=>p.id===n))return;const l=Gp.get(t);if(f.length===1&&l){const p=l();p instanceof Promise&&p.catch(()=>{})}i()},a=s();if(Nu.set(t,[...a,{id:n,fns:e}]),a&&a.length>0)return o;const c={};for(const f in e)c[f]=(...l)=>{var d,m;const p=s();if(p.length!==0)for(const b of p)(m=(d=b.fns)[f])==null||m.call(d,...l)};const u=r(c);return typeof u=="function"&&Gp.set(t,u),o}async function Gl(t){return new Promise(e=>setTimeout(e,t))}function Ki(t,{emitOnBegin:e,initialWaitTime:r,interval:n}){let s=!0;const i=()=>s=!1;return(async()=>{let a;e&&(a=await t({unpoll:i}));const c=await(r==null?void 0:r(a))??n;await Gl(c);const u=async()=>{s&&(await t({unpoll:i}),await Gl(n),u())};u()})(),i}const cA=new Map,uA=new Map;function fA(t){const e=(s,i)=>({clear:()=>i.delete(s),get:()=>i.get(s),set:o=>i.set(s,o)}),r=e(t,cA),n=e(t,uA);return{clear:()=>{r.clear(),n.clear()},promise:r,response:n}}async function lA(t,{cacheKey:e,cacheTime:r=Number.POSITIVE_INFINITY}){const n=fA(e),s=n.response.get();if(s&&r>0&&Date.now()-s.created.getTime()<r)return s.data;let i=n.promise.get();i||(i=t(),n.promise.set(i));try{const o=await i;return n.response.set({created:new Date,data:o}),o}finally{n.promise.clear()}}const dA=t=>`blockNumber.${t}`;async function va(t,{cacheTime:e=t.cacheTime}={}){const r=await lA(()=>t.request({method:"eth_blockNumber"}),{cacheKey:dA(t.uid),cacheTime:e});return BigInt(r)}async function Yc(t,{filter:e}){const r="strict"in e&&e.strict,n=await e.request({method:"eth_getFilterChanges",params:[e.id]});if(typeof n[0]=="string")return n;const s=n.map(i=>kn(i));return!("abi"in e)||!e.abi?s:oh({abi:e.abi,logs:s,strict:r})}async function Xc(t,{filter:e}){return e.request({method:"eth_uninstallFilter",params:[e.id]})}function ng(t,e){const{abi:r,address:n,args:s,batch:i=!0,eventName:o,fromBlock:a,onError:c,onLogs:u,poll:f,pollingInterval:l=t.pollingInterval,strict:p}=e;return(typeof f<"u"?f:typeof a=="bigint"?!0:!(t.transport.type==="webSocket"||t.transport.type==="ipc"||t.transport.type==="fallback"&&(t.transport.transports[0].config.type==="webSocket"||t.transport.transports[0].config.type==="ipc")))?(()=>{const E=p??!1,S=Qe(["watchContractEvent",n,s,i,t.uid,o,l,E,a]);return Tn(S,{onLogs:u,onError:c},P=>{let A;a!==void 0&&(A=a-1n);let w,k=!1;const T=Ki(async()=>{var B;if(!k){try{w=await se(t,zd,"createContractEventFilter")({abi:r,address:n,args:s,eventName:o,strict:E,fromBlock:a})}catch{}k=!0;return}try{let N;if(w)N=await se(t,Yc,"getFilterChanges")({filter:w});else{const $=await se(t,va,"getBlockNumber")({});A&&A<$?N=await se(t,ch,"getContractEvents")({abi:r,address:n,args:s,eventName:o,fromBlock:A+1n,toBlock:$,strict:E}):N=[],A=$}if(N.length===0)return;if(i)P.onLogs(N);else for(const $ of N)P.onLogs([$])}catch(N){w&&N instanceof Ms&&(k=!1),(B=P.onError)==null||B.call(P,N)}},{emitOnBegin:!0,interval:l});return async()=>{w&&await se(t,Xc,"uninstallFilter")({filter:w}),T()}})})():(()=>{const E=p??!1,S=Qe(["watchContractEvent",n,s,i,t.uid,o,l,E]);let P=!0,A=()=>P=!1;return Tn(S,{onLogs:u,onError:c},w=>((async()=>{try{const k=(()=>{if(t.transport.type==="fallback"){const N=t.transport.transports.find($=>$.config.type==="webSocket"||$.config.type==="ipc");return N?N.value:t.transport}return t.transport})(),T=o?pa({abi:r,eventName:o,args:s}):[],{unsubscribe:B}=await k.subscribe({params:["logs",{address:n,topics:T}],onData(N){var H;if(!P)return;const $=N.result;try{const{eventName:M,args:V}=ih({abi:r,data:$.data,topics:$.topics,strict:p}),G=kn($,{args:V,eventName:M});w.onLogs([G])}catch(M){let V,G;if(M instanceof Po||M instanceof Rc){if(p)return;V=M.abiItem.name,G=(H=M.abiItem.inputs)==null?void 0:H.some(W=>!("name"in W&&W.name))}const Q=kn($,{args:G?[]:{},eventName:V});w.onLogs([Q])}},onError(N){var $;($=w.onError)==null||$.call(w,N)}});A=B,P||A()}catch(k){c==null||c(k)}})(),()=>A()))})()}class Js extends L{constructor({docsPath:e}={}){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:e,docsSlug:"account",name:"AccountNotFoundError"})}}class sc extends L{constructor({docsPath:e,metaMessages:r,type:n}){super(`Account type "${n}" is not supported.`,{docsPath:e,metaMessages:r,name:"AccountTypeNotSupportedError"})}}function sg({chain:t,currentChainId:e}){if(!t)throw new rA;if(e!==t.id)throw new tA({chain:t,currentChainId:e})}function ig(t,{docsPath:e,...r}){const n=(()=>{const s=Dc(t,r);return s instanceof ba?t:s})();return new U5(n,{docsPath:e,...r})}async function dh(t,{serializedTransaction:e}){return t.request({method:"eth_sendRawTransaction",params:[e]},{retryCount:0})}const Uu=new Fc(128);async function Jc(t,e){var P,A,w,k;const{account:r=t.account,chain:n=t.chain,accessList:s,authorizationList:i,blobs:o,data:a,gas:c,gasPrice:u,maxFeePerBlobGas:f,maxFeePerGas:l,maxPriorityFeePerGas:p,nonce:d,type:m,value:b,...E}=e;if(typeof r>"u")throw new Js({docsPath:"/docs/actions/wallet/sendTransaction"});const S=r?Ze(r):null;try{Ys(e);const T=await(async()=>{if(e.to)return e.to;if(e.to!==null&&i&&i.length>0)return await Wd({authorization:i[0]}).catch(()=>{throw new L("`to` is required. Could not infer from `authorizationList`.")})})();if((S==null?void 0:S.type)==="json-rpc"||S===null){let B;n!==null&&(B=await se(t,qi,"getChainId")({}),sg({currentChainId:B,chain:n}));const N=(w=(A=(P=t.chain)==null?void 0:P.formatters)==null?void 0:A.transactionRequest)==null?void 0:w.format,H=(N||Vi)({...zc(E,{format:N}),accessList:s,authorizationList:i,blobs:o,chainId:B,data:a,from:S==null?void 0:S.address,gas:c,gasPrice:u,maxFeePerBlobGas:f,maxFeePerGas:l,maxPriorityFeePerGas:p,nonce:d,to:T,type:m,value:b}),M=Uu.get(t.uid),V=M?"wallet_sendTransaction":"eth_sendTransaction";try{return await t.request({method:V,params:[H]},{retryCount:0})}catch(G){if(M===!1)throw G;const Q=G;if(Q.name==="InvalidInputRpcError"||Q.name==="InvalidParamsRpcError"||Q.name==="MethodNotFoundRpcError"||Q.name==="MethodNotSupportedRpcError")return await t.request({method:"wallet_sendTransaction",params:[H]},{retryCount:0}).then(W=>(Uu.set(t.uid,!0),W)).catch(W=>{const K=W;throw K.name==="MethodNotFoundRpcError"||K.name==="MethodNotSupportedRpcError"?(Uu.set(t.uid,!1),Q):K});throw Q}}if((S==null?void 0:S.type)==="local"){const B=await se(t,Gc,"prepareTransactionRequest")({account:S,accessList:s,authorizationList:i,blobs:o,chain:n,data:a,gas:c,gasPrice:u,maxFeePerBlobGas:f,maxFeePerGas:l,maxPriorityFeePerGas:p,nonce:d,nonceManager:S.nonceManager,parameters:[...Rb,"sidecars"],type:m,value:b,...E,to:T}),N=(k=n==null?void 0:n.serializers)==null?void 0:k.transaction,$=await S.signTransaction(B,{serializer:N});return await se(t,dh,"sendRawTransaction")({serializedTransaction:$})}throw(S==null?void 0:S.type)==="smart"?new sc({metaMessages:["Consider using the `sendUserOperation` Action instead."],docsPath:"/docs/actions/bundler/sendUserOperation",type:"smart"}):new sc({docsPath:"/docs/actions/wallet/sendTransaction",type:S==null?void 0:S.type})}catch(T){throw T instanceof sc?T:ig(T,{...e,account:S,chain:e.chain||void 0})}}async function og(t,e){const{abi:r,account:n=t.account,address:s,args:i,dataSuffix:o,functionName:a,...c}=e;if(typeof n>"u")throw new Js({docsPath:"/docs/contract/writeContract"});const u=n?Ze(n):null,f=Xt({abi:r,args:i,functionName:a});try{return await se(t,Jc,"sendTransaction")({data:`${f}${o?o.replace("0x",""):""}`,to:s,account:u,...c})}catch(l){throw Fs(l,{abi:r,address:s,args:i,docsPath:"/docs/contract/writeContract",functionName:a,sender:u==null?void 0:u.address})}}function hh({abi:t,address:e,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 u=!1,f=!1,l=!1;for(const p of t)if(p.type==="function"?p.stateMutability==="view"||p.stateMutability==="pure"?u=!0:f=!0:p.type==="event"&&(l=!0),u&&f&&l)break;return o&&(u&&(c.read=new Proxy({},{get(p,d){return(...m)=>{const{args:b,options:E}=Ua(m);return se(s,dr,"readContract")({abi:t,address:e,functionName:d,args:b,...E})}}})),f&&(c.simulate=new Proxy({},{get(p,d){return(...m)=>{const{args:b,options:E}=Ua(m);return se(s,rg,"simulateContract")({abi:t,address:e,functionName:d,args:b,...E})}}})),l&&(c.createEventFilter=new Proxy({},{get(p,d){return(...m)=>{const b=t.find(P=>P.type==="event"&&P.name===d),{args:E,options:S}=Mu(m,b);return se(s,zd,"createContractEventFilter")({abi:t,address:e,eventName:d,args:E,...S})}}}),c.getEvents=new Proxy({},{get(p,d){return(...m)=>{const b=t.find(P=>P.type==="event"&&P.name===d),{args:E,options:S}=Mu(m,b);return se(s,ch,"getContractEvents")({abi:t,address:e,eventName:d,args:E,...S})}}}),c.watchEvent=new Proxy({},{get(p,d){return(...m)=>{const b=t.find(P=>P.type==="event"&&P.name===d),{args:E,options:S}=Mu(m,b);return se(s,ng,"watchContractEvent")({abi:t,address:e,eventName:d,args:E,...S})}}}))),a&&f&&(c.write=new Proxy({},{get(p,d){return(...m)=>{const{args:b,options:E}=Ua(m);return se(i,og,"writeContract")({abi:t,address:e,functionName:d,args:b,...E})}}})),(o||a)&&f&&(c.estimateGas=new Proxy({},{get(p,d){return(...m)=>{const{args:b,options:E}=Ua(m);return se(s??i,Nb,"estimateContractGas")({abi:t,address:e,functionName:d,args:b,...E,account:E.account??i.account})}}})),c.address=e,c.abi=t,c}function Ua(t){const e=t.length&&Array.isArray(t[0]),r=e?t[0]:[],n=(e?t[1]:t[0])??{};return{args:r,options:n}}function Mu(t,e){let r=!1;Array.isArray(t[0])?r=!0:t.length===1?r=e.inputs.some(i=>i.indexed):t.length===2&&(r=!0);const n=r?t[0]:void 0,s=(r?t[1]:t[0])??{};return{args:n,options:s}}class hA extends L{constructor(e){super(`Call bundle failed with status: ${e.statusCode}`,{name:"BundleFailedError"}),Object.defineProperty(this,"result",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.result=e}}function wc(t,{delay:e=100,retryCount:r=2,shouldRetry:n=()=>!0}={}){return new Promise((s,i)=>{const o=async({count:a=0}={})=>{const c=async({error:u})=>{const f=typeof e=="function"?e({count:a,error:u}):e;f&&await Gl(f),o({count:a+1})};try{const u=await t();s(u)}catch(u){if(a<r&&await n({count:a,error:u}))return c({error:u});i(u)}};o()})}const ag={"0x0":"reverted","0x1":"success"};function cg(t){const e={...t,blockNumber:t.blockNumber?BigInt(t.blockNumber):null,contractAddress:t.contractAddress?t.contractAddress:null,cumulativeGasUsed:t.cumulativeGasUsed?BigInt(t.cumulativeGasUsed):null,effectiveGasPrice:t.effectiveGasPrice?BigInt(t.effectiveGasPrice):null,gasUsed:t.gasUsed?BigInt(t.gasUsed):null,logs:t.logs?t.logs.map(r=>kn(r)):null,to:t.to?t.to:null,transactionIndex:t.transactionIndex?lr(t.transactionIndex):null,status:t.status?ag[t.status]:null,type:t.type?Eb[t.type]||t.type:null};return t.blobGasPrice&&(e.blobGasPrice=BigInt(t.blobGasPrice)),t.blobGasUsed&&(e.blobGasUsed=BigInt(t.blobGasUsed)),e}const pA=Kd("transactionReceipt",cg),ug="0x5792579257925792579257925792579257925792579257925792579257925792",fg=Z(0,{size:32});async function yA(t,e){const{account:r=t.account,capabilities:n,chain:s=t.chain,experimental_fallback:i,experimental_fallbackDelay:o=32,forceAtomic:a=!1,id:c,version:u="2.0.0"}=e,f=r?Ze(r):null,l=e.calls.map(p=>{const d=p,m=d.abi?Xt({abi:d.abi,functionName:d.functionName,args:d.args}):d.data;return{data:d.dataSuffix&&m?Wt([m,d.dataSuffix]):m,to:d.to,value:d.value?Z(d.value):void 0}});try{const p=await t.request({method:"wallet_sendCalls",params:[{atomicRequired:a,calls:l,capabilities:n,chainId:Z(s.id),from:f==null?void 0:f.address,id:c,version:u}]},{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")||d.details.toLowerCase().includes("feature toggled misconfigured"))){if(n&&Object.values(n).some(P=>!P.optional)){const P="non-optional `capabilities` are not supported on fallback to `eth_sendTransaction`.";throw new $i(new L(P,{details:P}))}if(a&&l.length>1){const S="`forceAtomic` is not supported on fallback to `eth_sendTransaction`.";throw new Ri(new L(S,{details:S}))}const m=[];for(const S of l){const P=Jc(t,{account:f,chain:s,data:S.data,to:S.to,value:S.value?ut(S.value):void 0});m.push(P),o>0&&await new Promise(A=>setTimeout(A,o))}const b=await Promise.allSettled(m);if(b.every(S=>S.status==="rejected"))throw b[0].reason;const E=b.map(S=>S.status==="fulfilled"?S.value:fg);return{id:Wt([...E,Z(s.id,{size:32}),ug])}}throw ig(p,{...e,account:f,chain:e.chain})}}async function lg(t,e){async function r(f){if(f.endsWith(ug.slice(2))){const p=fr(Ol(f,-64,-32)),d=Ol(f,0,-64).slice(2).match(/.{1,64}/g),m=await Promise.all(d.map(E=>fg.slice(2)!==E?t.request({method:"eth_getTransactionReceipt",params:[`0x${E}`]},{dedupe:!0}):void 0)),b=m.some(E=>E===null)?100:m.every(E=>(E==null?void 0:E.status)==="0x1")?200:m.every(E=>(E==null?void 0:E.status)==="0x0")?500:600;return{atomic:!1,chainId:lr(p),receipts:m.filter(Boolean),status:b,version:"2.0.0"}}return t.request({method:"wallet_getCallsStatus",params:[f]})}const{atomic:n=!1,chainId:s,receipts:i,version:o="2.0.0",...a}=await r(e.id),[c,u]=(()=>{const f=a.status;return f>=100&&f<200?["pending",f]:f>=200&&f<300?["success",f]:f>=300&&f<700?["failure",f]:f==="CONFIRMED"?["success",200]:f==="PENDING"?["pending",100]:[void 0,f]})();return{...a,atomic:n,chainId:s?lr(s):void 0,receipts:(i==null?void 0:i.map(f=>({...f,blockNumber:ut(f.blockNumber),gasUsed:ut(f.gasUsed),status:ag[f.status]})))??[],statusCode:u,status:c,version:o}}async function mA(t,e){const{id:r,pollingInterval:n=t.pollingInterval,status:s=({statusCode:b})=>b===200||b>=300,retryCount:i=4,retryDelay:o=({count:b})=>~~(1<<b)*200,timeout:a=6e4,throwOnFailure:c=!1}=e,u=Qe(["waitForCallsStatus",t.uid,r]),{promise:f,resolve:l,reject:p}=lh();let d;const m=Tn(u,{resolve:l,reject:p},b=>{const E=Ki(async()=>{const S=P=>{clearTimeout(d),E(),P(),m()};try{const P=await wc(async()=>{const A=await se(t,lg,"getCallsStatus")({id:r});if(c&&A.status==="failure")throw new hA(A);return A},{retryCount:i,delay:o});if(!s(P))return;S(()=>b.resolve(P))}catch(P){S(()=>b.reject(P))}},{interval:n,emitOnBegin:!0});return E});return d=a?setTimeout(()=>{m(),clearTimeout(d),p(new bA({id:r}))},a):void 0,await f}class bA extends L{constructor({id:e}){super(`Timed out while waiting for call bundle with id "${e}" to be confirmed.`,{name:"WaitForCallsStatusTimeoutError"})}}const Wl=256;let Ma=Wl,Fa;function dg(t=11){if(!Fa||Ma+t>Wl*2){Fa="",Ma=0;for(let e=0;e<Wl;e++)Fa+=(256+Math.random()*256|0).toString(16).substring(1)}return Fa.substring(Ma,Ma+++t)}function hg(t){const{batch:e,chain:r,ccipRead:n,key:s="base",name:i="Base Client",type:o="base"}=t,a=t.experimental_blockTag??(typeof(r==null?void 0:r.experimental_preconfirmationTime)=="number"?"pending":void 0),c=(r==null?void 0:r.blockTime)??12e3,u=Math.min(Math.max(Math.floor(c/2),500),4e3),f=t.pollingInterval??u,l=t.cacheTime??f,p=t.account?Ze(t.account):void 0,{config:d,request:m,value:b}=t.transport({chain:r,pollingInterval:f}),E={...d,...b},S={account:p,batch:e,cacheTime:l,ccipRead:n,chain:r,key:s,name:i,pollingInterval:f,request:m,transport:E,type:o,uid:dg(),...a?{experimental_blockTag:a}:{}};function P(A){return w=>{const k=w(A);for(const B in S)delete k[B];const T={...A,...k};return Object.assign(T,{extend:P(T)})}}return Object.assign(S,{extend:P(S)})}function ph(t){var r,n,s,i,o,a;if(!(t instanceof L))return!1;const e=t.walk(c=>c instanceof $l);return e instanceof $l?((r=e.data)==null?void 0:r.errorName)==="HttpError"||((n=e.data)==null?void 0:n.errorName)==="ResolverError"||((s=e.data)==null?void 0:s.errorName)==="ResolverNotContract"||((i=e.data)==null?void 0:i.errorName)==="ResolverNotFound"||((o=e.data)==null?void 0:o.errorName)==="ReverseAddressMismatch"||((a=e.data)==null?void 0:a.errorName)==="UnsupportedResolverProfile":!1}function gA(t){const{abi:e,data:r}=t,n=Ns(r,0,4),s=e.find(i=>i.type==="function"&&n===ha(Tr(i)));if(!s)throw new uv(n,{docsPath:"/docs/contract/decodeFunctionData"});return{functionName:s.name,args:"inputs"in s&&s.inputs&&s.inputs.length>0?ya(s.inputs,Ns(r,4)):void 0}}const Fu="/docs/contract/encodeErrorResult";function Wp(t){const{abi:e,errorName:r,args:n}=t;let s=e[0];if(r){const c=Zs({abi:e,args:n,name:r});if(!c)throw new vp(r,{docsPath:Fu});s=c}if(s.type!=="error")throw new vp(void 0,{docsPath:Fu});const i=Tr(s),o=ha(i);let a="0x";if(n&&n.length>0){if(!s.inputs)throw new av(s.name,{docsPath:Fu});a=fs(s.inputs,n)}return Cr([o,a])}const ju="/docs/contract/encodeFunctionResult";function wA(t){const{abi:e,functionName:r,result:n}=t;let s=e[0];if(r){const o=Zs({abi:e,name:r});if(!o)throw new Oi(r,{docsPath:ju});s=o}if(s.type!=="function")throw new Oi(void 0,{docsPath:ju});if(!s.outputs)throw new Mm(s.name,{docsPath:ju});const i=(()=>{if(s.outputs.length===0)return[];if(s.outputs.length===1)return[n];if(Array.isArray(n))return n;throw new Fm(n)})();return fs(s.outputs,i)}const Ea="x-batch-gateway:true";async function pg(t){const{data:e,ccipRequest:r}=t,{args:[n]}=gA({abi:Vl,data:e}),s=[],i=[];return await Promise.all(n.map(async(o,a)=>{try{i[a]=o.urls.includes(Ea)?await pg({data:o.data,ccipRequest:r}):await r(o),s[a]=!1}catch(c){s[a]=!0,i[a]=vA(c)}})),wA({abi:Vl,functionName:"query",result:[s,i]})}function vA(t){return t.name==="HttpRequestError"&&t.status?Wp({abi:Vl,errorName:"HttpError",args:[t.status,t.shortMessage]}):Wp({abi:[cb],errorName:"Error",args:["shortMessage"in t?t.shortMessage:t.message]})}function yg(t){if(t.length!==66||t.indexOf("[")!==0||t.indexOf("]")!==65)return null;const e=`0x${t.slice(1,65)}`;return _r(e)?e:null}function Kl(t){let e=new Uint8Array(32).fill(0);if(!t)return et(e);const r=t.split(".");for(let n=r.length-1;n>=0;n-=1){const s=yg(r[n]),i=s?zi(s):ht(_s(r[n]),"bytes");e=ht(Wt([e,i]),"bytes")}return et(e)}function EA(t){return`[${t.slice(2)}]`}function AA(t){const e=new Uint8Array(32).fill(0);return t?yg(t)||ht(_s(t)):et(e)}function yh(t){const e=t.replace(/^\.|\.$/gm,"");if(e.length===0)return new Uint8Array(1);const r=new Uint8Array(_s(e).byteLength+2);let n=0;const s=e.split(".");for(let i=0;i<s.length;i++){let o=_s(s[i]);o.byteLength>255&&(o=_s(EA(AA(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 SA(t,e){const{blockNumber:r,blockTag:n,coinType:s,name:i,gatewayUrls:o,strict:a}=e,{chain:c}=t,u=(()=>{if(e.universalResolverAddress)return e.universalResolverAddress;if(!c)throw new Error("client chain not configured. universalResolverAddress is required.");return Wi({blockNumber:r,chain:c,contract:"ensUniversalResolver"})})(),f=c==null?void 0:c.ensTlds;if(f&&!f.some(p=>i.endsWith(p)))return null;const l=s!=null?[Kl(i),BigInt(s)]:[Kl(i)];try{const p=Xt({abi:Vp,functionName:"addr",args:l}),d={address:u,abi:Zb,functionName:"resolveWithGateways",args:[Bt(yh(i)),p,o??[Ea]],blockNumber:r,blockTag:n},b=await se(t,dr,"readContract")(d);if(b[0]==="0x")return null;const E=Xs({abi:Vp,args:l,functionName:"addr",data:b[0]});return E==="0x"||fr(E)==="0x00"?null:E}catch(p){if(a)throw p;if(ph(p))return null;throw p}}class xA extends L{constructor({data:e}){super("Unable to extract image from metadata. The metadata may be malformed or invalid.",{metaMessages:["- Metadata must be a JSON object with at least an `image`, `image_url` or `image_data` property.","",`Provided data: ${JSON.stringify(e)}`],name:"EnsAvatarInvalidMetadataError"})}}class ro extends L{constructor({reason:e}){super(`ENS NFT avatar URI is invalid. ${e}`,{name:"EnsAvatarInvalidNftUriError"})}}class mh extends L{constructor({uri:e}){super(`Unable to resolve ENS avatar URI "${e}". The URI may be malformed, invalid, or does not respond with a valid image.`,{name:"EnsAvatarUriResolutionError"})}}class kA extends L{constructor({namespace:e}){super(`ENS NFT avatar namespace "${e}" is not supported. Must be "erc721" or "erc1155".`,{name:"EnsAvatarUnsupportedNamespaceError"})}}const TA=/(?<protocol>https?:\/\/[^/]*|ipfs:\/|ipns:\/|ar:\/)?(?<root>\/)?(?<subpath>ipfs\/|ipns\/)?(?<target>[\w\-.]+)(?<subtarget>\/.*)?/,_A=/^(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>\/.*)?$/,PA=/^data:([a-zA-Z\-/+]*);base64,([^"].*)/,IA=/^data:([a-zA-Z\-/+]*)?(;[a-zA-Z0-9].*?)?(,)/;async function OA(t){try{const e=await fetch(t,{method:"HEAD"});if(e.status===200){const r=e.headers.get("content-type");return r==null?void 0:r.startsWith("image/")}return!1}catch(e){return typeof e=="object"&&typeof e.response<"u"||!Object.hasOwn(globalThis,"Image")?!1:new Promise(r=>{const n=new Image;n.onload=()=>{r(!0)},n.onerror=()=>{r(!1)},n.src=t})}}function Kp(t,e){return t?t.endsWith("/")?t.slice(0,-1):t:e}function mg({uri:t,gatewayUrls:e}){const r=PA.test(t);if(r)return{uri:t,isOnChain:!0,isEncoded:r};const n=Kp(e==null?void 0:e.ipfs,"https://ipfs.io"),s=Kp(e==null?void 0:e.arweave,"https://arweave.net"),i=t.match(TA),{protocol:o,subpath:a,target:c,subtarget:u=""}=(i==null?void 0:i.groups)||{},f=o==="ipns:/"||a==="ipns/",l=o==="ipfs:/"||a==="ipfs/"||_A.test(t);if(t.startsWith("http")&&!f&&!l){let d=t;return e!=null&&e.arweave&&(d=t.replace(/https:\/\/arweave.net/g,e==null?void 0:e.arweave)),{uri:d,isOnChain:!1,isEncoded:!1}}if((f||l)&&c)return{uri:`${n}/${f?"ipns":"ipfs"}/${c}${u}`,isOnChain:!1,isEncoded:!1};if(o==="ar:/"&&c)return{uri:`${s}/${c}${u||""}`,isOnChain:!1,isEncoded:!1};let p=t.replace(IA,"");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 mh({uri:t})}function bg(t){if(typeof t!="object"||!("image"in t)&&!("image_url"in t)&&!("image_data"in t))throw new xA({data:t});return t.image||t.image_url||t.image_data}async function BA({gatewayUrls:t,uri:e}){try{const r=await fetch(e).then(s=>s.json());return await bh({gatewayUrls:t,uri:bg(r)})}catch{throw new mh({uri:e})}}async function bh({gatewayUrls:t,uri:e}){const{uri:r,isOnChain:n}=mg({uri:e,gatewayUrls:t});if(n||await OA(r))return r;throw new mh({uri:e})}function CA(t){let e=t;e.startsWith("did:nft:")&&(e=e.replace("did:nft:","").replace(/_/g,"/"));const[r,n,s]=e.split("/"),[i,o]=r.split(":"),[a,c]=n.split(":");if(!i||i.toLowerCase()!=="eip155")throw new ro({reason:"Only EIP-155 supported"});if(!o)throw new ro({reason:"Chain ID not found"});if(!c)throw new ro({reason:"Contract address not found"});if(!s)throw new ro({reason:"Token ID not found"});if(!a)throw new ro({reason:"ERC namespace not found"});return{chainID:Number.parseInt(o,10),namespace:a.toLowerCase(),contractAddress:c,tokenID:s}}async function $A(t,{nft:e}){if(e.namespace==="erc721")return dr(t,{address:e.contractAddress,abi:[{name:"tokenURI",type:"function",stateMutability:"view",inputs:[{name:"tokenId",type:"uint256"}],outputs:[{name:"",type:"string"}]}],functionName:"tokenURI",args:[BigInt(e.tokenID)]});if(e.namespace==="erc1155")return dr(t,{address:e.contractAddress,abi:[{name:"uri",type:"function",stateMutability:"view",inputs:[{name:"_id",type:"uint256"}],outputs:[{name:"",type:"string"}]}],functionName:"uri",args:[BigInt(e.tokenID)]});throw new kA({namespace:e.namespace})}async function RA(t,{gatewayUrls:e,record:r}){return/eip155:/i.test(r)?NA(t,{gatewayUrls:e,record:r}):bh({uri:r,gatewayUrls:e})}async function NA(t,{gatewayUrls:e,record:r}){const n=CA(r),s=await $A(t,{nft:n}),{uri:i,isOnChain:o,isEncoded:a}=mg({uri:s,gatewayUrls:e});if(o&&(i.includes("data:application/json;base64,")||i.startsWith("{"))){const u=a?atob(i.replace("data:application/json;base64,","")):i,f=JSON.parse(u);return bh({uri:bg(f),gatewayUrls:e})}let c=n.tokenID;return n.namespace==="erc1155"&&(c=c.replace("0x","").padStart(64,"0")),BA({gatewayUrls:e,uri:i.replace(/(?:0x)?{id}/,c)})}async function gg(t,e){const{blockNumber:r,blockTag:n,key:s,name:i,gatewayUrls:o,strict:a}=e,{chain:c}=t,u=(()=>{if(e.universalResolverAddress)return e.universalResolverAddress;if(!c)throw new Error("client chain not configured. universalResolverAddress is required.");return Wi({blockNumber:r,chain:c,contract:"ensUniversalResolver"})})(),f=c==null?void 0:c.ensTlds;if(f&&!f.some(l=>i.endsWith(l)))return null;try{const l={address:u,abi:Zb,args:[Bt(yh(i)),Xt({abi:zp,functionName:"text",args:[Kl(i),s]}),o??[Ea]],functionName:"resolveWithGateways",blockNumber:r,blockTag:n},d=await se(t,dr,"readContract")(l);if(d[0]==="0x")return null;const m=Xs({abi:zp,functionName:"text",data:d[0]});return m===""?null:m}catch(l){if(a)throw l;if(ph(l))return null;throw l}}async function UA(t,{blockNumber:e,blockTag:r,assetGatewayUrls:n,name:s,gatewayUrls:i,strict:o,universalResolverAddress:a}){const c=await se(t,gg,"getEnsText")({blockNumber:e,blockTag:r,key:"avatar",name:s,universalResolverAddress:a,gatewayUrls:i,strict:o});if(!c)return null;try{return await RA(t,{record:c,gatewayUrls:n})}catch{return null}}async function MA(t,e){const{address:r,blockNumber:n,blockTag:s,coinType:i=60n,gatewayUrls:o,strict:a}=e,{chain:c}=t,u=(()=>{if(e.universalResolverAddress)return e.universalResolverAddress;if(!c)throw new Error("client chain not configured. universalResolverAddress is required.");return Wi({blockNumber:n,chain:c,contract:"ensUniversalResolver"})})();try{const f={address:u,abi:XE,args:[r,i,o??[Ea]],functionName:"reverseWithGateways",blockNumber:n,blockTag:s},l=se(t,dr,"readContract"),[p]=await l(f);return p||null}catch(f){if(a)throw f;if(ph(f))return null;throw f}}async function FA(t,e){const{blockNumber:r,blockTag:n,name:s}=e,{chain:i}=t,o=(()=>{if(e.universalResolverAddress)return e.universalResolverAddress;if(!i)throw new Error("client chain not configured. universalResolverAddress is required.");return Wi({blockNumber:r,chain:i,contract:"ensUniversalResolver"})})(),a=i==null?void 0:i.ensTlds;if(a&&!a.some(u=>s.endsWith(u)))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(t,dr,"readContract")({address:o,abi:[{inputs:[{type:"bytes"}],name:"findResolver",outputs:[{type:"address"},{type:"bytes32"},{type:"uint256"}],stateMutability:"view",type:"function"}],functionName:"findResolver",args:[Bt(yh(s))],blockNumber:r,blockTag:n});return c}async function wg(t,e){var E,S,P;const{account:r=t.account,blockNumber:n,blockTag:s="latest",blobs:i,data:o,gas:a,gasPrice:c,maxFeePerBlobGas:u,maxFeePerGas:f,maxPriorityFeePerGas:l,to:p,value:d,...m}=e,b=r?Ze(r):void 0;try{Ys(e);const w=(typeof n=="bigint"?Z(n):void 0)||s,k=(P=(S=(E=t.chain)==null?void 0:E.formatters)==null?void 0:S.transactionRequest)==null?void 0:P.format,B=(k||Vi)({...zc(m,{format:k}),from:b==null?void 0:b.address,blobs:i,data:o,gas:a,gasPrice:c,maxFeePerBlobGas:u,maxFeePerGas:f,maxPriorityFeePerGas:l,to:p,value:d}),N=await t.request({method:"eth_createAccessList",params:[B,w]});return{accessList:N.accessList,gasUsed:BigInt(N.gasUsed)}}catch(A){throw Qb(A,{...e,account:b,chain:t.chain})}}async function jA(t){const e=jc(t,{method:"eth_newBlockFilter"}),r=await t.request({method:"eth_newBlockFilter"});return{id:r,request:e(r),type:"block"}}async function vg(t,{address:e,args:r,event:n,events:s,fromBlock:i,strict:o,toBlock:a}={}){const c=s??(n?[n]:void 0),u=jc(t,{method:"eth_newFilter"});let f=[];c&&(f=[c.flatMap(d=>pa({abi:[d],eventName:d.name,args:r}))],n&&(f=f[0]));const l=await t.request({method:"eth_newFilter",params:[{address:e,fromBlock:typeof i=="bigint"?Z(i):i,toBlock:typeof a=="bigint"?Z(a):a,...f.length?{topics:f}:{}}]});return{abi:c,args:r,eventName:n?n.name:void 0,fromBlock:i,id:l,request:u(l),strict:!!o,toBlock:a,type:"event"}}async function Eg(t){const e=jc(t,{method:"eth_newPendingTransactionFilter"}),r=await t.request({method:"eth_newPendingTransactionFilter"});return{id:r,request:e(r),type:"transaction"}}async function LA(t,{address:e,blockNumber:r,blockTag:n=t.experimental_blockTag??"latest"}){const s=typeof r=="bigint"?Z(r):void 0,i=await t.request({method:"eth_getBalance",params:[e,s||n]});return BigInt(i)}async function HA(t){const e=await t.request({method:"eth_blobBaseFee"});return BigInt(e)}async function DA(t,{blockHash:e,blockNumber:r,blockTag:n="latest"}={}){const s=r!==void 0?Z(r):void 0;let i;return e?i=await t.request({method:"eth_getBlockTransactionCountByHash",params:[e]},{dedupe:!0}):i=await t.request({method:"eth_getBlockTransactionCountByNumber",params:[s||n]},{dedupe:!!s}),lr(i)}async function Zl(t,{address:e,blockNumber:r,blockTag:n="latest"}){const s=r!==void 0?Z(r):void 0,i=await t.request({method:"eth_getCode",params:[e,s||n]},{dedupe:!!s});if(i!=="0x")return i}class zA extends L{constructor({address:e}){super(`No EIP-712 domain found on contract "${e}".`,{metaMessages:["Ensure that:",`- The contract is deployed at the address "${e}".`,"- `eip712Domain()` function exists on the contract.","- `eip712Domain()` function matches signature to ERC-5267 specification."],name:"Eip712DomainNotFoundError"})}}async function VA(t,e){const{address:r,factory:n,factoryData:s}=e;try{const[i,o,a,c,u,f,l]=await se(t,dr,"readContract")({abi:qA,address:r,functionName:"eip712Domain",factory:n,factoryData:s});return{domain:{name:o,version:a,chainId:Number(c),verifyingContract:u,salt:f},extensions:l,fields:i}}catch(i){const o=i;throw o.name==="ContractFunctionExecutionError"&&o.cause.name==="ContractFunctionZeroDataError"?new zA({address:r}):o}}const qA=[{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 GA(t){var e;return{baseFeePerGas:t.baseFeePerGas.map(r=>BigInt(r)),gasUsedRatio:t.gasUsedRatio,oldestBlock:BigInt(t.oldestBlock),reward:(e=t.reward)==null?void 0:e.map(r=>r.map(n=>BigInt(n)))}}async function WA(t,{blockCount:e,blockNumber:r,blockTag:n="latest",rewardPercentiles:s}){const i=typeof r=="bigint"?Z(r):void 0,o=await t.request({method:"eth_feeHistory",params:[Z(e),i||n,s]},{dedupe:!!i});return GA(o)}async function KA(t,{filter:e}){const r=e.strict??!1,s=(await e.request({method:"eth_getFilterLogs",params:[e.id]})).map(i=>kn(i));return e.abi?oh({abi:e.abi,logs:s,strict:r}):s}function ZA(t){const{authorizationList:e}=t;if(e)for(const r of e){const{chainId:n}=r,s=r.address;if(!at(s))throw new $t({address:s});if(n<0)throw new Kc({chainId:n})}gh(t)}function YA(t){const{blobVersionedHashes:e}=t;if(e){if(e.length===0)throw new Bb;for(const r of e){const n=De(r),s=lr(Ns(r,0,1));if(n!==32)throw new gE({hash:r,size:n});if(s!==Ob)throw new wE({hash:r,version:s})}}gh(t)}function gh(t){const{chainId:e,maxPriorityFeePerGas:r,maxFeePerGas:n,to:s}=t;if(e<=0)throw new Kc({chainId:e});if(s&&!at(s))throw new $t({address:s});if(n&&n>Vc)throw new js({maxFeePerGas:n});if(r&&n&&r>n)throw new Zo({maxFeePerGas:n,maxPriorityFeePerGas:r})}function XA(t){const{chainId:e,maxPriorityFeePerGas:r,gasPrice:n,maxFeePerGas:s,to:i}=t;if(e<=0)throw new Kc({chainId:e});if(i&&!at(i))throw new $t({address:i});if(r||s)throw new L("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid EIP-2930 Transaction attribute.");if(n&&n>Vc)throw new js({maxFeePerGas:n})}function JA(t){const{chainId:e,maxPriorityFeePerGas:r,gasPrice:n,maxFeePerGas:s,to:i}=t;if(i&&!at(i))throw new $t({address:i});if(typeof e<"u"&&e<=0)throw new Kc({chainId:e});if(r||s)throw new L("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid Legacy Transaction attribute.");if(n&&n>Vc)throw new js({maxFeePerGas:n})}function Qc(t){if(!t||t.length===0)return[];const e=[];for(let r=0;r<t.length;r++){const{address:n,storageKeys:s}=t[r];for(let i=0;i<s.length;i++)if(s[i].length-2!==64)throw new N5({storageKey:s[i]});if(!at(n,{strict:!1}))throw new $t({address:n});e.push([n,s])}return e}function QA(t,e){const r=$b(t);return r==="eip1559"?r8(t,e):r==="eip2930"?n8(t,e):r==="eip4844"?t8(t,e):r==="eip7702"?e8(t,e):s8(t,e)}function e8(t,e){const{authorizationList:r,chainId:n,gas:s,nonce:i,to:o,value:a,maxFeePerGas:c,maxPriorityFeePerGas:u,accessList:f,data:l}=t;ZA(t);const p=Qc(f),d=i8(r);return Cr(["0x04",as([Z(n),i?Z(i):"0x",u?Z(u):"0x",c?Z(c):"0x",s?Z(s):"0x",o??"0x",a?Z(a):"0x",l??"0x",p,d,...Aa(t,e)])])}function t8(t,e){const{chainId:r,gas:n,nonce:s,to:i,value:o,maxFeePerBlobGas:a,maxFeePerGas:c,maxPriorityFeePerGas:u,accessList:f,data:l}=t;YA(t);let p=t.blobVersionedHashes,d=t.sidecars;if(t.blobs&&(typeof p>"u"||typeof d>"u")){const A=typeof t.blobs[0]=="string"?t.blobs:t.blobs.map(T=>et(T)),w=t.kzg,k=eh({blobs:A,kzg:w});if(typeof p>"u"&&(p=_b({commitments:k})),typeof d>"u"){const T=th({blobs:A,commitments:k,kzg:w});d=Cb({blobs:A,commitments:k,proofs:T})}}const m=Qc(f),b=[Z(r),s?Z(s):"0x",u?Z(u):"0x",c?Z(c):"0x",n?Z(n):"0x",i??"0x",o?Z(o):"0x",l??"0x",m,a?Z(a):"0x",p??[],...Aa(t,e)],E=[],S=[],P=[];if(d)for(let A=0;A<d.length;A++){const{blob:w,commitment:k,proof:T}=d[A];E.push(w),S.push(k),P.push(T)}return Cr(["0x03",as(d?[b,E,S,P]:b)])}function r8(t,e){const{chainId:r,gas:n,nonce:s,to:i,value:o,maxFeePerGas:a,maxPriorityFeePerGas:c,accessList:u,data:f}=t;gh(t);const l=Qc(u),p=[Z(r),s?Z(s):"0x",c?Z(c):"0x",a?Z(a):"0x",n?Z(n):"0x",i??"0x",o?Z(o):"0x",f??"0x",l,...Aa(t,e)];return Cr(["0x02",as(p)])}function n8(t,e){const{chainId:r,gas:n,data:s,nonce:i,to:o,value:a,accessList:c,gasPrice:u}=t;XA(t);const f=Qc(c),l=[Z(r),i?Z(i):"0x",u?Z(u):"0x",n?Z(n):"0x",o??"0x",a?Z(a):"0x",s??"0x",f,...Aa(t,e)];return Cr(["0x01",as(l)])}function s8(t,e){const{chainId:r=0,gas:n,data:s,nonce:i,to:o,value:a,gasPrice:c}=t;JA(t);let u=[i?Z(i):"0x",c?Z(c):"0x",n?Z(n):"0x",o??"0x",a?Z(a):"0x",s??"0x"];if(e){const f=(()=>{if(e.v>=35n)return(e.v-35n)/2n>0?e.v:27n+(e.v===35n?0n:1n);if(r>0)return BigInt(r*2)+BigInt(35n+e.v-27n);const d=27n+(e.v===27n?0n:1n);if(e.v!==d)throw new $5({v:e.v});return d})(),l=fr(e.r),p=fr(e.s);u=[...u,Z(f),l==="0x00"?"0x":l,p==="0x00"?"0x":p]}else r>0&&(u=[...u,Z(r),"0x","0x"]);return as(u)}function Aa(t,e){const r=e??t,{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=fr(r.r),o=fr(r.s);return[typeof s=="number"?s?Z(1):"0x":n===0n?"0x":n===1n?Z(1):n===27n?"0x":Z(1),i==="0x00"?"0x":i,o==="0x00"?"0x":o]}function i8(t){if(!t||t.length===0)return[];const e=[];for(const r of t){const{chainId:n,nonce:s,...i}=r,o=r.address;e.push([n?Bt(n):"0x",o,s?Bt(s):"0x",...Aa({},i)])}return e}async function o8({address:t,authorization:e,signature:r}){return Gi(jd(t),await Wd({authorization:e,signature:r}))}const ja=new Fc(8192);function a8(t,{enabled:e=!0,id:r}){if(!e||!r)return t();if(ja.get(r))return ja.get(r);const n=t().finally(()=>ja.delete(r));return ja.set(r,n),n}function c8(t,e={}){return async(r,n={})=>{var l;const{dedupe:s=!1,methods:i,retryDelay:o=150,retryCount:a=3,uid:c}={...e,...n},{method:u}=r;if((l=i==null?void 0:i.exclude)!=null&&l.includes(u))throw new vs(new Error("method not supported"),{method:u});if(i!=null&&i.include&&!i.include.includes(u))throw new vs(new Error("method not supported"),{method:u});const f=s?Bi(`${c}.${Qe(r)}`):void 0;return a8(()=>wc(async()=>{try{return await t(r)}catch(p){const d=p;switch(d.code){case Bo.code:throw new Bo(d);case Co.code:throw new Co(d);case $o.code:throw new $o(d,{method:r.method});case Ro.code:throw new Ro(d);case Us.code:throw new Us(d);case Ms.code:throw new Ms(d);case No.code:throw new No(d);case Uo.code:throw new Uo(d);case Mo.code:throw new Mo(d);case vs.code:throw new vs(d,{method:r.method});case Ci.code:throw new Ci(d);case Fo.code:throw new Fo(d);case Ei.code:throw new Ei(d);case jo.code:throw new jo(d);case Lo.code:throw new Lo(d);case Ho.code:throw new Ho(d);case Do.code:throw new Do(d);case zo.code:throw new zo(d);case $i.code:throw new $i(d);case Vo.code:throw new Vo(d);case qo.code:throw new qo(d);case Go.code:throw new Go(d);case Wo.code:throw new Wo(d);case Ko.code:throw new Ko(d);case Ri.code:throw new Ri(d);case 5e3:throw new Ei(d);default:throw p instanceof L?p:new D5(d)}}},{delay:({count:p,error:d})=>{var m;if(d&&d instanceof vi){const b=(m=d==null?void 0:d.headers)==null?void 0:m.get("Retry-After");if(b!=null&&b.match(/\d/))return Number.parseInt(b,10)*1e3}return~~(1<<p)*o},retryCount:a,shouldRetry:({error:p})=>u8(p)}),{enabled:s,id:f})}}function u8(t){return"code"in t&&typeof t.code=="number"?t.code===-1||t.code===Ci.code||t.code===Us.code:t instanceof vi&&t.status?t.status===403||t.status===408||t.status===413||t.status===429||t.status===500||t.status===502||t.status===503||t.status===504:!0}function yt(t){return{formatters:void 0,fees:void 0,serializers:void 0,...t}}const f8=Uint8Array.from([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),Ag=Uint8Array.from(new Array(16).fill(0).map((t,e)=>e)),l8=Ag.map(t=>(9*t+5)%16),Sg=(()=>{const r=[[Ag],[l8]];for(let n=0;n<4;n++)for(let s of r)s.push(s[n].map(i=>f8[i]));return r})(),xg=Sg[0],kg=Sg[1],Tg=[[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(t=>Uint8Array.from(t)),d8=xg.map((t,e)=>t.map(r=>Tg[e][r])),h8=kg.map((t,e)=>t.map(r=>Tg[e][r])),p8=Uint32Array.from([0,1518500249,1859775393,2400959708,2840853838]),y8=Uint32Array.from([1352829926,1548603684,1836072691,2053994217,0]);function Zp(t,e,r,n){return t===0?e^r^n:t===1?e&r|~e&n:t===2?(e|~r)^n:t===3?e&n|r&~n:e^(r|~n)}const La=new Uint32Array(16);let _g=class extends Sb{constructor(){super(64,20,8,!0),this.h0=1732584193,this.h1=-271733879,this.h2=-1732584194,this.h3=271733878,this.h4=-1009589776}get(){const{h0:e,h1:r,h2:n,h3:s,h4:i}=this;return[e,r,n,s,i]}set(e,r,n,s,i){this.h0=e|0,this.h1=r|0,this.h2=n|0,this.h3=s|0,this.h4=i|0}process(e,r){for(let d=0;d<16;d++,r+=4)La[d]=e.getUint32(r,!0);let n=this.h0|0,s=n,i=this.h1|0,o=i,a=this.h2|0,c=a,u=this.h3|0,f=u,l=this.h4|0,p=l;for(let d=0;d<5;d++){const m=4-d,b=p8[d],E=y8[d],S=xg[d],P=kg[d],A=d8[d],w=h8[d];for(let k=0;k<16;k++){const T=Na(n+Zp(d,i,a,u)+La[S[k]]+b,A[k])+l|0;n=l,l=u,u=Na(a,10)|0,a=i,i=T}for(let k=0;k<16;k++){const T=Na(s+Zp(m,o,c,f)+La[P[k]]+E,w[k])+p|0;s=p,p=f,f=Na(c,10)|0,c=o,o=T}}this.set(this.h1+a+f|0,this.h2+u+p|0,this.h3+l+s|0,this.h4+n+o|0,this.h0+i+c|0)}roundClean(){Pr(La)}destroy(){this.destroyed=!0,Pr(this.buffer),this.set(0,0,0,0,0)}};const m8=Uc(()=>new _g),b8=_g,g8=m8,w8=Object.freeze(Object.defineProperty({__proto__:null,RIPEMD160:b8,ripemd160:g8},Symbol.toStringTag,{value:"Module"}));function v8(t,{errorInstance:e=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 t({signal:(a==null?void 0:a.signal)||null}))}catch(a){(a==null?void 0:a.name)==="AbortError"&&i(e),i(a)}finally{clearTimeout(o)}})()})}function E8(){return{current:0,take(){return this.current++},reset(){this.current=0}}}const Yp=E8();function A8(t,e={}){return{async request(r){var p;const{body:n,fetchFn:s=e.fetchFn??fetch,onRequest:i=e.onRequest,onResponse:o=e.onResponse,timeout:a=e.timeout??1e4}=r,c={...e.fetchOptions??{},...r.fetchOptions??{}},{headers:u,method:f,signal:l}=c;try{const d=await v8(async({signal:b})=>{const E={...c,body:Array.isArray(n)?Qe(n.map(w=>({jsonrpc:"2.0",id:w.id??Yp.take(),...w}))):Qe({jsonrpc:"2.0",id:n.id??Yp.take(),...n}),headers:{"Content-Type":"application/json",...u},method:f||"POST",signal:l||(a>0?b:null)},S=new Request(t,E),P=await(i==null?void 0:i(S,E))??{...E,url:t};return await s(P.url??t,P)},{errorInstance:new $p({body:n,url:t}),timeout:a,signal:!0});o&&await o(d);let m;if((p=d.headers.get("Content-Type"))!=null&&p.startsWith("application/json"))m=await d.json();else{m=await d.text();try{m=JSON.parse(m||"{}")}catch(b){if(d.ok)throw b;m={error:m}}}if(!d.ok)throw new vi({body:n,details:Qe(m.error)||d.statusText,headers:d.headers,status:d.status,url:t});return m}catch(d){throw d instanceof vi||d instanceof $p?d:new vi({body:n,cause:d,url:t})}}}}const S8=`Ethereum Signed Message:
|
|
43
43
|
`;function x8(t){const e=typeof t=="string"?Bi(t):typeof t.raw=="string"?t.raw:et(t.raw),r=Bi(`${S8}${De(e)}`);return Wt([r,e])}function Pg(t,e){return ht(x8(t),e)}class k8 extends L{constructor({domain:e}){super(`Invalid domain "${Qe(e)}".`,{metaMessages:["Must be a valid EIP-712 domain."]})}}class T8 extends L{constructor({primaryType:e,types:r}){super(`Invalid primary type \`${e}\` 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 _8 extends L{constructor({type:e}){super(`Struct type "${e}" is invalid.`,{metaMessages:["Struct type must not be a Solidity type."],name:"InvalidStructTypeError"})}}function P8(t){const{domain:e,message:r,primaryType:n,types:s}=t,i=(c,u)=>{const f={...u};for(const l of c){const{name:p,type:d}=l;d==="address"&&(f[p]=f[p].toLowerCase())}return f},o=s.EIP712Domain?e?i(s.EIP712Domain,e):{}:{},a=(()=>{if(n!=="EIP712Domain")return i(s[n],r)})();return Qe({domain:o,message:a,primaryType:n,types:s})}function Ig(t){const{domain:e,message:r,primaryType:n,types:s}=t,i=(o,a)=>{for(const c of o){const{name:u,type:f}=c,l=a[u],p=f.match(ob);if(p&&(typeof l=="number"||typeof l=="bigint")){const[b,E,S]=p;Z(l,{signed:E==="int",size:Number.parseInt(S,10)/8})}if(f==="address"&&typeof l=="string"&&!at(l))throw new $t({address:l});const d=f.match(n5);if(d){const[b,E]=d;if(E&&De(l)!==Number.parseInt(E,10))throw new lv({expectedSize:Number.parseInt(E,10),givenSize:De(l)})}const m=s[f];m&&(I8(f),i(m,l))}};if(s.EIP712Domain&&e){if(typeof e!="object")throw new k8({domain:e});i(s.EIP712Domain,e)}if(n!=="EIP712Domain")if(s[n])i(s[n],r);else throw new T8({primaryType:n,types:s})}function Og({domain:t}){return[typeof(t==null?void 0:t.name)=="string"&&{name:"name",type:"string"},(t==null?void 0:t.version)&&{name:"version",type:"string"},(typeof(t==null?void 0:t.chainId)=="number"||typeof(t==null?void 0:t.chainId)=="bigint")&&{name:"chainId",type:"uint256"},(t==null?void 0:t.verifyingContract)&&{name:"verifyingContract",type:"address"},(t==null?void 0:t.salt)&&{name:"salt",type:"bytes32"}].filter(Boolean)}function I8(t){if(t==="address"||t==="bool"||t==="string"||t.startsWith("bytes")||t.startsWith("uint")||t.startsWith("int"))throw new _8({type:t})}function O8(t){const{domain:e={},message:r,primaryType:n}=t,s={EIP712Domain:Og({domain:e}),...t.types};Ig({domain:e,message:r,primaryType:n,types:s});const i=["0x1901"];return e&&i.push(B8({domain:e,types:s})),n!=="EIP712Domain"&&i.push(Bg({data:r,primaryType:n,types:s})),ht(Wt(i))}function B8({domain:t,types:e}){return Bg({data:t,primaryType:"EIP712Domain",types:e})}function Bg({data:t,primaryType:e,types:r}){const n=Cg({data:t,primaryType:e,types:r});return ht(n)}function Cg({data:t,primaryType:e,types:r}){const n=[{type:"bytes32"}],s=[C8({primaryType:e,types:r})];for(const i of r[e]){const[o,a]=Rg({types:r,name:i.name,type:i.type,value:t[i.name]});n.push(o),s.push(a)}return fs(n,s)}function C8({primaryType:t,types:e}){const r=Bt($8({primaryType:t,types:e}));return ht(r)}function $8({primaryType:t,types:e}){let r="";const n=$g({primaryType:t,types:e});n.delete(t);const s=[t,...Array.from(n).sort()];for(const i of s)r+=`${i}(${e[i].map(({name:o,type:a})=>`${a} ${o}`).join(",")})`;return r}function $g({primaryType:t,types:e},r=new Set){const n=t.match(/^\w*/u),s=n==null?void 0:n[0];if(r.has(s)||e[s]===void 0)return r;r.add(s);for(const i of e[s])$g({primaryType:i.type,types:e},r);return r}function Rg({types:t,name:e,type:r,value:n}){if(t[r]!==void 0)return[{type:"bytes32"},ht(Cg({data:n,primaryType:r,types:t}))];if(r==="bytes")return n=`0x${(n.length%2?"0":"")+n.slice(2)}`,[{type:"bytes32"},ht(n)];if(r==="string")return[{type:"bytes32"},ht(Bt(n))];if(r.lastIndexOf("]")===r.length-1){const s=r.slice(0,r.lastIndexOf("[")),i=n.map(o=>Rg({name:e,type:s,types:t,value:o}));return[{type:"bytes32"},ht(fs(i.map(([o])=>o),i.map(([,o])=>o)))]}return[{type:r},n]}const R8="1.1.1";class pt extends Error{constructor(e,r={}){var o;const n=r.cause instanceof pt?r.cause.details:(o=r.cause)!=null&&o.message?r.cause.message:r.details,s=r.cause instanceof pt&&r.cause.docsPath||r.docsPath,i=[e||"An error occurred.","",...r.metaMessages?[...r.metaMessages,""]:[],...s?[`Docs: https://abitype.dev${s}`]:[],...n?[`Details: ${n}`]:[],`Version: abitype@${R8}`].join(`
|
|
44
44
|
`);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=e}}function $n(t,e){const r=t.exec(e);return r==null?void 0:r.groups}const Ng=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,Ug=/^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)?$/,Mg=/^\(.+?\).*?$/,Xp=/^tuple(?<array>(\[(\d*)\])*)$/;function Yl(t){let e=t.type;if(Xp.test(t.type)&&"components"in t){e="(";const r=t.components.length;for(let s=0;s<r;s++){const i=t.components[s];e+=Yl(i),s<r-1&&(e+=", ")}const n=$n(Xp,t.type);return e+=`)${(n==null?void 0:n.array)??""}`,Yl({...t,type:e})}return"indexed"in t&&t.indexed&&(e=`${e} indexed`),t.name?`${e} ${t.name}`:e}function ci(t){let e="";const r=t.length;for(let n=0;n<r;n++){const s=t[n];e+=Yl(s),n!==r-1&&(e+=", ")}return e}function Xl(t){var e;return t.type==="function"?`function ${t.name}(${ci(t.inputs)})${t.stateMutability&&t.stateMutability!=="nonpayable"?` ${t.stateMutability}`:""}${(e=t.outputs)!=null&&e.length?` returns (${ci(t.outputs)})`:""}`:t.type==="event"?`event ${t.name}(${ci(t.inputs)})`:t.type==="error"?`error ${t.name}(${ci(t.inputs)})`:t.type==="constructor"?`constructor(${ci(t.inputs)})${t.stateMutability==="payable"?" payable":""}`:t.type==="fallback"?`fallback() external${t.stateMutability==="payable"?" payable":""}`:"receive() external payable"}const Fg=/^error (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/;function N8(t){return Fg.test(t)}function U8(t){return $n(Fg,t)}const jg=/^event (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/;function M8(t){return jg.test(t)}function F8(t){return $n(jg,t)}const Lg=/^function (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)(?: (?<scope>external|public{1}))?(?: (?<stateMutability>pure|view|nonpayable|payable{1}))?(?: returns\s?\((?<returns>.*?)\))?$/;function j8(t){return Lg.test(t)}function L8(t){return $n(Lg,t)}const Hg=/^struct (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*) \{(?<properties>.*?)\}$/;function wh(t){return Hg.test(t)}function H8(t){return $n(Hg,t)}const Dg=/^constructor\((?<parameters>.*?)\)(?:\s(?<stateMutability>payable{1}))?$/;function D8(t){return Dg.test(t)}function z8(t){return $n(Dg,t)}const zg=/^fallback\(\) external(?:\s(?<stateMutability>payable{1}))?$/;function V8(t){return zg.test(t)}function q8(t){return $n(zg,t)}const G8=/^receive\(\) external payable$/;function W8(t){return G8.test(t)}const Jp=new Set(["memory","indexed","storage","calldata"]),K8=new Set(["indexed"]),Jl=new Set(["calldata","memory","storage"]);class Z8 extends pt{constructor({signature:e}){super("Failed to parse ABI item.",{details:`parseAbiItem(${JSON.stringify(e,null,2)})`,docsPath:"/api/human#parseabiitem-1"}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidAbiItemError"})}}class Y8 extends pt{constructor({type:e}){super("Unknown type.",{metaMessages:[`Type "${e}" is not a valid ABI type. Perhaps you forgot to include a struct signature?`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownTypeError"})}}class X8 extends pt{constructor({type:e}){super("Unknown type.",{metaMessages:[`Type "${e}" is not a valid ABI type.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownSolidityTypeError"})}}class J8 extends pt{constructor({params:e}){super("Failed to parse ABI parameters.",{details:`parseAbiParameters(${JSON.stringify(e,null,2)})`,docsPath:"/api/human#parseabiparameters-1"}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidAbiParametersError"})}}class Q8 extends pt{constructor({param:e}){super("Invalid ABI parameter.",{details:e}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidParameterError"})}}class eS extends pt{constructor({param:e,name:r}){super("Invalid ABI parameter.",{details:e,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 tS extends pt{constructor({param:e,type:r,modifier:n}){super("Invalid ABI parameter.",{details:e,metaMessages:[`Modifier "${n}" not allowed${r?` in "${r}" type`:""}.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidModifierError"})}}class rS extends pt{constructor({param:e,type:r,modifier:n}){super("Invalid ABI parameter.",{details:e,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 nS extends pt{constructor({abiParameter:e}){super("Invalid ABI parameter.",{details:JSON.stringify(e,null,2),metaMessages:["ABI parameter type is invalid."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidAbiTypeParameterError"})}}class Zi extends pt{constructor({signature:e,type:r}){super(`Invalid ${r} signature.`,{details:e}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidSignatureError"})}}class sS extends pt{constructor({signature:e}){super("Unknown signature.",{details:e}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownSignatureError"})}}class iS extends pt{constructor({signature:e}){super("Invalid struct signature.",{details:e,metaMessages:["No properties exist."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidStructSignatureError"})}}class oS extends pt{constructor({type:e}){super("Circular reference detected.",{metaMessages:[`Struct "${e}" is a circular reference.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"CircularReferenceError"})}}class aS extends pt{constructor({current:e,depth:r}){super("Unbalanced parentheses.",{metaMessages:[`"${e.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 cS(t,e,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 e?`${e}:${t}${n}`:t}const Lu=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 Qp(t,e={}){if(j8(t))return uS(t,e);if(M8(t))return fS(t,e);if(N8(t))return lS(t,e);if(D8(t))return dS(t,e);if(V8(t))return hS(t);if(W8(t))return{type:"receive",stateMutability:"payable"};throw new sS({signature:t})}function uS(t,e={}){const r=L8(t);if(!r)throw new Zi({signature:t,type:"function"});const n=Vt(r.parameters),s=[],i=n.length;for(let a=0;a<i;a++)s.push(_n(n[a],{modifiers:Jl,structs:e,type:"function"}));const o=[];if(r.returns){const a=Vt(r.returns),c=a.length;for(let u=0;u<c;u++)o.push(_n(a[u],{modifiers:Jl,structs:e,type:"function"}))}return{name:r.name,type:"function",stateMutability:r.stateMutability??"nonpayable",inputs:s,outputs:o}}function fS(t,e={}){const r=F8(t);if(!r)throw new Zi({signature:t,type:"event"});const n=Vt(r.parameters),s=[],i=n.length;for(let o=0;o<i;o++)s.push(_n(n[o],{modifiers:K8,structs:e,type:"event"}));return{name:r.name,type:"event",inputs:s}}function lS(t,e={}){const r=U8(t);if(!r)throw new Zi({signature:t,type:"error"});const n=Vt(r.parameters),s=[],i=n.length;for(let o=0;o<i;o++)s.push(_n(n[o],{structs:e,type:"error"}));return{name:r.name,type:"error",inputs:s}}function dS(t,e={}){const r=z8(t);if(!r)throw new Zi({signature:t,type:"constructor"});const n=Vt(r.parameters),s=[],i=n.length;for(let o=0;o<i;o++)s.push(_n(n[o],{structs:e,type:"constructor"}));return{type:"constructor",stateMutability:r.stateMutability??"nonpayable",inputs:s}}function hS(t){const e=q8(t);if(!e)throw new Zi({signature:t,type:"fallback"});return{type:"fallback",stateMutability:e.stateMutability??"nonpayable"}}const pS=/^(?<type>[a-zA-Z$_][a-zA-Z0-9$_]*(?:\spayable)?)(?<array>(?:\[\d*?\])+?)?(?:\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\s(?<name>[a-zA-Z$_][a-zA-Z0-9$_]*))?$/,yS=/^\((?<type>.+?)\)(?<array>(?:\[\d*?\])+?)?(?:\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\s(?<name>[a-zA-Z$_][a-zA-Z0-9$_]*))?$/,mS=/^u?int$/;function _n(t,e){var l,p;const r=cS(t,e==null?void 0:e.type,e==null?void 0:e.structs);if(Lu.has(r))return Lu.get(r);const n=Mg.test(t),s=$n(n?yS:pS,t);if(!s)throw new Q8({param:t});if(s.name&&gS(s.name))throw new eS({param:t,name:s.name});const i=s.name?{name:s.name}:{},o=s.modifier==="indexed"?{indexed:!0}:{},a=(e==null?void 0:e.structs)??{};let c,u={};if(n){c="tuple";const d=Vt(s.type),m=[],b=d.length;for(let E=0;E<b;E++)m.push(_n(d[E],{structs:a}));u={components:m}}else if(s.type in a)c="tuple",u={components:a[s.type]};else if(mS.test(s.type))c=`${s.type}256`;else if(s.type==="address payable")c="address";else if(c=s.type,(e==null?void 0:e.type)!=="struct"&&!Vg(c))throw new X8({type:c});if(s.modifier){if(!((p=(l=e==null?void 0:e.modifiers)==null?void 0:l.has)!=null&&p.call(l,s.modifier)))throw new tS({param:t,type:e==null?void 0:e.type,modifier:s.modifier});if(Jl.has(s.modifier)&&!wS(c,!!s.array))throw new rS({param:t,type:e==null?void 0:e.type,modifier:s.modifier})}const f={type:`${c}${s.array??""}`,...i,...o,...u};return Lu.set(r,f),f}function Vt(t,e=[],r="",n=0){const s=t.trim().length;for(let i=0;i<s;i++){const o=t[i],a=t.slice(i+1);switch(o){case",":return n===0?Vt(a,[...e,r.trim()]):Vt(a,e,`${r}${o}`,n);case"(":return Vt(a,e,`${r}${o}`,n+1);case")":return Vt(a,e,`${r}${o}`,n-1);default:return Vt(a,e,`${r}${o}`,n)}}if(r==="")return e;if(n!==0)throw new aS({current:r,depth:n});return e.push(r.trim()),e}function Vg(t){return t==="address"||t==="bool"||t==="function"||t==="string"||Ng.test(t)||Ug.test(t)}const bS=/^(?: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 gS(t){return t==="address"||t==="bool"||t==="function"||t==="string"||t==="tuple"||Ng.test(t)||Ug.test(t)||bS.test(t)}function wS(t,e){return e||t==="bytes"||t==="string"||t==="tuple"}function qg(t){const e={},r=t.length;for(let o=0;o<r;o++){const a=t[o];if(!wh(a))continue;const c=H8(a);if(!c)throw new Zi({signature:a,type:"struct"});const u=c.properties.split(";"),f=[],l=u.length;for(let p=0;p<l;p++){const m=u[p].trim();if(!m)continue;const b=_n(m,{type:"struct"});f.push(b)}if(!f.length)throw new iS({signature:a});e[c.name]=f}const n={},s=Object.entries(e),i=s.length;for(let o=0;o<i;o++){const[a,c]=s[o];n[a]=Gg(c,e)}return n}const vS=/^(?<type>[a-zA-Z$_][a-zA-Z0-9$_]*)(?<array>(?:\[\d*?\])+?)?$/;function Gg(t,e,r=new Set){const n=[],s=t.length;for(let i=0;i<s;i++){const o=t[i];if(Mg.test(o.type))n.push(o);else{const c=$n(vS,o.type);if(!(c!=null&&c.type))throw new nS({abiParameter:o});const{array:u,type:f}=c;if(f in e){if(r.has(f))throw new oS({type:f});n.push({...o,type:`tuple${u??""}`,components:Gg(e[f]??[],e,new Set([...r,f]))})}else if(Vg(f))n.push(o);else throw new Y8({type:f})}}return n}function e0(t){let e;if(typeof t=="string")e=Qp(t);else{const r=qg(t),n=t.length;for(let s=0;s<n;s++){const i=t[s];if(!wh(i)){e=Qp(i,r);break}}}if(!e)throw new Z8({signature:t});return e}function t0(t){const e=[];if(typeof t=="string"){const r=Vt(t),n=r.length;for(let s=0;s<n;s++)e.push(_n(r[s],{modifiers:Jp}))}else{const r=qg(t),n=t.length;for(let s=0;s<n;s++){const i=t[s];if(wh(i))continue;const o=Vt(i),a=o.length;for(let c=0;c<a;c++)e.push(_n(o[c],{modifiers:Jp,structs:r}))}}if(e.length===0)throw new J8({params:t});return e}class ES extends Map{constructor(e){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=e}get(e){const r=super.get(e);return super.has(e)&&r!==void 0&&(this.delete(e),super.set(e,r)),r}set(e,r){if(super.set(e,r),this.maxSize&&this.size>this.maxSize){const n=this.keys().next().value;n&&this.delete(n)}return this}}const AS={checksum:new ES(8192)},Hu=AS.checksum;function Wg(t,e={}){const{as:r=typeof t=="string"?"Hex":"Bytes"}=e,n=tb(BE(t));return r==="Bytes"?n:Or(n)}const SS=/^0x[a-fA-F0-9]{40}$/;function eu(t,e={}){const{strict:r=!0}=e;if(!SS.test(t))throw new r0({address:t,cause:new xS});if(r){if(t.toLowerCase()===t)return;if(Kg(t)!==t)throw new r0({address:t,cause:new kS})}}function Kg(t){if(Hu.has(t))return Hu.get(t);eu(t,{strict:!1});const e=t.substring(2).toLowerCase(),r=Wg($E(e),{as:"Bytes"}),n=e.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 Hu.set(t,s),s}function Ql(t,e={}){const{strict:r=!0}=e??{};try{return eu(t,{strict:r}),!0}catch{return!1}}class r0 extends ve{constructor({address:e,cause:r}){super(`Address "${e}" is invalid.`,{cause:r}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidAddressError"})}}class xS extends ve{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 kS extends ve{constructor(){super("Address does not match its checksum counterpart."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidChecksumError"})}}const TS=/^(.*)\[([0-9]*)\]$/,_S=/^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)?$/,n0=2n**256n-1n;function Ai(t,e,r){const{checksumAddress:n,staticPosition:s}=r,i=Ah(e.type);if(i){const[o,a]=i;return IS(t,{...e,type:a},{checksumAddress:n,length:o,staticPosition:s})}if(e.type==="tuple")return $S(t,e,{checksumAddress:n,staticPosition:s});if(e.type==="address")return PS(t,{checksum:n});if(e.type==="bool")return OS(t);if(e.type.startsWith("bytes"))return BS(t,e,{staticPosition:s});if(e.type.startsWith("uint")||e.type.startsWith("int"))return CS(t,e);if(e.type==="string")return RS(t,{staticPosition:s});throw new xh(e.type)}const s0=32,ed=32;function PS(t,e={}){const{checksum:r=!1}=e,n=t.readBytes(32);return[(i=>r?Kg(i):i)(Or(NE(n,-20))),32]}function IS(t,e,r){const{checksumAddress:n,length:s,staticPosition:i}=r;if(!s){const c=Sn(t.readBytes(ed)),u=i+c,f=u+s0;t.setPosition(u);const l=Sn(t.readBytes(s0)),p=Yo(e);let d=0;const m=[];for(let b=0;b<l;++b){t.setPosition(f+(p?b*32:d));const[E,S]=Ai(t,e,{checksumAddress:n,staticPosition:f});d+=S,m.push(E)}return t.setPosition(i+32),[m,32]}if(Yo(e)){const c=Sn(t.readBytes(ed)),u=i+c,f=[];for(let l=0;l<s;++l){t.setPosition(u+l*32);const[p]=Ai(t,e,{checksumAddress:n,staticPosition:u});f.push(p)}return t.setPosition(i+32),[f,32]}let o=0;const a=[];for(let c=0;c<s;++c){const[u,f]=Ai(t,e,{checksumAddress:n,staticPosition:i+o});o+=f,a.push(u)}return[a,o]}function OS(t){return[ME(t.readBytes(32),{size:32}),32]}function BS(t,e,{staticPosition:r}){const[n,s]=e.type.split("bytes");if(!s){const o=Sn(t.readBytes(32));t.setPosition(r+o);const a=Sn(t.readBytes(32));if(a===0)return t.setPosition(r+32),["0x",32];const c=t.readBytes(a);return t.setPosition(r+32),[Or(c),32]}return[Or(t.readBytes(Number.parseInt(s,10),32)),32]}function CS(t,e){const r=e.type.startsWith("int"),n=Number.parseInt(e.type.split("int")[1]||"256",10),s=t.readBytes(32);return[n>48?UE(s,{signed:r}):Sn(s,{signed:r}),32]}function $S(t,e,r){const{checksumAddress:n,staticPosition:s}=r,i=e.components.length===0||e.components.some(({name:c})=>!c),o=i?[]:{};let a=0;if(Yo(e)){const c=Sn(t.readBytes(ed)),u=s+c;for(let f=0;f<e.components.length;++f){const l=e.components[f];t.setPosition(u+a);const[p,d]=Ai(t,l,{checksumAddress:n,staticPosition:u});a+=d,o[i?f:l==null?void 0:l.name]=p}return t.setPosition(s+32),[o,32]}for(let c=0;c<e.components.length;++c){const u=e.components[c],[f,l]=Ai(t,u,{checksumAddress:n,staticPosition:s});o[i?c:u==null?void 0:u.name]=f,a+=l}return[o,a]}function RS(t,{staticPosition:e}){const r=Sn(t.readBytes(32)),n=e+r;t.setPosition(n);const s=Sn(t.readBytes(32));if(s===0)return t.setPosition(e+32),["",32];const i=t.readBytes(s,32),o=FE(Hb(i));return t.setPosition(e+32),[o,32]}function NS({checksumAddress:t,parameters:e,values:r}){const n=[];for(let s=0;s<e.length;s++)n.push(vh({checksumAddress:t,parameter:e[s],value:r[s]}));return n}function vh({checksumAddress:t=!1,parameter:e,value:r}){const n=e,s=Ah(n.type);if(s){const[i,o]=s;return MS(r,{checksumAddress:t,length:i,parameter:{...n,type:o}})}if(n.type==="tuple")return DS(r,{checksumAddress:t,parameter:n});if(n.type==="address")return US(r,{checksum:t});if(n.type==="bool")return jS(r);if(n.type.startsWith("uint")||n.type.startsWith("int")){const i=n.type.startsWith("int"),[,,o="256"]=Zg.exec(n.type)??[];return LS(r,{signed:i,size:Number(o)})}if(n.type.startsWith("bytes"))return FS(r,{type:n.type});if(n.type==="string")return HS(r);throw new xh(n.type)}function Eh(t){let e=0;for(let i=0;i<t.length;i++){const{dynamic:o,encoded:a}=t[i];o?e+=32:e+=Kt(a)}const r=[],n=[];let s=0;for(let i=0;i<t.length;i++){const{dynamic:o,encoded:a}=t[i];o?(r.push(It(e+s,{size:32})),n.push(a),s+=Kt(a)):r.push(a)}return Ir(...r,...n)}function US(t,e){const{checksum:r=!1}=e;return eu(t,{strict:r}),{dynamic:!1,encoded:Ls(t.toLowerCase())}}function MS(t,e){const{checksumAddress:r,length:n,parameter:s}=e,i=n===null;if(!Array.isArray(t))throw new XS(t);if(!i&&t.length!==n)throw new YS({expectedLength:n,givenLength:t.length,type:`${s.type}[${n}]`});let o=!1;const a=[];for(let c=0;c<t.length;c++){const u=vh({checksumAddress:r,parameter:s,value:t[c]});u.dynamic&&(o=!0),a.push(u)}if(i||o){const c=Eh(a);if(i){const u=It(a.length,{size:32});return{dynamic:!0,encoded:a.length>0?Ir(u,c):u}}if(o)return{dynamic:!0,encoded:c}}return{dynamic:!1,encoded:Ir(...a.map(({encoded:c})=>c))}}function FS(t,{type:e}){const[,r]=e.split("bytes"),n=Kt(t);if(!r){let s=t;return n%32!==0&&(s=Hs(s,Math.ceil((t.length-2)/2/32)*32)),{dynamic:!0,encoded:Ir(Ls(It(n,{size:32})),s)}}if(n!==Number.parseInt(r,10))throw new Xg({expectedSize:Number.parseInt(r,10),value:t});return{dynamic:!1,encoded:Hs(t)}}function jS(t){if(typeof t!="boolean")throw new ve(`Invalid boolean value: "${t}" (type: ${typeof t}). Expected: \`true\` or \`false\`.`);return{dynamic:!1,encoded:Ls(Db(t))}}function LS(t,{signed:e,size:r}){if(typeof r=="number"){const n=2n**(BigInt(r)-(e?1n:0n))-1n,s=e?-n-1n:0n;if(t>n||t<s)throw new qb({max:n.toString(),min:s.toString(),signed:e,size:r/8,value:t.toString()})}return{dynamic:!1,encoded:It(t,{size:32,signed:e})}}function HS(t){const e=uh(t),r=Math.ceil(Kt(e)/32),n=[];for(let s=0;s<r;s++)n.push(Hs(Yr(e,s*32,(s+1)*32)));return{dynamic:!0,encoded:Ir(Hs(It(Kt(e),{size:32})),...n)}}function DS(t,e){const{checksumAddress:r,parameter:n}=e;let s=!1;const i=[];for(let o=0;o<n.components.length;o++){const a=n.components[o],c=Array.isArray(t)?o:a.name,u=vh({checksumAddress:r,parameter:a,value:t[c]});i.push(u),u.dynamic&&(s=!0)}return{dynamic:s,encoded:s?Eh(i):Ir(...i.map(({encoded:o})=>o))}}function Ah(t){const e=t.match(/^(.*)\[(\d+)?\]$/);return e?[e[2]?Number(e[2]):null,e[1]]:void 0}function Yo(t){var n;const{type:e}=t;if(e==="string"||e==="bytes"||e.endsWith("[]"))return!0;if(e==="tuple")return(n=t.components)==null?void 0:n.some(Yo);const r=Ah(t.type);return!!(r&&Yo({...t,type:r[1]}))}const zS={bytes:new Uint8Array,dataView:new DataView(new ArrayBuffer(0)),position:0,positionReadCount:new Map,recursiveReadCount:0,recursiveReadLimit:Number.POSITIVE_INFINITY,assertReadLimit(){if(this.recursiveReadCount>=this.recursiveReadLimit)throw new GS({count:this.recursiveReadCount+1,limit:this.recursiveReadLimit})},assertPosition(t){if(t<0||t>this.bytes.length-1)throw new qS({length:this.bytes.length,position:t})},decrementPosition(t){if(t<0)throw new i0({offset:t});const e=this.position-t;this.assertPosition(e),this.position=e},getReadCount(t){return this.positionReadCount.get(t||this.position)||0},incrementPosition(t){if(t<0)throw new i0({offset:t});const e=this.position+t;this.assertPosition(e),this.position=e},inspectByte(t){const e=t??this.position;return this.assertPosition(e),this.bytes[e]},inspectBytes(t,e){const r=e??this.position;return this.assertPosition(r+t-1),this.bytes.subarray(r,r+t)},inspectUint8(t){const e=t??this.position;return this.assertPosition(e),this.bytes[e]},inspectUint16(t){const e=t??this.position;return this.assertPosition(e+1),this.dataView.getUint16(e)},inspectUint24(t){const e=t??this.position;return this.assertPosition(e+2),(this.dataView.getUint16(e)<<8)+this.dataView.getUint8(e+2)},inspectUint32(t){const e=t??this.position;return this.assertPosition(e+3),this.dataView.getUint32(e)},pushByte(t){this.assertPosition(this.position),this.bytes[this.position]=t,this.position++},pushBytes(t){this.assertPosition(this.position+t.length-1),this.bytes.set(t,this.position),this.position+=t.length},pushUint8(t){this.assertPosition(this.position),this.bytes[this.position]=t,this.position++},pushUint16(t){this.assertPosition(this.position+1),this.dataView.setUint16(this.position,t),this.position+=2},pushUint24(t){this.assertPosition(this.position+2),this.dataView.setUint16(this.position,t>>8),this.dataView.setUint8(this.position+2,t&255),this.position+=3},pushUint32(t){this.assertPosition(this.position+3),this.dataView.setUint32(this.position,t),this.position+=4},readByte(){this.assertReadLimit(),this._touch();const t=this.inspectByte();return this.position++,t},readBytes(t,e){this.assertReadLimit(),this._touch();const r=this.inspectBytes(t);return this.position+=e??t,r},readUint8(){this.assertReadLimit(),this._touch();const t=this.inspectUint8();return this.position+=1,t},readUint16(){this.assertReadLimit(),this._touch();const t=this.inspectUint16();return this.position+=2,t},readUint24(){this.assertReadLimit(),this._touch();const t=this.inspectUint24();return this.position+=3,t},readUint32(){this.assertReadLimit(),this._touch();const t=this.inspectUint32();return this.position+=4,t},get remaining(){return this.bytes.length-this.position},setPosition(t){const e=this.position;return this.assertPosition(t),this.position=t,()=>this.position=e},_touch(){if(this.recursiveReadLimit===Number.POSITIVE_INFINITY)return;const t=this.getReadCount();this.positionReadCount.set(this.position,t+1),t>0&&this.recursiveReadCount++}};function VS(t,{recursiveReadLimit:e=8192}={}){const r=Object.create(zS);return r.bytes=t,r.dataView=new DataView(t.buffer,t.byteOffset,t.byteLength),r.positionReadCount=new Map,r.recursiveReadLimit=e,r}class i0 extends ve{constructor({offset:e}){super(`Offset \`${e}\` cannot be negative.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Cursor.NegativeOffsetError"})}}class qS extends ve{constructor({length:e,position:r}){super(`Position \`${r}\` is out of bounds (\`0 < position < ${e}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Cursor.PositionOutOfBoundsError"})}}class GS extends ve{constructor({count:e,limit:r}){super(`Recursive read limit of \`${r}\` exceeded (recursive read count: \`${e}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Cursor.RecursiveReadLimitExceededError"})}}function WS(t,e,r={}){const{as:n="Array",checksumAddress:s=!1}=r,i=typeof e=="string"?Lb(e):e,o=VS(i);if(bi(i)===0&&t.length>0)throw new ZS;if(bi(i)&&bi(i)<32)throw new KS({data:typeof e=="string"?e:Or(e),parameters:t,size:bi(i)});let a=0;const c=n==="Array"?[]:{};for(let u=0;u<t.length;++u){const f=t[u];o.setPosition(a);const[l,p]=Ai(o,f,{checksumAddress:s,staticPosition:0});a+=p,n==="Array"?c.push(l):c[f.name??u]=l}return c}function Sh(t,e,r){const{checksumAddress:n=!1}={};if(t.length!==e.length)throw new Jg({expectedLength:t.length,givenLength:e.length});const s=NS({checksumAddress:n,parameters:t,values:e}),i=Eh(s);return i.length===0?"0x":i}function td(t,e){if(t.length!==e.length)throw new Jg({expectedLength:t.length,givenLength:e.length});const r=[];for(let n=0;n<t.length;n++){const s=t[n],i=e[n];r.push(td.encode(s,i))}return Ir(...r)}(function(t){function e(r,n,s=!1){if(r==="address"){const c=n;return eu(c),Ls(c.toLowerCase(),s?32:0)}if(r==="string")return uh(n);if(r==="bytes")return n;if(r==="bool")return Ls(Db(n),s?32:1);const i=r.match(Zg);if(i){const[c,u,f="256"]=i,l=Number.parseInt(f,10)/8;return It(n,{size:s?32:l,signed:u==="int"})}const o=r.match(_S);if(o){const[c,u]=o;if(Number.parseInt(u,10)!==(n.length-2)/2)throw new Xg({expectedSize:Number.parseInt(u,10),value:n});return Hs(n,s?32:0)}const a=r.match(TS);if(a&&Array.isArray(n)){const[c,u]=a,f=[];for(let l=0;l<n.length;l++)f.push(e(u,n[l],!0));return f.length===0?"0x":Ir(...f)}throw new xh(r)}t.encode=e})(td||(td={}));function Yg(t){return Array.isArray(t)&&typeof t[0]=="string"||typeof t=="string"?t0(t):t}class KS extends ve{constructor({data:e,parameters:r,size:n}){super(`Data size of ${n} bytes is too small for given parameters.`,{metaMessages:[`Params: (${ci(r)})`,`Data: ${e} (${n} bytes)`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.DataSizeTooSmallError"})}}class ZS extends ve{constructor(){super('Cannot decode zero data ("0x") with ABI parameters.'),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.ZeroDataError"})}}class YS extends ve{constructor({expectedLength:e,givenLength:r,type:n}){super(`Array length mismatch for type \`${n}\`. Expected: \`${e}\`. Given: \`${r}\`.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.ArrayLengthMismatchError"})}}class Xg extends ve{constructor({expectedSize:e,value:r}){super(`Size of bytes "${r}" (bytes${Kt(r)}) does not match expected size (bytes${e}).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.BytesSizeMismatchError"})}}class Jg extends ve{constructor({expectedLength:e,givenLength:r}){super(["ABI encoding parameters/values length mismatch.",`Expected length (parameters): ${e}`,`Given length (values): ${r}`].join(`
|
|
@@ -70,7 +70,7 @@ ${B5(d)}`),super(e.shortMessage,{cause:e,docsPath:n,metaMessages:[...e.metaMessa
|
|
|
70
70
|
OP_CHECKSIGADD
|
|
71
71
|
OP_2
|
|
72
72
|
OP_NUMEQUAL
|
|
73
|
-
`.trim().replace(/\s+/g," "))}generateLeaves(e,r){let n,s,i;switch(r){case"redeem":n=e.destination_swap,s=n.delegate,i=n.delegate;break;case"refund":n=e.source_swap,s=n.delegate,i=n.delegate;break;case"instantRefund":n=e.source_swap,s=n.redeemer,i=n.redeemer;break;default:throw new Error("Invalid leaf generation type")}return[{version:Ya,output:this.redeemLeaf(n.secret_hash,je(s))},[{version:Ya,output:this.refundLeaf(n.timelock,je(n.initiator))},{version:Ya,output:this.instantRefundLeaf(je(n.initiator),je(i))}]]}generateMerkleProofFor(e,r){const n=this.leafHash(1,r),s=this.leafHash(2,r),i=this.leafHash(0,r);switch(e){case 1:{const o=qk(i,s);return[Se.crypto.taggedHash("TapBranch",Buffer.concat(o))]}case 0:return[s,n];case 2:return[i,n];default:throw new Error(rr.invalidLeaf)}}getProvider(){return this.signer.getProvider()}get getPublicKey(){return this.signer.getPublicKey()}get htlcActorAddress(){return this.signer.getPublicKey()}};class cw{constructor(e,r){this.quoteUrl=new g.Url(e),this.auth=r}async getQuoteFromAssets({fromAsset:e,toAsset:r,amount:n,isExactOut:s=!1,options:i}){const o=X.ChainAsset.from(e),a=X.ChainAsset.from(r);return this.getQuote(o,a,n,s,i)}async getQuote(e,r,n,s=!1,i){try{const o=await this.auth.getAuthHeaders();if(o.error)return g.Err(o.error);const a={from:X.ChainAsset.from(e).toString(),to:X.ChainAsset.from(r).toString(),...s?{to_amount:n.toString()}:{from_amount:n.toString()},...(i==null?void 0:i.affiliateFee)!==void 0&&{affiliate_fee:i.affiliateFee.toString()}},c=this.quoteUrl.endpoint("/v2/quote").addSearchParams(a),u=await g.Fetcher.get(c,{retryCount:0,...i==null?void 0:i.request,headers:{...o.val,"Content-Type":"application/json"}});return u.error?g.Err(u.error):u.result?g.Ok(u.result):g.Err("GetQuote: Unexpected error, result is undefined")}catch(o){return g.Err("GetQuote:",String(o))}}}class Mi extends g.EventBroker{get isInitialized(){return!!this.digestKey}constructor(e,r){super(),this.digestKey=e,this.walletClient=r}static fromDigestKey(e){return new Mi(g.trim0x(e))}static fromWalletClient(e){return new Mi(void 0,e)}async initialize(){if(this.digestKey)return g.Ok("Already initialized");const e=await this.deriveDigestKeyFromWalletClient();return e.error?g.Err(e.error):(this.emit("initialized",!0),g.Ok("Initialized"))}async deriveDigestKeyFromWalletClient(){if(!this.walletClient)return g.Err("No walletClient found");if(!this.walletClient.account)return g.Err("No account found");try{const e=await this.walletClient.signTypedData({account:this.walletClient.account,types:{EIP712Domain:[{name:"name",type:"string"},{name:"version",type:"string"}],Data:[{name:"Message",type:"string"},{name:"Version",type:"string"},{name:"Nonce",type:"uint256"}]},domain:{name:"GARDEN FINANCE",version:"1"},primaryType:"Data",message:{Message:"Initialize your account",Version:"1.0.2",Nonce:1n}});return this.digestKey=g.trim0x(ho(e)),this.emit("initialized",!0),g.Ok(this.digestKey)}catch(e){return g.Err("Failed to initialize: "+e)}}async getDigestKey(){if(!this.digestKey&&!this.walletClient)return g.Err("No private key or wallet client found");if(!this.digestKey&&this.walletClient){const e=await this.deriveDigestKeyFromWalletClient();if(e.error)return g.Err(e.error)}return this.digestKey?g.Ok(this.digestKey):g.Err("No private key found")}async generateSecret(e){const r=await this.signMessage(e);if(!r.ok)return g.Err(r.error);const n=ho(g.with0x(r.val)),s=ho(n);return g.Ok({secret:n,secretHash:s})}async signMessage(e){if(!this.digestKey){const u=await this.getDigestKey();if(!u.ok)return g.Err(u.error);this.digestKey=u.val}const r=nc.ECPairFactory(ur),n="Garden.fi"+e.toString(),s=Buffer.from(n,"utf8"),i=ho(s),o=Buffer.from(g.trim0x(this.digestKey),"hex");if(o.length!==32)return g.Err("Invalid private key length. Expected 32 bytes.");const c=r.fromPrivateKey(o).sign(Buffer.from(g.trim0x(i),"hex"));return g.Ok(c.toString("hex"))}}const uw=[{inputs:[{internalType:"address",name:"token_",type:"address"},{internalType:"string",name:"name",type:"string"},{internalType:"string",name:"version",type:"string"}],stateMutability:"nonpayable",type:"constructor"},{inputs:[],name:"InvalidShortString",type:"error"},{inputs:[{internalType:"string",name:"str",type:"string"}],name:"StringTooLong",type:"error"},{anonymous:!1,inputs:[],name:"EIP712DomainChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes32",name:"orderID",type:"bytes32"},{indexed:!0,internalType:"bytes32",name:"secretHash",type:"bytes32"},{indexed:!1,internalType:"uint256",name:"amount",type:"uint256"}],name:"Initiated",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes32",name:"orderID",type:"bytes32"},{indexed:!0,internalType:"bytes32",name:"secretHash",type:"bytes32"},{indexed:!1,internalType:"bytes",name:"secret",type:"bytes"}],name:"Redeemed",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes32",name:"orderID",type:"bytes32"}],name:"Refunded",type:"event"},{inputs:[],name:"eip712Domain",outputs:[{internalType:"bytes1",name:"fields",type:"bytes1"},{internalType:"string",name:"name",type:"string"},{internalType:"string",name:"version",type:"string"},{internalType:"uint256",name:"chainId",type:"uint256"},{internalType:"address",name:"verifyingContract",type:"address"},{internalType:"bytes32",name:"salt",type:"bytes32"},{internalType:"uint256[]",name:"extensions",type:"uint256[]"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"redeemer",type:"address"},{internalType:"uint256",name:"timelock",type:"uint256"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"bytes32",name:"secretHash",type:"bytes32"}],name:"initiate",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"redeemer",type:"address"},{internalType:"uint256",name:"timelock",type:"uint256"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"bytes32",name:"secretHash",type:"bytes32"},{internalType:"bytes",name:"signature",type:"bytes"}],name:"initiateWithSignature",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"orderID",type:"bytes32"},{internalType:"bytes",name:"signature",type:"bytes"}],name:"instantRefund",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{internalType:"address",name:"redeemer",type:"address"},{internalType:"uint256",name:"expiry",type:"uint256"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"bytes32",name:"secretHash",type:"bytes32"},{internalType:"bytes",name:"signature",type:"bytes"}],internalType:"struct HTLC.InitWithSig[]",name:"inits",type:"tuple[]"},{components:[{internalType:"bytes32",name:"orderID",type:"bytes32"},{internalType:"bytes",name:"secret",type:"bytes"}],internalType:"struct HTLC.Redeem[]",name:"redeems",type:"tuple[]"},{components:[{internalType:"bytes32",name:"orderID",type:"bytes32"}],internalType:"struct HTLC.Refund[]",name:"refunds",type:"tuple[]"}],name:"multicall",outputs:[{internalType:"bool[]",name:"results",type:"bool[]"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"",type:"bytes32"}],name:"orders",outputs:[{internalType:"bool",name:"isFulfilled",type:"bool"},{internalType:"address",name:"initiator",type:"address"},{internalType:"address",name:"redeemer",type:"address"},{internalType:"uint256",name:"initiatedAt",type:"uint256"},{internalType:"uint256",name:"timelock",type:"uint256"},{internalType:"uint256",name:"amount",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"orderID",type:"bytes32"},{internalType:"bytes",name:"secret",type:"bytes"}],name:"redeem",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"orderID",type:"bytes32"}],name:"refund",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"token",outputs:[{internalType:"contract IERC20",name:"",type:"address"}],stateMutability:"view",type:"function"}],c_=[{inputs:[{internalType:"string",name:"name",type:"string"},{internalType:"string",name:"version",type:"string"}],stateMutability:"nonpayable",type:"constructor"},{inputs:[],name:"InvalidShortString",type:"error"},{inputs:[],name:"NativeHTLC__DuplicateOrder",type:"error"},{inputs:[],name:"NativeHTLC__IncorrectFundsRecieved",type:"error"},{inputs:[],name:"NativeHTLC__IncorrectSecret",type:"error"},{inputs:[],name:"NativeHTLC__InsufficientBalance",type:"error"},{inputs:[],name:"NativeHTLC__InvalidRedeemerSignature",type:"error"},{inputs:[],name:"NativeHTLC__OrderFulfilled",type:"error"},{inputs:[],name:"NativeHTLC__OrderNotExpired",type:"error"},{inputs:[],name:"NativeHTLC__OrderNotInitiated",type:"error"},{inputs:[],name:"NativeHTLC__SameInitiatorAndRedeemer",type:"error"},{inputs:[],name:"NativeHTLC__ZeroAddressInitiator",type:"error"},{inputs:[],name:"NativeHTLC__ZeroAddressRedeemer",type:"error"},{inputs:[],name:"NativeHTLC__ZeroAmount",type:"error"},{inputs:[],name:"NativeHTLC__ZeroTimelock",type:"error"},{inputs:[{internalType:"string",name:"str",type:"string"}],name:"StringTooLong",type:"error"},{anonymous:!1,inputs:[],name:"EIP712DomainChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes32",name:"orderID",type:"bytes32"},{indexed:!0,internalType:"bytes32",name:"secretHash",type:"bytes32"},{indexed:!1,internalType:"uint256",name:"amount",type:"uint256"}],name:"Initiated",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes32",name:"orderID",type:"bytes32"},{indexed:!0,internalType:"bytes32",name:"secretHash",type:"bytes32"},{indexed:!1,internalType:"bytes",name:"secret",type:"bytes"}],name:"Redeemed",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes32",name:"orderID",type:"bytes32"}],name:"Refunded",type:"event"},{inputs:[],name:"eip712Domain",outputs:[{internalType:"bytes1",name:"fields",type:"bytes1"},{internalType:"string",name:"name",type:"string"},{internalType:"string",name:"version",type:"string"},{internalType:"uint256",name:"chainId",type:"uint256"},{internalType:"address",name:"verifyingContract",type:"address"},{internalType:"bytes32",name:"salt",type:"bytes32"},{internalType:"uint256[]",name:"extensions",type:"uint256[]"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address payable",name:"redeemer",type:"address"},{internalType:"uint256",name:"timelock",type:"uint256"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"bytes32",name:"secretHash",type:"bytes32"}],name:"initiate",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address payable",name:"initiator",type:"address"},{internalType:"address payable",name:"redeemer",type:"address"},{internalType:"uint256",name:"timelock",type:"uint256"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"bytes32",name:"secretHash",type:"bytes32"}],name:"initiateOnBehalf",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"bytes32",name:"orderID",type:"bytes32"},{internalType:"bytes",name:"signature",type:"bytes"}],name:"instantRefund",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"orderID",type:"bytes32"}],name:"instantRefundDigest",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"",type:"bytes32"}],name:"orders",outputs:[{internalType:"bool",name:"isFulfilled",type:"bool"},{internalType:"address payable",name:"initiator",type:"address"},{internalType:"address payable",name:"redeemer",type:"address"},{internalType:"uint256",name:"initiatedAt",type:"uint256"},{internalType:"uint256",name:"timelock",type:"uint256"},{internalType:"uint256",name:"amount",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"orderID",type:"bytes32"},{internalType:"bytes",name:"secret",type:"bytes"}],name:"redeem",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"orderID",type:"bytes32"}],name:"refund",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"token",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"}];class Pa{constructor(e,r){this.auth=e,this.url=r instanceof g.Url?r:new g.Url(r)}async initiate(e,r){try{const n=await this.auth.getAuthHeaders();if(!n.ok)return g.Err(n.error);const s=await g.Fetcher.patch(this.url.endpoint("/v2/orders").endpoint(e).addSearchParams({action:"initiate"}),{body:JSON.stringify({signature:r}),headers:{...n.val,"Content-Type":"application/json"}});return s.error||!s.result?g.Err(s.error||"Initiate failed"):g.Ok(s.result)}catch(n){return g.Err(String(n))}}async redeem(e,r){try{const n=await this.auth.getAuthHeaders();if(!n.ok)return g.Err(n.error);const s=await g.Fetcher.patch(this.url.endpoint("/v2/orders").endpoint(e).addSearchParams({action:"redeem"}),{body:JSON.stringify({secret:g.trim0x(r)}),headers:{...n.val,"Content-Type":"application/json"},retryCount:10,retryDelay:2e3});return s.error?g.Err(s.error):s.result?g.Ok(s.result):g.Err("Redeem: No result found")}catch(n){return g.Err(String(n))}}}const u_=async(t,e)=>{if(!t.account)return g.Err("No account found");try{const n=await hh({address:g.with0x(e.htlc),abi:c_,client:t}).write.initiate([g.with0x(e.redeemer),e.timelock,e.amount,g.with0x(e.secretHash)],{account:t.account,chain:t.chain,value:e.amount}),s=await g.waitForTransactionReceipt(t,n);return s.ok?!s.val||s.val.status!=="success"?g.Err("Native initiate transaction failed"):g.Ok(n):g.Err(s.error)}catch(r){return $h(r)?g.Ok("already initiated"):g.Err("Failed to initiate on native HTLC",String(r))}},f_=async(t,e,r,n)=>{if(!t.account)return g.Err("No account found");try{const s=hh({address:g.with0x(n.htlc),abi:uw,client:t}),i=await g.checkAllowanceAndApprove(Number(n.amount),n.token,n.htlc,t);if(!i.ok)return g.Err(i.error);const o=await s.read.eip712Domain(),a=await t.signTypedData({account:t.account,domain:{name:o[1],version:o[2],chainId:Number(o[3]),verifyingContract:o[4]},types:{Initiate:[{name:"redeemer",type:"address"},{name:"timelock",type:"uint256"},{name:"amount",type:"uint256"},{name:"secretHash",type:"bytes32"}]},primaryType:"Initiate",message:{redeemer:g.with0x(n.redeemer),timelock:n.timelock,amount:n.amount,secretHash:g.with0x(n.secretHash)}}),c=new Pa(r,e),u=await B1({wallet:t,attempt:()=>c.initiate(n.orderId,a)});if(u)return g.Ok(u);const f=await s.write.initiate([g.with0x(n.redeemer),n.timelock,n.amount,g.with0x(n.secretHash)],{account:t.account,chain:t.chain}),l=await g.waitForTransactionReceipt(t,f);return l.ok?!l.val||l.val.status!=="success"?g.Err("Failed to initiate (fallback)"):g.Ok(f):g.Err(l.error)}catch(s){return $h(s)?g.Ok("already initiated"):g.Err("Failed to initiate on ERC20 HTLC",String(s))}},l_=async(t,e)=>{if(!t.account)return g.Err("No account found");try{const r=await t.sendTransaction({account:t.account,to:g.with0x(e.to),value:BigInt(e.value),data:g.with0x(e.data),gas:BigInt(e.gas_limit),chain:t.chain}),n=await g.waitForTransactionReceipt(t,r);return n.ok?!n.val||n.val.status!=="success"?g.Err("Approval transaction failed"):g.Ok(r):g.Err(n.error)}catch(r){return g.Err("Failed to execute approval: "+String(r))}},d_={gasPriceOracle:{address:"0x420000000000000000000000000000000000000F"},l1Block:{address:"0x4200000000000000000000000000000000000015"},l2CrossDomainMessenger:{address:"0x4200000000000000000000000000000000000007"},l2Erc721Bridge:{address:"0x4200000000000000000000000000000000000014"},l2StandardBridge:{address:"0x4200000000000000000000000000000000000010"},l2ToL1MessagePasser:{address:"0x4200000000000000000000000000000000000016"}},h_={block:sE({format(t){var r;return{transactions:(r=t.transactions)==null?void 0:r.map(n=>{if(typeof n=="string")return n;const s=qc(n);return s.typeHex==="0x7e"&&(s.isSystemTx=n.isSystemTx,s.mint=n.mint?ut(n.mint):void 0,s.sourceHash=n.sourceHash,s.type="deposit"),s}),stateRoot:t.stateRoot}}}),transaction:rE({format(t){const e={};return t.type==="0x7e"&&(e.isSystemTx=t.isSystemTx,e.mint=t.mint?ut(t.mint):void 0,e.sourceHash=t.sourceHash,e.type="deposit"),e}}),transactionReceipt:pA({format(t){return{l1GasPrice:t.l1GasPrice?ut(t.l1GasPrice):null,l1GasUsed:t.l1GasUsed?ut(t.l1GasUsed):null,l1Fee:t.l1Fee?ut(t.l1Fee):null,l1FeeScalar:t.l1FeeScalar?Number(t.l1FeeScalar):null}}})};function p_(t,e){return b_(t)?m_(t):QA(t,e)}const y_={transaction:p_};function m_(t){g_(t);const{sourceHash:e,data:r,from:n,gas:s,isSystemTx:i,mint:o,to:a,value:c}=t,u=[e,n,a??"0x",o?Bt(o):"0x",c?Bt(c):"0x",s?Bt(s):"0x",i?"0x1":"0x",r??"0x"];return Cr(["0x7e",as(u)])}function b_(t){return t.type==="deposit"||typeof t.sourceHash<"u"}function g_(t){const{from:e,to:r}=t;if(e&&!at(e))throw new $t({address:e});if(r&&!at(r))throw new $t({address:r})}const Fi={blockTime:2e3,contracts:d_,formatters:h_,serializers:y_},w_=yt({id:42161,name:"Arbitrum One",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},blockTime:250,rpcUrls:{default:{http:["https://arb1.arbitrum.io/rpc"]}},blockExplorers:{default:{name:"Arbiscan",url:"https://arbiscan.io",apiUrl:"https://api.arbiscan.io/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:7654707}}}),v_=yt({id:421614,name:"Arbitrum Sepolia",blockTime:250,nativeCurrency:{name:"Arbitrum Sepolia Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://sepolia-rollup.arbitrum.io/rpc"]}},blockExplorers:{default:{name:"Arbiscan",url:"https://sepolia.arbiscan.io",apiUrl:"https://api-sepolia.arbiscan.io/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:81930}},testnet:!0}),ao=1,fw=yt({...Fi,id:8453,name:"Base",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://mainnet.base.org"]}},blockExplorers:{default:{name:"Basescan",url:"https://basescan.org",apiUrl:"https://api.basescan.org/api"}},contracts:{...Fi.contracts,disputeGameFactory:{[ao]:{address:"0x43edB88C4B80fDD2AdFF2412A7BebF9dF42cB40e"}},l2OutputOracle:{[ao]:{address:"0x56315b90c40730925ec5485cf004d835058518A0"}},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:5022},portal:{[ao]:{address:"0x49048044D57e1C92A77f79988d21Fa8fAF74E97e",blockCreated:17482143}},l1StandardBridge:{[ao]:{address:"0x3154Cf16ccdb4C6d922629664174b904d80F2C35",blockCreated:17482143}}},sourceId:ao});({...fw});const co=11155111,lw=yt({...Fi,id:84532,network:"base-sepolia",name:"Base Sepolia",nativeCurrency:{name:"Sepolia Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://sepolia.base.org"]}},blockExplorers:{default:{name:"Basescan",url:"https://sepolia.basescan.org",apiUrl:"https://api-sepolia.basescan.org/api"}},contracts:{...Fi.contracts,disputeGameFactory:{[co]:{address:"0xd6E6dBf4F7EA0ac412fD8b65ED297e64BB7a06E1"}},l2OutputOracle:{[co]:{address:"0x84457ca9D0163FbC4bbfe4Dfbb20ba46e48DF254"}},portal:{[co]:{address:"0x49f53e41452c74589e85ca1677426ba426459e85",blockCreated:4446677}},l1StandardBridge:{[co]:{address:"0xfd0Bf71F60660E2f608ed56e1659C450eB113120",blockCreated:4446677}},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:1059647}},testnet:!0,sourceId:co});({...lw});const E_=yt({id:80094,name:"Berachain",blockTime:2e3,nativeCurrency:{decimals:18,name:"BERA Token",symbol:"BERA"},contracts:{multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:0},ensRegistry:{address:"0x5b22280886a2f5e09a49bea7e320eab0e5320e28",blockCreated:877007},ensUniversalResolver:{address:"0x4D41762915F83c76EcaF6776d9b08076aA32b492",blockCreated:9310021}},rpcUrls:{default:{http:["https://rpc.berachain.com"]}},blockExplorers:{default:{name:"Berascan",url:"https://berascan.com"}},ensTlds:[".bera"],testnet:!1}),A_=yt({id:80084,name:"Berachain bArtio",nativeCurrency:{decimals:18,name:"BERA Token",symbol:"BERA"},contracts:{multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:109269},ensRegistry:{address:"0xB0eef18971290b333450586D33dcA6cE122651D2",blockCreated:7736794},ensUniversalResolver:{address:"0x41692Ef1EA0C79E6b73077E4A67572D2BDbD7057",blockCreated:7736795}},ensTlds:[".bera"],rpcUrls:{default:{http:["https://bartio.rpc.berachain.com"]}},blockExplorers:{default:{name:"Berachain bArtio Beratrail",url:"https://bartio.beratrail.io"}},testnet:!0}),S_=yt({id:56,name:"BNB Smart Chain",blockTime:750,nativeCurrency:{decimals:18,name:"BNB",symbol:"BNB"},rpcUrls:{default:{http:["https://56.rpc.thirdweb.com"]}},blockExplorers:{default:{name:"BscScan",url:"https://bscscan.com",apiUrl:"https://api.bscscan.com/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:15921452}}}),x_=yt({id:97,name:"BNB Smart Chain Testnet",nativeCurrency:{decimals:18,name:"BNB",symbol:"tBNB"},rpcUrls:{default:{http:["https://data-seed-prebsc-1-s1.bnbchain.org:8545"]}},blockExplorers:{default:{name:"BscScan",url:"https://testnet.bscscan.com",apiUrl:"https://api-testnet.bscscan.com/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:17422483}},testnet:!0}),k_=yt({id:5115,name:"Citrea Testnet",nativeCurrency:{name:"cBTC",symbol:"cBTC",decimals:18},rpcUrls:{default:{http:["https://rpc.testnet.citrea.xyz"]}},blockExplorers:{default:{name:"Citrea Explorer",url:"https://explorer.testnet.citrea.xyz",apiUrl:"https://explorer.testnet.citrea.xyz/api"}},testnet:!0}),T_=yt({id:1116,name:"Core Dao",nativeCurrency:{decimals:18,name:"Core",symbol:"CORE"},rpcUrls:{default:{http:["https://rpc.coredao.org"]}},blockExplorers:{default:{name:"CoreDao",url:"https://scan.coredao.org"}},contracts:{multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:11907934}},testnet:!1}),__=1,P_=yt({id:21e6,name:"Corn",nativeCurrency:{decimals:18,name:"Bitcorn",symbol:"BTCN"},rpcUrls:{default:{http:["https://21000000.rpc.thirdweb.com"]}},blockExplorers:{default:{name:"Corn Explorer",url:"https://cornscan.io",apiUrl:"https://api.routescan.io/v2/network/mainnet/evm/21000000/etherscan/api"}},contracts:{multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:3228}},sourceId:__}),I_=yt({id:1,name:"Ethereum",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},blockTime:12e3,rpcUrls:{default:{http:["https://eth.merkle.io"]}},blockExplorers:{default:{name:"Etherscan",url:"https://etherscan.io",apiUrl:"https://api.etherscan.io/api"}},contracts:{ensUniversalResolver:{address:"0xeeeeeeee14d718c2b47d9923deab1335e144eeee",blockCreated:23085558},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:14353601}}}),O_=yt({id:10143,name:"Monad Testnet",blockTime:400,nativeCurrency:{name:"Testnet MON Token",symbol:"MON",decimals:18},rpcUrls:{default:{http:["https://testnet-rpc.monad.xyz"]}},blockExplorers:{default:{name:"Monad Testnet explorer",url:"https://testnet.monadexplorer.com"}},contracts:{multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:251449}},testnet:!0}),B_=yt({id:11155111,name:"Sepolia",nativeCurrency:{name:"Sepolia Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://sepolia.drpc.org"]}},blockExplorers:{default:{name:"Etherscan",url:"https://sepolia.etherscan.io",apiUrl:"https://api-sepolia.etherscan.io/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:751532},ensUniversalResolver:{address:"0xeeeeeeee14d718c2b47d9923deab1335e144eeee",blockCreated:8928790}},testnet:!0}),Xa=1,C_=yt({...Fi,id:130,name:"Unichain",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},blockTime:1e3,rpcUrls:{default:{http:["https://mainnet.unichain.org/"]}},blockExplorers:{default:{name:"Uniscan",url:"https://uniscan.xyz",apiUrl:"https://api.uniscan.xyz/api"}},contracts:{...Fi.contracts,multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:0},disputeGameFactory:{[Xa]:{address:"0x2F12d621a16e2d3285929C9996f478508951dFe4"}},portal:{[Xa]:{address:"0x0bd48f6B86a26D3a217d0Fa6FfE2B491B956A7a2"}},l1StandardBridge:{[Xa]:{address:"0x81014F44b0a345033bB2b3B21C7a1A308B35fEeA"}}},sourceId:Xa}),$_={...B_,rpcUrls:{default:{http:["https://ethereum-sepolia-rpc.publicnode.com"]}}},dw={id:3637,name:"Botanix",nativeCurrency:{name:"Botanix",symbol:"BOTX",decimals:18},blockExplorers:{default:{name:"Botanix Explorer",url:"https://botanixscan.io/"}},rpcUrls:{default:{http:["https://rpc.botanixlabs.com/"]}}},hw={id:998,name:"Hyperliquid EVM Testnet",nativeCurrency:{name:"Hyperliquid",symbol:"HYPE",decimals:18},blockExplorers:{default:{name:"Hyperliquid Explorer",url:"https://testnet.purrsec.com/"}},rpcUrls:{default:{http:["https://rpc.hyperliquid-testnet.xyz/evm"]}}},pw={id:999,name:"HyperEVM",nativeCurrency:{name:"Hyperliquid",symbol:"HYPE",decimals:18},blockExplorers:{default:{name:"Hyperliquid Explorer",url:"https://hyperscan.gas.zip/"}},rpcUrls:{default:{http:["https://rpc.hyperliquid.xyz/evm"]}}},yw={id:2892,name:"Alpen Network",nativeCurrency:{name:"Signet bitcoin",symbol:"sBTC",decimals:18},blockExplorers:{default:{name:"Alpen Explorer",url:"https://explorer.testnet.alpenlabs.io"}},rpcUrls:{default:{http:["https://rpc.testnet.alpenlabs.io/"]}}},R_={id:143,name:"Monad",nativeCurrency:{name:"Monad",symbol:"MON",decimals:18},blockExplorers:{default:{name:"Monad Explorer",url:"https://monadvision.com/"}},rpcUrls:{default:{http:["https://rpc1.monad.xyz"]}}},yu={ethereum:I_,arbitrum:w_,ethereum_sepolia:$_,arbitrum_sepolia:v_,ethereum_localnet:X.EthereumLocalnet,arbitrum_localnet:X.ArbitrumLocalnet,base_sepolia:lw,base:fw,bera_testnet:A_,citrea_testnet:k_,core:T_,bera:E_,monad:R_,monad_testnet:O_,hyperliquid_testnet:hw,hyperliquid:pw,unichain:C_,corn:P_,botanix:dw,bnbchain:S_,bnbchain_testnet:x_,alpen_testnet:yw,hypercore:{},hypercore_testnet:{}},mw=t=>{for(const[e,r]of Object.entries(yu))if(r.id===t)return e;return null},gd=async(t,e)=>{var s,i,o;const r=yu[t],n=await e.getChainId();if(r)try{if(r.id===n)return g.Ok({message:"Already on the network",walletClient:e});await e.switchChain({id:r.id});const a=Xu({account:e.account,chain:r,transport:m0(e.transport)});return g.Ok({message:"Switched chain",walletClient:a})}catch(a){if(N_(a))if(a.code===4902||a.code===-32603)try{await e.addChain({chain:r});const c=Xu({account:e.account,chain:r,transport:m0(e.transport)});return g.Ok({message:"Added network",walletClient:c})}catch{return g.Err("Failed to add network")}else if((i=(s=a.body)==null?void 0:s.method)!=null&&i.includes("wallet_switchEthereumChain")||(o=a.message)!=null&&o.includes("wallet_switchEthereumChain")){const c=Xu({account:e.account,chain:r,transport:P1()});return g.Ok({message:"Added network",walletClient:c})}else return g.Err("Failed to switch network");else return g.Err("Failed to switch network")}else return g.Err("Chain not supported")},N_=t=>typeof t=="object"&&t!=null&&("code"in t||"message"in t||"body"in t);class bw{constructor(e,r,n){this.wallet=r,this.auth=n,this.url=e instanceof g.Url?e:new g.Url(e),this.relayer=new Pa(this.auth,this.url)}get htlcActorAddress(){if(!this.wallet.account)throw new Error("No account found");return this.wallet.account.address}async initiate(e){if(X.isEvmOrderResponse(e))return this.initiateFromAPI(e);if(!this.wallet.account)return g.Err("No account found");if(!X.isEVM(e.source_swap.chain))return g.Err("Not an EVM chain");if(this.wallet.account.address.toLowerCase()!==e.source_swap.initiator.toLowerCase())return g.Err("Account address and order initiator mismatch");const r=e.source_swap.chain,n=await gd(r,this.wallet);if(!n.ok)return g.Err(n.error);this.wallet=n.val.walletClient;const{source_swap:s}=e;if(!s.amount||!s.timelock||!s.redeemer||!s.secret_hash)return g.Err("Invalid order");const i=await Ch(s.asset,this.url);if(!i.ok)return g.Err(i.error);const o=X.ChainAsset.fromString(s.asset),a={redeemer:g.with0x(s.redeemer),timelock:BigInt(s.timelock),amount:BigInt(s.amount),secretHash:g.with0x(s.secret_hash)};return X.isEvmNativeToken(o.chain,o.symbol)?u_(this.wallet,{...a,htlc:i.val.htlcAddress}):f_(this.wallet,this.url,this.auth,{...a,htlc:i.val.htlcAddress,token:i.val.tokenAddress,orderId:e.order_id})}async initiateFromAPI(e){const r=mw(e.initiate_transaction.chain_id);if(!r)return g.Err("Unsupported chain");const n=await gd(r,this.wallet);if(!n.ok)return g.Err(n.error);if(this.wallet=n.val.walletClient,!this.wallet.account)return g.Err("No account found");if(!e.typed_data){const o=e.initiate_transaction,a=await this.wallet.sendTransaction({account:this.wallet.account,chain:this.wallet.chain,to:g.with0x(o.to),value:BigInt(o.value),data:g.with0x(o.data),gas:BigInt(o.gas_limit)}),c=await g.waitForTransactionReceipt(this.wallet,a);return c.ok?!c.val||c.val.status!=="success"?g.Err("Native initiate transaction failed"):g.Ok(a):g.Err(c.error)}if(e.approval_transaction){const o=await l_(this.wallet,e.approval_transaction);if(o.error)return g.Err(`Approval failed: ${o.error}`);console.log("Approval transaction completed:",o.val)}const s=await this.wallet.signTypedData({account:this.wallet.account,...e.typed_data}),i=await B1({wallet:this.wallet,attempt:()=>this.relayer.initiate(e.order_id,s)});if(i)return g.Ok(i);try{const o=hh({address:g.with0x(e.initiate_transaction.to),abi:uw,client:this.wallet}),a=e.typed_data.message,c=await o.write.initiate([g.with0x(a.redeemer),BigInt(a.timelock),BigInt(a.amount),g.with0x(a.secretHash)],{account:this.wallet.account,chain:this.wallet.chain}),u=await g.waitForTransactionReceipt(this.wallet,c);return u.ok?!u.val||u.val.status!=="success"?g.Err("Failed to initiate via contract"):g.Ok(c):g.Err(u.error)}catch(o){return $h(o)?g.Ok("already initiated"):g.Err(`Failed to initiate via contract: ${String(o)}`)}}async redeem(e,r){const n=await this.relayer.redeem(e.order_id,r);if(n.error)return g.Err(n.error);try{const s=yu[e.destination_swap.chain],o=await xk({chain:s,transport:P1()}).waitForTransactionReceipt({hash:n.val,confirmations:1,timeout:3e5});return o&&o.status==="success"?g.Ok(n.val?n.val:"Redeem hash not found"):g.Err("Redeem failed: Transaction receipt not successful")}catch(s){return g.Err(String(s))}}async refund(){return g.Err("Refund not supported")}}const gw=[{name:"LockingContract",type:"impl",interface_name:"src::mintable_lock_interface::ILockingContract"},{name:"src::mintable_lock_interface::ILockingContract",type:"interface",items:[{name:"set_locking_contract",type:"function",inputs:[{name:"locking_contract",type:"core::starknet::contract_address::ContractAddress"}],outputs:[],state_mutability:"external"},{name:"get_locking_contract",type:"function",inputs:[],outputs:[{type:"core::starknet::contract_address::ContractAddress"}],state_mutability:"view"}]},{name:"LockAndDelegate",type:"impl",interface_name:"src::mintable_lock_interface::ILockAndDelegate"},{name:"core::integer::u256",type:"struct",members:[{name:"low",type:"core::integer::u128"},{name:"high",type:"core::integer::u128"}]},{name:"src::mintable_lock_interface::ILockAndDelegate",type:"interface",items:[{name:"lock_and_delegate",type:"function",inputs:[{name:"delegatee",type:"core::starknet::contract_address::ContractAddress"},{name:"amount",type:"core::integer::u256"}],outputs:[],state_mutability:"external"},{name:"lock_and_delegate_by_sig",type:"function",inputs:[{name:"account",type:"core::starknet::contract_address::ContractAddress"},{name:"delegatee",type:"core::starknet::contract_address::ContractAddress"},{name:"amount",type:"core::integer::u256"},{name:"nonce",type:"core::felt252"},{name:"expiry",type:"core::integer::u64"},{name:"signature",type:"core::array::Array::<core::felt252>"}],outputs:[],state_mutability:"external"}]},{name:"MintableToken",type:"impl",interface_name:"src::mintable_token_interface::IMintableToken"},{name:"src::mintable_token_interface::IMintableToken",type:"interface",items:[{name:"permissioned_mint",type:"function",inputs:[{name:"account",type:"core::starknet::contract_address::ContractAddress"},{name:"amount",type:"core::integer::u256"}],outputs:[],state_mutability:"external"},{name:"permissioned_burn",type:"function",inputs:[{name:"account",type:"core::starknet::contract_address::ContractAddress"},{name:"amount",type:"core::integer::u256"}],outputs:[],state_mutability:"external"}]},{name:"MintableTokenCamelImpl",type:"impl",interface_name:"src::mintable_token_interface::IMintableTokenCamel"},{name:"src::mintable_token_interface::IMintableTokenCamel",type:"interface",items:[{name:"permissionedMint",type:"function",inputs:[{name:"account",type:"core::starknet::contract_address::ContractAddress"},{name:"amount",type:"core::integer::u256"}],outputs:[],state_mutability:"external"},{name:"permissionedBurn",type:"function",inputs:[{name:"account",type:"core::starknet::contract_address::ContractAddress"},{name:"amount",type:"core::integer::u256"}],outputs:[],state_mutability:"external"}]},{name:"Replaceable",type:"impl",interface_name:"src::replaceability_interface::IReplaceable"},{name:"core::array::Span::<core::felt252>",type:"struct",members:[{name:"snapshot",type:"@core::array::Array::<core::felt252>"}]},{name:"src::replaceability_interface::EICData",type:"struct",members:[{name:"eic_hash",type:"core::starknet::class_hash::ClassHash"},{name:"eic_init_data",type:"core::array::Span::<core::felt252>"}]},{name:"core::option::Option::<src::replaceability_interface::EICData>",type:"enum",variants:[{name:"Some",type:"src::replaceability_interface::EICData"},{name:"None",type:"()"}]},{name:"core::bool",type:"enum",variants:[{name:"False",type:"()"},{name:"True",type:"()"}]},{name:"src::replaceability_interface::ImplementationData",type:"struct",members:[{name:"impl_hash",type:"core::starknet::class_hash::ClassHash"},{name:"eic_data",type:"core::option::Option::<src::replaceability_interface::EICData>"},{name:"final",type:"core::bool"}]},{name:"src::replaceability_interface::IReplaceable",type:"interface",items:[{name:"get_upgrade_delay",type:"function",inputs:[],outputs:[{type:"core::integer::u64"}],state_mutability:"view"},{name:"get_impl_activation_time",type:"function",inputs:[{name:"implementation_data",type:"src::replaceability_interface::ImplementationData"}],outputs:[{type:"core::integer::u64"}],state_mutability:"view"},{name:"add_new_implementation",type:"function",inputs:[{name:"implementation_data",type:"src::replaceability_interface::ImplementationData"}],outputs:[],state_mutability:"external"},{name:"remove_implementation",type:"function",inputs:[{name:"implementation_data",type:"src::replaceability_interface::ImplementationData"}],outputs:[],state_mutability:"external"},{name:"replace_to",type:"function",inputs:[{name:"implementation_data",type:"src::replaceability_interface::ImplementationData"}],outputs:[],state_mutability:"external"}]},{name:"AccessControlImplExternal",type:"impl",interface_name:"src::access_control_interface::IAccessControl"},{name:"src::access_control_interface::IAccessControl",type:"interface",items:[{name:"has_role",type:"function",inputs:[{name:"role",type:"core::felt252"},{name:"account",type:"core::starknet::contract_address::ContractAddress"}],outputs:[{type:"core::bool"}],state_mutability:"view"},{name:"get_role_admin",type:"function",inputs:[{name:"role",type:"core::felt252"}],outputs:[{type:"core::felt252"}],state_mutability:"view"}]},{name:"RolesImpl",type:"impl",interface_name:"src::roles_interface::IMinimalRoles"},{name:"src::roles_interface::IMinimalRoles",type:"interface",items:[{name:"is_governance_admin",type:"function",inputs:[{name:"account",type:"core::starknet::contract_address::ContractAddress"}],outputs:[{type:"core::bool"}],state_mutability:"view"},{name:"is_upgrade_governor",type:"function",inputs:[{name:"account",type:"core::starknet::contract_address::ContractAddress"}],outputs:[{type:"core::bool"}],state_mutability:"view"},{name:"register_governance_admin",type:"function",inputs:[{name:"account",type:"core::starknet::contract_address::ContractAddress"}],outputs:[],state_mutability:"external"},{name:"remove_governance_admin",type:"function",inputs:[{name:"account",type:"core::starknet::contract_address::ContractAddress"}],outputs:[],state_mutability:"external"},{name:"register_upgrade_governor",type:"function",inputs:[{name:"account",type:"core::starknet::contract_address::ContractAddress"}],outputs:[],state_mutability:"external"},{name:"remove_upgrade_governor",type:"function",inputs:[{name:"account",type:"core::starknet::contract_address::ContractAddress"}],outputs:[],state_mutability:"external"},{name:"renounce",type:"function",inputs:[{name:"role",type:"core::felt252"}],outputs:[],state_mutability:"external"}]},{name:"ERC20Impl",type:"impl",interface_name:"openzeppelin::token::erc20::interface::IERC20"},{name:"openzeppelin::token::erc20::interface::IERC20",type:"interface",items:[{name:"name",type:"function",inputs:[],outputs:[{type:"core::felt252"}],state_mutability:"view"},{name:"symbol",type:"function",inputs:[],outputs:[{type:"core::felt252"}],state_mutability:"view"},{name:"decimals",type:"function",inputs:[],outputs:[{type:"core::integer::u8"}],state_mutability:"view"},{name:"total_supply",type:"function",inputs:[],outputs:[{type:"core::integer::u256"}],state_mutability:"view"},{name:"balance_of",type:"function",inputs:[{name:"account",type:"core::starknet::contract_address::ContractAddress"}],outputs:[{type:"core::integer::u256"}],state_mutability:"view"},{name:"allowance",type:"function",inputs:[{name:"owner",type:"core::starknet::contract_address::ContractAddress"},{name:"spender",type:"core::starknet::contract_address::ContractAddress"}],outputs:[{type:"core::integer::u256"}],state_mutability:"view"},{name:"transfer",type:"function",inputs:[{name:"recipient",type:"core::starknet::contract_address::ContractAddress"},{name:"amount",type:"core::integer::u256"}],outputs:[{type:"core::bool"}],state_mutability:"external"},{name:"transfer_from",type:"function",inputs:[{name:"sender",type:"core::starknet::contract_address::ContractAddress"},{name:"recipient",type:"core::starknet::contract_address::ContractAddress"},{name:"amount",type:"core::integer::u256"}],outputs:[{type:"core::bool"}],state_mutability:"external"},{name:"approve",type:"function",inputs:[{name:"spender",type:"core::starknet::contract_address::ContractAddress"},{name:"amount",type:"core::integer::u256"}],outputs:[{type:"core::bool"}],state_mutability:"external"}]},{name:"ERC20CamelOnlyImpl",type:"impl",interface_name:"openzeppelin::token::erc20::interface::IERC20CamelOnly"},{name:"openzeppelin::token::erc20::interface::IERC20CamelOnly",type:"interface",items:[{name:"totalSupply",type:"function",inputs:[],outputs:[{type:"core::integer::u256"}],state_mutability:"view"},{name:"balanceOf",type:"function",inputs:[{name:"account",type:"core::starknet::contract_address::ContractAddress"}],outputs:[{type:"core::integer::u256"}],state_mutability:"view"},{name:"transferFrom",type:"function",inputs:[{name:"sender",type:"core::starknet::contract_address::ContractAddress"},{name:"recipient",type:"core::starknet::contract_address::ContractAddress"},{name:"amount",type:"core::integer::u256"}],outputs:[{type:"core::bool"}],state_mutability:"external"}]},{name:"constructor",type:"constructor",inputs:[{name:"name",type:"core::felt252"},{name:"symbol",type:"core::felt252"},{name:"decimals",type:"core::integer::u8"},{name:"initial_supply",type:"core::integer::u256"},{name:"recipient",type:"core::starknet::contract_address::ContractAddress"},{name:"permitted_minter",type:"core::starknet::contract_address::ContractAddress"},{name:"provisional_governance_admin",type:"core::starknet::contract_address::ContractAddress"},{name:"upgrade_delay",type:"core::integer::u64"}]},{name:"increase_allowance",type:"function",inputs:[{name:"spender",type:"core::starknet::contract_address::ContractAddress"},{name:"added_value",type:"core::integer::u256"}],outputs:[{type:"core::bool"}],state_mutability:"external"},{name:"decrease_allowance",type:"function",inputs:[{name:"spender",type:"core::starknet::contract_address::ContractAddress"},{name:"subtracted_value",type:"core::integer::u256"}],outputs:[{type:"core::bool"}],state_mutability:"external"},{name:"increaseAllowance",type:"function",inputs:[{name:"spender",type:"core::starknet::contract_address::ContractAddress"},{name:"addedValue",type:"core::integer::u256"}],outputs:[{type:"core::bool"}],state_mutability:"external"},{name:"decreaseAllowance",type:"function",inputs:[{name:"spender",type:"core::starknet::contract_address::ContractAddress"},{name:"subtractedValue",type:"core::integer::u256"}],outputs:[{type:"core::bool"}],state_mutability:"external"},{kind:"struct",name:"src::strk::erc20_lockable::ERC20Lockable::Transfer",type:"event",members:[{kind:"data",name:"from",type:"core::starknet::contract_address::ContractAddress"},{kind:"data",name:"to",type:"core::starknet::contract_address::ContractAddress"},{kind:"data",name:"value",type:"core::integer::u256"}]},{kind:"struct",name:"src::strk::erc20_lockable::ERC20Lockable::Approval",type:"event",members:[{kind:"data",name:"owner",type:"core::starknet::contract_address::ContractAddress"},{kind:"data",name:"spender",type:"core::starknet::contract_address::ContractAddress"},{kind:"data",name:"value",type:"core::integer::u256"}]},{kind:"struct",name:"src::replaceability_interface::ImplementationAdded",type:"event",members:[{kind:"data",name:"implementation_data",type:"src::replaceability_interface::ImplementationData"}]},{kind:"struct",name:"src::replaceability_interface::ImplementationRemoved",type:"event",members:[{kind:"data",name:"implementation_data",type:"src::replaceability_interface::ImplementationData"}]},{kind:"struct",name:"src::replaceability_interface::ImplementationReplaced",type:"event",members:[{kind:"data",name:"implementation_data",type:"src::replaceability_interface::ImplementationData"}]},{kind:"struct",name:"src::replaceability_interface::ImplementationFinalized",type:"event",members:[{kind:"data",name:"impl_hash",type:"core::starknet::class_hash::ClassHash"}]},{kind:"struct",name:"src::access_control_interface::RoleGranted",type:"event",members:[{kind:"data",name:"role",type:"core::felt252"},{kind:"data",name:"account",type:"core::starknet::contract_address::ContractAddress"},{kind:"data",name:"sender",type:"core::starknet::contract_address::ContractAddress"}]},{kind:"struct",name:"src::access_control_interface::RoleRevoked",type:"event",members:[{kind:"data",name:"role",type:"core::felt252"},{kind:"data",name:"account",type:"core::starknet::contract_address::ContractAddress"},{kind:"data",name:"sender",type:"core::starknet::contract_address::ContractAddress"}]},{kind:"struct",name:"src::access_control_interface::RoleAdminChanged",type:"event",members:[{kind:"data",name:"role",type:"core::felt252"},{kind:"data",name:"previous_admin_role",type:"core::felt252"},{kind:"data",name:"new_admin_role",type:"core::felt252"}]},{kind:"struct",name:"src::roles_interface::GovernanceAdminAdded",type:"event",members:[{kind:"data",name:"added_account",type:"core::starknet::contract_address::ContractAddress"},{kind:"data",name:"added_by",type:"core::starknet::contract_address::ContractAddress"}]},{kind:"struct",name:"src::roles_interface::GovernanceAdminRemoved",type:"event",members:[{kind:"data",name:"removed_account",type:"core::starknet::contract_address::ContractAddress"},{kind:"data",name:"removed_by",type:"core::starknet::contract_address::ContractAddress"}]},{kind:"struct",name:"src::roles_interface::UpgradeGovernorAdded",type:"event",members:[{kind:"data",name:"added_account",type:"core::starknet::contract_address::ContractAddress"},{kind:"data",name:"added_by",type:"core::starknet::contract_address::ContractAddress"}]},{kind:"struct",name:"src::roles_interface::UpgradeGovernorRemoved",type:"event",members:[{kind:"data",name:"removed_account",type:"core::starknet::contract_address::ContractAddress"},{kind:"data",name:"removed_by",type:"core::starknet::contract_address::ContractAddress"}]},{kind:"enum",name:"src::strk::erc20_lockable::ERC20Lockable::Event",type:"event",variants:[{kind:"nested",name:"Transfer",type:"src::strk::erc20_lockable::ERC20Lockable::Transfer"},{kind:"nested",name:"Approval",type:"src::strk::erc20_lockable::ERC20Lockable::Approval"},{kind:"nested",name:"ImplementationAdded",type:"src::replaceability_interface::ImplementationAdded"},{kind:"nested",name:"ImplementationRemoved",type:"src::replaceability_interface::ImplementationRemoved"},{kind:"nested",name:"ImplementationReplaced",type:"src::replaceability_interface::ImplementationReplaced"},{kind:"nested",name:"ImplementationFinalized",type:"src::replaceability_interface::ImplementationFinalized"},{kind:"nested",name:"RoleGranted",type:"src::access_control_interface::RoleGranted"},{kind:"nested",name:"RoleRevoked",type:"src::access_control_interface::RoleRevoked"},{kind:"nested",name:"RoleAdminChanged",type:"src::access_control_interface::RoleAdminChanged"},{kind:"nested",name:"GovernanceAdminAdded",type:"src::roles_interface::GovernanceAdminAdded"},{kind:"nested",name:"GovernanceAdminRemoved",type:"src::roles_interface::GovernanceAdminRemoved"},{kind:"nested",name:"UpgradeGovernorAdded",type:"src::roles_interface::UpgradeGovernorAdded"},{kind:"nested",name:"UpgradeGovernorRemoved",type:"src::roles_interface::UpgradeGovernorRemoved"}]}],ww=async(t,e,r,n,s)=>{try{const i=await Ao(t.address,e,r,s);if(!i.ok)return g.Err(i.error);if(i.val>=n)return g.Ok("Allowance already approved");const a=Je.cairo.uint256(BigInt(n)),c=await t.execute([{contractAddress:g.with0x(e),entrypoint:"approve",calldata:[g.with0x(r),a.low,a.high]}]);await s.waitForTransaction(c.transaction_hash,{retryInterval:3e3,successStates:[Je.TransactionExecutionStatus.SUCCEEDED]}),await g.sleep(2e3);for(let u=0;u<20;u++){const f=await Ao(t.address,e,r,s);if(!f.ok)return g.Err(f.error);if(f.val>=n)return g.Ok(c.transaction_hash);await g.sleep(2e3);let l=0n;for(let p=0;p<20;p++){const d=await Ao(t.address,e,r,s);if(!d.ok)return g.Err(d.error);if(l=d.val,l>=n)break;await g.sleep(2e3)}return l<n?g.Err("Allowance not approved"):g.Ok(c.transaction_hash)}return g.Err("Allowance not approved after transaction.")}catch(i){return g.Err(`Failed to check or approve allowance: ${i instanceof Error?i.message:String(i)}`)}},Ao=async(t,e,r,n)=>{try{const i=await new Je.Contract(gw,g.with0x(e),n).call("allowance",[g.with0x(t),g.with0x(r)]);return g.Ok(BigInt((i==null?void 0:i.toString())||"0"))}catch(s){return g.Err(`Failed to check allowance: ${s instanceof Error?s.message:String(s)}`)}},vw=async(t,e,r,n,s)=>{const i=await Ao(t,e,r,n);return i.ok?g.Ok(i.val>=s):g.Err(i.error)},Ew=[{name:"HTLC",type:"impl",interface_name:"starknet_htlc::interface::IHTLC"},{name:"core::integer::u256",type:"struct",members:[{name:"low",type:"core::integer::u128"},{name:"high",type:"core::integer::u128"}]},{name:"starknet_htlc::interface::IHTLC",type:"interface",items:[{name:"token",type:"function",inputs:[],outputs:[{type:"core::starknet::contract_address::ContractAddress"}],state_mutability:"view"},{name:"initiate",type:"function",inputs:[{name:"redeemer",type:"core::starknet::contract_address::ContractAddress"},{name:"timelock",type:"core::integer::u128"},{name:"amount",type:"core::integer::u256"},{name:"secret_hash",type:"[core::integer::u32; 8]"}],outputs:[],state_mutability:"external"},{name:"initiate_on_behalf",type:"function",inputs:[{name:"initiator",type:"core::starknet::contract_address::ContractAddress"},{name:"redeemer",type:"core::starknet::contract_address::ContractAddress"},{name:"timelock",type:"core::integer::u128"},{name:"amount",type:"core::integer::u256"},{name:"secret_hash",type:"[core::integer::u32; 8]"}],outputs:[],state_mutability:"external"},{name:"initiate_with_signature",type:"function",inputs:[{name:"initiator",type:"core::starknet::contract_address::ContractAddress"},{name:"redeemer",type:"core::starknet::contract_address::ContractAddress"},{name:"timelock",type:"core::integer::u128"},{name:"amount",type:"core::integer::u256"},{name:"secret_hash",type:"[core::integer::u32; 8]"},{name:"signature",type:"core::array::Array::<core::felt252>"}],outputs:[],state_mutability:"external"},{name:"redeem",type:"function",inputs:[{name:"order_id",type:"core::felt252"},{name:"secret",type:"core::array::Array::<core::integer::u32>"}],outputs:[],state_mutability:"external"},{name:"refund",type:"function",inputs:[{name:"order_id",type:"core::felt252"}],outputs:[],state_mutability:"external"},{name:"instant_refund",type:"function",inputs:[{name:"order_id",type:"core::felt252"},{name:"signature",type:"core::array::Array::<core::felt252>"}],outputs:[],state_mutability:"external"}]},{name:"constructor",type:"constructor",inputs:[{name:"token",type:"core::starknet::contract_address::ContractAddress"}]},{kind:"struct",name:"starknet_htlc::interface::events::Initiated",type:"event",members:[{kind:"key",name:"order_id",type:"core::felt252"},{kind:"data",name:"secret_hash",type:"[core::integer::u32; 8]"},{kind:"data",name:"amount",type:"core::integer::u256"}]},{kind:"struct",name:"starknet_htlc::interface::events::Redeemed",type:"event",members:[{kind:"key",name:"order_id",type:"core::felt252"},{kind:"data",name:"secret_hash",type:"[core::integer::u32; 8]"},{kind:"data",name:"secret",type:"core::array::Array::<core::integer::u32>"}]},{kind:"struct",name:"starknet_htlc::interface::events::Refunded",type:"event",members:[{kind:"key",name:"order_id",type:"core::felt252"}]},{kind:"enum",name:"starknet_htlc::htlc::HTLC::Event",type:"event",variants:[{kind:"nested",name:"Initiated",type:"starknet_htlc::interface::events::Initiated"},{kind:"nested",name:"Redeemed",type:"starknet_htlc::interface::events::Redeemed"},{kind:"nested",name:"Refunded",type:"starknet_htlc::interface::events::Refunded"}]}],U_={StarknetDomain:[{name:"name",type:"shortstring"},{name:"version",type:"shortstring"},{name:"chainId",type:"shortstring"},{name:"revision",type:"shortstring"}],Initiate:[{name:"redeemer",type:"ContractAddress"},{name:"amount",type:"u256"},{name:"timelock",type:"u128"},{name:"secretHash",type:"u128*"}]};class Aw{constructor(e,r,n,s,i){this.url=e instanceof g.Url?e:new g.Url(e),this.account=r,this.starknetProvider=new Je.RpcProvider({nodeUrl:i||Qo[n].nodeUrl}),this.chainId=Qo[n].chainId,this.auth=s,this.relayer=new Pa(this.auth,this.url)}get htlcActorAddress(){if(!this.account.address)throw new Error("No account found");return this.account.address}async initiate(e){if(X.isStarknetOrderResponse(e))return this.initiateWithCreateOrderResponse(e);if(!this.account.address)return g.Err("No account address");const{source_swap:r}=e,{redeemer:n,amount:s}=r;if(!s||!n||!r.secret_hash||!r.timelock)return g.Err("Invalid order");try{const i=new Je.Contract(Ew,e.source_swap.asset,this.account),o=await(i==null?void 0:i.token()),a=Je.num.toHex(o),c=await vw(this.account.address,a,r.asset,this.starknetProvider,BigInt(r.amount));return c.error?g.Err(c.error):c.val?this.initiateRelay(e):this.approveAndInitiate(a,e)}catch(i){return g.Err(String(i))}}async approveAndInitiate(e,r){const{source_swap:n}=r,{redeemer:s,amount:i}=n,{secret_hash:o,timelock:a}=n,c=n.asset;try{const u=Je.cairo.uint256(BigInt(i)),f={contractAddress:g.with0x(e),entrypoint:"approve",calldata:[c,u.low,u.high]},l=Je.cairo.uint256(i),p={contractAddress:g.with0x(c),entrypoint:"initiate",calldata:[s,a.toString(),l.low.toString(),l.high.toString(),...g.hexToU32Array(o)]},d=await this.account.execute([f,p]);return await this.starknetProvider.waitForTransaction(d.transaction_hash,{retryInterval:2e3,successStates:[Je.TransactionExecutionStatus.SUCCEEDED]}),g.Ok(d.transaction_hash)}catch(u){return g.Err(`Failed to approve and initiate: ${String(u)}`)}}async initiateRelay(e){const{source_swap:r}=e,{redeemer:n,amount:s}=r;if(!r.secret_hash)return g.Err("Invalid order: secret_hash is undefined");const i=g.with0x(r.secret_hash),a={domain:{name:"HTLC",version:Je.shortString.encodeShortString("1"),chainId:this.chainId,revision:Je.TypedDataRevision.ACTIVE},primaryType:"Initiate",types:U_,message:{redeemer:n,amount:Je.cairo.uint256(s),timelock:e.source_swap.timelock,secretHash:g.hexToU32Array(i)}};try{const c=await this.account.signMessage(a),u=g0(c);if(u.error||!u.val)return g.Err(u.error||"Invalid signature");const f=await this.relayer.initiate(e.order_id,u.val);return f.error?g.Err(f.error):f.val?g.Ok(f.val):g.Err("Initiate: No result found")}catch(c){return g.Err(`Failed to initiate relayer: ${String(c)}`)}}async redeem(e,r){try{const n=await this.relayer.redeem(e.order_id,r);return n.error?g.Err(n.error):g.Ok(n.val)}catch(n){return g.Err(String(n))}}async executeApprovalTransaction(e){if(!this.account.address)return g.Err("No account address");if(!e.approval_transaction)return g.Ok("No approval transaction required");try{const r=e.approval_transaction,n=await this.account.execute([{contractAddress:g.with0x(r.to),entrypoint:g.with0x(r.selector),calldata:r.calldata}]);return await this.starknetProvider.waitForTransaction(n.transaction_hash,{retryInterval:2e3,successStates:[Je.TransactionExecutionStatus.SUCCEEDED]}),g.Ok(n.transaction_hash)}catch(r){return console.error("executeApprovalTransaction error:",r),g.Err("Failed to execute approval: "+(r instanceof Error&&(r==null?void 0:r.message)||String(r)))}}async initiateWithCreateOrderResponse(e){const r=await this.auth.getAuthHeaders();if(!r.ok)return g.Err(r.error);if(!this.account.address)return g.Err("No account address");const n=await this.executeApprovalTransaction(e);if(n.error)return g.Err(n.error);const{typed_data:s}=e;if(s===null){const c=e.initiate_transaction;if(!c)return g.Err("No initiate_transaction found for native initiate");const u=await this.account.execute([{contractAddress:g.with0x(c.to),entrypoint:g.with0x(c.selector),calldata:c.calldata}]);return await this.starknetProvider.waitForTransaction(u.transaction_hash,{retryInterval:2e3,successStates:[Je.TransactionExecutionStatus.SUCCEEDED]}),g.Ok(u.transaction_hash)}const i=await this.account.signMessage(s),o=g0(i);if(o.error)return g.Err(o.error);const a=await g.Fetcher.patch(this.url.endpoint("/v2/orders").endpoint(e.order_id).addSearchParams({action:"initiate"}),{body:JSON.stringify({signature:Array.isArray(o.val)?o.val.join(","):o.val}),headers:{...r.val,"Content-Type":"application/json"}});return a.error?g.Err(a.error):g.Ok(a.result)}async refund(){return g.Err("Refund is taken care of by the relayer")}}const M_="2WXpY8havGjfRxme9LUxtjFHTh1EfU3ur4v6wiK4KdNC",F_={name:"solana_spl_swaps",version:"0.4.0",spec:"0.1.0",description:"Created with Anchor"},j_=[{name:"initiate",docs:["Initiates the atomic swap. Funds are transferred from the initiator to the token vault.","As such, the initiator's signature is required for this instruction.","A sponsor may be involved, who pays PDA rent and transaction fees in SOL, allowing for the","initiator to participate without holding SOL. As such, the sponsor must also sign this transaction.","`swap_amount` represents the quantity of tokens to be transferred through this atomic swap","in base units of the token mint.",'E.g: A quantity of $1 represented by the token "USDC" with "6" decimals',"must be provided as 1,000,000.","`expires_in_slots` represents the number of slots after which (non-instant) refunds are allowed.","`destination_data` can hold optional information regarding the destination chain","in the atomic swap, to be emitted in the logs as-is."],discriminator:[5,63,123,113,153,75,148,14],accounts:[{name:"identity_pda",docs:["the token transfers of the `token_vault` PDA.","This PDA will be created during the first most invocation of the `initiate()` function","using the `init_if_needed` attribute, and be reused for all succeeding instructions."],writable:!0,pda:{seeds:[]}},{name:"swap_data",docs:["A PDA that maintains the on-chain state of the atomic swap throughout its lifecycle.","The choice of seeds ensure that any swap with equal `initiator` and","`secret_hash` wont be created until an existing one completes.","This PDA will be deleted upon completion of the swap."],writable:!0,pda:{seeds:[{kind:"account",path:"initiator"},{kind:"arg",path:"secret_hash"}]}},{name:"token_vault",docs:["A permanent PDA that is controlled by the program through the `identity_pda`, as implied",'by the value of the `authority` field below. As such, it serves as the "vault" by escrowing tokens',"of type `mint` for the atomic swap.","It is intended to be reused for all swaps involving the same mint.","Just like `identity_pda`, it will be created during the first most invocation of `initiate()`","of every distinct mint using the `init_if_needed` attribute."],writable:!0,pda:{seeds:[{kind:"account",path:"mint"}]}},{name:"initiator",docs:["The initiator of the atomic swap. They must sign this transaction."],signer:!0},{name:"initiator_token_account",docs:["The token account of the initiator"],writable:!0},{name:"mint",docs:["The mint of the tokens involved in this swap. As this is a parameter, this program can thus be reused","for atomic swaps with different mints."]},{name:"sponsor",docs:["Any entity that pays the PDA rent.","Upon completion of the swap, the PDA rent refund resulting from the","deletion of `swap_data` will be refunded to this address."],writable:!0,signer:!0},{name:"token_program",address:"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"},{name:"system_program",address:"11111111111111111111111111111111"}],args:[{name:"expires_in_slots",type:"u64"},{name:"redeemer",type:"pubkey"},{name:"secret_hash",type:{array:["u8",32]}},{name:"swap_amount",type:"u64"},{name:"destination_data",type:{option:"bytes"}}]},{name:"instant_refund",docs:["Funds are returned to the initiator, with the redeemer's consent.","As such, the redeemer's signature is required for this instruction.","This allows for refunds before the expiry slot."],discriminator:[211,202,103,41,183,147,59,251],accounts:[{name:"identity_pda",pda:{seeds:[]}},{name:"swap_data",docs:["The PDA holding the state information of the atomic swap. Will be closed upon successful execution","and the resulting rent refund will be sent to the sponsor."],writable:!0},{name:"token_vault",docs:["A token account controlled by the program, escrowing the tokens for this atomic swap"],writable:!0},{name:"initiator_token_account",writable:!0},{name:"redeemer",docs:["The redeemer of the atomic swap. They must sign this transaction."],writable:!0,signer:!0},{name:"sponsor",writable:!0},{name:"token_program",address:"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"}],args:[]},{name:"redeem",docs:["Funds are transferred to the redeemer. This instruction does not require any signatures."],discriminator:[184,12,86,149,70,196,97,225],accounts:[{name:"identity_pda",pda:{seeds:[]}},{name:"swap_data",docs:["The PDA holding the state information of the atomic swap. Will be closed upon successful execution","and the resulting rent refund will be sent to the sponsor."],writable:!0},{name:"token_vault",docs:["A token account controlled by the program, escrowing the tokens for this atomic swap"],writable:!0},{name:"redeemer_token_account",writable:!0},{name:"sponsor",writable:!0},{name:"token_program",address:"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"}],args:[{name:"secret",type:{array:["u8",32]}}]},{name:"refund",docs:["Funds are returned to the initiator, given that no redeems have occured","and the expiry slot has been reached.","This instruction does not require any signatures."],discriminator:[2,96,183,251,63,208,46,46],accounts:[{name:"identity_pda",pda:{seeds:[]}},{name:"swap_data",docs:["The PDA holding the state information of the atomic swap. Will be closed upon successful execution","and the resulting rent refund will be sent to the sponsor."],writable:!0},{name:"token_vault",docs:["A token account controlled by the program, escrowing the tokens for this atomic swap"],writable:!0},{name:"initiator_token_account",writable:!0},{name:"sponsor",writable:!0},{name:"token_program",address:"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"}],args:[]}],L_=[{name:"SwapAccount",discriminator:[53,126,9,14,14,197,105,182]}],H_=[{name:"Initiated",discriminator:[6,108,212,91,67,60,207,221]},{name:"InstantRefunded",discriminator:[220,50,18,207,183,232,218,25]},{name:"Redeemed",discriminator:[14,29,183,71,31,165,107,38]},{name:"Refunded",discriminator:[35,103,149,246,196,123,221,99]}],D_=[{code:6e3,name:"InvalidRedeemer",msg:"The provider redeemer is not the original redeemer of this swap"},{code:6001,name:"InvalidSecret",msg:"The provided secret does not correspond to the secret hash of this swap"},{code:6002,name:"InvalidSponsor",msg:"The provided sponsor is not the original sponsor of this swap"},{code:6003,name:"RefundBeforeExpiry",msg:"Attempt to perform a refund before expiry time"}],z_=[{name:"Initiated",docs:["Represents the initiated state of the swap where the initiator has deposited funds into the vault"],type:{kind:"struct",fields:[{name:"swap_amount",docs:["The quantity of tokens transferred through this atomic swap in base units of the token mint.",'E.g: A quantity of $1 represented by the token "USDC" with "6" decimals will be represented as 1,000,000.'],type:"u64"},{name:"expires_in_slots",docs:["`expires_in_slots` represents the number of slots after which (non-instant) refunds are allowed"],type:"u64"},{name:"initiator",type:"pubkey"},{name:"mint",type:"pubkey"},{name:"redeemer",type:"pubkey"},{name:"secret_hash",type:{array:["u8",32]}},{name:"destination_data",docs:["Information regarding the destination chain in the atomic swap"],type:{option:"bytes"}}]}},{name:"InstantRefunded",docs:["Represents the instant refund state of the swap, where the initiator has withdrawn funds the vault","with the redeemer's consent"],type:{kind:"struct",fields:[{name:"initiator",type:"pubkey"},{name:"secret_hash",type:{array:["u8",32]}}]}},{name:"Redeemed",docs:["Represents the redeemed state of the swap, where the redeemer has withdrawn funds from the vault"],type:{kind:"struct",fields:[{name:"initiator",type:"pubkey"},{name:"secret",type:{array:["u8",32]}}]}},{name:"Refunded",docs:["Represents the refund state of the swap, where the initiator has withdrawn funds from the vault past expiry"],type:{kind:"struct",fields:[{name:"initiator",type:"pubkey"},{name:"secret_hash",type:{array:["u8",32]}}]}},{name:"SwapAccount",docs:["Stores the state information of the atomic swap on-chain"],type:{kind:"struct",fields:[{name:"expiry_slot",docs:["The exact slot after which (non-instant) refunds are allowed"],type:"u64"},{name:"initiator",docs:["The initiator of the atomic swap"],type:"pubkey"},{name:"redeemer",docs:["The redeemer of the atomic swap"],type:"pubkey"},{name:"secret_hash",docs:["The secret hash associated with the atomic swap"],type:{array:["u8",32]}},{name:"swap_amount",docs:["The quantity tokens to be transferred through this atomic swap","in base units of the token mint.",'E.g: A quantity of $1 represented by the token "USDC" with "6" decimals',"must be provided as 1,000,000."],type:"u64"},{name:"identity_pda_bump",docs:["The bump associated with the identity pda.","This is needed by the program to authorize token transfers via the token vault."],type:"u8"},{name:"sponsor",docs:["The entity that paid the rent fees for the creation of this PDA.","This will be referenced during the refund of the same upon closing this PDA."],type:"pubkey"}]}}],G0={address:M_,metadata:F_,instructions:j_,accounts:L_,events:H_,errors:D_,types:z_},V_="2bag6xpshpvPe7SJ9nSDLHpxqhEAoHPGpEkjNSv7gxoF",q_={name:"solana_native_swaps",version:"0.3.0",spec:"0.1.0",description:"Created with Anchor"},G_=[{name:"initiate",discriminator:[5,63,123,113,153,75,148,14],accounts:[{name:"swap_account",writable:!0,pda:{seeds:[{kind:"const",value:[115,119,97,112,95,97,99,99,111,117,110,116]},{kind:"account",path:"initiator"},{kind:"arg",path:"secret_hash"}]}},{name:"initiator",docs:["Initiator must sign this transaction"],writable:!0,signer:!0},{name:"system_program",address:"11111111111111111111111111111111"}],args:[{name:"amount_lamports",type:"u64"},{name:"expires_in_slots",type:"u64"},{name:"redeemer",type:"pubkey"},{name:"secret_hash",type:{array:["u8",32]}}]},{name:"instant_refund",discriminator:[211,202,103,41,183,147,59,251],accounts:[{name:"swap_account",writable:!0},{name:"initiator",writable:!0},{name:"redeemer",docs:["Redeemer must sign this transaction"],signer:!0}],args:[]},{name:"redeem",discriminator:[184,12,86,149,70,196,97,225],accounts:[{name:"swap_account",writable:!0},{name:"initiator",docs:["This is included here for the PDA rent refund using the `close` attribute above"],writable:!0},{name:"redeemer",writable:!0}],args:[{name:"secret",type:{array:["u8",32]}}]},{name:"refund",discriminator:[2,96,183,251,63,208,46,46],accounts:[{name:"swap_account",writable:!0},{name:"initiator",writable:!0}],args:[]}],W_=[{name:"SwapAccount",discriminator:[53,126,9,14,14,197,105,182]}],K_=[{name:"Initiated",discriminator:[6,108,212,91,67,60,207,221]},{name:"InstantRefunded",discriminator:[220,50,18,207,183,232,218,25]},{name:"Redeemed",discriminator:[14,29,183,71,31,165,107,38]},{name:"Refunded",discriminator:[35,103,149,246,196,123,221,99]}],Z_=[{code:6e3,name:"InvalidInitiator",msg:"The provided initiator is not the original initiator of this swap account"},{code:6001,name:"InvalidRedeemer",msg:"The provided redeemer is not the original redeemer of this swap amount"},{code:6002,name:"InvalidSecret",msg:"The provided secret does not correspond to the secret hash in the swap account"},{code:6003,name:"RefundBeforeExpiry",msg:"Attempt to perform a refund before expiry time"}],Y_=[{name:"Initiated",type:{kind:"struct",fields:[{name:"amount_lamports",type:"u64"},{name:"expires_in_slots",type:"u64"},{name:"initiator",type:"pubkey"},{name:"redeemer",type:"pubkey"},{name:"secret_hash",type:{array:["u8",32]}}]}},{name:"InstantRefunded",type:{kind:"struct",fields:[{name:"initiator",type:"pubkey"},{name:"secret_hash",type:{array:["u8",32]}}]}},{name:"Redeemed",type:{kind:"struct",fields:[{name:"initiator",type:"pubkey"},{name:"secret",type:{array:["u8",32]}}]}},{name:"Refunded",type:{kind:"struct",fields:[{name:"initiator",type:"pubkey"},{name:"secret_hash",type:{array:["u8",32]}}]}},{name:"SwapAccount",type:{kind:"struct",fields:[{name:"amount_lamports",type:"u64"},{name:"expiry_slot",type:"u64"},{name:"initiator",type:"pubkey"},{name:"redeemer",type:"pubkey"},{name:"secret_hash",type:{array:["u8",32]}}]}}],wd={address:V_,metadata:q_,instructions:G_,accounts:W_,events:K_,errors:Z_,types:Y_};var wn={},mu={};Object.defineProperty(mu,"__esModule",{value:!0});mu.encode=X_;mu.decode=J_;const W0=Qs;function X_(t){return t.reduce((e,r)=>e+r.toString(16).padStart(2,"0"),"0x")}function J_(t){t.indexOf("0x")===0&&(t=t.substr(2)),t.length%2===1&&(t="0"+t);let e=t.match(/.{2}/g);return e===null?W0.Buffer.from([]):W0.Buffer.from(e.map(r=>parseInt(r,16)))}var bu={},qs={},lf;Object.defineProperty(qs,"__esModule",{value:!0});qs.isVersionedTransaction=qs.isBrowser=void 0;qs.chunks=Q_;qs.isBrowser=process.env.ANCHOR_BROWSER||typeof window<"u"&&!(!((lf=window.process)===null||lf===void 0)&&lf.hasOwnProperty("type"));function Q_(t,e){return Array.apply(0,new Array(Math.ceil(t.length/e))).map((r,n)=>t.slice(n*e,(n+1)*e))}const eP=t=>"version"in t;qs.isVersionedTransaction=eP;var df={},hf={},pf,K0;function Sw(){return K0||(K0=1,pf=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var e={},r=Symbol("test"),n=Object(r);if(typeof r=="string"||Object.prototype.toString.call(r)!=="[object Symbol]"||Object.prototype.toString.call(n)!=="[object Symbol]")return!1;var s=42;e[r]=s;for(var i in e)return!1;if(typeof Object.keys=="function"&&Object.keys(e).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(e).length!==0)return!1;var o=Object.getOwnPropertySymbols(e);if(o.length!==1||o[0]!==r||!Object.prototype.propertyIsEnumerable.call(e,r))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var a=Object.getOwnPropertyDescriptor(e,r);if(a.value!==s||a.enumerable!==!0)return!1}return!0}),pf}var yf,Z0;function gu(){if(Z0)return yf;Z0=1;var t=Sw();return yf=function(){return t()&&!!Symbol.toStringTag},yf}var mf,Y0;function xw(){return Y0||(Y0=1,mf=Object),mf}var bf,X0;function tP(){return X0||(X0=1,bf=Error),bf}var gf,J0;function rP(){return J0||(J0=1,gf=EvalError),gf}var wf,Q0;function nP(){return Q0||(Q0=1,wf=RangeError),wf}var vf,ey;function sP(){return ey||(ey=1,vf=ReferenceError),vf}var Ef,ty;function kw(){return ty||(ty=1,Ef=SyntaxError),Ef}var Af,ry;function Ia(){return ry||(ry=1,Af=TypeError),Af}var Sf,ny;function iP(){return ny||(ny=1,Sf=URIError),Sf}var xf,sy;function oP(){return sy||(sy=1,xf=Math.abs),xf}var kf,iy;function aP(){return iy||(iy=1,kf=Math.floor),kf}var Tf,oy;function cP(){return oy||(oy=1,Tf=Math.max),Tf}var _f,ay;function uP(){return ay||(ay=1,_f=Math.min),_f}var Pf,cy;function fP(){return cy||(cy=1,Pf=Math.pow),Pf}var If,uy;function lP(){return uy||(uy=1,If=Math.round),If}var Of,fy;function dP(){return fy||(fy=1,Of=Number.isNaN||function(e){return e!==e}),Of}var Bf,ly;function hP(){if(ly)return Bf;ly=1;var t=dP();return Bf=function(r){return t(r)||r===0?r:r<0?-1:1},Bf}var Cf,dy;function pP(){return dy||(dy=1,Cf=Object.getOwnPropertyDescriptor),Cf}var $f,hy;function Yi(){if(hy)return $f;hy=1;var t=pP();if(t)try{t([],"length")}catch{t=null}return $f=t,$f}var Rf,py;function wu(){if(py)return Rf;py=1;var t=Object.defineProperty||!1;if(t)try{t({},"a",{value:1})}catch{t=!1}return Rf=t,Rf}var Nf,yy;function yP(){if(yy)return Nf;yy=1;var t=typeof Symbol<"u"&&Symbol,e=Sw();return Nf=function(){return typeof t!="function"||typeof Symbol!="function"||typeof t("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:e()},Nf}var Uf,my;function Tw(){return my||(my=1,Uf=typeof Reflect<"u"&&Reflect.getPrototypeOf||null),Uf}var Mf,by;function _w(){if(by)return Mf;by=1;var t=xw();return Mf=t.getPrototypeOf||null,Mf}var Ff,gy;function mP(){if(gy)return Ff;gy=1;var t="Function.prototype.bind called on incompatible ",e=Object.prototype.toString,r=Math.max,n="[object Function]",s=function(c,u){for(var f=[],l=0;l<c.length;l+=1)f[l]=c[l];for(var p=0;p<u.length;p+=1)f[p+c.length]=u[p];return f},i=function(c,u){for(var f=[],l=u,p=0;l<c.length;l+=1,p+=1)f[p]=c[l];return f},o=function(a,c){for(var u="",f=0;f<a.length;f+=1)u+=a[f],f+1<a.length&&(u+=c);return u};return Ff=function(c){var u=this;if(typeof u!="function"||e.apply(u)!==n)throw new TypeError(t+u);for(var f=i(arguments,1),l,p=function(){if(this instanceof l){var S=u.apply(this,s(f,arguments));return Object(S)===S?S:this}return u.apply(c,s(f,arguments))},d=r(0,u.length-f.length),m=[],b=0;b<d;b++)m[b]="$"+b;if(l=Function("binder","return function ("+o(m,",")+"){ return binder.apply(this,arguments); }")(p),u.prototype){var E=function(){};E.prototype=u.prototype,l.prototype=new E,E.prototype=null}return l},Ff}var jf,wy;function Oa(){if(wy)return jf;wy=1;var t=mP();return jf=Function.prototype.bind||t,jf}var Lf,vy;function Gh(){return vy||(vy=1,Lf=Function.prototype.call),Lf}var Hf,Ey;function Wh(){return Ey||(Ey=1,Hf=Function.prototype.apply),Hf}var Df,Ay;function bP(){return Ay||(Ay=1,Df=typeof Reflect<"u"&&Reflect&&Reflect.apply),Df}var zf,Sy;function Pw(){if(Sy)return zf;Sy=1;var t=Oa(),e=Wh(),r=Gh(),n=bP();return zf=n||t.call(r,e),zf}var Vf,xy;function Kh(){if(xy)return Vf;xy=1;var t=Oa(),e=Ia(),r=Gh(),n=Pw();return Vf=function(i){if(i.length<1||typeof i[0]!="function")throw new e("a function is required");return n(t,r,i)},Vf}var qf,ky;function gP(){if(ky)return qf;ky=1;var t=Kh(),e=Yi(),r;try{r=[].__proto__===Array.prototype}catch(o){if(!o||typeof o!="object"||!("code"in o)||o.code!=="ERR_PROTO_ACCESS")throw o}var n=!!r&&e&&e(Object.prototype,"__proto__"),s=Object,i=s.getPrototypeOf;return qf=n&&typeof n.get=="function"?t([n.get]):typeof i=="function"?function(a){return i(a==null?a:s(a))}:!1,qf}var Gf,Ty;function Zh(){if(Ty)return Gf;Ty=1;var t=Tw(),e=_w(),r=gP();return Gf=t?function(s){return t(s)}:e?function(s){if(!s||typeof s!="object"&&typeof s!="function")throw new TypeError("getProto: not an object");return e(s)}:r?function(s){return r(s)}:null,Gf}var Wf,_y;function Iw(){if(_y)return Wf;_y=1;var t=Function.prototype.call,e=Object.prototype.hasOwnProperty,r=Oa();return Wf=r.call(t,e),Wf}var Kf,Py;function Ow(){if(Py)return Kf;Py=1;var t,e=xw(),r=tP(),n=rP(),s=nP(),i=sP(),o=kw(),a=Ia(),c=iP(),u=oP(),f=aP(),l=cP(),p=uP(),d=fP(),m=lP(),b=hP(),E=Function,S=function(oe){try{return E('"use strict"; return ('+oe+").constructor;")()}catch{}},P=Yi(),A=wu(),w=function(){throw new a},k=P?function(){try{return arguments.callee,w}catch{try{return P(arguments,"callee").get}catch{return w}}}():w,T=yP()(),B=Zh(),N=_w(),$=Tw(),H=Wh(),M=Gh(),V={},G=typeof Uint8Array>"u"||!B?t:B(Uint8Array),Q={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?t:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?t:ArrayBuffer,"%ArrayIteratorPrototype%":T&&B?B([][Symbol.iterator]()):t,"%AsyncFromSyncIteratorPrototype%":t,"%AsyncFunction%":V,"%AsyncGenerator%":V,"%AsyncGeneratorFunction%":V,"%AsyncIteratorPrototype%":V,"%Atomics%":typeof Atomics>"u"?t:Atomics,"%BigInt%":typeof BigInt>"u"?t:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?t:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?t:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?t:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":r,"%eval%":eval,"%EvalError%":n,"%Float16Array%":typeof Float16Array>"u"?t:Float16Array,"%Float32Array%":typeof Float32Array>"u"?t:Float32Array,"%Float64Array%":typeof Float64Array>"u"?t:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?t:FinalizationRegistry,"%Function%":E,"%GeneratorFunction%":V,"%Int8Array%":typeof Int8Array>"u"?t:Int8Array,"%Int16Array%":typeof Int16Array>"u"?t:Int16Array,"%Int32Array%":typeof Int32Array>"u"?t:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":T&&B?B(B([][Symbol.iterator]())):t,"%JSON%":typeof JSON=="object"?JSON:t,"%Map%":typeof Map>"u"?t:Map,"%MapIteratorPrototype%":typeof Map>"u"||!T||!B?t:B(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":e,"%Object.getOwnPropertyDescriptor%":P,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?t:Promise,"%Proxy%":typeof Proxy>"u"?t:Proxy,"%RangeError%":s,"%ReferenceError%":i,"%Reflect%":typeof Reflect>"u"?t:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?t:Set,"%SetIteratorPrototype%":typeof Set>"u"||!T||!B?t:B(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?t:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":T&&B?B(""[Symbol.iterator]()):t,"%Symbol%":T?Symbol:t,"%SyntaxError%":o,"%ThrowTypeError%":k,"%TypedArray%":G,"%TypeError%":a,"%Uint8Array%":typeof Uint8Array>"u"?t:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?t:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?t:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?t:Uint32Array,"%URIError%":c,"%WeakMap%":typeof WeakMap>"u"?t:WeakMap,"%WeakRef%":typeof WeakRef>"u"?t:WeakRef,"%WeakSet%":typeof WeakSet>"u"?t:WeakSet,"%Function.prototype.call%":M,"%Function.prototype.apply%":H,"%Object.defineProperty%":A,"%Object.getPrototypeOf%":N,"%Math.abs%":u,"%Math.floor%":f,"%Math.max%":l,"%Math.min%":p,"%Math.pow%":d,"%Math.round%":m,"%Math.sign%":b,"%Reflect.getPrototypeOf%":$};if(B)try{null.error}catch(oe){var W=B(B(oe));Q["%Error.prototype%"]=W}var K=function oe(ie){var me;if(ie==="%AsyncFunction%")me=S("async function () {}");else if(ie==="%GeneratorFunction%")me=S("function* () {}");else if(ie==="%AsyncGeneratorFunction%")me=S("async function* () {}");else if(ie==="%AsyncGenerator%"){var be=oe("%AsyncGeneratorFunction%");be&&(me=be.prototype)}else if(ie==="%AsyncIteratorPrototype%"){var we=oe("%AsyncGenerator%");we&&B&&(me=B(we.prototype))}return Q[ie]=me,me},re={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},q=Oa(),I=Iw(),j=q.call(M,Array.prototype.concat),J=q.call(H,Array.prototype.splice),O=q.call(M,String.prototype.replace),R=q.call(M,String.prototype.slice),F=q.call(M,RegExp.prototype.exec),ne=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,ae=/\\(\\)?/g,le=function(ie){var me=R(ie,0,1),be=R(ie,-1);if(me==="%"&&be!=="%")throw new o("invalid intrinsic syntax, expected closing `%`");if(be==="%"&&me!=="%")throw new o("invalid intrinsic syntax, expected opening `%`");var we=[];return O(ie,ne,function(ke,tt,Oe,Rr){we[we.length]=Oe?O(Rr,ae,"$1"):tt||ke}),we},ue=function(ie,me){var be=ie,we;if(I(re,be)&&(we=re[be],be="%"+we[0]+"%"),I(Q,be)){var ke=Q[be];if(ke===V&&(ke=K(be)),typeof ke>"u"&&!me)throw new a("intrinsic "+ie+" exists, but is not available. Please file an issue!");return{alias:we,name:be,value:ke}}throw new o("intrinsic "+ie+" does not exist!")};return Kf=function(ie,me){if(typeof ie!="string"||ie.length===0)throw new a("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof me!="boolean")throw new a('"allowMissing" argument must be a boolean');if(F(/^%?[^%]*%?$/,ie)===null)throw new o("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var be=le(ie),we=be.length>0?be[0]:"",ke=ue("%"+we+"%",me),tt=ke.name,Oe=ke.value,Rr=!1,ds=ke.alias;ds&&(we=ds[0],J(be,j([0,1],ds)));for(var z=1,Nr=!0;z<be.length;z+=1){var At=be[z],St=R(At,0,1),Rn=R(At,-1);if((St==='"'||St==="'"||St==="`"||Rn==='"'||Rn==="'"||Rn==="`")&&St!==Rn)throw new o("property names with quotes must have matching quotes");if((At==="constructor"||!Nr)&&(Rr=!0),we+="."+At,tt="%"+we+"%",I(Q,tt))Oe=Q[tt];else if(Oe!=null){if(!(At in Oe)){if(!me)throw new a("base intrinsic for "+ie+" exists, but the property is not available.");return}if(P&&z+1>=be.length){var ni=P(Oe,At);Nr=!!ni,Nr&&"get"in ni&&!("originalValue"in ni.get)?Oe=ni.get:Oe=Oe[At]}else Nr=I(Oe,At),Oe=Oe[At];Nr&&!Rr&&(Q[tt]=Oe)}}return Oe},Kf}var Zf,Iy;function Ba(){if(Iy)return Zf;Iy=1;var t=Ow(),e=Kh(),r=e([t("%String.prototype.indexOf%")]);return Zf=function(s,i){var o=t(s,!!i);return typeof o=="function"&&r(s,".prototype.")>-1?e([o]):o},Zf}var Yf,Oy;function wP(){if(Oy)return Yf;Oy=1;var t=gu()(),e=Ba(),r=e("Object.prototype.toString"),n=function(a){return t&&a&&typeof a=="object"&&Symbol.toStringTag in a?!1:r(a)==="[object Arguments]"},s=function(a){return n(a)?!0:a!==null&&typeof a=="object"&&"length"in a&&typeof a.length=="number"&&a.length>=0&&r(a)!=="[object Array]"&&"callee"in a&&r(a.callee)==="[object Function]"},i=function(){return n(arguments)}();return n.isLegacyArguments=s,Yf=i?n:s,Yf}var Xf,By;function vP(){if(By)return Xf;By=1;var t=Ba(),e=gu()(),r=Iw(),n=Yi(),s;if(e){var i=t("RegExp.prototype.exec"),o={},a=function(){throw o},c={toString:a,valueOf:a};typeof Symbol.toPrimitive=="symbol"&&(c[Symbol.toPrimitive]=a),s=function(p){if(!p||typeof p!="object")return!1;var d=n(p,"lastIndex"),m=d&&r(d,"value");if(!m)return!1;try{i(p,c)}catch(b){return b===o}}}else{var u=t("Object.prototype.toString"),f="[object RegExp]";s=function(p){return!p||typeof p!="object"&&typeof p!="function"?!1:u(p)===f}}return Xf=s,Xf}var Jf,Cy;function EP(){if(Cy)return Jf;Cy=1;var t=Ba(),e=vP(),r=t("RegExp.prototype.exec"),n=Ia();return Jf=function(i){if(!e(i))throw new n("`regex` must be a RegExp");return function(a){return r(i,a)!==null}},Jf}var Qf,$y;function AP(){if($y)return Qf;$y=1;var t=Ba(),e=EP(),r=e(/^\s*(?:function)?\*/),n=gu()(),s=Zh(),i=t("Object.prototype.toString"),o=t("Function.prototype.toString"),a=function(){if(!n)return!1;try{return Function("return function*() {}")()}catch{}},c;return Qf=function(f){if(typeof f!="function")return!1;if(r(o(f)))return!0;if(!n){var l=i(f);return l==="[object GeneratorFunction]"}if(!s)return!1;if(typeof c>"u"){var p=a();c=p?s(p):!1}return s(f)===c},Qf}var el,Ry;function SP(){if(Ry)return el;Ry=1;var t=Function.prototype.toString,e=typeof Reflect=="object"&&Reflect!==null&&Reflect.apply,r,n;if(typeof e=="function"&&typeof Object.defineProperty=="function")try{r=Object.defineProperty({},"length",{get:function(){throw n}}),n={},e(function(){throw 42},null,r)}catch(P){P!==n&&(e=null)}else e=null;var s=/^\s*class\b/,i=function(A){try{var w=t.call(A);return s.test(w)}catch{return!1}},o=function(A){try{return i(A)?!1:(t.call(A),!0)}catch{return!1}},a=Object.prototype.toString,c="[object Object]",u="[object Function]",f="[object GeneratorFunction]",l="[object HTMLAllCollection]",p="[object HTML document.all class]",d="[object HTMLCollection]",m=typeof Symbol=="function"&&!!Symbol.toStringTag,b=!(0 in[,]),E=function(){return!1};if(typeof document=="object"){var S=document.all;a.call(S)===a.call(document.all)&&(E=function(A){if((b||!A)&&(typeof A>"u"||typeof A=="object"))try{var w=a.call(A);return(w===l||w===p||w===d||w===c)&&A("")==null}catch{}return!1})}return el=e?function(A){if(E(A))return!0;if(!A||typeof A!="function"&&typeof A!="object")return!1;try{e(A,null,r)}catch(w){if(w!==n)return!1}return!i(A)&&o(A)}:function(A){if(E(A))return!0;if(!A||typeof A!="function"&&typeof A!="object")return!1;if(m)return o(A);if(i(A))return!1;var w=a.call(A);return w!==u&&w!==f&&!/^\[object HTML/.test(w)?!1:o(A)},el}var tl,Ny;function xP(){if(Ny)return tl;Ny=1;var t=SP(),e=Object.prototype.toString,r=Object.prototype.hasOwnProperty,n=function(c,u,f){for(var l=0,p=c.length;l<p;l++)r.call(c,l)&&(f==null?u(c[l],l,c):u.call(f,c[l],l,c))},s=function(c,u,f){for(var l=0,p=c.length;l<p;l++)f==null?u(c.charAt(l),l,c):u.call(f,c.charAt(l),l,c)},i=function(c,u,f){for(var l in c)r.call(c,l)&&(f==null?u(c[l],l,c):u.call(f,c[l],l,c))};function o(a){return e.call(a)==="[object Array]"}return tl=function(c,u,f){if(!t(u))throw new TypeError("iterator must be a function");var l;arguments.length>=3&&(l=f),o(c)?n(c,u,l):typeof c=="string"?s(c,u,l):i(c,u,l)},tl}var rl,Uy;function kP(){return Uy||(Uy=1,rl=["Float16Array","Float32Array","Float64Array","Int8Array","Int16Array","Int32Array","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array"]),rl}var nl,My;function TP(){if(My)return nl;My=1;var t=kP(),e=typeof globalThis>"u"?Qr:globalThis;return nl=function(){for(var n=[],s=0;s<t.length;s++)typeof e[t[s]]=="function"&&(n[n.length]=t[s]);return n},nl}var sl={exports:{}},il,Fy;function _P(){if(Fy)return il;Fy=1;var t=wu(),e=kw(),r=Ia(),n=Yi();return il=function(i,o,a){if(!i||typeof i!="object"&&typeof i!="function")throw new r("`obj` must be an object or a function`");if(typeof o!="string"&&typeof o!="symbol")throw new r("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new r("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new r("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new r("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new r("`loose`, if provided, must be a boolean");var c=arguments.length>3?arguments[3]:null,u=arguments.length>4?arguments[4]:null,f=arguments.length>5?arguments[5]:null,l=arguments.length>6?arguments[6]:!1,p=!!n&&n(i,o);if(t)t(i,o,{configurable:f===null&&p?p.configurable:!f,enumerable:c===null&&p?p.enumerable:!c,value:a,writable:u===null&&p?p.writable:!u});else if(l||!c&&!u&&!f)i[o]=a;else throw new e("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},il}var ol,jy;function PP(){if(jy)return ol;jy=1;var t=wu(),e=function(){return!!t};return e.hasArrayLengthDefineBug=function(){if(!t)return null;try{return t([],"length",{value:1}).length!==1}catch{return!0}},ol=e,ol}var al,Ly;function IP(){if(Ly)return al;Ly=1;var t=Ow(),e=_P(),r=PP()(),n=Yi(),s=Ia(),i=t("%Math.floor%");return al=function(a,c){if(typeof a!="function")throw new s("`fn` is not a function");if(typeof c!="number"||c<0||c>4294967295||i(c)!==c)throw new s("`length` must be a positive 32-bit integer");var u=arguments.length>2&&!!arguments[2],f=!0,l=!0;if("length"in a&&n){var p=n(a,"length");p&&!p.configurable&&(f=!1),p&&!p.writable&&(l=!1)}return(f||l||!u)&&(r?e(a,"length",c,!0,!0):e(a,"length",c)),a},al}var cl,Hy;function OP(){if(Hy)return cl;Hy=1;var t=Oa(),e=Wh(),r=Pw();return cl=function(){return r(t,e,arguments)},cl}var Dy;function BP(){return Dy||(Dy=1,function(t){var e=IP(),r=wu(),n=Kh(),s=OP();t.exports=function(o){var a=n(arguments),c=o.length-(arguments.length-1);return e(a,1+(c>0?c:0),!0)},r?r(t.exports,"apply",{value:s}):t.exports.apply=s}(sl)),sl.exports}var ul,zy;function Bw(){if(zy)return ul;zy=1;var t=xP(),e=TP(),r=BP(),n=Ba(),s=Yi(),i=Zh(),o=n("Object.prototype.toString"),a=gu()(),c=typeof globalThis>"u"?Qr:globalThis,u=e(),f=n("String.prototype.slice"),l=n("Array.prototype.indexOf",!0)||function(E,S){for(var P=0;P<E.length;P+=1)if(E[P]===S)return P;return-1},p={__proto__:null};a&&s&&i?t(u,function(b){var E=new c[b];if(Symbol.toStringTag in E&&i){var S=i(E),P=s(S,Symbol.toStringTag);if(!P&&S){var A=i(S);P=s(A,Symbol.toStringTag)}p["$"+b]=r(P.get)}}):t(u,function(b){var E=new c[b],S=E.slice||E.set;S&&(p["$"+b]=r(S))});var d=function(E){var S=!1;return t(p,function(P,A){if(!S)try{"$"+P(E)===A&&(S=f(A,1))}catch{}}),S},m=function(E){var S=!1;return t(p,function(P,A){if(!S)try{P(E),S=f(A,1)}catch{}}),S};return ul=function(E){if(!E||typeof E!="object")return!1;if(!a){var S=f(o(E),8,-1);return l(u,S)>-1?S:S!=="Object"?!1:m(E)}return s?d(E):null},ul}var fl,Vy;function CP(){if(Vy)return fl;Vy=1;var t=Bw();return fl=function(r){return!!t(r)},fl}var qy;function $P(){return qy||(qy=1,function(t){var e=wP(),r=AP(),n=Bw(),s=CP();function i(z){return z.call.bind(z)}var o=typeof BigInt<"u",a=typeof Symbol<"u",c=i(Object.prototype.toString),u=i(Number.prototype.valueOf),f=i(String.prototype.valueOf),l=i(Boolean.prototype.valueOf);if(o)var p=i(BigInt.prototype.valueOf);if(a)var d=i(Symbol.prototype.valueOf);function m(z,Nr){if(typeof z!="object")return!1;try{return Nr(z),!0}catch{return!1}}t.isArgumentsObject=e,t.isGeneratorFunction=r,t.isTypedArray=s;function b(z){return typeof Promise<"u"&&z instanceof Promise||z!==null&&typeof z=="object"&&typeof z.then=="function"&&typeof z.catch=="function"}t.isPromise=b;function E(z){return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?ArrayBuffer.isView(z):s(z)||R(z)}t.isArrayBufferView=E;function S(z){return n(z)==="Uint8Array"}t.isUint8Array=S;function P(z){return n(z)==="Uint8ClampedArray"}t.isUint8ClampedArray=P;function A(z){return n(z)==="Uint16Array"}t.isUint16Array=A;function w(z){return n(z)==="Uint32Array"}t.isUint32Array=w;function k(z){return n(z)==="Int8Array"}t.isInt8Array=k;function T(z){return n(z)==="Int16Array"}t.isInt16Array=T;function B(z){return n(z)==="Int32Array"}t.isInt32Array=B;function N(z){return n(z)==="Float32Array"}t.isFloat32Array=N;function $(z){return n(z)==="Float64Array"}t.isFloat64Array=$;function H(z){return n(z)==="BigInt64Array"}t.isBigInt64Array=H;function M(z){return n(z)==="BigUint64Array"}t.isBigUint64Array=M;function V(z){return c(z)==="[object Map]"}V.working=typeof Map<"u"&&V(new Map);function G(z){return typeof Map>"u"?!1:V.working?V(z):z instanceof Map}t.isMap=G;function Q(z){return c(z)==="[object Set]"}Q.working=typeof Set<"u"&&Q(new Set);function W(z){return typeof Set>"u"?!1:Q.working?Q(z):z instanceof Set}t.isSet=W;function K(z){return c(z)==="[object WeakMap]"}K.working=typeof WeakMap<"u"&&K(new WeakMap);function re(z){return typeof WeakMap>"u"?!1:K.working?K(z):z instanceof WeakMap}t.isWeakMap=re;function q(z){return c(z)==="[object WeakSet]"}q.working=typeof WeakSet<"u"&&q(new WeakSet);function I(z){return q(z)}t.isWeakSet=I;function j(z){return c(z)==="[object ArrayBuffer]"}j.working=typeof ArrayBuffer<"u"&&j(new ArrayBuffer);function J(z){return typeof ArrayBuffer>"u"?!1:j.working?j(z):z instanceof ArrayBuffer}t.isArrayBuffer=J;function O(z){return c(z)==="[object DataView]"}O.working=typeof ArrayBuffer<"u"&&typeof DataView<"u"&&O(new DataView(new ArrayBuffer(1),0,1));function R(z){return typeof DataView>"u"?!1:O.working?O(z):z instanceof DataView}t.isDataView=R;var F=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:void 0;function ne(z){return c(z)==="[object SharedArrayBuffer]"}function ae(z){return typeof F>"u"?!1:(typeof ne.working>"u"&&(ne.working=ne(new F)),ne.working?ne(z):z instanceof F)}t.isSharedArrayBuffer=ae;function le(z){return c(z)==="[object AsyncFunction]"}t.isAsyncFunction=le;function ue(z){return c(z)==="[object Map Iterator]"}t.isMapIterator=ue;function oe(z){return c(z)==="[object Set Iterator]"}t.isSetIterator=oe;function ie(z){return c(z)==="[object Generator]"}t.isGeneratorObject=ie;function me(z){return c(z)==="[object WebAssembly.Module]"}t.isWebAssemblyCompiledModule=me;function be(z){return m(z,u)}t.isNumberObject=be;function we(z){return m(z,f)}t.isStringObject=we;function ke(z){return m(z,l)}t.isBooleanObject=ke;function tt(z){return o&&m(z,p)}t.isBigIntObject=tt;function Oe(z){return a&&m(z,d)}t.isSymbolObject=Oe;function Rr(z){return be(z)||we(z)||ke(z)||tt(z)||Oe(z)}t.isBoxedPrimitive=Rr;function ds(z){return typeof Uint8Array<"u"&&(J(z)||ae(z))}t.isAnyArrayBuffer=ds,["isProxy","isExternal","isModuleNamespaceObject"].forEach(function(z){Object.defineProperty(t,z,{enumerable:!1,value:function(){throw new Error(z+" is not supported in userland")}})})}(hf)),hf}var ll,Gy;function RP(){return Gy||(Gy=1,ll=function(e){return e&&typeof e=="object"&&typeof e.copy=="function"&&typeof e.fill=="function"&&typeof e.readUInt8=="function"}),ll}var Ja={exports:{}},Wy;function NP(){return Wy||(Wy=1,typeof Object.create=="function"?Ja.exports=function(e,r){r&&(e.super_=r,e.prototype=Object.create(r.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:Ja.exports=function(e,r){if(r){e.super_=r;var n=function(){};n.prototype=r.prototype,e.prototype=new n,e.prototype.constructor=e}}),Ja.exports}var Ky;function Cw(){return Ky||(Ky=1,function(t){var e=Object.getOwnPropertyDescriptors||function(R){for(var F=Object.keys(R),ne={},ae=0;ae<F.length;ae++)ne[F[ae]]=Object.getOwnPropertyDescriptor(R,F[ae]);return ne},r=/%[sdj%]/g;t.format=function(O){if(!k(O)){for(var R=[],F=0;F<arguments.length;F++)R.push(o(arguments[F]));return R.join(" ")}for(var F=1,ne=arguments,ae=ne.length,le=String(O).replace(r,function(oe){if(oe==="%%")return"%";if(F>=ae)return oe;switch(oe){case"%s":return String(ne[F++]);case"%d":return Number(ne[F++]);case"%j":try{return JSON.stringify(ne[F++])}catch{return"[Circular]"}default:return oe}}),ue=ne[F];F<ae;ue=ne[++F])P(ue)||!$(ue)?le+=" "+ue:le+=" "+o(ue);return le},t.deprecate=function(O,R){if(typeof process<"u"&&process.noDeprecation===!0)return O;if(typeof process>"u")return function(){return t.deprecate(O,R).apply(this,arguments)};var F=!1;function ne(){if(!F){if(process.throwDeprecation)throw new Error(R);process.traceDeprecation?console.trace(R):console.error(R),F=!0}return O.apply(this,arguments)}return ne};var n={},s=/^$/;if(process.env.NODE_DEBUG){var i=process.env.NODE_DEBUG;i=i.replace(/[|\\{}()[\]^$+?.]/g,"\\$&").replace(/\*/g,".*").replace(/,/g,"$|^").toUpperCase(),s=new RegExp("^"+i+"$","i")}t.debuglog=function(O){if(O=O.toUpperCase(),!n[O])if(s.test(O)){var R=process.pid;n[O]=function(){var F=t.format.apply(t,arguments);console.error("%s %d: %s",O,R,F)}}else n[O]=function(){};return n[O]};function o(O,R){var F={seen:[],stylize:c};return arguments.length>=3&&(F.depth=arguments[2]),arguments.length>=4&&(F.colors=arguments[3]),S(R)?F.showHidden=R:R&&t._extend(F,R),B(F.showHidden)&&(F.showHidden=!1),B(F.depth)&&(F.depth=2),B(F.colors)&&(F.colors=!1),B(F.customInspect)&&(F.customInspect=!0),F.colors&&(F.stylize=a),f(F,O,F.depth)}t.inspect=o,o.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},o.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"};function a(O,R){var F=o.styles[R];return F?"\x1B["+o.colors[F][0]+"m"+O+"\x1B["+o.colors[F][1]+"m":O}function c(O,R){return O}function u(O){var R={};return O.forEach(function(F,ne){R[F]=!0}),R}function f(O,R,F){if(O.customInspect&&R&&V(R.inspect)&&R.inspect!==t.inspect&&!(R.constructor&&R.constructor.prototype===R)){var ne=R.inspect(F,O);return k(ne)||(ne=f(O,ne,F)),ne}var ae=l(O,R);if(ae)return ae;var le=Object.keys(R),ue=u(le);if(O.showHidden&&(le=Object.getOwnPropertyNames(R)),M(R)&&(le.indexOf("message")>=0||le.indexOf("description")>=0))return p(R);if(le.length===0){if(V(R)){var oe=R.name?": "+R.name:"";return O.stylize("[Function"+oe+"]","special")}if(N(R))return O.stylize(RegExp.prototype.toString.call(R),"regexp");if(H(R))return O.stylize(Date.prototype.toString.call(R),"date");if(M(R))return p(R)}var ie="",me=!1,be=["{","}"];if(E(R)&&(me=!0,be=["[","]"]),V(R)){var we=R.name?": "+R.name:"";ie=" [Function"+we+"]"}if(N(R)&&(ie=" "+RegExp.prototype.toString.call(R)),H(R)&&(ie=" "+Date.prototype.toUTCString.call(R)),M(R)&&(ie=" "+p(R)),le.length===0&&(!me||R.length==0))return be[0]+ie+be[1];if(F<0)return N(R)?O.stylize(RegExp.prototype.toString.call(R),"regexp"):O.stylize("[Object]","special");O.seen.push(R);var ke;return me?ke=d(O,R,F,ue,le):ke=le.map(function(tt){return m(O,R,F,ue,tt,me)}),O.seen.pop(),b(ke,ie,be)}function l(O,R){if(B(R))return O.stylize("undefined","undefined");if(k(R)){var F="'"+JSON.stringify(R).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return O.stylize(F,"string")}if(w(R))return O.stylize(""+R,"number");if(S(R))return O.stylize(""+R,"boolean");if(P(R))return O.stylize("null","null")}function p(O){return"["+Error.prototype.toString.call(O)+"]"}function d(O,R,F,ne,ae){for(var le=[],ue=0,oe=R.length;ue<oe;++ue)q(R,String(ue))?le.push(m(O,R,F,ne,String(ue),!0)):le.push("");return ae.forEach(function(ie){ie.match(/^\d+$/)||le.push(m(O,R,F,ne,ie,!0))}),le}function m(O,R,F,ne,ae,le){var ue,oe,ie;if(ie=Object.getOwnPropertyDescriptor(R,ae)||{value:R[ae]},ie.get?ie.set?oe=O.stylize("[Getter/Setter]","special"):oe=O.stylize("[Getter]","special"):ie.set&&(oe=O.stylize("[Setter]","special")),q(ne,ae)||(ue="["+ae+"]"),oe||(O.seen.indexOf(ie.value)<0?(P(F)?oe=f(O,ie.value,null):oe=f(O,ie.value,F-1),oe.indexOf(`
|
|
73
|
+
`.trim().replace(/\s+/g," "))}generateLeaves(e,r){let n,s,i;switch(r){case"redeem":n=e.destination_swap,s=n.delegate,i=n.delegate;break;case"refund":n=e.source_swap,s=n.delegate,i=n.delegate;break;case"instantRefund":n=e.source_swap,s=n.redeemer,i=n.redeemer;break;default:throw new Error("Invalid leaf generation type")}return[{version:Ya,output:this.redeemLeaf(n.secret_hash,je(s))},[{version:Ya,output:this.refundLeaf(n.timelock,je(n.initiator))},{version:Ya,output:this.instantRefundLeaf(je(n.initiator),je(i))}]]}generateMerkleProofFor(e,r){const n=this.leafHash(1,r),s=this.leafHash(2,r),i=this.leafHash(0,r);switch(e){case 1:{const o=qk(i,s);return[Se.crypto.taggedHash("TapBranch",Buffer.concat(o))]}case 0:return[s,n];case 2:return[i,n];default:throw new Error(rr.invalidLeaf)}}getProvider(){return this.signer.getProvider()}get getPublicKey(){return this.signer.getPublicKey()}get htlcActorAddress(){return this.signer.getPublicKey()}};class cw{constructor(e,r){this.quoteUrl=new g.Url(e),this.auth=r}async getQuoteFromAssets({fromAsset:e,toAsset:r,amount:n,isExactOut:s=!1,options:i}){const o=X.ChainAsset.from(e),a=X.ChainAsset.from(r);return this.getQuote(o,a,n,s,i)}async getQuote(e,r,n,s=!1,i){try{const o=await this.auth.getAuthHeaders();if(o.error)return g.Err(o.error);const a={from:X.ChainAsset.from(e).toString(),to:X.ChainAsset.from(r).toString(),...s?{to_amount:n.toString()}:{from_amount:n.toString()},...(i==null?void 0:i.affiliateFee)!==void 0&&{affiliate_fee:i.affiliateFee.toString()}},c=this.quoteUrl.endpoint("/v2/quote").addSearchParams(a),u=await g.Fetcher.get(c,{retryCount:0,...i==null?void 0:i.request,headers:{...o.val,"Content-Type":"application/json"}});return u.error?g.Err(u.error):u.result?g.Ok(u.result):g.Err("GetQuote: Unexpected error, result is undefined")}catch(o){return g.Err("GetQuote:",String(o))}}}class Mi extends g.EventBroker{get isInitialized(){return!!this.digestKey}constructor(e,r){super(),this.digestKey=e,this.walletClient=r}static fromDigestKey(e){return new Mi(g.trim0x(e))}static fromWalletClient(e){return new Mi(void 0,e)}async initialize(){if(this.digestKey)return g.Ok("Already initialized");const e=await this.deriveDigestKeyFromWalletClient();return e.error?g.Err(e.error):(this.emit("initialized",!0),g.Ok("Initialized"))}async deriveDigestKeyFromWalletClient(){if(!this.walletClient)return g.Err("No walletClient found");if(!this.walletClient.account)return g.Err("No account found");try{const e=await this.walletClient.signTypedData({account:this.walletClient.account,types:{EIP712Domain:[{name:"name",type:"string"},{name:"version",type:"string"}],Data:[{name:"Message",type:"string"},{name:"Version",type:"string"},{name:"Nonce",type:"uint256"}]},domain:{name:"GARDEN FINANCE",version:"1"},primaryType:"Data",message:{Message:"Initialize your account",Version:"1.0.2",Nonce:1n}});return this.digestKey=g.trim0x(ho(e)),this.emit("initialized",!0),g.Ok(this.digestKey)}catch(e){return g.Err("Failed to initialize: "+e)}}async getDigestKey(){if(!this.digestKey&&!this.walletClient)return g.Err("No private key or wallet client found");if(!this.digestKey&&this.walletClient){const e=await this.deriveDigestKeyFromWalletClient();if(e.error)return g.Err(e.error)}return this.digestKey?g.Ok(this.digestKey):g.Err("No private key found")}async generateSecret(e){const r=await this.signMessage(e);if(!r.ok)return g.Err(r.error);const n=ho(g.with0x(r.val)),s=ho(n);return g.Ok({secret:n,secretHash:s})}async signMessage(e){if(!this.digestKey){const u=await this.getDigestKey();if(!u.ok)return g.Err(u.error);this.digestKey=u.val}const r=nc.ECPairFactory(ur),n="Garden.fi"+e.toString(),s=Buffer.from(n,"utf8"),i=ho(s),o=Buffer.from(g.trim0x(this.digestKey),"hex");if(o.length!==32)return g.Err("Invalid private key length. Expected 32 bytes.");const c=r.fromPrivateKey(o).sign(Buffer.from(g.trim0x(i),"hex"));return g.Ok(c.toString("hex"))}}const uw=[{inputs:[{internalType:"address",name:"token_",type:"address"},{internalType:"string",name:"name",type:"string"},{internalType:"string",name:"version",type:"string"}],stateMutability:"nonpayable",type:"constructor"},{inputs:[],name:"InvalidShortString",type:"error"},{inputs:[{internalType:"string",name:"str",type:"string"}],name:"StringTooLong",type:"error"},{anonymous:!1,inputs:[],name:"EIP712DomainChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes32",name:"orderID",type:"bytes32"},{indexed:!0,internalType:"bytes32",name:"secretHash",type:"bytes32"},{indexed:!1,internalType:"uint256",name:"amount",type:"uint256"}],name:"Initiated",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes32",name:"orderID",type:"bytes32"},{indexed:!0,internalType:"bytes32",name:"secretHash",type:"bytes32"},{indexed:!1,internalType:"bytes",name:"secret",type:"bytes"}],name:"Redeemed",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes32",name:"orderID",type:"bytes32"}],name:"Refunded",type:"event"},{inputs:[],name:"eip712Domain",outputs:[{internalType:"bytes1",name:"fields",type:"bytes1"},{internalType:"string",name:"name",type:"string"},{internalType:"string",name:"version",type:"string"},{internalType:"uint256",name:"chainId",type:"uint256"},{internalType:"address",name:"verifyingContract",type:"address"},{internalType:"bytes32",name:"salt",type:"bytes32"},{internalType:"uint256[]",name:"extensions",type:"uint256[]"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"redeemer",type:"address"},{internalType:"uint256",name:"timelock",type:"uint256"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"bytes32",name:"secretHash",type:"bytes32"}],name:"initiate",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"redeemer",type:"address"},{internalType:"uint256",name:"timelock",type:"uint256"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"bytes32",name:"secretHash",type:"bytes32"},{internalType:"bytes",name:"signature",type:"bytes"}],name:"initiateWithSignature",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"orderID",type:"bytes32"},{internalType:"bytes",name:"signature",type:"bytes"}],name:"instantRefund",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{internalType:"address",name:"redeemer",type:"address"},{internalType:"uint256",name:"expiry",type:"uint256"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"bytes32",name:"secretHash",type:"bytes32"},{internalType:"bytes",name:"signature",type:"bytes"}],internalType:"struct HTLC.InitWithSig[]",name:"inits",type:"tuple[]"},{components:[{internalType:"bytes32",name:"orderID",type:"bytes32"},{internalType:"bytes",name:"secret",type:"bytes"}],internalType:"struct HTLC.Redeem[]",name:"redeems",type:"tuple[]"},{components:[{internalType:"bytes32",name:"orderID",type:"bytes32"}],internalType:"struct HTLC.Refund[]",name:"refunds",type:"tuple[]"}],name:"multicall",outputs:[{internalType:"bool[]",name:"results",type:"bool[]"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"",type:"bytes32"}],name:"orders",outputs:[{internalType:"bool",name:"isFulfilled",type:"bool"},{internalType:"address",name:"initiator",type:"address"},{internalType:"address",name:"redeemer",type:"address"},{internalType:"uint256",name:"initiatedAt",type:"uint256"},{internalType:"uint256",name:"timelock",type:"uint256"},{internalType:"uint256",name:"amount",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"orderID",type:"bytes32"},{internalType:"bytes",name:"secret",type:"bytes"}],name:"redeem",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"orderID",type:"bytes32"}],name:"refund",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"token",outputs:[{internalType:"contract IERC20",name:"",type:"address"}],stateMutability:"view",type:"function"}],c_=[{inputs:[{internalType:"string",name:"name",type:"string"},{internalType:"string",name:"version",type:"string"}],stateMutability:"nonpayable",type:"constructor"},{inputs:[],name:"InvalidShortString",type:"error"},{inputs:[],name:"NativeHTLC__DuplicateOrder",type:"error"},{inputs:[],name:"NativeHTLC__IncorrectFundsRecieved",type:"error"},{inputs:[],name:"NativeHTLC__IncorrectSecret",type:"error"},{inputs:[],name:"NativeHTLC__InsufficientBalance",type:"error"},{inputs:[],name:"NativeHTLC__InvalidRedeemerSignature",type:"error"},{inputs:[],name:"NativeHTLC__OrderFulfilled",type:"error"},{inputs:[],name:"NativeHTLC__OrderNotExpired",type:"error"},{inputs:[],name:"NativeHTLC__OrderNotInitiated",type:"error"},{inputs:[],name:"NativeHTLC__SameInitiatorAndRedeemer",type:"error"},{inputs:[],name:"NativeHTLC__ZeroAddressInitiator",type:"error"},{inputs:[],name:"NativeHTLC__ZeroAddressRedeemer",type:"error"},{inputs:[],name:"NativeHTLC__ZeroAmount",type:"error"},{inputs:[],name:"NativeHTLC__ZeroTimelock",type:"error"},{inputs:[{internalType:"string",name:"str",type:"string"}],name:"StringTooLong",type:"error"},{anonymous:!1,inputs:[],name:"EIP712DomainChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes32",name:"orderID",type:"bytes32"},{indexed:!0,internalType:"bytes32",name:"secretHash",type:"bytes32"},{indexed:!1,internalType:"uint256",name:"amount",type:"uint256"}],name:"Initiated",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes32",name:"orderID",type:"bytes32"},{indexed:!0,internalType:"bytes32",name:"secretHash",type:"bytes32"},{indexed:!1,internalType:"bytes",name:"secret",type:"bytes"}],name:"Redeemed",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes32",name:"orderID",type:"bytes32"}],name:"Refunded",type:"event"},{inputs:[],name:"eip712Domain",outputs:[{internalType:"bytes1",name:"fields",type:"bytes1"},{internalType:"string",name:"name",type:"string"},{internalType:"string",name:"version",type:"string"},{internalType:"uint256",name:"chainId",type:"uint256"},{internalType:"address",name:"verifyingContract",type:"address"},{internalType:"bytes32",name:"salt",type:"bytes32"},{internalType:"uint256[]",name:"extensions",type:"uint256[]"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address payable",name:"redeemer",type:"address"},{internalType:"uint256",name:"timelock",type:"uint256"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"bytes32",name:"secretHash",type:"bytes32"}],name:"initiate",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address payable",name:"initiator",type:"address"},{internalType:"address payable",name:"redeemer",type:"address"},{internalType:"uint256",name:"timelock",type:"uint256"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"bytes32",name:"secretHash",type:"bytes32"}],name:"initiateOnBehalf",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"bytes32",name:"orderID",type:"bytes32"},{internalType:"bytes",name:"signature",type:"bytes"}],name:"instantRefund",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"orderID",type:"bytes32"}],name:"instantRefundDigest",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"",type:"bytes32"}],name:"orders",outputs:[{internalType:"bool",name:"isFulfilled",type:"bool"},{internalType:"address payable",name:"initiator",type:"address"},{internalType:"address payable",name:"redeemer",type:"address"},{internalType:"uint256",name:"initiatedAt",type:"uint256"},{internalType:"uint256",name:"timelock",type:"uint256"},{internalType:"uint256",name:"amount",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"orderID",type:"bytes32"},{internalType:"bytes",name:"secret",type:"bytes"}],name:"redeem",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"orderID",type:"bytes32"}],name:"refund",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"token",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"}];class Pa{constructor(e,r){this.auth=e,this.url=r instanceof g.Url?r:new g.Url(r)}async initiate(e,r){try{const n=await this.auth.getAuthHeaders();if(!n.ok)return g.Err(n.error);const s=await g.Fetcher.patch(this.url.endpoint("/v2/orders").endpoint(e).addSearchParams({action:"initiate"}),{body:JSON.stringify({signature:r}),headers:{...n.val,"Content-Type":"application/json"}});return s.error||!s.result?g.Err(s.error||"Initiate failed"):g.Ok(s.result)}catch(n){return g.Err(String(n))}}async redeem(e,r){try{const n=await this.auth.getAuthHeaders();if(!n.ok)return g.Err(n.error);const s=await g.Fetcher.patch(this.url.endpoint("/v2/orders").endpoint(e).addSearchParams({action:"redeem"}),{body:JSON.stringify({secret:g.trim0x(r)}),headers:{...n.val,"Content-Type":"application/json"},retryCount:10,retryDelay:2e3});return s.error?g.Err(s.error):s.result?g.Ok(s.result):g.Err("Redeem: No result found")}catch(n){return g.Err(String(n))}}}const u_=async(t,e)=>{if(!t.account)return g.Err("No account found");try{const n=await hh({address:g.with0x(e.htlc),abi:c_,client:t}).write.initiate([g.with0x(e.redeemer),e.timelock,e.amount,g.with0x(e.secretHash)],{account:t.account,chain:t.chain,value:e.amount}),s=await g.waitForTransactionReceipt(t,n);return s.ok?!s.val||s.val.status!=="success"?g.Err("Native initiate transaction failed"):g.Ok(n):g.Err(s.error)}catch(r){return $h(r)?g.Ok("already initiated"):g.Err("Failed to initiate on native HTLC",String(r))}},f_=async(t,e,r,n)=>{if(!t.account)return g.Err("No account found");try{const s=hh({address:g.with0x(n.htlc),abi:uw,client:t}),i=await g.checkAllowanceAndApprove(Number(n.amount),n.token,n.htlc,t);if(!i.ok)return g.Err(i.error);const o=await s.read.eip712Domain(),a=await t.signTypedData({account:t.account,domain:{name:o[1],version:o[2],chainId:Number(o[3]),verifyingContract:o[4]},types:{Initiate:[{name:"redeemer",type:"address"},{name:"timelock",type:"uint256"},{name:"amount",type:"uint256"},{name:"secretHash",type:"bytes32"}]},primaryType:"Initiate",message:{redeemer:g.with0x(n.redeemer),timelock:n.timelock,amount:n.amount,secretHash:g.with0x(n.secretHash)}}),c=new Pa(r,e),u=await B1({wallet:t,attempt:()=>c.initiate(n.orderId,a)});if(u)return g.Ok(u);const f=await s.write.initiate([g.with0x(n.redeemer),n.timelock,n.amount,g.with0x(n.secretHash)],{account:t.account,chain:t.chain}),l=await g.waitForTransactionReceipt(t,f);return l.ok?!l.val||l.val.status!=="success"?g.Err("Failed to initiate (fallback)"):g.Ok(f):g.Err(l.error)}catch(s){return $h(s)?g.Ok("already initiated"):g.Err("Failed to initiate on ERC20 HTLC",String(s))}},l_=async(t,e)=>{if(!t.account)return g.Err("No account found");try{const r=await t.sendTransaction({account:t.account,to:g.with0x(e.to),value:BigInt(e.value),data:g.with0x(e.data),gas:BigInt(e.gas_limit),chain:t.chain}),n=await g.waitForTransactionReceipt(t,r);return n.ok?!n.val||n.val.status!=="success"?g.Err("Approval transaction failed"):g.Ok(r):g.Err(n.error)}catch(r){return g.Err("Failed to execute approval: "+String(r))}},d_={gasPriceOracle:{address:"0x420000000000000000000000000000000000000F"},l1Block:{address:"0x4200000000000000000000000000000000000015"},l2CrossDomainMessenger:{address:"0x4200000000000000000000000000000000000007"},l2Erc721Bridge:{address:"0x4200000000000000000000000000000000000014"},l2StandardBridge:{address:"0x4200000000000000000000000000000000000010"},l2ToL1MessagePasser:{address:"0x4200000000000000000000000000000000000016"}},h_={block:sE({format(t){var r;return{transactions:(r=t.transactions)==null?void 0:r.map(n=>{if(typeof n=="string")return n;const s=qc(n);return s.typeHex==="0x7e"&&(s.isSystemTx=n.isSystemTx,s.mint=n.mint?ut(n.mint):void 0,s.sourceHash=n.sourceHash,s.type="deposit"),s}),stateRoot:t.stateRoot}}}),transaction:rE({format(t){const e={};return t.type==="0x7e"&&(e.isSystemTx=t.isSystemTx,e.mint=t.mint?ut(t.mint):void 0,e.sourceHash=t.sourceHash,e.type="deposit"),e}}),transactionReceipt:pA({format(t){return{l1GasPrice:t.l1GasPrice?ut(t.l1GasPrice):null,l1GasUsed:t.l1GasUsed?ut(t.l1GasUsed):null,l1Fee:t.l1Fee?ut(t.l1Fee):null,l1FeeScalar:t.l1FeeScalar?Number(t.l1FeeScalar):null}}})};function p_(t,e){return b_(t)?m_(t):QA(t,e)}const y_={transaction:p_};function m_(t){g_(t);const{sourceHash:e,data:r,from:n,gas:s,isSystemTx:i,mint:o,to:a,value:c}=t,u=[e,n,a??"0x",o?Bt(o):"0x",c?Bt(c):"0x",s?Bt(s):"0x",i?"0x1":"0x",r??"0x"];return Cr(["0x7e",as(u)])}function b_(t){return t.type==="deposit"||typeof t.sourceHash<"u"}function g_(t){const{from:e,to:r}=t;if(e&&!at(e))throw new $t({address:e});if(r&&!at(r))throw new $t({address:r})}const Fi={blockTime:2e3,contracts:d_,formatters:h_,serializers:y_},w_=yt({id:42161,name:"Arbitrum One",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},blockTime:250,rpcUrls:{default:{http:["https://arb1.arbitrum.io/rpc"]}},blockExplorers:{default:{name:"Arbiscan",url:"https://arbiscan.io",apiUrl:"https://api.arbiscan.io/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:7654707}}}),v_=yt({id:421614,name:"Arbitrum Sepolia",blockTime:250,nativeCurrency:{name:"Arbitrum Sepolia Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://sepolia-rollup.arbitrum.io/rpc"]}},blockExplorers:{default:{name:"Arbiscan",url:"https://sepolia.arbiscan.io",apiUrl:"https://api-sepolia.arbiscan.io/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:81930}},testnet:!0}),ao=1,fw=yt({...Fi,id:8453,name:"Base",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://mainnet.base.org"]}},blockExplorers:{default:{name:"Basescan",url:"https://basescan.org",apiUrl:"https://api.basescan.org/api"}},contracts:{...Fi.contracts,disputeGameFactory:{[ao]:{address:"0x43edB88C4B80fDD2AdFF2412A7BebF9dF42cB40e"}},l2OutputOracle:{[ao]:{address:"0x56315b90c40730925ec5485cf004d835058518A0"}},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:5022},portal:{[ao]:{address:"0x49048044D57e1C92A77f79988d21Fa8fAF74E97e",blockCreated:17482143}},l1StandardBridge:{[ao]:{address:"0x3154Cf16ccdb4C6d922629664174b904d80F2C35",blockCreated:17482143}}},sourceId:ao});({...fw});const co=11155111,lw=yt({...Fi,id:84532,network:"base-sepolia",name:"Base Sepolia",nativeCurrency:{name:"Sepolia Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://sepolia.base.org"]}},blockExplorers:{default:{name:"Basescan",url:"https://sepolia.basescan.org",apiUrl:"https://api-sepolia.basescan.org/api"}},contracts:{...Fi.contracts,disputeGameFactory:{[co]:{address:"0xd6E6dBf4F7EA0ac412fD8b65ED297e64BB7a06E1"}},l2OutputOracle:{[co]:{address:"0x84457ca9D0163FbC4bbfe4Dfbb20ba46e48DF254"}},portal:{[co]:{address:"0x49f53e41452c74589e85ca1677426ba426459e85",blockCreated:4446677}},l1StandardBridge:{[co]:{address:"0xfd0Bf71F60660E2f608ed56e1659C450eB113120",blockCreated:4446677}},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:1059647}},testnet:!0,sourceId:co});({...lw});const E_=yt({id:80094,name:"Berachain",blockTime:2e3,nativeCurrency:{decimals:18,name:"BERA Token",symbol:"BERA"},contracts:{multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:0},ensRegistry:{address:"0x5b22280886a2f5e09a49bea7e320eab0e5320e28",blockCreated:877007},ensUniversalResolver:{address:"0x4D41762915F83c76EcaF6776d9b08076aA32b492",blockCreated:9310021}},rpcUrls:{default:{http:["https://rpc.berachain.com"]}},blockExplorers:{default:{name:"Berascan",url:"https://berascan.com"}},ensTlds:[".bera"],testnet:!1}),A_=yt({id:80084,name:"Berachain bArtio",nativeCurrency:{decimals:18,name:"BERA Token",symbol:"BERA"},contracts:{multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:109269},ensRegistry:{address:"0xB0eef18971290b333450586D33dcA6cE122651D2",blockCreated:7736794},ensUniversalResolver:{address:"0x41692Ef1EA0C79E6b73077E4A67572D2BDbD7057",blockCreated:7736795}},ensTlds:[".bera"],rpcUrls:{default:{http:["https://bartio.rpc.berachain.com"]}},blockExplorers:{default:{name:"Berachain bArtio Beratrail",url:"https://bartio.beratrail.io"}},testnet:!0}),S_=yt({id:56,name:"BNB Smart Chain",blockTime:750,nativeCurrency:{decimals:18,name:"BNB",symbol:"BNB"},rpcUrls:{default:{http:["https://56.rpc.thirdweb.com"]}},blockExplorers:{default:{name:"BscScan",url:"https://bscscan.com",apiUrl:"https://api.bscscan.com/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:15921452}}}),x_=yt({id:97,name:"BNB Smart Chain Testnet",nativeCurrency:{decimals:18,name:"BNB",symbol:"tBNB"},rpcUrls:{default:{http:["https://data-seed-prebsc-1-s1.bnbchain.org:8545"]}},blockExplorers:{default:{name:"BscScan",url:"https://testnet.bscscan.com",apiUrl:"https://api-testnet.bscscan.com/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:17422483}},testnet:!0}),k_=yt({id:5115,name:"Citrea Testnet",nativeCurrency:{name:"cBTC",symbol:"cBTC",decimals:18},rpcUrls:{default:{http:["https://rpc.testnet.citrea.xyz"]}},blockExplorers:{default:{name:"Citrea Explorer",url:"https://explorer.testnet.citrea.xyz",apiUrl:"https://explorer.testnet.citrea.xyz/api"}},testnet:!0}),T_=yt({id:1116,name:"Core Dao",nativeCurrency:{decimals:18,name:"Core",symbol:"CORE"},rpcUrls:{default:{http:["https://rpc.coredao.org"]}},blockExplorers:{default:{name:"CoreDao",url:"https://scan.coredao.org"}},contracts:{multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:11907934}},testnet:!1}),__=1,P_=yt({id:21e6,name:"Corn",nativeCurrency:{decimals:18,name:"Bitcorn",symbol:"BTCN"},rpcUrls:{default:{http:["https://21000000.rpc.thirdweb.com"]}},blockExplorers:{default:{name:"Corn Explorer",url:"https://cornscan.io",apiUrl:"https://api.routescan.io/v2/network/mainnet/evm/21000000/etherscan/api"}},contracts:{multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:3228}},sourceId:__}),I_=yt({id:1,name:"Ethereum",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},blockTime:12e3,rpcUrls:{default:{http:["https://eth.merkle.io"]}},blockExplorers:{default:{name:"Etherscan",url:"https://etherscan.io",apiUrl:"https://api.etherscan.io/api"}},contracts:{ensUniversalResolver:{address:"0xeeeeeeee14d718c2b47d9923deab1335e144eeee",blockCreated:23085558},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:14353601}}}),O_=yt({id:10143,name:"Monad Testnet",blockTime:400,nativeCurrency:{name:"Testnet MON Token",symbol:"MON",decimals:18},rpcUrls:{default:{http:["https://testnet-rpc.monad.xyz"]}},blockExplorers:{default:{name:"Monad Testnet explorer",url:"https://testnet.monadexplorer.com"}},contracts:{multicall3:{address:"0xcA11bde05977b3631167028862bE2a173976CA11",blockCreated:251449}},testnet:!0}),B_=yt({id:11155111,name:"Sepolia",nativeCurrency:{name:"Sepolia Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://sepolia.drpc.org"]}},blockExplorers:{default:{name:"Etherscan",url:"https://sepolia.etherscan.io",apiUrl:"https://api-sepolia.etherscan.io/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:751532},ensUniversalResolver:{address:"0xeeeeeeee14d718c2b47d9923deab1335e144eeee",blockCreated:8928790}},testnet:!0}),Xa=1,C_=yt({...Fi,id:130,name:"Unichain",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},blockTime:1e3,rpcUrls:{default:{http:["https://mainnet.unichain.org/"]}},blockExplorers:{default:{name:"Uniscan",url:"https://uniscan.xyz",apiUrl:"https://api.uniscan.xyz/api"}},contracts:{...Fi.contracts,multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:0},disputeGameFactory:{[Xa]:{address:"0x2F12d621a16e2d3285929C9996f478508951dFe4"}},portal:{[Xa]:{address:"0x0bd48f6B86a26D3a217d0Fa6FfE2B491B956A7a2"}},l1StandardBridge:{[Xa]:{address:"0x81014F44b0a345033bB2b3B21C7a1A308B35fEeA"}}},sourceId:Xa}),$_={...B_,rpcUrls:{default:{http:["https://ethereum-sepolia-rpc.publicnode.com"]}}},dw={id:3637,name:"Botanix",nativeCurrency:{name:"Botanix",symbol:"BOTX",decimals:18},blockExplorers:{default:{name:"Botanix Explorer",url:"https://botanixscan.io/"}},rpcUrls:{default:{http:["https://rpc.botanixlabs.com/"]}}},hw={id:998,name:"Hyperliquid EVM Testnet",nativeCurrency:{name:"Hyperliquid",symbol:"HYPE",decimals:18},blockExplorers:{default:{name:"Hyperliquid Explorer",url:"https://testnet.purrsec.com/"}},rpcUrls:{default:{http:["https://rpc.hyperliquid-testnet.xyz/evm"]}}},pw={id:999,name:"HyperEVM",nativeCurrency:{name:"Hyperliquid",symbol:"HYPE",decimals:18},blockExplorers:{default:{name:"Hyperliquid Explorer",url:"https://hyperscan.gas.zip/"}},rpcUrls:{default:{http:["https://rpc.hyperliquid.xyz/evm"]}}},yw={id:8150,name:"Alpen Network",nativeCurrency:{name:"Signet bitcoin",symbol:"sBTC",decimals:18},blockExplorers:{default:{name:"Alpen Explorer",url:"https://explorer.pectra-testnet.alpenlabs.io"}},rpcUrls:{default:{http:["https://rpc.pectra-testnet.alpenlabs.io"]}}},R_={id:143,name:"Monad",nativeCurrency:{name:"Monad",symbol:"MON",decimals:18},blockExplorers:{default:{name:"Monad Explorer",url:"https://monadvision.com/"}},rpcUrls:{default:{http:["https://rpc1.monad.xyz"]}}},yu={ethereum:I_,arbitrum:w_,ethereum_sepolia:$_,arbitrum_sepolia:v_,ethereum_localnet:X.EthereumLocalnet,arbitrum_localnet:X.ArbitrumLocalnet,base_sepolia:lw,base:fw,bera_testnet:A_,citrea_testnet:k_,core:T_,bera:E_,monad:R_,monad_testnet:O_,hyperliquid_testnet:hw,hyperliquid:pw,unichain:C_,corn:P_,botanix:dw,bnbchain:S_,bnbchain_testnet:x_,alpen_testnet:yw,hypercore:{},hypercore_testnet:{}},mw=t=>{for(const[e,r]of Object.entries(yu))if(r.id===t)return e;return null},gd=async(t,e)=>{var s,i,o;const r=yu[t],n=await e.getChainId();if(r)try{if(r.id===n)return g.Ok({message:"Already on the network",walletClient:e});await e.switchChain({id:r.id});const a=Xu({account:e.account,chain:r,transport:m0(e.transport)});return g.Ok({message:"Switched chain",walletClient:a})}catch(a){if(N_(a))if(a.code===4902||a.code===-32603)try{await e.addChain({chain:r});const c=Xu({account:e.account,chain:r,transport:m0(e.transport)});return g.Ok({message:"Added network",walletClient:c})}catch{return g.Err("Failed to add network")}else if((i=(s=a.body)==null?void 0:s.method)!=null&&i.includes("wallet_switchEthereumChain")||(o=a.message)!=null&&o.includes("wallet_switchEthereumChain")){const c=Xu({account:e.account,chain:r,transport:P1()});return g.Ok({message:"Added network",walletClient:c})}else return g.Err("Failed to switch network");else return g.Err("Failed to switch network")}else return g.Err("Chain not supported")},N_=t=>typeof t=="object"&&t!=null&&("code"in t||"message"in t||"body"in t);class bw{constructor(e,r,n){this.wallet=r,this.auth=n,this.url=e instanceof g.Url?e:new g.Url(e),this.relayer=new Pa(this.auth,this.url)}get htlcActorAddress(){if(!this.wallet.account)throw new Error("No account found");return this.wallet.account.address}async initiate(e){if(X.isEvmOrderResponse(e))return this.initiateFromAPI(e);if(!this.wallet.account)return g.Err("No account found");if(!X.isEVM(e.source_swap.chain))return g.Err("Not an EVM chain");if(this.wallet.account.address.toLowerCase()!==e.source_swap.initiator.toLowerCase())return g.Err("Account address and order initiator mismatch");const r=e.source_swap.chain,n=await gd(r,this.wallet);if(!n.ok)return g.Err(n.error);this.wallet=n.val.walletClient;const{source_swap:s}=e;if(!s.amount||!s.timelock||!s.redeemer||!s.secret_hash)return g.Err("Invalid order");const i=await Ch(s.asset,this.url);if(!i.ok)return g.Err(i.error);const o=X.ChainAsset.fromString(s.asset),a={redeemer:g.with0x(s.redeemer),timelock:BigInt(s.timelock),amount:BigInt(s.amount),secretHash:g.with0x(s.secret_hash)};return X.isEvmNativeToken(o.chain,o.symbol)?u_(this.wallet,{...a,htlc:i.val.htlcAddress}):f_(this.wallet,this.url,this.auth,{...a,htlc:i.val.htlcAddress,token:i.val.tokenAddress,orderId:e.order_id})}async initiateFromAPI(e){const r=mw(e.initiate_transaction.chain_id);if(!r)return g.Err("Unsupported chain");const n=await gd(r,this.wallet);if(!n.ok)return g.Err(n.error);if(this.wallet=n.val.walletClient,!this.wallet.account)return g.Err("No account found");if(!e.typed_data){const o=e.initiate_transaction,a=await this.wallet.sendTransaction({account:this.wallet.account,chain:this.wallet.chain,to:g.with0x(o.to),value:BigInt(o.value),data:g.with0x(o.data),gas:BigInt(o.gas_limit)}),c=await g.waitForTransactionReceipt(this.wallet,a);return c.ok?!c.val||c.val.status!=="success"?g.Err("Native initiate transaction failed"):g.Ok(a):g.Err(c.error)}if(e.approval_transaction){const o=await l_(this.wallet,e.approval_transaction);if(o.error)return g.Err(`Approval failed: ${o.error}`);console.log("Approval transaction completed:",o.val)}const s=await this.wallet.signTypedData({account:this.wallet.account,...e.typed_data}),i=await B1({wallet:this.wallet,attempt:()=>this.relayer.initiate(e.order_id,s)});if(i)return g.Ok(i);try{const o=hh({address:g.with0x(e.initiate_transaction.to),abi:uw,client:this.wallet}),a=e.typed_data.message,c=await o.write.initiate([g.with0x(a.redeemer),BigInt(a.timelock),BigInt(a.amount),g.with0x(a.secretHash)],{account:this.wallet.account,chain:this.wallet.chain}),u=await g.waitForTransactionReceipt(this.wallet,c);return u.ok?!u.val||u.val.status!=="success"?g.Err("Failed to initiate via contract"):g.Ok(c):g.Err(u.error)}catch(o){return $h(o)?g.Ok("already initiated"):g.Err(`Failed to initiate via contract: ${String(o)}`)}}async redeem(e,r){const n=await this.relayer.redeem(e.order_id,r);if(n.error)return g.Err(n.error);try{const s=yu[e.destination_swap.chain],o=await xk({chain:s,transport:P1()}).waitForTransactionReceipt({hash:n.val,confirmations:1,timeout:3e5});return o&&o.status==="success"?g.Ok(n.val?n.val:"Redeem hash not found"):g.Err("Redeem failed: Transaction receipt not successful")}catch(s){return g.Err(String(s))}}async refund(){return g.Err("Refund not supported")}}const gw=[{name:"LockingContract",type:"impl",interface_name:"src::mintable_lock_interface::ILockingContract"},{name:"src::mintable_lock_interface::ILockingContract",type:"interface",items:[{name:"set_locking_contract",type:"function",inputs:[{name:"locking_contract",type:"core::starknet::contract_address::ContractAddress"}],outputs:[],state_mutability:"external"},{name:"get_locking_contract",type:"function",inputs:[],outputs:[{type:"core::starknet::contract_address::ContractAddress"}],state_mutability:"view"}]},{name:"LockAndDelegate",type:"impl",interface_name:"src::mintable_lock_interface::ILockAndDelegate"},{name:"core::integer::u256",type:"struct",members:[{name:"low",type:"core::integer::u128"},{name:"high",type:"core::integer::u128"}]},{name:"src::mintable_lock_interface::ILockAndDelegate",type:"interface",items:[{name:"lock_and_delegate",type:"function",inputs:[{name:"delegatee",type:"core::starknet::contract_address::ContractAddress"},{name:"amount",type:"core::integer::u256"}],outputs:[],state_mutability:"external"},{name:"lock_and_delegate_by_sig",type:"function",inputs:[{name:"account",type:"core::starknet::contract_address::ContractAddress"},{name:"delegatee",type:"core::starknet::contract_address::ContractAddress"},{name:"amount",type:"core::integer::u256"},{name:"nonce",type:"core::felt252"},{name:"expiry",type:"core::integer::u64"},{name:"signature",type:"core::array::Array::<core::felt252>"}],outputs:[],state_mutability:"external"}]},{name:"MintableToken",type:"impl",interface_name:"src::mintable_token_interface::IMintableToken"},{name:"src::mintable_token_interface::IMintableToken",type:"interface",items:[{name:"permissioned_mint",type:"function",inputs:[{name:"account",type:"core::starknet::contract_address::ContractAddress"},{name:"amount",type:"core::integer::u256"}],outputs:[],state_mutability:"external"},{name:"permissioned_burn",type:"function",inputs:[{name:"account",type:"core::starknet::contract_address::ContractAddress"},{name:"amount",type:"core::integer::u256"}],outputs:[],state_mutability:"external"}]},{name:"MintableTokenCamelImpl",type:"impl",interface_name:"src::mintable_token_interface::IMintableTokenCamel"},{name:"src::mintable_token_interface::IMintableTokenCamel",type:"interface",items:[{name:"permissionedMint",type:"function",inputs:[{name:"account",type:"core::starknet::contract_address::ContractAddress"},{name:"amount",type:"core::integer::u256"}],outputs:[],state_mutability:"external"},{name:"permissionedBurn",type:"function",inputs:[{name:"account",type:"core::starknet::contract_address::ContractAddress"},{name:"amount",type:"core::integer::u256"}],outputs:[],state_mutability:"external"}]},{name:"Replaceable",type:"impl",interface_name:"src::replaceability_interface::IReplaceable"},{name:"core::array::Span::<core::felt252>",type:"struct",members:[{name:"snapshot",type:"@core::array::Array::<core::felt252>"}]},{name:"src::replaceability_interface::EICData",type:"struct",members:[{name:"eic_hash",type:"core::starknet::class_hash::ClassHash"},{name:"eic_init_data",type:"core::array::Span::<core::felt252>"}]},{name:"core::option::Option::<src::replaceability_interface::EICData>",type:"enum",variants:[{name:"Some",type:"src::replaceability_interface::EICData"},{name:"None",type:"()"}]},{name:"core::bool",type:"enum",variants:[{name:"False",type:"()"},{name:"True",type:"()"}]},{name:"src::replaceability_interface::ImplementationData",type:"struct",members:[{name:"impl_hash",type:"core::starknet::class_hash::ClassHash"},{name:"eic_data",type:"core::option::Option::<src::replaceability_interface::EICData>"},{name:"final",type:"core::bool"}]},{name:"src::replaceability_interface::IReplaceable",type:"interface",items:[{name:"get_upgrade_delay",type:"function",inputs:[],outputs:[{type:"core::integer::u64"}],state_mutability:"view"},{name:"get_impl_activation_time",type:"function",inputs:[{name:"implementation_data",type:"src::replaceability_interface::ImplementationData"}],outputs:[{type:"core::integer::u64"}],state_mutability:"view"},{name:"add_new_implementation",type:"function",inputs:[{name:"implementation_data",type:"src::replaceability_interface::ImplementationData"}],outputs:[],state_mutability:"external"},{name:"remove_implementation",type:"function",inputs:[{name:"implementation_data",type:"src::replaceability_interface::ImplementationData"}],outputs:[],state_mutability:"external"},{name:"replace_to",type:"function",inputs:[{name:"implementation_data",type:"src::replaceability_interface::ImplementationData"}],outputs:[],state_mutability:"external"}]},{name:"AccessControlImplExternal",type:"impl",interface_name:"src::access_control_interface::IAccessControl"},{name:"src::access_control_interface::IAccessControl",type:"interface",items:[{name:"has_role",type:"function",inputs:[{name:"role",type:"core::felt252"},{name:"account",type:"core::starknet::contract_address::ContractAddress"}],outputs:[{type:"core::bool"}],state_mutability:"view"},{name:"get_role_admin",type:"function",inputs:[{name:"role",type:"core::felt252"}],outputs:[{type:"core::felt252"}],state_mutability:"view"}]},{name:"RolesImpl",type:"impl",interface_name:"src::roles_interface::IMinimalRoles"},{name:"src::roles_interface::IMinimalRoles",type:"interface",items:[{name:"is_governance_admin",type:"function",inputs:[{name:"account",type:"core::starknet::contract_address::ContractAddress"}],outputs:[{type:"core::bool"}],state_mutability:"view"},{name:"is_upgrade_governor",type:"function",inputs:[{name:"account",type:"core::starknet::contract_address::ContractAddress"}],outputs:[{type:"core::bool"}],state_mutability:"view"},{name:"register_governance_admin",type:"function",inputs:[{name:"account",type:"core::starknet::contract_address::ContractAddress"}],outputs:[],state_mutability:"external"},{name:"remove_governance_admin",type:"function",inputs:[{name:"account",type:"core::starknet::contract_address::ContractAddress"}],outputs:[],state_mutability:"external"},{name:"register_upgrade_governor",type:"function",inputs:[{name:"account",type:"core::starknet::contract_address::ContractAddress"}],outputs:[],state_mutability:"external"},{name:"remove_upgrade_governor",type:"function",inputs:[{name:"account",type:"core::starknet::contract_address::ContractAddress"}],outputs:[],state_mutability:"external"},{name:"renounce",type:"function",inputs:[{name:"role",type:"core::felt252"}],outputs:[],state_mutability:"external"}]},{name:"ERC20Impl",type:"impl",interface_name:"openzeppelin::token::erc20::interface::IERC20"},{name:"openzeppelin::token::erc20::interface::IERC20",type:"interface",items:[{name:"name",type:"function",inputs:[],outputs:[{type:"core::felt252"}],state_mutability:"view"},{name:"symbol",type:"function",inputs:[],outputs:[{type:"core::felt252"}],state_mutability:"view"},{name:"decimals",type:"function",inputs:[],outputs:[{type:"core::integer::u8"}],state_mutability:"view"},{name:"total_supply",type:"function",inputs:[],outputs:[{type:"core::integer::u256"}],state_mutability:"view"},{name:"balance_of",type:"function",inputs:[{name:"account",type:"core::starknet::contract_address::ContractAddress"}],outputs:[{type:"core::integer::u256"}],state_mutability:"view"},{name:"allowance",type:"function",inputs:[{name:"owner",type:"core::starknet::contract_address::ContractAddress"},{name:"spender",type:"core::starknet::contract_address::ContractAddress"}],outputs:[{type:"core::integer::u256"}],state_mutability:"view"},{name:"transfer",type:"function",inputs:[{name:"recipient",type:"core::starknet::contract_address::ContractAddress"},{name:"amount",type:"core::integer::u256"}],outputs:[{type:"core::bool"}],state_mutability:"external"},{name:"transfer_from",type:"function",inputs:[{name:"sender",type:"core::starknet::contract_address::ContractAddress"},{name:"recipient",type:"core::starknet::contract_address::ContractAddress"},{name:"amount",type:"core::integer::u256"}],outputs:[{type:"core::bool"}],state_mutability:"external"},{name:"approve",type:"function",inputs:[{name:"spender",type:"core::starknet::contract_address::ContractAddress"},{name:"amount",type:"core::integer::u256"}],outputs:[{type:"core::bool"}],state_mutability:"external"}]},{name:"ERC20CamelOnlyImpl",type:"impl",interface_name:"openzeppelin::token::erc20::interface::IERC20CamelOnly"},{name:"openzeppelin::token::erc20::interface::IERC20CamelOnly",type:"interface",items:[{name:"totalSupply",type:"function",inputs:[],outputs:[{type:"core::integer::u256"}],state_mutability:"view"},{name:"balanceOf",type:"function",inputs:[{name:"account",type:"core::starknet::contract_address::ContractAddress"}],outputs:[{type:"core::integer::u256"}],state_mutability:"view"},{name:"transferFrom",type:"function",inputs:[{name:"sender",type:"core::starknet::contract_address::ContractAddress"},{name:"recipient",type:"core::starknet::contract_address::ContractAddress"},{name:"amount",type:"core::integer::u256"}],outputs:[{type:"core::bool"}],state_mutability:"external"}]},{name:"constructor",type:"constructor",inputs:[{name:"name",type:"core::felt252"},{name:"symbol",type:"core::felt252"},{name:"decimals",type:"core::integer::u8"},{name:"initial_supply",type:"core::integer::u256"},{name:"recipient",type:"core::starknet::contract_address::ContractAddress"},{name:"permitted_minter",type:"core::starknet::contract_address::ContractAddress"},{name:"provisional_governance_admin",type:"core::starknet::contract_address::ContractAddress"},{name:"upgrade_delay",type:"core::integer::u64"}]},{name:"increase_allowance",type:"function",inputs:[{name:"spender",type:"core::starknet::contract_address::ContractAddress"},{name:"added_value",type:"core::integer::u256"}],outputs:[{type:"core::bool"}],state_mutability:"external"},{name:"decrease_allowance",type:"function",inputs:[{name:"spender",type:"core::starknet::contract_address::ContractAddress"},{name:"subtracted_value",type:"core::integer::u256"}],outputs:[{type:"core::bool"}],state_mutability:"external"},{name:"increaseAllowance",type:"function",inputs:[{name:"spender",type:"core::starknet::contract_address::ContractAddress"},{name:"addedValue",type:"core::integer::u256"}],outputs:[{type:"core::bool"}],state_mutability:"external"},{name:"decreaseAllowance",type:"function",inputs:[{name:"spender",type:"core::starknet::contract_address::ContractAddress"},{name:"subtractedValue",type:"core::integer::u256"}],outputs:[{type:"core::bool"}],state_mutability:"external"},{kind:"struct",name:"src::strk::erc20_lockable::ERC20Lockable::Transfer",type:"event",members:[{kind:"data",name:"from",type:"core::starknet::contract_address::ContractAddress"},{kind:"data",name:"to",type:"core::starknet::contract_address::ContractAddress"},{kind:"data",name:"value",type:"core::integer::u256"}]},{kind:"struct",name:"src::strk::erc20_lockable::ERC20Lockable::Approval",type:"event",members:[{kind:"data",name:"owner",type:"core::starknet::contract_address::ContractAddress"},{kind:"data",name:"spender",type:"core::starknet::contract_address::ContractAddress"},{kind:"data",name:"value",type:"core::integer::u256"}]},{kind:"struct",name:"src::replaceability_interface::ImplementationAdded",type:"event",members:[{kind:"data",name:"implementation_data",type:"src::replaceability_interface::ImplementationData"}]},{kind:"struct",name:"src::replaceability_interface::ImplementationRemoved",type:"event",members:[{kind:"data",name:"implementation_data",type:"src::replaceability_interface::ImplementationData"}]},{kind:"struct",name:"src::replaceability_interface::ImplementationReplaced",type:"event",members:[{kind:"data",name:"implementation_data",type:"src::replaceability_interface::ImplementationData"}]},{kind:"struct",name:"src::replaceability_interface::ImplementationFinalized",type:"event",members:[{kind:"data",name:"impl_hash",type:"core::starknet::class_hash::ClassHash"}]},{kind:"struct",name:"src::access_control_interface::RoleGranted",type:"event",members:[{kind:"data",name:"role",type:"core::felt252"},{kind:"data",name:"account",type:"core::starknet::contract_address::ContractAddress"},{kind:"data",name:"sender",type:"core::starknet::contract_address::ContractAddress"}]},{kind:"struct",name:"src::access_control_interface::RoleRevoked",type:"event",members:[{kind:"data",name:"role",type:"core::felt252"},{kind:"data",name:"account",type:"core::starknet::contract_address::ContractAddress"},{kind:"data",name:"sender",type:"core::starknet::contract_address::ContractAddress"}]},{kind:"struct",name:"src::access_control_interface::RoleAdminChanged",type:"event",members:[{kind:"data",name:"role",type:"core::felt252"},{kind:"data",name:"previous_admin_role",type:"core::felt252"},{kind:"data",name:"new_admin_role",type:"core::felt252"}]},{kind:"struct",name:"src::roles_interface::GovernanceAdminAdded",type:"event",members:[{kind:"data",name:"added_account",type:"core::starknet::contract_address::ContractAddress"},{kind:"data",name:"added_by",type:"core::starknet::contract_address::ContractAddress"}]},{kind:"struct",name:"src::roles_interface::GovernanceAdminRemoved",type:"event",members:[{kind:"data",name:"removed_account",type:"core::starknet::contract_address::ContractAddress"},{kind:"data",name:"removed_by",type:"core::starknet::contract_address::ContractAddress"}]},{kind:"struct",name:"src::roles_interface::UpgradeGovernorAdded",type:"event",members:[{kind:"data",name:"added_account",type:"core::starknet::contract_address::ContractAddress"},{kind:"data",name:"added_by",type:"core::starknet::contract_address::ContractAddress"}]},{kind:"struct",name:"src::roles_interface::UpgradeGovernorRemoved",type:"event",members:[{kind:"data",name:"removed_account",type:"core::starknet::contract_address::ContractAddress"},{kind:"data",name:"removed_by",type:"core::starknet::contract_address::ContractAddress"}]},{kind:"enum",name:"src::strk::erc20_lockable::ERC20Lockable::Event",type:"event",variants:[{kind:"nested",name:"Transfer",type:"src::strk::erc20_lockable::ERC20Lockable::Transfer"},{kind:"nested",name:"Approval",type:"src::strk::erc20_lockable::ERC20Lockable::Approval"},{kind:"nested",name:"ImplementationAdded",type:"src::replaceability_interface::ImplementationAdded"},{kind:"nested",name:"ImplementationRemoved",type:"src::replaceability_interface::ImplementationRemoved"},{kind:"nested",name:"ImplementationReplaced",type:"src::replaceability_interface::ImplementationReplaced"},{kind:"nested",name:"ImplementationFinalized",type:"src::replaceability_interface::ImplementationFinalized"},{kind:"nested",name:"RoleGranted",type:"src::access_control_interface::RoleGranted"},{kind:"nested",name:"RoleRevoked",type:"src::access_control_interface::RoleRevoked"},{kind:"nested",name:"RoleAdminChanged",type:"src::access_control_interface::RoleAdminChanged"},{kind:"nested",name:"GovernanceAdminAdded",type:"src::roles_interface::GovernanceAdminAdded"},{kind:"nested",name:"GovernanceAdminRemoved",type:"src::roles_interface::GovernanceAdminRemoved"},{kind:"nested",name:"UpgradeGovernorAdded",type:"src::roles_interface::UpgradeGovernorAdded"},{kind:"nested",name:"UpgradeGovernorRemoved",type:"src::roles_interface::UpgradeGovernorRemoved"}]}],ww=async(t,e,r,n,s)=>{try{const i=await Ao(t.address,e,r,s);if(!i.ok)return g.Err(i.error);if(i.val>=n)return g.Ok("Allowance already approved");const a=Je.cairo.uint256(BigInt(n)),c=await t.execute([{contractAddress:g.with0x(e),entrypoint:"approve",calldata:[g.with0x(r),a.low,a.high]}]);await s.waitForTransaction(c.transaction_hash,{retryInterval:3e3,successStates:[Je.TransactionExecutionStatus.SUCCEEDED]}),await g.sleep(2e3);for(let u=0;u<20;u++){const f=await Ao(t.address,e,r,s);if(!f.ok)return g.Err(f.error);if(f.val>=n)return g.Ok(c.transaction_hash);await g.sleep(2e3);let l=0n;for(let p=0;p<20;p++){const d=await Ao(t.address,e,r,s);if(!d.ok)return g.Err(d.error);if(l=d.val,l>=n)break;await g.sleep(2e3)}return l<n?g.Err("Allowance not approved"):g.Ok(c.transaction_hash)}return g.Err("Allowance not approved after transaction.")}catch(i){return g.Err(`Failed to check or approve allowance: ${i instanceof Error?i.message:String(i)}`)}},Ao=async(t,e,r,n)=>{try{const i=await new Je.Contract(gw,g.with0x(e),n).call("allowance",[g.with0x(t),g.with0x(r)]);return g.Ok(BigInt((i==null?void 0:i.toString())||"0"))}catch(s){return g.Err(`Failed to check allowance: ${s instanceof Error?s.message:String(s)}`)}},vw=async(t,e,r,n,s)=>{const i=await Ao(t,e,r,n);return i.ok?g.Ok(i.val>=s):g.Err(i.error)},Ew=[{name:"HTLC",type:"impl",interface_name:"starknet_htlc::interface::IHTLC"},{name:"core::integer::u256",type:"struct",members:[{name:"low",type:"core::integer::u128"},{name:"high",type:"core::integer::u128"}]},{name:"starknet_htlc::interface::IHTLC",type:"interface",items:[{name:"token",type:"function",inputs:[],outputs:[{type:"core::starknet::contract_address::ContractAddress"}],state_mutability:"view"},{name:"initiate",type:"function",inputs:[{name:"redeemer",type:"core::starknet::contract_address::ContractAddress"},{name:"timelock",type:"core::integer::u128"},{name:"amount",type:"core::integer::u256"},{name:"secret_hash",type:"[core::integer::u32; 8]"}],outputs:[],state_mutability:"external"},{name:"initiate_on_behalf",type:"function",inputs:[{name:"initiator",type:"core::starknet::contract_address::ContractAddress"},{name:"redeemer",type:"core::starknet::contract_address::ContractAddress"},{name:"timelock",type:"core::integer::u128"},{name:"amount",type:"core::integer::u256"},{name:"secret_hash",type:"[core::integer::u32; 8]"}],outputs:[],state_mutability:"external"},{name:"initiate_with_signature",type:"function",inputs:[{name:"initiator",type:"core::starknet::contract_address::ContractAddress"},{name:"redeemer",type:"core::starknet::contract_address::ContractAddress"},{name:"timelock",type:"core::integer::u128"},{name:"amount",type:"core::integer::u256"},{name:"secret_hash",type:"[core::integer::u32; 8]"},{name:"signature",type:"core::array::Array::<core::felt252>"}],outputs:[],state_mutability:"external"},{name:"redeem",type:"function",inputs:[{name:"order_id",type:"core::felt252"},{name:"secret",type:"core::array::Array::<core::integer::u32>"}],outputs:[],state_mutability:"external"},{name:"refund",type:"function",inputs:[{name:"order_id",type:"core::felt252"}],outputs:[],state_mutability:"external"},{name:"instant_refund",type:"function",inputs:[{name:"order_id",type:"core::felt252"},{name:"signature",type:"core::array::Array::<core::felt252>"}],outputs:[],state_mutability:"external"}]},{name:"constructor",type:"constructor",inputs:[{name:"token",type:"core::starknet::contract_address::ContractAddress"}]},{kind:"struct",name:"starknet_htlc::interface::events::Initiated",type:"event",members:[{kind:"key",name:"order_id",type:"core::felt252"},{kind:"data",name:"secret_hash",type:"[core::integer::u32; 8]"},{kind:"data",name:"amount",type:"core::integer::u256"}]},{kind:"struct",name:"starknet_htlc::interface::events::Redeemed",type:"event",members:[{kind:"key",name:"order_id",type:"core::felt252"},{kind:"data",name:"secret_hash",type:"[core::integer::u32; 8]"},{kind:"data",name:"secret",type:"core::array::Array::<core::integer::u32>"}]},{kind:"struct",name:"starknet_htlc::interface::events::Refunded",type:"event",members:[{kind:"key",name:"order_id",type:"core::felt252"}]},{kind:"enum",name:"starknet_htlc::htlc::HTLC::Event",type:"event",variants:[{kind:"nested",name:"Initiated",type:"starknet_htlc::interface::events::Initiated"},{kind:"nested",name:"Redeemed",type:"starknet_htlc::interface::events::Redeemed"},{kind:"nested",name:"Refunded",type:"starknet_htlc::interface::events::Refunded"}]}],U_={StarknetDomain:[{name:"name",type:"shortstring"},{name:"version",type:"shortstring"},{name:"chainId",type:"shortstring"},{name:"revision",type:"shortstring"}],Initiate:[{name:"redeemer",type:"ContractAddress"},{name:"amount",type:"u256"},{name:"timelock",type:"u128"},{name:"secretHash",type:"u128*"}]};class Aw{constructor(e,r,n,s,i){this.url=e instanceof g.Url?e:new g.Url(e),this.account=r,this.starknetProvider=new Je.RpcProvider({nodeUrl:i||Qo[n].nodeUrl}),this.chainId=Qo[n].chainId,this.auth=s,this.relayer=new Pa(this.auth,this.url)}get htlcActorAddress(){if(!this.account.address)throw new Error("No account found");return this.account.address}async initiate(e){if(X.isStarknetOrderResponse(e))return this.initiateWithCreateOrderResponse(e);if(!this.account.address)return g.Err("No account address");const{source_swap:r}=e,{redeemer:n,amount:s}=r;if(!s||!n||!r.secret_hash||!r.timelock)return g.Err("Invalid order");try{const i=new Je.Contract(Ew,e.source_swap.asset,this.account),o=await(i==null?void 0:i.token()),a=Je.num.toHex(o),c=await vw(this.account.address,a,r.asset,this.starknetProvider,BigInt(r.amount));return c.error?g.Err(c.error):c.val?this.initiateRelay(e):this.approveAndInitiate(a,e)}catch(i){return g.Err(String(i))}}async approveAndInitiate(e,r){const{source_swap:n}=r,{redeemer:s,amount:i}=n,{secret_hash:o,timelock:a}=n,c=n.asset;try{const u=Je.cairo.uint256(BigInt(i)),f={contractAddress:g.with0x(e),entrypoint:"approve",calldata:[c,u.low,u.high]},l=Je.cairo.uint256(i),p={contractAddress:g.with0x(c),entrypoint:"initiate",calldata:[s,a.toString(),l.low.toString(),l.high.toString(),...g.hexToU32Array(o)]},d=await this.account.execute([f,p]);return await this.starknetProvider.waitForTransaction(d.transaction_hash,{retryInterval:2e3,successStates:[Je.TransactionExecutionStatus.SUCCEEDED]}),g.Ok(d.transaction_hash)}catch(u){return g.Err(`Failed to approve and initiate: ${String(u)}`)}}async initiateRelay(e){const{source_swap:r}=e,{redeemer:n,amount:s}=r;if(!r.secret_hash)return g.Err("Invalid order: secret_hash is undefined");const i=g.with0x(r.secret_hash),a={domain:{name:"HTLC",version:Je.shortString.encodeShortString("1"),chainId:this.chainId,revision:Je.TypedDataRevision.ACTIVE},primaryType:"Initiate",types:U_,message:{redeemer:n,amount:Je.cairo.uint256(s),timelock:e.source_swap.timelock,secretHash:g.hexToU32Array(i)}};try{const c=await this.account.signMessage(a),u=g0(c);if(u.error||!u.val)return g.Err(u.error||"Invalid signature");const f=await this.relayer.initiate(e.order_id,u.val);return f.error?g.Err(f.error):f.val?g.Ok(f.val):g.Err("Initiate: No result found")}catch(c){return g.Err(`Failed to initiate relayer: ${String(c)}`)}}async redeem(e,r){try{const n=await this.relayer.redeem(e.order_id,r);return n.error?g.Err(n.error):g.Ok(n.val)}catch(n){return g.Err(String(n))}}async executeApprovalTransaction(e){if(!this.account.address)return g.Err("No account address");if(!e.approval_transaction)return g.Ok("No approval transaction required");try{const r=e.approval_transaction,n=await this.account.execute([{contractAddress:g.with0x(r.to),entrypoint:g.with0x(r.selector),calldata:r.calldata}]);return await this.starknetProvider.waitForTransaction(n.transaction_hash,{retryInterval:2e3,successStates:[Je.TransactionExecutionStatus.SUCCEEDED]}),g.Ok(n.transaction_hash)}catch(r){return console.error("executeApprovalTransaction error:",r),g.Err("Failed to execute approval: "+(r instanceof Error&&(r==null?void 0:r.message)||String(r)))}}async initiateWithCreateOrderResponse(e){const r=await this.auth.getAuthHeaders();if(!r.ok)return g.Err(r.error);if(!this.account.address)return g.Err("No account address");const n=await this.executeApprovalTransaction(e);if(n.error)return g.Err(n.error);const{typed_data:s}=e;if(s===null){const c=e.initiate_transaction;if(!c)return g.Err("No initiate_transaction found for native initiate");const u=await this.account.execute([{contractAddress:g.with0x(c.to),entrypoint:g.with0x(c.selector),calldata:c.calldata}]);return await this.starknetProvider.waitForTransaction(u.transaction_hash,{retryInterval:2e3,successStates:[Je.TransactionExecutionStatus.SUCCEEDED]}),g.Ok(u.transaction_hash)}const i=await this.account.signMessage(s),o=g0(i);if(o.error)return g.Err(o.error);const a=await g.Fetcher.patch(this.url.endpoint("/v2/orders").endpoint(e.order_id).addSearchParams({action:"initiate"}),{body:JSON.stringify({signature:Array.isArray(o.val)?o.val.join(","):o.val}),headers:{...r.val,"Content-Type":"application/json"}});return a.error?g.Err(a.error):g.Ok(a.result)}async refund(){return g.Err("Refund is taken care of by the relayer")}}const M_="2WXpY8havGjfRxme9LUxtjFHTh1EfU3ur4v6wiK4KdNC",F_={name:"solana_spl_swaps",version:"0.4.0",spec:"0.1.0",description:"Created with Anchor"},j_=[{name:"initiate",docs:["Initiates the atomic swap. Funds are transferred from the initiator to the token vault.","As such, the initiator's signature is required for this instruction.","A sponsor may be involved, who pays PDA rent and transaction fees in SOL, allowing for the","initiator to participate without holding SOL. As such, the sponsor must also sign this transaction.","`swap_amount` represents the quantity of tokens to be transferred through this atomic swap","in base units of the token mint.",'E.g: A quantity of $1 represented by the token "USDC" with "6" decimals',"must be provided as 1,000,000.","`expires_in_slots` represents the number of slots after which (non-instant) refunds are allowed.","`destination_data` can hold optional information regarding the destination chain","in the atomic swap, to be emitted in the logs as-is."],discriminator:[5,63,123,113,153,75,148,14],accounts:[{name:"identity_pda",docs:["the token transfers of the `token_vault` PDA.","This PDA will be created during the first most invocation of the `initiate()` function","using the `init_if_needed` attribute, and be reused for all succeeding instructions."],writable:!0,pda:{seeds:[]}},{name:"swap_data",docs:["A PDA that maintains the on-chain state of the atomic swap throughout its lifecycle.","The choice of seeds ensure that any swap with equal `initiator` and","`secret_hash` wont be created until an existing one completes.","This PDA will be deleted upon completion of the swap."],writable:!0,pda:{seeds:[{kind:"account",path:"initiator"},{kind:"arg",path:"secret_hash"}]}},{name:"token_vault",docs:["A permanent PDA that is controlled by the program through the `identity_pda`, as implied",'by the value of the `authority` field below. As such, it serves as the "vault" by escrowing tokens',"of type `mint` for the atomic swap.","It is intended to be reused for all swaps involving the same mint.","Just like `identity_pda`, it will be created during the first most invocation of `initiate()`","of every distinct mint using the `init_if_needed` attribute."],writable:!0,pda:{seeds:[{kind:"account",path:"mint"}]}},{name:"initiator",docs:["The initiator of the atomic swap. They must sign this transaction."],signer:!0},{name:"initiator_token_account",docs:["The token account of the initiator"],writable:!0},{name:"mint",docs:["The mint of the tokens involved in this swap. As this is a parameter, this program can thus be reused","for atomic swaps with different mints."]},{name:"sponsor",docs:["Any entity that pays the PDA rent.","Upon completion of the swap, the PDA rent refund resulting from the","deletion of `swap_data` will be refunded to this address."],writable:!0,signer:!0},{name:"token_program",address:"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"},{name:"system_program",address:"11111111111111111111111111111111"}],args:[{name:"expires_in_slots",type:"u64"},{name:"redeemer",type:"pubkey"},{name:"secret_hash",type:{array:["u8",32]}},{name:"swap_amount",type:"u64"},{name:"destination_data",type:{option:"bytes"}}]},{name:"instant_refund",docs:["Funds are returned to the initiator, with the redeemer's consent.","As such, the redeemer's signature is required for this instruction.","This allows for refunds before the expiry slot."],discriminator:[211,202,103,41,183,147,59,251],accounts:[{name:"identity_pda",pda:{seeds:[]}},{name:"swap_data",docs:["The PDA holding the state information of the atomic swap. Will be closed upon successful execution","and the resulting rent refund will be sent to the sponsor."],writable:!0},{name:"token_vault",docs:["A token account controlled by the program, escrowing the tokens for this atomic swap"],writable:!0},{name:"initiator_token_account",writable:!0},{name:"redeemer",docs:["The redeemer of the atomic swap. They must sign this transaction."],writable:!0,signer:!0},{name:"sponsor",writable:!0},{name:"token_program",address:"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"}],args:[]},{name:"redeem",docs:["Funds are transferred to the redeemer. This instruction does not require any signatures."],discriminator:[184,12,86,149,70,196,97,225],accounts:[{name:"identity_pda",pda:{seeds:[]}},{name:"swap_data",docs:["The PDA holding the state information of the atomic swap. Will be closed upon successful execution","and the resulting rent refund will be sent to the sponsor."],writable:!0},{name:"token_vault",docs:["A token account controlled by the program, escrowing the tokens for this atomic swap"],writable:!0},{name:"redeemer_token_account",writable:!0},{name:"sponsor",writable:!0},{name:"token_program",address:"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"}],args:[{name:"secret",type:{array:["u8",32]}}]},{name:"refund",docs:["Funds are returned to the initiator, given that no redeems have occured","and the expiry slot has been reached.","This instruction does not require any signatures."],discriminator:[2,96,183,251,63,208,46,46],accounts:[{name:"identity_pda",pda:{seeds:[]}},{name:"swap_data",docs:["The PDA holding the state information of the atomic swap. Will be closed upon successful execution","and the resulting rent refund will be sent to the sponsor."],writable:!0},{name:"token_vault",docs:["A token account controlled by the program, escrowing the tokens for this atomic swap"],writable:!0},{name:"initiator_token_account",writable:!0},{name:"sponsor",writable:!0},{name:"token_program",address:"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"}],args:[]}],L_=[{name:"SwapAccount",discriminator:[53,126,9,14,14,197,105,182]}],H_=[{name:"Initiated",discriminator:[6,108,212,91,67,60,207,221]},{name:"InstantRefunded",discriminator:[220,50,18,207,183,232,218,25]},{name:"Redeemed",discriminator:[14,29,183,71,31,165,107,38]},{name:"Refunded",discriminator:[35,103,149,246,196,123,221,99]}],D_=[{code:6e3,name:"InvalidRedeemer",msg:"The provider redeemer is not the original redeemer of this swap"},{code:6001,name:"InvalidSecret",msg:"The provided secret does not correspond to the secret hash of this swap"},{code:6002,name:"InvalidSponsor",msg:"The provided sponsor is not the original sponsor of this swap"},{code:6003,name:"RefundBeforeExpiry",msg:"Attempt to perform a refund before expiry time"}],z_=[{name:"Initiated",docs:["Represents the initiated state of the swap where the initiator has deposited funds into the vault"],type:{kind:"struct",fields:[{name:"swap_amount",docs:["The quantity of tokens transferred through this atomic swap in base units of the token mint.",'E.g: A quantity of $1 represented by the token "USDC" with "6" decimals will be represented as 1,000,000.'],type:"u64"},{name:"expires_in_slots",docs:["`expires_in_slots` represents the number of slots after which (non-instant) refunds are allowed"],type:"u64"},{name:"initiator",type:"pubkey"},{name:"mint",type:"pubkey"},{name:"redeemer",type:"pubkey"},{name:"secret_hash",type:{array:["u8",32]}},{name:"destination_data",docs:["Information regarding the destination chain in the atomic swap"],type:{option:"bytes"}}]}},{name:"InstantRefunded",docs:["Represents the instant refund state of the swap, where the initiator has withdrawn funds the vault","with the redeemer's consent"],type:{kind:"struct",fields:[{name:"initiator",type:"pubkey"},{name:"secret_hash",type:{array:["u8",32]}}]}},{name:"Redeemed",docs:["Represents the redeemed state of the swap, where the redeemer has withdrawn funds from the vault"],type:{kind:"struct",fields:[{name:"initiator",type:"pubkey"},{name:"secret",type:{array:["u8",32]}}]}},{name:"Refunded",docs:["Represents the refund state of the swap, where the initiator has withdrawn funds from the vault past expiry"],type:{kind:"struct",fields:[{name:"initiator",type:"pubkey"},{name:"secret_hash",type:{array:["u8",32]}}]}},{name:"SwapAccount",docs:["Stores the state information of the atomic swap on-chain"],type:{kind:"struct",fields:[{name:"expiry_slot",docs:["The exact slot after which (non-instant) refunds are allowed"],type:"u64"},{name:"initiator",docs:["The initiator of the atomic swap"],type:"pubkey"},{name:"redeemer",docs:["The redeemer of the atomic swap"],type:"pubkey"},{name:"secret_hash",docs:["The secret hash associated with the atomic swap"],type:{array:["u8",32]}},{name:"swap_amount",docs:["The quantity tokens to be transferred through this atomic swap","in base units of the token mint.",'E.g: A quantity of $1 represented by the token "USDC" with "6" decimals',"must be provided as 1,000,000."],type:"u64"},{name:"identity_pda_bump",docs:["The bump associated with the identity pda.","This is needed by the program to authorize token transfers via the token vault."],type:"u8"},{name:"sponsor",docs:["The entity that paid the rent fees for the creation of this PDA.","This will be referenced during the refund of the same upon closing this PDA."],type:"pubkey"}]}}],G0={address:M_,metadata:F_,instructions:j_,accounts:L_,events:H_,errors:D_,types:z_},V_="2bag6xpshpvPe7SJ9nSDLHpxqhEAoHPGpEkjNSv7gxoF",q_={name:"solana_native_swaps",version:"0.3.0",spec:"0.1.0",description:"Created with Anchor"},G_=[{name:"initiate",discriminator:[5,63,123,113,153,75,148,14],accounts:[{name:"swap_account",writable:!0,pda:{seeds:[{kind:"const",value:[115,119,97,112,95,97,99,99,111,117,110,116]},{kind:"account",path:"initiator"},{kind:"arg",path:"secret_hash"}]}},{name:"initiator",docs:["Initiator must sign this transaction"],writable:!0,signer:!0},{name:"system_program",address:"11111111111111111111111111111111"}],args:[{name:"amount_lamports",type:"u64"},{name:"expires_in_slots",type:"u64"},{name:"redeemer",type:"pubkey"},{name:"secret_hash",type:{array:["u8",32]}}]},{name:"instant_refund",discriminator:[211,202,103,41,183,147,59,251],accounts:[{name:"swap_account",writable:!0},{name:"initiator",writable:!0},{name:"redeemer",docs:["Redeemer must sign this transaction"],signer:!0}],args:[]},{name:"redeem",discriminator:[184,12,86,149,70,196,97,225],accounts:[{name:"swap_account",writable:!0},{name:"initiator",docs:["This is included here for the PDA rent refund using the `close` attribute above"],writable:!0},{name:"redeemer",writable:!0}],args:[{name:"secret",type:{array:["u8",32]}}]},{name:"refund",discriminator:[2,96,183,251,63,208,46,46],accounts:[{name:"swap_account",writable:!0},{name:"initiator",writable:!0}],args:[]}],W_=[{name:"SwapAccount",discriminator:[53,126,9,14,14,197,105,182]}],K_=[{name:"Initiated",discriminator:[6,108,212,91,67,60,207,221]},{name:"InstantRefunded",discriminator:[220,50,18,207,183,232,218,25]},{name:"Redeemed",discriminator:[14,29,183,71,31,165,107,38]},{name:"Refunded",discriminator:[35,103,149,246,196,123,221,99]}],Z_=[{code:6e3,name:"InvalidInitiator",msg:"The provided initiator is not the original initiator of this swap account"},{code:6001,name:"InvalidRedeemer",msg:"The provided redeemer is not the original redeemer of this swap amount"},{code:6002,name:"InvalidSecret",msg:"The provided secret does not correspond to the secret hash in the swap account"},{code:6003,name:"RefundBeforeExpiry",msg:"Attempt to perform a refund before expiry time"}],Y_=[{name:"Initiated",type:{kind:"struct",fields:[{name:"amount_lamports",type:"u64"},{name:"expires_in_slots",type:"u64"},{name:"initiator",type:"pubkey"},{name:"redeemer",type:"pubkey"},{name:"secret_hash",type:{array:["u8",32]}}]}},{name:"InstantRefunded",type:{kind:"struct",fields:[{name:"initiator",type:"pubkey"},{name:"secret_hash",type:{array:["u8",32]}}]}},{name:"Redeemed",type:{kind:"struct",fields:[{name:"initiator",type:"pubkey"},{name:"secret",type:{array:["u8",32]}}]}},{name:"Refunded",type:{kind:"struct",fields:[{name:"initiator",type:"pubkey"},{name:"secret_hash",type:{array:["u8",32]}}]}},{name:"SwapAccount",type:{kind:"struct",fields:[{name:"amount_lamports",type:"u64"},{name:"expiry_slot",type:"u64"},{name:"initiator",type:"pubkey"},{name:"redeemer",type:"pubkey"},{name:"secret_hash",type:{array:["u8",32]}}]}}],wd={address:V_,metadata:q_,instructions:G_,accounts:W_,events:K_,errors:Z_,types:Y_};var wn={},mu={};Object.defineProperty(mu,"__esModule",{value:!0});mu.encode=X_;mu.decode=J_;const W0=Qs;function X_(t){return t.reduce((e,r)=>e+r.toString(16).padStart(2,"0"),"0x")}function J_(t){t.indexOf("0x")===0&&(t=t.substr(2)),t.length%2===1&&(t="0"+t);let e=t.match(/.{2}/g);return e===null?W0.Buffer.from([]):W0.Buffer.from(e.map(r=>parseInt(r,16)))}var bu={},qs={},lf;Object.defineProperty(qs,"__esModule",{value:!0});qs.isVersionedTransaction=qs.isBrowser=void 0;qs.chunks=Q_;qs.isBrowser=process.env.ANCHOR_BROWSER||typeof window<"u"&&!(!((lf=window.process)===null||lf===void 0)&&lf.hasOwnProperty("type"));function Q_(t,e){return Array.apply(0,new Array(Math.ceil(t.length/e))).map((r,n)=>t.slice(n*e,(n+1)*e))}const eP=t=>"version"in t;qs.isVersionedTransaction=eP;var df={},hf={},pf,K0;function Sw(){return K0||(K0=1,pf=function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var e={},r=Symbol("test"),n=Object(r);if(typeof r=="string"||Object.prototype.toString.call(r)!=="[object Symbol]"||Object.prototype.toString.call(n)!=="[object Symbol]")return!1;var s=42;e[r]=s;for(var i in e)return!1;if(typeof Object.keys=="function"&&Object.keys(e).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(e).length!==0)return!1;var o=Object.getOwnPropertySymbols(e);if(o.length!==1||o[0]!==r||!Object.prototype.propertyIsEnumerable.call(e,r))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var a=Object.getOwnPropertyDescriptor(e,r);if(a.value!==s||a.enumerable!==!0)return!1}return!0}),pf}var yf,Z0;function gu(){if(Z0)return yf;Z0=1;var t=Sw();return yf=function(){return t()&&!!Symbol.toStringTag},yf}var mf,Y0;function xw(){return Y0||(Y0=1,mf=Object),mf}var bf,X0;function tP(){return X0||(X0=1,bf=Error),bf}var gf,J0;function rP(){return J0||(J0=1,gf=EvalError),gf}var wf,Q0;function nP(){return Q0||(Q0=1,wf=RangeError),wf}var vf,ey;function sP(){return ey||(ey=1,vf=ReferenceError),vf}var Ef,ty;function kw(){return ty||(ty=1,Ef=SyntaxError),Ef}var Af,ry;function Ia(){return ry||(ry=1,Af=TypeError),Af}var Sf,ny;function iP(){return ny||(ny=1,Sf=URIError),Sf}var xf,sy;function oP(){return sy||(sy=1,xf=Math.abs),xf}var kf,iy;function aP(){return iy||(iy=1,kf=Math.floor),kf}var Tf,oy;function cP(){return oy||(oy=1,Tf=Math.max),Tf}var _f,ay;function uP(){return ay||(ay=1,_f=Math.min),_f}var Pf,cy;function fP(){return cy||(cy=1,Pf=Math.pow),Pf}var If,uy;function lP(){return uy||(uy=1,If=Math.round),If}var Of,fy;function dP(){return fy||(fy=1,Of=Number.isNaN||function(e){return e!==e}),Of}var Bf,ly;function hP(){if(ly)return Bf;ly=1;var t=dP();return Bf=function(r){return t(r)||r===0?r:r<0?-1:1},Bf}var Cf,dy;function pP(){return dy||(dy=1,Cf=Object.getOwnPropertyDescriptor),Cf}var $f,hy;function Yi(){if(hy)return $f;hy=1;var t=pP();if(t)try{t([],"length")}catch{t=null}return $f=t,$f}var Rf,py;function wu(){if(py)return Rf;py=1;var t=Object.defineProperty||!1;if(t)try{t({},"a",{value:1})}catch{t=!1}return Rf=t,Rf}var Nf,yy;function yP(){if(yy)return Nf;yy=1;var t=typeof Symbol<"u"&&Symbol,e=Sw();return Nf=function(){return typeof t!="function"||typeof Symbol!="function"||typeof t("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:e()},Nf}var Uf,my;function Tw(){return my||(my=1,Uf=typeof Reflect<"u"&&Reflect.getPrototypeOf||null),Uf}var Mf,by;function _w(){if(by)return Mf;by=1;var t=xw();return Mf=t.getPrototypeOf||null,Mf}var Ff,gy;function mP(){if(gy)return Ff;gy=1;var t="Function.prototype.bind called on incompatible ",e=Object.prototype.toString,r=Math.max,n="[object Function]",s=function(c,u){for(var f=[],l=0;l<c.length;l+=1)f[l]=c[l];for(var p=0;p<u.length;p+=1)f[p+c.length]=u[p];return f},i=function(c,u){for(var f=[],l=u,p=0;l<c.length;l+=1,p+=1)f[p]=c[l];return f},o=function(a,c){for(var u="",f=0;f<a.length;f+=1)u+=a[f],f+1<a.length&&(u+=c);return u};return Ff=function(c){var u=this;if(typeof u!="function"||e.apply(u)!==n)throw new TypeError(t+u);for(var f=i(arguments,1),l,p=function(){if(this instanceof l){var S=u.apply(this,s(f,arguments));return Object(S)===S?S:this}return u.apply(c,s(f,arguments))},d=r(0,u.length-f.length),m=[],b=0;b<d;b++)m[b]="$"+b;if(l=Function("binder","return function ("+o(m,",")+"){ return binder.apply(this,arguments); }")(p),u.prototype){var E=function(){};E.prototype=u.prototype,l.prototype=new E,E.prototype=null}return l},Ff}var jf,wy;function Oa(){if(wy)return jf;wy=1;var t=mP();return jf=Function.prototype.bind||t,jf}var Lf,vy;function Gh(){return vy||(vy=1,Lf=Function.prototype.call),Lf}var Hf,Ey;function Wh(){return Ey||(Ey=1,Hf=Function.prototype.apply),Hf}var Df,Ay;function bP(){return Ay||(Ay=1,Df=typeof Reflect<"u"&&Reflect&&Reflect.apply),Df}var zf,Sy;function Pw(){if(Sy)return zf;Sy=1;var t=Oa(),e=Wh(),r=Gh(),n=bP();return zf=n||t.call(r,e),zf}var Vf,xy;function Kh(){if(xy)return Vf;xy=1;var t=Oa(),e=Ia(),r=Gh(),n=Pw();return Vf=function(i){if(i.length<1||typeof i[0]!="function")throw new e("a function is required");return n(t,r,i)},Vf}var qf,ky;function gP(){if(ky)return qf;ky=1;var t=Kh(),e=Yi(),r;try{r=[].__proto__===Array.prototype}catch(o){if(!o||typeof o!="object"||!("code"in o)||o.code!=="ERR_PROTO_ACCESS")throw o}var n=!!r&&e&&e(Object.prototype,"__proto__"),s=Object,i=s.getPrototypeOf;return qf=n&&typeof n.get=="function"?t([n.get]):typeof i=="function"?function(a){return i(a==null?a:s(a))}:!1,qf}var Gf,Ty;function Zh(){if(Ty)return Gf;Ty=1;var t=Tw(),e=_w(),r=gP();return Gf=t?function(s){return t(s)}:e?function(s){if(!s||typeof s!="object"&&typeof s!="function")throw new TypeError("getProto: not an object");return e(s)}:r?function(s){return r(s)}:null,Gf}var Wf,_y;function Iw(){if(_y)return Wf;_y=1;var t=Function.prototype.call,e=Object.prototype.hasOwnProperty,r=Oa();return Wf=r.call(t,e),Wf}var Kf,Py;function Ow(){if(Py)return Kf;Py=1;var t,e=xw(),r=tP(),n=rP(),s=nP(),i=sP(),o=kw(),a=Ia(),c=iP(),u=oP(),f=aP(),l=cP(),p=uP(),d=fP(),m=lP(),b=hP(),E=Function,S=function(oe){try{return E('"use strict"; return ('+oe+").constructor;")()}catch{}},P=Yi(),A=wu(),w=function(){throw new a},k=P?function(){try{return arguments.callee,w}catch{try{return P(arguments,"callee").get}catch{return w}}}():w,T=yP()(),B=Zh(),N=_w(),$=Tw(),H=Wh(),M=Gh(),V={},G=typeof Uint8Array>"u"||!B?t:B(Uint8Array),Q={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?t:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?t:ArrayBuffer,"%ArrayIteratorPrototype%":T&&B?B([][Symbol.iterator]()):t,"%AsyncFromSyncIteratorPrototype%":t,"%AsyncFunction%":V,"%AsyncGenerator%":V,"%AsyncGeneratorFunction%":V,"%AsyncIteratorPrototype%":V,"%Atomics%":typeof Atomics>"u"?t:Atomics,"%BigInt%":typeof BigInt>"u"?t:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?t:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?t:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?t:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":r,"%eval%":eval,"%EvalError%":n,"%Float16Array%":typeof Float16Array>"u"?t:Float16Array,"%Float32Array%":typeof Float32Array>"u"?t:Float32Array,"%Float64Array%":typeof Float64Array>"u"?t:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?t:FinalizationRegistry,"%Function%":E,"%GeneratorFunction%":V,"%Int8Array%":typeof Int8Array>"u"?t:Int8Array,"%Int16Array%":typeof Int16Array>"u"?t:Int16Array,"%Int32Array%":typeof Int32Array>"u"?t:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":T&&B?B(B([][Symbol.iterator]())):t,"%JSON%":typeof JSON=="object"?JSON:t,"%Map%":typeof Map>"u"?t:Map,"%MapIteratorPrototype%":typeof Map>"u"||!T||!B?t:B(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":e,"%Object.getOwnPropertyDescriptor%":P,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?t:Promise,"%Proxy%":typeof Proxy>"u"?t:Proxy,"%RangeError%":s,"%ReferenceError%":i,"%Reflect%":typeof Reflect>"u"?t:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?t:Set,"%SetIteratorPrototype%":typeof Set>"u"||!T||!B?t:B(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?t:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":T&&B?B(""[Symbol.iterator]()):t,"%Symbol%":T?Symbol:t,"%SyntaxError%":o,"%ThrowTypeError%":k,"%TypedArray%":G,"%TypeError%":a,"%Uint8Array%":typeof Uint8Array>"u"?t:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?t:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?t:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?t:Uint32Array,"%URIError%":c,"%WeakMap%":typeof WeakMap>"u"?t:WeakMap,"%WeakRef%":typeof WeakRef>"u"?t:WeakRef,"%WeakSet%":typeof WeakSet>"u"?t:WeakSet,"%Function.prototype.call%":M,"%Function.prototype.apply%":H,"%Object.defineProperty%":A,"%Object.getPrototypeOf%":N,"%Math.abs%":u,"%Math.floor%":f,"%Math.max%":l,"%Math.min%":p,"%Math.pow%":d,"%Math.round%":m,"%Math.sign%":b,"%Reflect.getPrototypeOf%":$};if(B)try{null.error}catch(oe){var W=B(B(oe));Q["%Error.prototype%"]=W}var K=function oe(ie){var me;if(ie==="%AsyncFunction%")me=S("async function () {}");else if(ie==="%GeneratorFunction%")me=S("function* () {}");else if(ie==="%AsyncGeneratorFunction%")me=S("async function* () {}");else if(ie==="%AsyncGenerator%"){var be=oe("%AsyncGeneratorFunction%");be&&(me=be.prototype)}else if(ie==="%AsyncIteratorPrototype%"){var we=oe("%AsyncGenerator%");we&&B&&(me=B(we.prototype))}return Q[ie]=me,me},re={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},q=Oa(),I=Iw(),j=q.call(M,Array.prototype.concat),J=q.call(H,Array.prototype.splice),O=q.call(M,String.prototype.replace),R=q.call(M,String.prototype.slice),F=q.call(M,RegExp.prototype.exec),ne=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,ae=/\\(\\)?/g,le=function(ie){var me=R(ie,0,1),be=R(ie,-1);if(me==="%"&&be!=="%")throw new o("invalid intrinsic syntax, expected closing `%`");if(be==="%"&&me!=="%")throw new o("invalid intrinsic syntax, expected opening `%`");var we=[];return O(ie,ne,function(ke,tt,Oe,Rr){we[we.length]=Oe?O(Rr,ae,"$1"):tt||ke}),we},ue=function(ie,me){var be=ie,we;if(I(re,be)&&(we=re[be],be="%"+we[0]+"%"),I(Q,be)){var ke=Q[be];if(ke===V&&(ke=K(be)),typeof ke>"u"&&!me)throw new a("intrinsic "+ie+" exists, but is not available. Please file an issue!");return{alias:we,name:be,value:ke}}throw new o("intrinsic "+ie+" does not exist!")};return Kf=function(ie,me){if(typeof ie!="string"||ie.length===0)throw new a("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof me!="boolean")throw new a('"allowMissing" argument must be a boolean');if(F(/^%?[^%]*%?$/,ie)===null)throw new o("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var be=le(ie),we=be.length>0?be[0]:"",ke=ue("%"+we+"%",me),tt=ke.name,Oe=ke.value,Rr=!1,ds=ke.alias;ds&&(we=ds[0],J(be,j([0,1],ds)));for(var z=1,Nr=!0;z<be.length;z+=1){var At=be[z],St=R(At,0,1),Rn=R(At,-1);if((St==='"'||St==="'"||St==="`"||Rn==='"'||Rn==="'"||Rn==="`")&&St!==Rn)throw new o("property names with quotes must have matching quotes");if((At==="constructor"||!Nr)&&(Rr=!0),we+="."+At,tt="%"+we+"%",I(Q,tt))Oe=Q[tt];else if(Oe!=null){if(!(At in Oe)){if(!me)throw new a("base intrinsic for "+ie+" exists, but the property is not available.");return}if(P&&z+1>=be.length){var ni=P(Oe,At);Nr=!!ni,Nr&&"get"in ni&&!("originalValue"in ni.get)?Oe=ni.get:Oe=Oe[At]}else Nr=I(Oe,At),Oe=Oe[At];Nr&&!Rr&&(Q[tt]=Oe)}}return Oe},Kf}var Zf,Iy;function Ba(){if(Iy)return Zf;Iy=1;var t=Ow(),e=Kh(),r=e([t("%String.prototype.indexOf%")]);return Zf=function(s,i){var o=t(s,!!i);return typeof o=="function"&&r(s,".prototype.")>-1?e([o]):o},Zf}var Yf,Oy;function wP(){if(Oy)return Yf;Oy=1;var t=gu()(),e=Ba(),r=e("Object.prototype.toString"),n=function(a){return t&&a&&typeof a=="object"&&Symbol.toStringTag in a?!1:r(a)==="[object Arguments]"},s=function(a){return n(a)?!0:a!==null&&typeof a=="object"&&"length"in a&&typeof a.length=="number"&&a.length>=0&&r(a)!=="[object Array]"&&"callee"in a&&r(a.callee)==="[object Function]"},i=function(){return n(arguments)}();return n.isLegacyArguments=s,Yf=i?n:s,Yf}var Xf,By;function vP(){if(By)return Xf;By=1;var t=Ba(),e=gu()(),r=Iw(),n=Yi(),s;if(e){var i=t("RegExp.prototype.exec"),o={},a=function(){throw o},c={toString:a,valueOf:a};typeof Symbol.toPrimitive=="symbol"&&(c[Symbol.toPrimitive]=a),s=function(p){if(!p||typeof p!="object")return!1;var d=n(p,"lastIndex"),m=d&&r(d,"value");if(!m)return!1;try{i(p,c)}catch(b){return b===o}}}else{var u=t("Object.prototype.toString"),f="[object RegExp]";s=function(p){return!p||typeof p!="object"&&typeof p!="function"?!1:u(p)===f}}return Xf=s,Xf}var Jf,Cy;function EP(){if(Cy)return Jf;Cy=1;var t=Ba(),e=vP(),r=t("RegExp.prototype.exec"),n=Ia();return Jf=function(i){if(!e(i))throw new n("`regex` must be a RegExp");return function(a){return r(i,a)!==null}},Jf}var Qf,$y;function AP(){if($y)return Qf;$y=1;var t=Ba(),e=EP(),r=e(/^\s*(?:function)?\*/),n=gu()(),s=Zh(),i=t("Object.prototype.toString"),o=t("Function.prototype.toString"),a=function(){if(!n)return!1;try{return Function("return function*() {}")()}catch{}},c;return Qf=function(f){if(typeof f!="function")return!1;if(r(o(f)))return!0;if(!n){var l=i(f);return l==="[object GeneratorFunction]"}if(!s)return!1;if(typeof c>"u"){var p=a();c=p?s(p):!1}return s(f)===c},Qf}var el,Ry;function SP(){if(Ry)return el;Ry=1;var t=Function.prototype.toString,e=typeof Reflect=="object"&&Reflect!==null&&Reflect.apply,r,n;if(typeof e=="function"&&typeof Object.defineProperty=="function")try{r=Object.defineProperty({},"length",{get:function(){throw n}}),n={},e(function(){throw 42},null,r)}catch(P){P!==n&&(e=null)}else e=null;var s=/^\s*class\b/,i=function(A){try{var w=t.call(A);return s.test(w)}catch{return!1}},o=function(A){try{return i(A)?!1:(t.call(A),!0)}catch{return!1}},a=Object.prototype.toString,c="[object Object]",u="[object Function]",f="[object GeneratorFunction]",l="[object HTMLAllCollection]",p="[object HTML document.all class]",d="[object HTMLCollection]",m=typeof Symbol=="function"&&!!Symbol.toStringTag,b=!(0 in[,]),E=function(){return!1};if(typeof document=="object"){var S=document.all;a.call(S)===a.call(document.all)&&(E=function(A){if((b||!A)&&(typeof A>"u"||typeof A=="object"))try{var w=a.call(A);return(w===l||w===p||w===d||w===c)&&A("")==null}catch{}return!1})}return el=e?function(A){if(E(A))return!0;if(!A||typeof A!="function"&&typeof A!="object")return!1;try{e(A,null,r)}catch(w){if(w!==n)return!1}return!i(A)&&o(A)}:function(A){if(E(A))return!0;if(!A||typeof A!="function"&&typeof A!="object")return!1;if(m)return o(A);if(i(A))return!1;var w=a.call(A);return w!==u&&w!==f&&!/^\[object HTML/.test(w)?!1:o(A)},el}var tl,Ny;function xP(){if(Ny)return tl;Ny=1;var t=SP(),e=Object.prototype.toString,r=Object.prototype.hasOwnProperty,n=function(c,u,f){for(var l=0,p=c.length;l<p;l++)r.call(c,l)&&(f==null?u(c[l],l,c):u.call(f,c[l],l,c))},s=function(c,u,f){for(var l=0,p=c.length;l<p;l++)f==null?u(c.charAt(l),l,c):u.call(f,c.charAt(l),l,c)},i=function(c,u,f){for(var l in c)r.call(c,l)&&(f==null?u(c[l],l,c):u.call(f,c[l],l,c))};function o(a){return e.call(a)==="[object Array]"}return tl=function(c,u,f){if(!t(u))throw new TypeError("iterator must be a function");var l;arguments.length>=3&&(l=f),o(c)?n(c,u,l):typeof c=="string"?s(c,u,l):i(c,u,l)},tl}var rl,Uy;function kP(){return Uy||(Uy=1,rl=["Float16Array","Float32Array","Float64Array","Int8Array","Int16Array","Int32Array","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array"]),rl}var nl,My;function TP(){if(My)return nl;My=1;var t=kP(),e=typeof globalThis>"u"?Qr:globalThis;return nl=function(){for(var n=[],s=0;s<t.length;s++)typeof e[t[s]]=="function"&&(n[n.length]=t[s]);return n},nl}var sl={exports:{}},il,Fy;function _P(){if(Fy)return il;Fy=1;var t=wu(),e=kw(),r=Ia(),n=Yi();return il=function(i,o,a){if(!i||typeof i!="object"&&typeof i!="function")throw new r("`obj` must be an object or a function`");if(typeof o!="string"&&typeof o!="symbol")throw new r("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new r("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new r("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new r("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new r("`loose`, if provided, must be a boolean");var c=arguments.length>3?arguments[3]:null,u=arguments.length>4?arguments[4]:null,f=arguments.length>5?arguments[5]:null,l=arguments.length>6?arguments[6]:!1,p=!!n&&n(i,o);if(t)t(i,o,{configurable:f===null&&p?p.configurable:!f,enumerable:c===null&&p?p.enumerable:!c,value:a,writable:u===null&&p?p.writable:!u});else if(l||!c&&!u&&!f)i[o]=a;else throw new e("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},il}var ol,jy;function PP(){if(jy)return ol;jy=1;var t=wu(),e=function(){return!!t};return e.hasArrayLengthDefineBug=function(){if(!t)return null;try{return t([],"length",{value:1}).length!==1}catch{return!0}},ol=e,ol}var al,Ly;function IP(){if(Ly)return al;Ly=1;var t=Ow(),e=_P(),r=PP()(),n=Yi(),s=Ia(),i=t("%Math.floor%");return al=function(a,c){if(typeof a!="function")throw new s("`fn` is not a function");if(typeof c!="number"||c<0||c>4294967295||i(c)!==c)throw new s("`length` must be a positive 32-bit integer");var u=arguments.length>2&&!!arguments[2],f=!0,l=!0;if("length"in a&&n){var p=n(a,"length");p&&!p.configurable&&(f=!1),p&&!p.writable&&(l=!1)}return(f||l||!u)&&(r?e(a,"length",c,!0,!0):e(a,"length",c)),a},al}var cl,Hy;function OP(){if(Hy)return cl;Hy=1;var t=Oa(),e=Wh(),r=Pw();return cl=function(){return r(t,e,arguments)},cl}var Dy;function BP(){return Dy||(Dy=1,function(t){var e=IP(),r=wu(),n=Kh(),s=OP();t.exports=function(o){var a=n(arguments),c=o.length-(arguments.length-1);return e(a,1+(c>0?c:0),!0)},r?r(t.exports,"apply",{value:s}):t.exports.apply=s}(sl)),sl.exports}var ul,zy;function Bw(){if(zy)return ul;zy=1;var t=xP(),e=TP(),r=BP(),n=Ba(),s=Yi(),i=Zh(),o=n("Object.prototype.toString"),a=gu()(),c=typeof globalThis>"u"?Qr:globalThis,u=e(),f=n("String.prototype.slice"),l=n("Array.prototype.indexOf",!0)||function(E,S){for(var P=0;P<E.length;P+=1)if(E[P]===S)return P;return-1},p={__proto__:null};a&&s&&i?t(u,function(b){var E=new c[b];if(Symbol.toStringTag in E&&i){var S=i(E),P=s(S,Symbol.toStringTag);if(!P&&S){var A=i(S);P=s(A,Symbol.toStringTag)}p["$"+b]=r(P.get)}}):t(u,function(b){var E=new c[b],S=E.slice||E.set;S&&(p["$"+b]=r(S))});var d=function(E){var S=!1;return t(p,function(P,A){if(!S)try{"$"+P(E)===A&&(S=f(A,1))}catch{}}),S},m=function(E){var S=!1;return t(p,function(P,A){if(!S)try{P(E),S=f(A,1)}catch{}}),S};return ul=function(E){if(!E||typeof E!="object")return!1;if(!a){var S=f(o(E),8,-1);return l(u,S)>-1?S:S!=="Object"?!1:m(E)}return s?d(E):null},ul}var fl,Vy;function CP(){if(Vy)return fl;Vy=1;var t=Bw();return fl=function(r){return!!t(r)},fl}var qy;function $P(){return qy||(qy=1,function(t){var e=wP(),r=AP(),n=Bw(),s=CP();function i(z){return z.call.bind(z)}var o=typeof BigInt<"u",a=typeof Symbol<"u",c=i(Object.prototype.toString),u=i(Number.prototype.valueOf),f=i(String.prototype.valueOf),l=i(Boolean.prototype.valueOf);if(o)var p=i(BigInt.prototype.valueOf);if(a)var d=i(Symbol.prototype.valueOf);function m(z,Nr){if(typeof z!="object")return!1;try{return Nr(z),!0}catch{return!1}}t.isArgumentsObject=e,t.isGeneratorFunction=r,t.isTypedArray=s;function b(z){return typeof Promise<"u"&&z instanceof Promise||z!==null&&typeof z=="object"&&typeof z.then=="function"&&typeof z.catch=="function"}t.isPromise=b;function E(z){return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?ArrayBuffer.isView(z):s(z)||R(z)}t.isArrayBufferView=E;function S(z){return n(z)==="Uint8Array"}t.isUint8Array=S;function P(z){return n(z)==="Uint8ClampedArray"}t.isUint8ClampedArray=P;function A(z){return n(z)==="Uint16Array"}t.isUint16Array=A;function w(z){return n(z)==="Uint32Array"}t.isUint32Array=w;function k(z){return n(z)==="Int8Array"}t.isInt8Array=k;function T(z){return n(z)==="Int16Array"}t.isInt16Array=T;function B(z){return n(z)==="Int32Array"}t.isInt32Array=B;function N(z){return n(z)==="Float32Array"}t.isFloat32Array=N;function $(z){return n(z)==="Float64Array"}t.isFloat64Array=$;function H(z){return n(z)==="BigInt64Array"}t.isBigInt64Array=H;function M(z){return n(z)==="BigUint64Array"}t.isBigUint64Array=M;function V(z){return c(z)==="[object Map]"}V.working=typeof Map<"u"&&V(new Map);function G(z){return typeof Map>"u"?!1:V.working?V(z):z instanceof Map}t.isMap=G;function Q(z){return c(z)==="[object Set]"}Q.working=typeof Set<"u"&&Q(new Set);function W(z){return typeof Set>"u"?!1:Q.working?Q(z):z instanceof Set}t.isSet=W;function K(z){return c(z)==="[object WeakMap]"}K.working=typeof WeakMap<"u"&&K(new WeakMap);function re(z){return typeof WeakMap>"u"?!1:K.working?K(z):z instanceof WeakMap}t.isWeakMap=re;function q(z){return c(z)==="[object WeakSet]"}q.working=typeof WeakSet<"u"&&q(new WeakSet);function I(z){return q(z)}t.isWeakSet=I;function j(z){return c(z)==="[object ArrayBuffer]"}j.working=typeof ArrayBuffer<"u"&&j(new ArrayBuffer);function J(z){return typeof ArrayBuffer>"u"?!1:j.working?j(z):z instanceof ArrayBuffer}t.isArrayBuffer=J;function O(z){return c(z)==="[object DataView]"}O.working=typeof ArrayBuffer<"u"&&typeof DataView<"u"&&O(new DataView(new ArrayBuffer(1),0,1));function R(z){return typeof DataView>"u"?!1:O.working?O(z):z instanceof DataView}t.isDataView=R;var F=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:void 0;function ne(z){return c(z)==="[object SharedArrayBuffer]"}function ae(z){return typeof F>"u"?!1:(typeof ne.working>"u"&&(ne.working=ne(new F)),ne.working?ne(z):z instanceof F)}t.isSharedArrayBuffer=ae;function le(z){return c(z)==="[object AsyncFunction]"}t.isAsyncFunction=le;function ue(z){return c(z)==="[object Map Iterator]"}t.isMapIterator=ue;function oe(z){return c(z)==="[object Set Iterator]"}t.isSetIterator=oe;function ie(z){return c(z)==="[object Generator]"}t.isGeneratorObject=ie;function me(z){return c(z)==="[object WebAssembly.Module]"}t.isWebAssemblyCompiledModule=me;function be(z){return m(z,u)}t.isNumberObject=be;function we(z){return m(z,f)}t.isStringObject=we;function ke(z){return m(z,l)}t.isBooleanObject=ke;function tt(z){return o&&m(z,p)}t.isBigIntObject=tt;function Oe(z){return a&&m(z,d)}t.isSymbolObject=Oe;function Rr(z){return be(z)||we(z)||ke(z)||tt(z)||Oe(z)}t.isBoxedPrimitive=Rr;function ds(z){return typeof Uint8Array<"u"&&(J(z)||ae(z))}t.isAnyArrayBuffer=ds,["isProxy","isExternal","isModuleNamespaceObject"].forEach(function(z){Object.defineProperty(t,z,{enumerable:!1,value:function(){throw new Error(z+" is not supported in userland")}})})}(hf)),hf}var ll,Gy;function RP(){return Gy||(Gy=1,ll=function(e){return e&&typeof e=="object"&&typeof e.copy=="function"&&typeof e.fill=="function"&&typeof e.readUInt8=="function"}),ll}var Ja={exports:{}},Wy;function NP(){return Wy||(Wy=1,typeof Object.create=="function"?Ja.exports=function(e,r){r&&(e.super_=r,e.prototype=Object.create(r.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:Ja.exports=function(e,r){if(r){e.super_=r;var n=function(){};n.prototype=r.prototype,e.prototype=new n,e.prototype.constructor=e}}),Ja.exports}var Ky;function Cw(){return Ky||(Ky=1,function(t){var e=Object.getOwnPropertyDescriptors||function(R){for(var F=Object.keys(R),ne={},ae=0;ae<F.length;ae++)ne[F[ae]]=Object.getOwnPropertyDescriptor(R,F[ae]);return ne},r=/%[sdj%]/g;t.format=function(O){if(!k(O)){for(var R=[],F=0;F<arguments.length;F++)R.push(o(arguments[F]));return R.join(" ")}for(var F=1,ne=arguments,ae=ne.length,le=String(O).replace(r,function(oe){if(oe==="%%")return"%";if(F>=ae)return oe;switch(oe){case"%s":return String(ne[F++]);case"%d":return Number(ne[F++]);case"%j":try{return JSON.stringify(ne[F++])}catch{return"[Circular]"}default:return oe}}),ue=ne[F];F<ae;ue=ne[++F])P(ue)||!$(ue)?le+=" "+ue:le+=" "+o(ue);return le},t.deprecate=function(O,R){if(typeof process<"u"&&process.noDeprecation===!0)return O;if(typeof process>"u")return function(){return t.deprecate(O,R).apply(this,arguments)};var F=!1;function ne(){if(!F){if(process.throwDeprecation)throw new Error(R);process.traceDeprecation?console.trace(R):console.error(R),F=!0}return O.apply(this,arguments)}return ne};var n={},s=/^$/;if(process.env.NODE_DEBUG){var i=process.env.NODE_DEBUG;i=i.replace(/[|\\{}()[\]^$+?.]/g,"\\$&").replace(/\*/g,".*").replace(/,/g,"$|^").toUpperCase(),s=new RegExp("^"+i+"$","i")}t.debuglog=function(O){if(O=O.toUpperCase(),!n[O])if(s.test(O)){var R=process.pid;n[O]=function(){var F=t.format.apply(t,arguments);console.error("%s %d: %s",O,R,F)}}else n[O]=function(){};return n[O]};function o(O,R){var F={seen:[],stylize:c};return arguments.length>=3&&(F.depth=arguments[2]),arguments.length>=4&&(F.colors=arguments[3]),S(R)?F.showHidden=R:R&&t._extend(F,R),B(F.showHidden)&&(F.showHidden=!1),B(F.depth)&&(F.depth=2),B(F.colors)&&(F.colors=!1),B(F.customInspect)&&(F.customInspect=!0),F.colors&&(F.stylize=a),f(F,O,F.depth)}t.inspect=o,o.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},o.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"};function a(O,R){var F=o.styles[R];return F?"\x1B["+o.colors[F][0]+"m"+O+"\x1B["+o.colors[F][1]+"m":O}function c(O,R){return O}function u(O){var R={};return O.forEach(function(F,ne){R[F]=!0}),R}function f(O,R,F){if(O.customInspect&&R&&V(R.inspect)&&R.inspect!==t.inspect&&!(R.constructor&&R.constructor.prototype===R)){var ne=R.inspect(F,O);return k(ne)||(ne=f(O,ne,F)),ne}var ae=l(O,R);if(ae)return ae;var le=Object.keys(R),ue=u(le);if(O.showHidden&&(le=Object.getOwnPropertyNames(R)),M(R)&&(le.indexOf("message")>=0||le.indexOf("description")>=0))return p(R);if(le.length===0){if(V(R)){var oe=R.name?": "+R.name:"";return O.stylize("[Function"+oe+"]","special")}if(N(R))return O.stylize(RegExp.prototype.toString.call(R),"regexp");if(H(R))return O.stylize(Date.prototype.toString.call(R),"date");if(M(R))return p(R)}var ie="",me=!1,be=["{","}"];if(E(R)&&(me=!0,be=["[","]"]),V(R)){var we=R.name?": "+R.name:"";ie=" [Function"+we+"]"}if(N(R)&&(ie=" "+RegExp.prototype.toString.call(R)),H(R)&&(ie=" "+Date.prototype.toUTCString.call(R)),M(R)&&(ie=" "+p(R)),le.length===0&&(!me||R.length==0))return be[0]+ie+be[1];if(F<0)return N(R)?O.stylize(RegExp.prototype.toString.call(R),"regexp"):O.stylize("[Object]","special");O.seen.push(R);var ke;return me?ke=d(O,R,F,ue,le):ke=le.map(function(tt){return m(O,R,F,ue,tt,me)}),O.seen.pop(),b(ke,ie,be)}function l(O,R){if(B(R))return O.stylize("undefined","undefined");if(k(R)){var F="'"+JSON.stringify(R).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return O.stylize(F,"string")}if(w(R))return O.stylize(""+R,"number");if(S(R))return O.stylize(""+R,"boolean");if(P(R))return O.stylize("null","null")}function p(O){return"["+Error.prototype.toString.call(O)+"]"}function d(O,R,F,ne,ae){for(var le=[],ue=0,oe=R.length;ue<oe;++ue)q(R,String(ue))?le.push(m(O,R,F,ne,String(ue),!0)):le.push("");return ae.forEach(function(ie){ie.match(/^\d+$/)||le.push(m(O,R,F,ne,ie,!0))}),le}function m(O,R,F,ne,ae,le){var ue,oe,ie;if(ie=Object.getOwnPropertyDescriptor(R,ae)||{value:R[ae]},ie.get?ie.set?oe=O.stylize("[Getter/Setter]","special"):oe=O.stylize("[Getter]","special"):ie.set&&(oe=O.stylize("[Setter]","special")),q(ne,ae)||(ue="["+ae+"]"),oe||(O.seen.indexOf(ie.value)<0?(P(F)?oe=f(O,ie.value,null):oe=f(O,ie.value,F-1),oe.indexOf(`
|
|
74
74
|
`)>-1&&(le?oe=oe.split(`
|
|
75
75
|
`).map(function(me){return" "+me}).join(`
|
|
76
76
|
`).slice(2):oe=`
|
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-Dr2UWku_.cjs");exports.API=e.API;exports.BitcoinNetwork=e.BitcoinNetwork;exports.BitcoinProvider=e.BitcoinProvider;exports.BitcoinWallet=e.BitcoinWallet;exports.DEFAULT_AFFILIATE_ASSET=e.DEFAULT_AFFILIATE_ASSET;exports.EvmRelay=e.EvmRelay;exports.Garden=e.Garden;exports.Quote=e.Quote;exports.STARKNET_CONFIG=e.STARKNET_CONFIG;exports.SUI_CONFIG=e.SUI_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.alpenTestnet=e.alpenTestnet;exports.botanixMainnet=e.botanixMainnet;exports.checkStarknetAlloance=e.checkAllowance;exports.checkStarknetAllowanceAndApprove=e.checkAllowanceAndApprove;exports.constructOrderPair=e.constructOrderPair;exports.evmToViemChainMap=e.evmToViemChainMap;exports.getChainNameFromChainId=e.getChainNameFromChainId;exports.hyperliquid=e.hyperliquid;exports.hyperliquidTestnet=e.hyperliquidTestnet;exports.isStarknetAllowanceSufficient=e.isAllowanceSufficient;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 { K as s, D as t, F as n, I as r, J as o, E as i, G as l, Q as A, L as d, M as c, m as S, k as T, j as k, N as C, h, S as p, A as m, u as y, p as I, n as v, q as F, w as N, x as u, y as w, z as E, o as O, r as L, O as R, C as f, t as g, v as B } from "./index-
|
|
1
|
+
import { K as s, D as t, F as n, I as r, J as o, E as i, G as l, Q as A, L as d, M as c, m as S, k as T, j as k, N as C, h, S as p, A as m, u as y, p as I, n as v, q as F, w as N, x as u, y as w, z as E, o as O, r as L, O as R, C as f, t as g, v as B } from "./index-DnqAlC96.js";
|
|
2
2
|
export {
|
|
3
3
|
s as API,
|
|
4
4
|
t as BitcoinNetwork,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gardenfi/core",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "vite build",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@coral-xyz/anchor": "^0.31.1",
|
|
31
|
-
"@gardenfi/orderbook": "3.0.
|
|
31
|
+
"@gardenfi/orderbook": "3.0.4",
|
|
32
32
|
"@gardenfi/utils": "3.0.0",
|
|
33
33
|
"@mysten/signers": "^0.3.4",
|
|
34
34
|
"@mysten/sui": "^1.37.1",
|