@dcl/blog-site 0.2.3-24088316758.commit-34384cf → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/{QueryClientProvider-DFnrqjxK.js → QueryClientProvider-DVt1z-lo.js} +1 -1
- package/assets/{SignInRedirect-YsS_y43O.js → SignInRedirect-DQ2EXIlf.js} +2 -2
- package/assets/{X-DQRyaTAP.js → X-_bf2yze4.js} +1 -1
- package/assets/{__federation_expose_App-BWDr6ljs.js → __federation_expose_App-DpSY-Y9d.js} +1 -1
- package/assets/{__federation_fn_import-DsoKw508.js → __federation_fn_import-D82-s3kA.js} +1 -1
- package/assets/__federation_shared_@dcl/{hooks-P78bsY9M.js → hooks-35itWugh.js} +3 -3
- package/assets/__federation_shared_@emotion/react-LISJiiTk.js +1 -0
- package/assets/__federation_shared_@emotion/{styled-CtXq_gFe.js → styled-CER0OT-8.js} +1 -1
- package/assets/{__federation_shared_decentraland-ui2-DRl5ehN-.js → __federation_shared_decentraland-ui2-qV0BHWTj.js} +6 -6
- package/assets/{__federation_shared_react-redux-DRaqgPHP.js → __federation_shared_react-redux-7pAtHZvO.js} +1 -1
- package/assets/{__federation_shared_react-router-dom-ClUJIur8.js → __federation_shared_react-router-dom-DM3U0-DJ.js} +1 -1
- package/assets/{__federation_shared_viem-OkDZ_da3.js → __federation_shared_viem-B7de3aIh.js} +1 -1
- package/assets/{__federation_shared_wagmi-DxQyjTpB.js → __federation_shared_wagmi-B-FL62eC.js} +1 -1
- package/assets/{add-BJhrLyz2.js → add-D95ShjVd.js} +1 -1
- package/assets/{all-wallets-BKl1d9ay.js → all-wallets-BY6r5fcR.js} +1 -1
- package/assets/{app-store-Cz4wx5Ml.js → app-store-SmbPBgEb.js} +1 -1
- package/assets/{apple-ZB0nqM0P.js → apple-D8pqe3de.js} +1 -1
- package/assets/{arrow-bottom-DPabveW2.js → arrow-bottom-DQy0lFo0.js} +1 -1
- package/assets/{arrow-bottom-circle-qQ6xlCaO.js → arrow-bottom-circle-OyHlN-U-.js} +1 -1
- package/assets/{arrow-left-D_0jfro8.js → arrow-left-CXPqeZRE.js} +1 -1
- package/assets/{arrow-right-Bxr-_0TM.js → arrow-right-BI45gebZ.js} +1 -1
- package/assets/{arrow-top-CcZJfPaY.js → arrow-top-BxYGxPQg.js} +1 -1
- package/assets/{auto-track-CXTejErn.js → auto-track-IXpT7xap.js} +1 -1
- package/assets/{bank-qzSNVmpL.js → bank-DvWpLZQG.js} +1 -1
- package/assets/{basic-CriAqicR.js → basic-DENnvNSD.js} +1 -1
- package/assets/{biconomy-7PcFs3b0.js → biconomy-GzbQEJRq.js} +1 -1
- package/assets/{browser-B01ZPlHW.js → browser-COUlM8GK.js} +1 -1
- package/assets/{card-C8yazSyG.js → card-DCZ4hxW7.js} +1 -1
- package/assets/{ccip-D0tvzkwi.js → ccip-DGW5U0-8.js} +1 -1
- package/assets/{checkmark-DEpAI8yr.js → checkmark-C3MmlUGU.js} +1 -1
- package/assets/{checkmark-bold-CmJidmVJ.js → checkmark-bold-BZz12uQW.js} +1 -1
- package/assets/{chevron-bottom-DWsbL4vJ.js → chevron-bottom-BITHvcvn.js} +1 -1
- package/assets/{chevron-left-DLMg9i5k.js → chevron-left-DLcgw6J3.js} +1 -1
- package/assets/{chevron-right-BR2L5tDn.js → chevron-right-CgvlwKH_.js} +1 -1
- package/assets/{chevron-top-BWtZfQ2F.js → chevron-top-E2kQk6Yb.js} +1 -1
- package/assets/{chrome-store-BGE1p2Hx.js → chrome-store-IGBWJmfs.js} +1 -1
- package/assets/{clock-B12ZBUD7.js → clock-Dnnqv_UX.js} +1 -1
- package/assets/{close-B54jTe2O.js → close-h_pw4dRD.js} +1 -1
- package/assets/{coinPlaceholder-B5PhQfVg.js → coinPlaceholder-CpzdwguN.js} +1 -1
- package/assets/{compass-CEs6S01I.js → compass-CLIqD2Io.js} +1 -1
- package/assets/{controller-n5F8mc3X.js → controller-DOHoljGI.js} +2 -2
- package/assets/{copy-DwrKUUfz.js → copy-56eIYa9K.js} +1 -1
- package/assets/{core-DPOUi4Tl.js → core-iy2F1EJT.js} +3 -3
- package/assets/{createBundlerClient-YqcE2yqs.js → createBundlerClient-Cb3DWn31.js} +1 -1
- package/assets/{createClient-BxHhKlNq.js → createClient-BJ5w543s.js} +1 -1
- package/assets/{cursor-CGBFNPoh.js → cursor-DHAIalN2.js} +1 -1
- package/assets/{cursor-transparent-D3nfFufs.js → cursor-transparent-USINvuuv.js} +1 -1
- package/assets/{decimals-D0IunObY.js → decimals-CVjZGYo0.js} +1 -1
- package/assets/{decimals-BMO-32AD.js → decimals-DIZDmdnI.js} +1 -1
- package/assets/{desktop-Bjkc6WkG.js → desktop-Ck9zNNDL.js} +1 -1
- package/assets/{detectExtension-BEr9WLqO.js → detectExtension-DQNsMd7m.js} +1 -1
- package/assets/{disconnect-D9dYAsxs.js → disconnect-B6rD3ARw.js} +1 -1
- package/assets/{discord-DZuYBrqS.js → discord-QyDy6H2Z.js} +1 -1
- package/assets/{emotion-react.browser.esm-Ce2LppU1.js → emotion-react.browser.esm-BHtRLI5r.js} +1 -1
- package/assets/{emotion-use-insertion-effect-with-fallbacks.browser.esm-ByQDcQjl.js → emotion-use-insertion-effect-with-fallbacks.browser.esm-DxyPSsfO.js} +1 -1
- package/assets/{encode-cHgp5mHv.js → encode-JOmK-dAM.js} +2 -2
- package/assets/{engine-BVbFCTQK.js → engine-Cr6ElJJw.js} +1 -1
- package/assets/{estimate-gas-DBgT8NWo.js → estimate-gas-CMPxVjuF.js} +3 -3
- package/assets/{estimate-l1-fee-C2ptcVct.js → estimate-l1-fee-B90S_dRF.js} +1 -1
- package/assets/{eth_getStorageAt-B9Y_JVAm.js → eth_getStorageAt-BzWA0XEw.js} +1 -1
- package/assets/{etherscan-oUtlOsmK.js → etherscan-BSyc5b_s.js} +1 -1
- package/assets/{exclamation-triangle-BdB5oh3a.js → exclamation-triangle-Cbq68j9M.js} +1 -1
- package/assets/{extension-CjK6xfgN.js → extension-Ef7aJ2Fj.js} +1 -1
- package/assets/{external-link-dD0-Gy7Y.js → external-link-bVFEWzQf.js} +1 -1
- package/assets/{extractIPFS-BN8-L65J.js → extractIPFS-kNuMOSPp.js} +1 -1
- package/assets/{facebook-CInWYo4e.js → facebook-KWDQXnqW.js} +1 -1
- package/assets/{farcaster-Dk7xCnWZ.js → farcaster-OZKU6ag9.js} +1 -1
- package/assets/{fee-data-DBS1-uI-.js → fee-data-BCMgs11D.js} +1 -1
- package/assets/{fetchTokenMetadata-sBUH3xE3.js → fetchTokenMetadata-BPHUGga-.js} +2 -2
- package/assets/{filters-CQJE56FO.js → filters-hVFxrfbM.js} +1 -1
- package/assets/{get-ecosystem-wallet-info-DkhEjWQL.js → get-ecosystem-wallet-info-mPW-S8xG.js} +1 -1
- package/assets/{getBalance-NroDyfvQ.js → getBalance-B1iUU342.js} +1 -1
- package/assets/{getInstalledModules-DFAdG78-.js → getInstalledModules-BnNuIBJw.js} +1 -1
- package/assets/{getNFT-CM6jDDoS.js → getNFT-BPxN7Ctt.js} +1 -1
- package/assets/{getNFT-CZphITDU.js → getNFT-DF0DVjz_.js} +2 -2
- package/assets/{github-D7bNXBE_.js → github-BzQnkFuN.js} +1 -1
- package/assets/{google-C7wxpdtc.js → google-Gdkba30S.js} +1 -1
- package/assets/{help-circle-jHfnx5-M.js → help-circle-CzuLd4UT.js} +1 -1
- package/assets/{id-B0bg6br2.js → id--DiZoCMN.js} +1 -1
- package/assets/{image-CFkOYVVZ.js → image-S2doqbWs.js} +1 -1
- package/assets/{in-app-wallet-calls-CUJMAfNk.js → in-app-wallet-calls-C1SY2oWN.js} +1 -1
- package/assets/{index-DyFSxszr.js → index-1ERaFZsE.js} +1 -1
- package/assets/index-BjzJcZq6.js +1 -1
- package/assets/{index-B6POK61z.js → index-C52TjtZ8.js} +1 -1
- package/assets/{index-CgabfD28.js → index-CH2z5aZN.js} +2 -2
- package/assets/{index-C9ZtSkAF.js → index-CfDhCkmV.js} +1 -1
- package/assets/{index-p2T8GhRA.js → index-CgkAqmHX.js} +1 -1
- package/assets/{index-C2t4sTPE.js → index-CwwTvCG6.js} +1 -1
- package/assets/{index-BgKyyaW6.js → index-D7VWCQbE.js} +1 -1
- package/assets/index-DIxygMtO.js +1 -0
- package/assets/{index-CDUZj6Gh.js → index-Dg2V4ned.js} +1 -1
- package/assets/index-Dy0yjznp.js +1 -1
- package/assets/{index-DuUs6XE9.js → index-T692f3s9.js} +1 -1
- package/assets/{index-BqaO8h_q.js → index-b9i0Ibxp.js} +2 -2
- package/assets/{index-CK_y9rJC.js → index-f2LDpGwT.js} +3 -3
- package/assets/{index-HwVh-q7L.js → index-ww85HWCV.js} +1 -1
- package/assets/{index.es-DiIxomE4.js → index.es-CzqZMQ08.js} +3 -3
- package/assets/{index.es-C4uogg3R.js → index.es-D_Iyl52g.js} +1 -1
- package/assets/{info-a5qnZWSp.js → info-DEpm9K4l.js} +1 -1
- package/assets/{info-circle-CtpHiT1K.js → info-circle-BFBSJV6L.js} +1 -1
- package/assets/jsx-runtime-DncYoG30.js +1 -1
- package/assets/{lightbulb-Cedc0rYJ.js → lightbulb-GZWMuOVt.js} +1 -1
- package/assets/{localBatchGatewayRequest-xHNW-Ehl.js → localBatchGatewayRequest-Df9EBRM7.js} +1 -1
- package/assets/{mail-D96xVokz.js → mail-CUdb6dNj.js} +1 -1
- package/assets/{mobile-DsDxm8mI.js → mobile-BeQz2cn_.js} +1 -1
- package/assets/{more-BedDVxwf.js → more-TsN-CR-t.js} +1 -1
- package/assets/{network-placeholder-CpA4BghL.js → network-placeholder-DwFC6B_7.js} +1 -1
- package/assets/{nftPlaceholder-E0nNrT1f.js → nftPlaceholder-CiT4A3-l.js} +1 -1
- package/assets/{off-C8YtcDJA.js → off-CUv-83kc.js} +1 -1
- package/assets/{openzeppelin-CQer_fI1.js → openzeppelin-BBJIIsPB.js} +1 -1
- package/assets/{ownerOf-GjaKoeq1.js → ownerOf-DYtTCeNU.js} +1 -1
- package/assets/{parseNft-CxF6cVbB.js → parseNft-Buclbv5Y.js} +2 -2
- package/assets/{play-store-wzv988wO.js → play-store-RQqRTPUT.js} +1 -1
- package/assets/{plus-BOnP2W3B.js → plus-C7MITUNH.js} +1 -1
- package/assets/preload-helper-BokH5fd6.js +1 -0
- package/assets/{qr-code-5Zy3Jwmz.js → qr-code-CpEPSAYR.js} +1 -1
- package/assets/{qr-overlay-qPTQSVWY.js → qr-overlay-DryFOQCX.js} +1 -1
- package/assets/{recycle-horizontal-BiLXE1ph.js → recycle-horizontal-B1QKxNTd.js} +1 -1
- package/assets/{refresh-DrIaQxXR.js → refresh-DdqLkUQx.js} +1 -1
- package/assets/remoteEntry.js +1 -1
- package/assets/{reown-logo-C50d_2u-.js → reown-logo-_t3NoThE.js} +1 -1
- package/assets/{resolveImplementation-Bp817C6y.js → resolveImplementation--gaCsV-s.js} +1 -1
- package/assets/{search-CtoMI8IW.js → search-B8WbQmvE.js} +1 -1
- package/assets/{secp256k1-lKd37s6b.js → secp256k1-DtCHzlC3.js} +1 -1
- package/assets/{send-DjyS4WAU.js → send-BFNT_o0R.js} +1 -1
- package/assets/{send-batch-transaction-DBV6UBBv.js → send-batch-transaction-ZanhTs8a.js} +1 -1
- package/assets/{send-eip712-transaction-CI65hvCl.js → send-eip712-transaction-CxRy-sD1.js} +2 -2
- package/assets/{send-gasless-transaction-C7lHksJD.js → send-gasless-transaction-Iz8ZLiHO.js} +2 -2
- package/assets/{serializeTransaction-6LlbmJwH.js → serializeTransaction-BufQeOel.js} +1 -1
- package/assets/{session-proposal-BJ6dUV4k.js → session-proposal-BD47nRI-.js} +1 -1
- package/assets/{session-request-Cen_JpY8.js → session-request-TkgpbjLp.js} +2 -2
- package/assets/{signing-BsPRCC1P.js → signing-TLGj9K79.js} +3 -3
- package/assets/{swapHorizontal-DUMDblJm.js → swapHorizontal-BiFAMUuS.js} +1 -1
- package/assets/{swapHorizontalBold-Du4gzczl.js → swapHorizontalBold-CP3dUSZb.js} +1 -1
- package/assets/{swapHorizontalMedium-BkSTzo9o.js → swapHorizontalMedium-BRNlkDrO.js} +1 -1
- package/assets/{swapHorizontalRoundedBold-CQD5i-I5.js → swapHorizontalRoundedBold-CHqEVcBs.js} +1 -1
- package/assets/{swapVertical-CjSXuBHb.js → swapVertical-Du0QoNAI.js} +1 -1
- package/assets/{telegram-uAGG8XwG.js → telegram-DQef1ILU.js} +1 -1
- package/assets/{thirdweb-DOoFBA7F.js → thirdweb-E-fErz2x.js} +3 -3
- package/assets/{three-dots-BWtFKrpY.js → three-dots-ByXtSGCV.js} +1 -1
- package/assets/{totalSupply-CjCaaPZD.js → totalSupply-DNIfxfBv.js} +1 -1
- package/assets/{twitch-VH9Dk-Bx.js → twitch-DIxDFqku.js} +1 -1
- package/assets/{twitterIcon-Bfs32uTm.js → twitterIcon-B-SNXvpz.js} +1 -1
- package/assets/{uid-XfAtrElX.js → uid-Bq9ktEE-.js} +3 -3
- package/assets/{verify-4fUj-WRm.js → verify-BT-sFhiZ.js} +1 -1
- package/assets/{verify-filled-sllS8Nrv.js → verify-filled-DUDJcSxD.js} +1 -1
- package/assets/{w3m-modal-Blb5XI95.js → w3m-modal-Ck71GkBa.js} +1 -1
- package/assets/{wait-for-tx-receipt-BR33kfvc.js → wait-for-tx-receipt-C5afrCK7.js} +1 -1
- package/assets/{wallet-DuQpuU5E.js → wallet-DiXkPY80.js} +1 -1
- package/assets/{wallet-placeholder-CERukyIC.js → wallet-placeholder-DHuJakoz.js} +1 -1
- package/assets/{walletconnect-CsB9GzlO.js → walletconnect-LtvddLlL.js} +1 -1
- package/assets/{wallets-vcnqEomN.js → wallets-BmZ-KVbp.js} +5 -5
- package/assets/{warning-circle-C8yGFMlX.js → warning-circle-DEf5ta8Y.js} +1 -1
- package/assets/{web-connector-Jj-2yhMg.js → web-connector-6KYcG8gr.js} +3 -3
- package/assets/{webSocket-BfTFTYzP.js → webSocket-2Mm3WVrI.js} +1 -1
- package/assets/{x-BXVsZnMK.js → x-Cl1yAHbN.js} +1 -1
- package/index.html +17 -17
- package/package.json +2 -2
- package/assets/__federation_shared_@emotion/react-CtCvVI4H.js +0 -1
- package/assets/index-Dot3cU3_.js +0 -1
- package/assets/preload-helper-2M-6abck.js +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__fileDeps=["assets/common-D37S_OFt.js","assets/utils-CozXUO91.js","assets/withCache-DYumIHzL.js","assets/index-
|
|
2
|
-
import{defineChain as re,getCachedChain as te}from"./utils-CozXUO91.js";import{b as v,a as I,w as zt,L as Bt,c as Rt,g as Nt}from"./withCache-DYumIHzL.js";import{stringify as A}from"./json-BHzNJmTy.js";import{i as Ve,b as de,H as Ut,e as fe,f as Pe,j as jt,l as Lt,w as Mt,r as P,s as Ze,g as F,a as ne,m as Ke,n as Ge,o as Ft,p as qt,h as Ht,k as Wt,q as Vt,u as Zt}from"./estimate-gas-DBgT8NWo.js";import{g as Je,u as Qe,t as Ye,n as Z,j as Kt,k as Gt,h as Jt,l as Qt,a as Yt,b as Xt,p as en,s as tn}from"./hex-B0Rx0hII.js";import{t as Xe,o as De,q as ye,u as et,N as Ee,v as we,w as tt,x as nt,y as C,z as rt,A as nn,B as rn,C as sn,D as on,E as an,Z as ze,F as cn,G as dn,H as un,I as ln,d as fn,J as hn,K as mn,L as pn,c as gn,M as yn,O as wn,p as _n,P as bn,r as kn,b as Tn,s as An,Q as In}from"./signing-BsPRCC1P.js";import{importShared as q}from"./__federation_fn_import-DsoKw508.js";import{encode as ie}from"./encode-cHgp5mHv.js";import{r as L}from"./op-gas-fee-reducer-CfxMcvXl.js";import{_}from"./preload-helper-2M-6abck.js";import{a as st,b as ot,e as vn,w as En}from"./wait-for-tx-receipt-BR33kfvc.js";import{eth_estimateGas as Sn}from"./eth_estimateGas-C2ENZ_HR.js";import{g as Cn,c as it,t as V,e as xn,d as $n,f as On,h as Pn,i as Dn,a as zn,b as Bn}from"./fee-data-DBS1-uI-.js";import{e as Rn}from"./eth_getStorageAt-B9Y_JVAm.js";import{eth_getTransactionCount as Nn}from"./eth_getTransactionCount-DWnnw2mX.js";import{getRpcClient as Se}from"./rpc-ti0b0r_u.js";import{decimals as _e}from"./decimals-D0IunObY.js";import{b as Un,a as jn,o as Ln,c as Mn,z as Fn,d as qn}from"./zora-sepolia-DNJ2DQat.js";import{a as Hn,s as Wn}from"./send-batch-transaction-DBV6UBBv.js";class z extends Error{constructor(t){super(t.message),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"correlationId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"statusCode",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.code=t.code,this.correlationId=t.correlationId,this.statusCode=t.statusCode}toString(){return A({code:this.code,correlationId:this.correlationId,message:this.message,statusCode:this.statusCode})}}async function Vn(e){const{originChainId:t,originTokenAddress:n,destinationChainId:r,destinationTokenAddress:s,client:o,maxSteps:i}=e,a="buyAmountWei"in e?e.buyAmountWei:e.amount,c=I(o),l=new URL(`${v("bridge")}/v1/buy/quote`);l.searchParams.set("originChainId",t.toString()),l.searchParams.set("originTokenAddress",n),l.searchParams.set("destinationChainId",r.toString()),l.searchParams.set("destinationTokenAddress",s),l.searchParams.set("buyAmountWei",a.toString()),l.searchParams.set("amount",a.toString()),i&&l.searchParams.set("maxSteps",i.toString());const h=await c(l.toString());if(!h.ok){const d=await h.json();throw new z({code:d.code||"UNKNOWN_ERROR",correlationId:d.correlationId||void 0,message:d.message||h.statusText,statusCode:h.status})}const{data:u}=await h.json();return{blockNumber:u.blockNumber?BigInt(u.blockNumber):void 0,destinationAmount:BigInt(u.destinationAmount),estimatedExecutionTimeMs:u.estimatedExecutionTimeMs,intent:{amount:a,buyAmountWei:a,destinationChainId:r,destinationTokenAddress:s,originChainId:t,originTokenAddress:n},originAmount:BigInt(u.originAmount),steps:u.steps,timestamp:u.timestamp}}async function at(e){const{originChainId:t,originTokenAddress:n,destinationChainId:r,destinationTokenAddress:s,sender:o,receiver:i,client:a,amount:c,purchaseData:l,maxSteps:h,paymentLinkId:u,slippageToleranceBps:d}=e,f=I(a),m=new URL(`${v("bridge")}/v1/buy/prepare`),p=await f(m.toString(),{body:A({amount:c.toString(),buyAmountWei:c.toString(),destinationChainId:r.toString(),destinationTokenAddress:s,maxSteps:h,originChainId:t.toString(),originTokenAddress:n,paymentLinkId:u,purchaseData:l,receiver:i,sender:o,slippageToleranceBps:d}),headers:{"Content-Type":"application/json"},method:"POST"});if(!p.ok){const g=await p.json();throw new z({code:g.code||"UNKNOWN_ERROR",correlationId:g.correlationId||void 0,message:g.message||p.statusText,statusCode:p.status})}const{data:y}=await p.json();return{blockNumber:y.blockNumber?BigInt(y.blockNumber):void 0,destinationAmount:BigInt(y.destinationAmount),estimatedExecutionTimeMs:y.estimatedExecutionTimeMs,intent:{amount:c,destinationChainId:r,destinationTokenAddress:s,originChainId:t,originTokenAddress:n,receiver:i,sender:o},originAmount:BigInt(y.originAmount),steps:y.steps.map(g=>({...g,transactions:g.transactions.map(w=>({...w,chain:re(w.chainId),client:a,value:w.value?BigInt(w.value):void 0}))})),timestamp:y.timestamp}}const Zn=Object.freeze(Object.defineProperty({__proto__:null,prepare:at,quote:Vn},Symbol.toStringTag,{value:"Module"}));async function Kn(e){const{client:t}=e;return zt(async()=>{const n=I(t),r=new URL(`${v("bridge")}/v1/chains`);e.testnet&&r.searchParams.set("testnet",e.testnet.toString()),"type"in e&&e.type?r.searchParams.set("type",e.type):"originChainId"in e&&e.originChainId?r.searchParams.set("originChainId",e.originChainId.toString()):"destinationChainId"in e&&e.destinationChainId&&r.searchParams.set("destinationChainId",e.destinationChainId.toString());const s=await n(r.toString());if(!s.ok){const i=await s.json();throw new z({code:i.code||"UNKNOWN_ERROR",correlationId:i.correlationId||void 0,message:i.message||s.statusText,statusCode:s.status})}const{data:o}=await s.json();return o},{cacheKey:`bridge-chains-${JSON.stringify(e)}`,cacheTime:1e3*60*60*1})}async function Gn(e){const{id:t,client:n}=e,r=I(n),s=new URL(`${v("bridge")}/v1/onramp/status`);s.searchParams.set("id",t);const o=await r(s.toString());if(!o.ok){const a=await o.json();throw new z({code:a.code||"UNKNOWN_ERROR",correlationId:a.correlationId||void 0,message:a.message||o.statusText,statusCode:o.status})}const{data:i}=await o.json();return i}async function Jn(e){const{client:t,onramp:n,chainId:r,tokenAddress:s,receiver:o,amount:i,purchaseData:a,sender:c,onrampTokenAddress:l,onrampChainId:h,currency:u,maxSteps:d,excludeChainIds:f,paymentLinkId:m,country:p}=e,y=I(t),g=`${v("bridge")}/v1/onramp/prepare`,w={chainId:Number(r),onramp:n,receiver:o,tokenAddress:s};i!==void 0&&(w.amount=i.toString()),a!==void 0&&(w.purchaseData=a),c!==void 0&&(w.sender=c),l!==void 0&&(w.onrampTokenAddress=l),h!==void 0&&(w.onrampChainId=Number(h)),u!==void 0&&(w.currency=u),d!==void 0&&(w.maxSteps=d),f!==void 0&&(w.excludeChainIds=Array.isArray(f)?f.join(","):f),m!==void 0&&(w.paymentLinkId=m),p!==void 0&&(w.country=p);const b=await y(g,{body:A(w),headers:{"Content-Type":"application/json"},method:"POST"});if(!b.ok){const $=await b.json();throw new z({code:$.code||"UNKNOWN_ERROR",correlationId:$.correlationId||void 0,message:$.message||b.statusText,statusCode:b.status})}const{data:k}=await b.json(),B=k.steps.map($=>({...$,destinationAmount:BigInt($.destinationAmount),originAmount:BigInt($.originAmount),transactions:$.transactions.map(H=>({...H,chain:re(H.chainId),client:t,value:H.value?BigInt(H.value):void 0}))})),N={...k.intent,amount:k.intent.amount?k.intent.amount:void 0};return{...k,destinationAmount:BigInt(k.destinationAmount),intent:N,steps:B}}const Qn=Object.freeze(Object.defineProperty({__proto__:null,prepare:Jn,status:Gn},Symbol.toStringTag,{value:"Module"}));async function Yn(e){const{originChainId:t,originTokenAddress:n,destinationChainId:r,destinationTokenAddress:s,amount:o,client:i,maxSteps:a}=e,c=I(i),l=new URL(`${v("bridge")}/v1/sell/quote`);l.searchParams.set("originChainId",t.toString()),l.searchParams.set("originTokenAddress",n),l.searchParams.set("destinationChainId",r.toString()),l.searchParams.set("destinationTokenAddress",s),l.searchParams.set("sellAmountWei",o.toString()),l.searchParams.set("amount",o.toString()),typeof a<"u"&&l.searchParams.set("maxSteps",a.toString());const h=await c(l.toString());if(!h.ok){const d=await h.json();throw new z({code:d.code||"UNKNOWN_ERROR",correlationId:d.correlationId||void 0,message:d.message||h.statusText,statusCode:h.status})}const{data:u}=await h.json();return{blockNumber:u.blockNumber?BigInt(u.blockNumber):void 0,destinationAmount:BigInt(u.destinationAmount),estimatedExecutionTimeMs:u.estimatedExecutionTimeMs,intent:{amount:o,destinationChainId:r,destinationTokenAddress:s,originChainId:t,originTokenAddress:n},originAmount:BigInt(u.originAmount),steps:u.steps,timestamp:u.timestamp}}async function ct(e){const{originChainId:t,originTokenAddress:n,destinationChainId:r,destinationTokenAddress:s,amount:o,sender:i,receiver:a,client:c,purchaseData:l,maxSteps:h,paymentLinkId:u,slippageToleranceBps:d}=e,f=I(c),m=new URL(`${v("bridge")}/v1/sell/prepare`),p=await f(m.toString(),{body:A({amount:o.toString(),destinationChainId:r.toString(),destinationTokenAddress:s,maxSteps:h,originChainId:t.toString(),originTokenAddress:n,paymentLinkId:u,purchaseData:l,receiver:a,sellAmountWei:o.toString(),sender:i,slippageToleranceBps:d}),headers:{"Content-Type":"application/json"},method:"POST"});if(!p.ok){const g=await p.json();throw new z({code:g.code||"UNKNOWN_ERROR",correlationId:g.correlationId||void 0,message:g.message||p.statusText,statusCode:p.status})}const{data:y}=await p.json();return{blockNumber:y.blockNumber?BigInt(y.blockNumber):void 0,destinationAmount:BigInt(y.destinationAmount),estimatedExecutionTimeMs:y.estimatedExecutionTimeMs,expiration:y.expiration,intent:{amount:o,destinationChainId:r,destinationTokenAddress:s,originChainId:t,originTokenAddress:n,purchaseData:l,receiver:a,sender:i},originAmount:BigInt(y.originAmount),steps:y.steps.map(g=>({...g,transactions:g.transactions.map(w=>({...w,chain:re(w.chainId),client:c,value:w.value?BigInt(w.value):void 0}))})),timestamp:y.timestamp}}const Xn=Object.freeze(Object.defineProperty({__proto__:null,prepare:ct,quote:Yn},Symbol.toStringTag,{value:"Module"}));async function dt(e){const{transactionHash:t,client:n,transactionId:r}=e,s="chainId"in e?e.chainId:e.chain.id,o=I(n),i=new URL(`${v("bridge")}/v1/status`);i.searchParams.set("transactionHash",t),i.searchParams.set("chainId",s.toString()),r&&i.searchParams.set("transactionId",r);const a=await o(i.toString());if(!a.ok){const l=await a.json();throw new z({code:l.code||"UNKNOWN_ERROR",correlationId:l.correlationId||void 0,message:l.message||a.statusText,statusCode:a.status})}const{data:c}=await a.json();return c.status==="FAILED"?{paymentId:c.paymentId,status:"FAILED",transactions:c.transactions}:c.status==="PENDING"?{destinationChainId:c.destinationChainId,destinationToken:c.destinationToken,destinationTokenAddress:c.destinationTokenAddress,originAmount:BigInt(c.originAmount),originChainId:c.originChainId,originToken:c.originToken,originTokenAddress:c.originTokenAddress,paymentId:c.paymentId,purchaseData:c.purchaseData,receiver:c.receiver,sender:c.sender,status:"PENDING",transactions:c.transactions}:c.status==="NOT_FOUND"?{paymentId:c.paymentId,status:"NOT_FOUND",transactions:[]}:{destinationAmount:BigInt(c.destinationAmount),destinationChainId:c.destinationChainId,destinationToken:c.destinationToken,destinationTokenAddress:c.destinationTokenAddress,originAmount:BigInt(c.originAmount),originChainId:c.originChainId,originToken:c.originToken,originTokenAddress:c.originTokenAddress,paymentId:c.paymentId,purchaseData:c.purchaseData,receiver:c.receiver,sender:c.sender,status:"COMPLETED",transactions:c.transactions}}async function er(e){const{client:t,chainId:n,tokenAddress:r,symbol:s,name:o,limit:i,offset:a,includePrices:c,sortBy:l,query:h}=e,u=I(t),d=new URL(`${v("bridge")}/v1/tokens`);n!=null&&d.searchParams.set("chainId",n.toString()),r&&d.searchParams.set("tokenAddress",r),s&&d.searchParams.set("symbol",s),o&&d.searchParams.set("name",o),i!==void 0&&d.searchParams.set("limit",i.toString()),a!=null&&d.searchParams.set("offset",a.toString()),c!==void 0&&d.searchParams.set("includePrices",c.toString()),l!==void 0&&d.searchParams.set("sortBy",l),h!==void 0&&d.searchParams.set("query",h);const f=await u(d.toString());if(!f.ok){const p=await f.json();throw new z({code:p.code||"UNKNOWN_ERROR",correlationId:p.correlationId||void 0,message:p.message||f.statusText,statusCode:f.status})}const{data:m}=await f.json();return m}async function ut(e){const{chainId:t,tokenAddress:n,sender:r,receiver:s,client:o,amount:i,purchaseData:a,feePayer:c,paymentLinkId:l}=e,h=I(o),u=new URL(`${v("bridge")}/v1/transfer/prepare`),d=await h(u.toString(),{body:A({amount:i.toString(),chainId:t.toString(),feePayer:c,paymentLinkId:l,purchaseData:a,receiver:s,sender:r,tokenAddress:n,transferAmountWei:i.toString()}),headers:{"Content-Type":"application/json"},method:"POST"});if(!d.ok){const m=await d.json();throw new z({code:m.code||"UNKNOWN_ERROR",correlationId:m.correlationId||void 0,message:m.message||d.statusText,statusCode:d.status})}const{data:f}=await d.json();return{blockNumber:f.blockNumber?BigInt(f.blockNumber):void 0,destinationAmount:BigInt(f.destinationAmount),estimatedExecutionTimeMs:f.estimatedExecutionTimeMs,intent:{amount:i,chainId:t,feePayer:c,receiver:s,sender:r,tokenAddress:n},originAmount:BigInt(f.originAmount),steps:f.steps.map(m=>({...m,transactions:m.transactions.map(p=>({...p,chain:re(p.chainId),client:o,value:p.value?BigInt(p.value):void 0}))})),timestamp:f.timestamp}}const tr=Object.freeze(Object.defineProperty({__proto__:null,prepare:ut},Symbol.toStringTag,{value:"Module"}));function T(e,t,n){function r(a,c){var l;Object.defineProperty(a,"_zod",{value:a._zod??{},enumerable:!1}),(l=a._zod).traits??(l.traits=new Set),a._zod.traits.add(e),t(a,c);for(const h in i.prototype)h in a||Object.defineProperty(a,h,{value:i.prototype[h].bind(a)});a._zod.constr=i,a._zod.def=c}const s=n?.Parent??Object;class o extends s{}Object.defineProperty(o,"name",{value:e});function i(a){var c;const l=n?.Parent?new o:this;r(l,a),(c=l._zod).deferred??(c.deferred=[]);for(const h of l._zod.deferred)h();return l}return Object.defineProperty(i,"init",{value:r}),Object.defineProperty(i,Symbol.hasInstance,{value:a=>n?.Parent&&a instanceof n.Parent?!0:a?._zod?.traits?.has(e)}),Object.defineProperty(i,"name",{value:e}),i}class ae extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}const lt={};function J(e){return lt}function nr(e){const t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,s])=>t.indexOf(+r)===-1).map(([r,s])=>s)}function rr(e,t){return typeof t=="bigint"?t.toString():t}function Ce(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function ft(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function R(e,t,n){Object.defineProperty(e,t,{get(){{const r=n();return e[t]=r,r}},set(r){Object.defineProperty(e,t,{value:r})},configurable:!0})}function sr(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function X(e){return JSON.stringify(e)}const ht=Error.captureStackTrace?Error.captureStackTrace:(...e)=>{};function ce(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const or=Ce(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function ir(e){if(ce(e)===!1)return!1;const t=e.constructor;if(t===void 0)return!0;const n=t.prototype;return!(ce(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}const ar=new Set(["string","number","symbol"]);function mt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function cr(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function O(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function dr(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}function he(e,t=0){for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function W(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function se(e){return typeof e=="string"?e:e?.message}function Q(e,t,n){const r={...e,path:e.path??[]};if(!e.message){const s=se(e.inst?._zod.def?.error?.(e))??se(t?.error?.(e))??se(n.customError?.(e))??se(n.localeError?.(e))??"Invalid input";r.message=s}return delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function ur(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}const pt=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),Object.defineProperty(e,"message",{get(){return JSON.stringify(t,rr,2)},enumerable:!0})},lr=T("$ZodError",pt),ue=T("$ZodError",pt,{Parent:Error}),fr=e=>(t,n,r,s)=>{const o=r?Object.assign(r,{async:!1}):{async:!1},i=t._zod.run({value:n,issues:[]},o);if(i instanceof Promise)throw new ae;if(i.issues.length){const a=new(s?.Err??e)(i.issues.map(c=>Q(c,o,J())));throw ht(a,s?.callee),a}return i.value},hr=fr(ue),mr=e=>async(t,n,r,s)=>{const o=r?Object.assign(r,{async:!0}):{async:!0};let i=t._zod.run({value:n,issues:[]},o);if(i instanceof Promise&&(i=await i),i.issues.length){const a=new(s?.Err??e)(i.issues.map(c=>Q(c,o,J())));throw ht(a,s?.callee),a}return i.value},pr=mr(ue),gr=e=>(t,n,r)=>{const s=r?{...r,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},s);if(o instanceof Promise)throw new ae;return o.issues.length?{success:!1,error:new(e??lr)(o.issues.map(i=>Q(i,s,J())))}:{success:!0,data:o.value}},gt=gr(ue),yr=e=>async(t,n,r)=>{const s=r?Object.assign(r,{async:!0}):{async:!0};let o=t._zod.run({value:n,issues:[]},s);return o instanceof Promise&&(o=await o),o.issues.length?{success:!1,error:new e(o.issues.map(i=>Q(i,s,J())))}:{success:!0,data:o.value}},yt=yr(ue),wr=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},_r=/^\d+n?$/,br=/^-?\d+(?:\.\d+)?/i,kr=T("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])});class Tr{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const r=t.split(`
|
|
1
|
+
const __vite__fileDeps=["assets/common-D37S_OFt.js","assets/utils-CozXUO91.js","assets/withCache-DYumIHzL.js","assets/index-ww85HWCV.js","assets/utils-C7urdXtO.js","assets/publicKeyToAddress-CxEKPAKT.js","assets/preload-helper-BokH5fd6.js","assets/sha256-DYtpy1Qz.js","assets/estimate-gas-CMPxVjuF.js","assets/__federation_fn_import-D82-s3kA.js","assets/hex-B0Rx0hII.js","assets/op-gas-fee-reducer-CfxMcvXl.js","assets/json-BHzNJmTy.js","assets/parseNft-Buclbv5Y.js","assets/totalSupply-DNIfxfBv.js","assets/signing-TLGj9K79.js","assets/fee-data-BCMgs11D.js","assets/rpc-ti0b0r_u.js","assets/encode-JOmK-dAM.js","assets/detectExtension-DQNsMd7m.js","assets/estimate-l1-fee-B90S_dRF.js"],__vite__mapDeps=i=>i.map(i=>__vite__fileDeps[i]);
|
|
2
|
+
import{defineChain as re,getCachedChain as te}from"./utils-CozXUO91.js";import{b as v,a as I,w as zt,L as Bt,c as Rt,g as Nt}from"./withCache-DYumIHzL.js";import{stringify as A}from"./json-BHzNJmTy.js";import{i as Ve,b as de,H as Ut,e as fe,f as Pe,j as jt,l as Lt,w as Mt,r as P,s as Ze,g as F,a as ne,m as Ke,n as Ge,o as Ft,p as qt,h as Ht,k as Wt,q as Vt,u as Zt}from"./estimate-gas-CMPxVjuF.js";import{g as Je,u as Qe,t as Ye,n as Z,j as Kt,k as Gt,h as Jt,l as Qt,a as Yt,b as Xt,p as en,s as tn}from"./hex-B0Rx0hII.js";import{t as Xe,o as De,q as ye,u as et,N as Ee,v as we,w as tt,x as nt,y as C,z as rt,A as nn,B as rn,C as sn,D as on,E as an,Z as ze,F as cn,G as dn,H as un,I as ln,d as fn,J as hn,K as mn,L as pn,c as gn,M as yn,O as wn,p as _n,P as bn,r as kn,b as Tn,s as An,Q as In}from"./signing-TLGj9K79.js";import{importShared as q}from"./__federation_fn_import-D82-s3kA.js";import{encode as ie}from"./encode-JOmK-dAM.js";import{r as L}from"./op-gas-fee-reducer-CfxMcvXl.js";import{_}from"./preload-helper-BokH5fd6.js";import{a as st,b as ot,e as vn,w as En}from"./wait-for-tx-receipt-C5afrCK7.js";import{eth_estimateGas as Sn}from"./eth_estimateGas-C2ENZ_HR.js";import{g as Cn,c as it,t as V,e as xn,d as $n,f as On,h as Pn,i as Dn,a as zn,b as Bn}from"./fee-data-BCMgs11D.js";import{e as Rn}from"./eth_getStorageAt-BzWA0XEw.js";import{eth_getTransactionCount as Nn}from"./eth_getTransactionCount-DWnnw2mX.js";import{getRpcClient as Se}from"./rpc-ti0b0r_u.js";import{decimals as _e}from"./decimals-CVjZGYo0.js";import{b as Un,a as jn,o as Ln,c as Mn,z as Fn,d as qn}from"./zora-sepolia-DNJ2DQat.js";import{a as Hn,s as Wn}from"./send-batch-transaction-ZanhTs8a.js";class z extends Error{constructor(t){super(t.message),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"correlationId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"statusCode",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.code=t.code,this.correlationId=t.correlationId,this.statusCode=t.statusCode}toString(){return A({code:this.code,correlationId:this.correlationId,message:this.message,statusCode:this.statusCode})}}async function Vn(e){const{originChainId:t,originTokenAddress:n,destinationChainId:r,destinationTokenAddress:s,client:o,maxSteps:i}=e,a="buyAmountWei"in e?e.buyAmountWei:e.amount,c=I(o),l=new URL(`${v("bridge")}/v1/buy/quote`);l.searchParams.set("originChainId",t.toString()),l.searchParams.set("originTokenAddress",n),l.searchParams.set("destinationChainId",r.toString()),l.searchParams.set("destinationTokenAddress",s),l.searchParams.set("buyAmountWei",a.toString()),l.searchParams.set("amount",a.toString()),i&&l.searchParams.set("maxSteps",i.toString());const h=await c(l.toString());if(!h.ok){const d=await h.json();throw new z({code:d.code||"UNKNOWN_ERROR",correlationId:d.correlationId||void 0,message:d.message||h.statusText,statusCode:h.status})}const{data:u}=await h.json();return{blockNumber:u.blockNumber?BigInt(u.blockNumber):void 0,destinationAmount:BigInt(u.destinationAmount),estimatedExecutionTimeMs:u.estimatedExecutionTimeMs,intent:{amount:a,buyAmountWei:a,destinationChainId:r,destinationTokenAddress:s,originChainId:t,originTokenAddress:n},originAmount:BigInt(u.originAmount),steps:u.steps,timestamp:u.timestamp}}async function at(e){const{originChainId:t,originTokenAddress:n,destinationChainId:r,destinationTokenAddress:s,sender:o,receiver:i,client:a,amount:c,purchaseData:l,maxSteps:h,paymentLinkId:u,slippageToleranceBps:d}=e,f=I(a),m=new URL(`${v("bridge")}/v1/buy/prepare`),p=await f(m.toString(),{body:A({amount:c.toString(),buyAmountWei:c.toString(),destinationChainId:r.toString(),destinationTokenAddress:s,maxSteps:h,originChainId:t.toString(),originTokenAddress:n,paymentLinkId:u,purchaseData:l,receiver:i,sender:o,slippageToleranceBps:d}),headers:{"Content-Type":"application/json"},method:"POST"});if(!p.ok){const g=await p.json();throw new z({code:g.code||"UNKNOWN_ERROR",correlationId:g.correlationId||void 0,message:g.message||p.statusText,statusCode:p.status})}const{data:y}=await p.json();return{blockNumber:y.blockNumber?BigInt(y.blockNumber):void 0,destinationAmount:BigInt(y.destinationAmount),estimatedExecutionTimeMs:y.estimatedExecutionTimeMs,intent:{amount:c,destinationChainId:r,destinationTokenAddress:s,originChainId:t,originTokenAddress:n,receiver:i,sender:o},originAmount:BigInt(y.originAmount),steps:y.steps.map(g=>({...g,transactions:g.transactions.map(w=>({...w,chain:re(w.chainId),client:a,value:w.value?BigInt(w.value):void 0}))})),timestamp:y.timestamp}}const Zn=Object.freeze(Object.defineProperty({__proto__:null,prepare:at,quote:Vn},Symbol.toStringTag,{value:"Module"}));async function Kn(e){const{client:t}=e;return zt(async()=>{const n=I(t),r=new URL(`${v("bridge")}/v1/chains`);e.testnet&&r.searchParams.set("testnet",e.testnet.toString()),"type"in e&&e.type?r.searchParams.set("type",e.type):"originChainId"in e&&e.originChainId?r.searchParams.set("originChainId",e.originChainId.toString()):"destinationChainId"in e&&e.destinationChainId&&r.searchParams.set("destinationChainId",e.destinationChainId.toString());const s=await n(r.toString());if(!s.ok){const i=await s.json();throw new z({code:i.code||"UNKNOWN_ERROR",correlationId:i.correlationId||void 0,message:i.message||s.statusText,statusCode:s.status})}const{data:o}=await s.json();return o},{cacheKey:`bridge-chains-${JSON.stringify(e)}`,cacheTime:1e3*60*60*1})}async function Gn(e){const{id:t,client:n}=e,r=I(n),s=new URL(`${v("bridge")}/v1/onramp/status`);s.searchParams.set("id",t);const o=await r(s.toString());if(!o.ok){const a=await o.json();throw new z({code:a.code||"UNKNOWN_ERROR",correlationId:a.correlationId||void 0,message:a.message||o.statusText,statusCode:o.status})}const{data:i}=await o.json();return i}async function Jn(e){const{client:t,onramp:n,chainId:r,tokenAddress:s,receiver:o,amount:i,purchaseData:a,sender:c,onrampTokenAddress:l,onrampChainId:h,currency:u,maxSteps:d,excludeChainIds:f,paymentLinkId:m,country:p}=e,y=I(t),g=`${v("bridge")}/v1/onramp/prepare`,w={chainId:Number(r),onramp:n,receiver:o,tokenAddress:s};i!==void 0&&(w.amount=i.toString()),a!==void 0&&(w.purchaseData=a),c!==void 0&&(w.sender=c),l!==void 0&&(w.onrampTokenAddress=l),h!==void 0&&(w.onrampChainId=Number(h)),u!==void 0&&(w.currency=u),d!==void 0&&(w.maxSteps=d),f!==void 0&&(w.excludeChainIds=Array.isArray(f)?f.join(","):f),m!==void 0&&(w.paymentLinkId=m),p!==void 0&&(w.country=p);const b=await y(g,{body:A(w),headers:{"Content-Type":"application/json"},method:"POST"});if(!b.ok){const $=await b.json();throw new z({code:$.code||"UNKNOWN_ERROR",correlationId:$.correlationId||void 0,message:$.message||b.statusText,statusCode:b.status})}const{data:k}=await b.json(),B=k.steps.map($=>({...$,destinationAmount:BigInt($.destinationAmount),originAmount:BigInt($.originAmount),transactions:$.transactions.map(H=>({...H,chain:re(H.chainId),client:t,value:H.value?BigInt(H.value):void 0}))})),N={...k.intent,amount:k.intent.amount?k.intent.amount:void 0};return{...k,destinationAmount:BigInt(k.destinationAmount),intent:N,steps:B}}const Qn=Object.freeze(Object.defineProperty({__proto__:null,prepare:Jn,status:Gn},Symbol.toStringTag,{value:"Module"}));async function Yn(e){const{originChainId:t,originTokenAddress:n,destinationChainId:r,destinationTokenAddress:s,amount:o,client:i,maxSteps:a}=e,c=I(i),l=new URL(`${v("bridge")}/v1/sell/quote`);l.searchParams.set("originChainId",t.toString()),l.searchParams.set("originTokenAddress",n),l.searchParams.set("destinationChainId",r.toString()),l.searchParams.set("destinationTokenAddress",s),l.searchParams.set("sellAmountWei",o.toString()),l.searchParams.set("amount",o.toString()),typeof a<"u"&&l.searchParams.set("maxSteps",a.toString());const h=await c(l.toString());if(!h.ok){const d=await h.json();throw new z({code:d.code||"UNKNOWN_ERROR",correlationId:d.correlationId||void 0,message:d.message||h.statusText,statusCode:h.status})}const{data:u}=await h.json();return{blockNumber:u.blockNumber?BigInt(u.blockNumber):void 0,destinationAmount:BigInt(u.destinationAmount),estimatedExecutionTimeMs:u.estimatedExecutionTimeMs,intent:{amount:o,destinationChainId:r,destinationTokenAddress:s,originChainId:t,originTokenAddress:n},originAmount:BigInt(u.originAmount),steps:u.steps,timestamp:u.timestamp}}async function ct(e){const{originChainId:t,originTokenAddress:n,destinationChainId:r,destinationTokenAddress:s,amount:o,sender:i,receiver:a,client:c,purchaseData:l,maxSteps:h,paymentLinkId:u,slippageToleranceBps:d}=e,f=I(c),m=new URL(`${v("bridge")}/v1/sell/prepare`),p=await f(m.toString(),{body:A({amount:o.toString(),destinationChainId:r.toString(),destinationTokenAddress:s,maxSteps:h,originChainId:t.toString(),originTokenAddress:n,paymentLinkId:u,purchaseData:l,receiver:a,sellAmountWei:o.toString(),sender:i,slippageToleranceBps:d}),headers:{"Content-Type":"application/json"},method:"POST"});if(!p.ok){const g=await p.json();throw new z({code:g.code||"UNKNOWN_ERROR",correlationId:g.correlationId||void 0,message:g.message||p.statusText,statusCode:p.status})}const{data:y}=await p.json();return{blockNumber:y.blockNumber?BigInt(y.blockNumber):void 0,destinationAmount:BigInt(y.destinationAmount),estimatedExecutionTimeMs:y.estimatedExecutionTimeMs,expiration:y.expiration,intent:{amount:o,destinationChainId:r,destinationTokenAddress:s,originChainId:t,originTokenAddress:n,purchaseData:l,receiver:a,sender:i},originAmount:BigInt(y.originAmount),steps:y.steps.map(g=>({...g,transactions:g.transactions.map(w=>({...w,chain:re(w.chainId),client:c,value:w.value?BigInt(w.value):void 0}))})),timestamp:y.timestamp}}const Xn=Object.freeze(Object.defineProperty({__proto__:null,prepare:ct,quote:Yn},Symbol.toStringTag,{value:"Module"}));async function dt(e){const{transactionHash:t,client:n,transactionId:r}=e,s="chainId"in e?e.chainId:e.chain.id,o=I(n),i=new URL(`${v("bridge")}/v1/status`);i.searchParams.set("transactionHash",t),i.searchParams.set("chainId",s.toString()),r&&i.searchParams.set("transactionId",r);const a=await o(i.toString());if(!a.ok){const l=await a.json();throw new z({code:l.code||"UNKNOWN_ERROR",correlationId:l.correlationId||void 0,message:l.message||a.statusText,statusCode:a.status})}const{data:c}=await a.json();return c.status==="FAILED"?{paymentId:c.paymentId,status:"FAILED",transactions:c.transactions}:c.status==="PENDING"?{destinationChainId:c.destinationChainId,destinationToken:c.destinationToken,destinationTokenAddress:c.destinationTokenAddress,originAmount:BigInt(c.originAmount),originChainId:c.originChainId,originToken:c.originToken,originTokenAddress:c.originTokenAddress,paymentId:c.paymentId,purchaseData:c.purchaseData,receiver:c.receiver,sender:c.sender,status:"PENDING",transactions:c.transactions}:c.status==="NOT_FOUND"?{paymentId:c.paymentId,status:"NOT_FOUND",transactions:[]}:{destinationAmount:BigInt(c.destinationAmount),destinationChainId:c.destinationChainId,destinationToken:c.destinationToken,destinationTokenAddress:c.destinationTokenAddress,originAmount:BigInt(c.originAmount),originChainId:c.originChainId,originToken:c.originToken,originTokenAddress:c.originTokenAddress,paymentId:c.paymentId,purchaseData:c.purchaseData,receiver:c.receiver,sender:c.sender,status:"COMPLETED",transactions:c.transactions}}async function er(e){const{client:t,chainId:n,tokenAddress:r,symbol:s,name:o,limit:i,offset:a,includePrices:c,sortBy:l,query:h}=e,u=I(t),d=new URL(`${v("bridge")}/v1/tokens`);n!=null&&d.searchParams.set("chainId",n.toString()),r&&d.searchParams.set("tokenAddress",r),s&&d.searchParams.set("symbol",s),o&&d.searchParams.set("name",o),i!==void 0&&d.searchParams.set("limit",i.toString()),a!=null&&d.searchParams.set("offset",a.toString()),c!==void 0&&d.searchParams.set("includePrices",c.toString()),l!==void 0&&d.searchParams.set("sortBy",l),h!==void 0&&d.searchParams.set("query",h);const f=await u(d.toString());if(!f.ok){const p=await f.json();throw new z({code:p.code||"UNKNOWN_ERROR",correlationId:p.correlationId||void 0,message:p.message||f.statusText,statusCode:f.status})}const{data:m}=await f.json();return m}async function ut(e){const{chainId:t,tokenAddress:n,sender:r,receiver:s,client:o,amount:i,purchaseData:a,feePayer:c,paymentLinkId:l}=e,h=I(o),u=new URL(`${v("bridge")}/v1/transfer/prepare`),d=await h(u.toString(),{body:A({amount:i.toString(),chainId:t.toString(),feePayer:c,paymentLinkId:l,purchaseData:a,receiver:s,sender:r,tokenAddress:n,transferAmountWei:i.toString()}),headers:{"Content-Type":"application/json"},method:"POST"});if(!d.ok){const m=await d.json();throw new z({code:m.code||"UNKNOWN_ERROR",correlationId:m.correlationId||void 0,message:m.message||d.statusText,statusCode:d.status})}const{data:f}=await d.json();return{blockNumber:f.blockNumber?BigInt(f.blockNumber):void 0,destinationAmount:BigInt(f.destinationAmount),estimatedExecutionTimeMs:f.estimatedExecutionTimeMs,intent:{amount:i,chainId:t,feePayer:c,receiver:s,sender:r,tokenAddress:n},originAmount:BigInt(f.originAmount),steps:f.steps.map(m=>({...m,transactions:m.transactions.map(p=>({...p,chain:re(p.chainId),client:o,value:p.value?BigInt(p.value):void 0}))})),timestamp:f.timestamp}}const tr=Object.freeze(Object.defineProperty({__proto__:null,prepare:ut},Symbol.toStringTag,{value:"Module"}));function T(e,t,n){function r(a,c){var l;Object.defineProperty(a,"_zod",{value:a._zod??{},enumerable:!1}),(l=a._zod).traits??(l.traits=new Set),a._zod.traits.add(e),t(a,c);for(const h in i.prototype)h in a||Object.defineProperty(a,h,{value:i.prototype[h].bind(a)});a._zod.constr=i,a._zod.def=c}const s=n?.Parent??Object;class o extends s{}Object.defineProperty(o,"name",{value:e});function i(a){var c;const l=n?.Parent?new o:this;r(l,a),(c=l._zod).deferred??(c.deferred=[]);for(const h of l._zod.deferred)h();return l}return Object.defineProperty(i,"init",{value:r}),Object.defineProperty(i,Symbol.hasInstance,{value:a=>n?.Parent&&a instanceof n.Parent?!0:a?._zod?.traits?.has(e)}),Object.defineProperty(i,"name",{value:e}),i}class ae extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}const lt={};function J(e){return lt}function nr(e){const t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,s])=>t.indexOf(+r)===-1).map(([r,s])=>s)}function rr(e,t){return typeof t=="bigint"?t.toString():t}function Ce(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function ft(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function R(e,t,n){Object.defineProperty(e,t,{get(){{const r=n();return e[t]=r,r}},set(r){Object.defineProperty(e,t,{value:r})},configurable:!0})}function sr(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function X(e){return JSON.stringify(e)}const ht=Error.captureStackTrace?Error.captureStackTrace:(...e)=>{};function ce(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const or=Ce(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function ir(e){if(ce(e)===!1)return!1;const t=e.constructor;if(t===void 0)return!0;const n=t.prototype;return!(ce(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}const ar=new Set(["string","number","symbol"]);function mt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function cr(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function O(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function dr(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}function he(e,t=0){for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function W(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function se(e){return typeof e=="string"?e:e?.message}function Q(e,t,n){const r={...e,path:e.path??[]};if(!e.message){const s=se(e.inst?._zod.def?.error?.(e))??se(t?.error?.(e))??se(n.customError?.(e))??se(n.localeError?.(e))??"Invalid input";r.message=s}return delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function ur(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}const pt=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),Object.defineProperty(e,"message",{get(){return JSON.stringify(t,rr,2)},enumerable:!0})},lr=T("$ZodError",pt),ue=T("$ZodError",pt,{Parent:Error}),fr=e=>(t,n,r,s)=>{const o=r?Object.assign(r,{async:!1}):{async:!1},i=t._zod.run({value:n,issues:[]},o);if(i instanceof Promise)throw new ae;if(i.issues.length){const a=new(s?.Err??e)(i.issues.map(c=>Q(c,o,J())));throw ht(a,s?.callee),a}return i.value},hr=fr(ue),mr=e=>async(t,n,r,s)=>{const o=r?Object.assign(r,{async:!0}):{async:!0};let i=t._zod.run({value:n,issues:[]},o);if(i instanceof Promise&&(i=await i),i.issues.length){const a=new(s?.Err??e)(i.issues.map(c=>Q(c,o,J())));throw ht(a,s?.callee),a}return i.value},pr=mr(ue),gr=e=>(t,n,r)=>{const s=r?{...r,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},s);if(o instanceof Promise)throw new ae;return o.issues.length?{success:!1,error:new(e??lr)(o.issues.map(i=>Q(i,s,J())))}:{success:!0,data:o.value}},gt=gr(ue),yr=e=>async(t,n,r)=>{const s=r?Object.assign(r,{async:!0}):{async:!0};let o=t._zod.run({value:n,issues:[]},s);return o instanceof Promise&&(o=await o),o.issues.length?{success:!1,error:new e(o.issues.map(i=>Q(i,s,J())))}:{success:!0,data:o.value}},yt=yr(ue),wr=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},_r=/^\d+n?$/,br=/^-?\d+(?:\.\d+)?/i,kr=T("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])});class Tr{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const r=t.split(`
|
|
3
3
|
`).filter(i=>i),s=Math.min(...r.map(i=>i.length-i.trimStart().length)),o=r.map(i=>i.slice(s)).map(i=>" ".repeat(this.indent*2)+i);for(const i of o)this.content.push(i)}compile(){const t=Function,n=this?.args,s=[...(this?.content??[""]).map(o=>` ${o}`)];return new t(...n,s.join(`
|
|
4
4
|
`))}}const Ar={major:4,minor:0,patch:0},S=T("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Ar;const r=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&r.unshift(e);for(const s of r)for(const o of s._zod.onattach)o(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const s=(o,i,a)=>{let c=he(o),l;for(const h of i){if(h._zod.when){if(!h._zod.when(o))continue}else if(c)continue;const u=o.issues.length,d=h._zod.check(o);if(d instanceof Promise&&a?.async===!1)throw new ae;if(l||d instanceof Promise)l=(l??Promise.resolve()).then(async()=>{await d,o.issues.length!==u&&(c||(c=he(o,u)))});else{if(o.issues.length===u)continue;c||(c=he(o,u))}}return l?l.then(()=>o):o};e._zod.run=(o,i)=>{const a=e._zod.parse(o,i);if(a instanceof Promise){if(i.async===!1)throw new ae;return a.then(c=>s(c,r,i))}return s(a,r,i)}}e["~standard"]={validate:s=>{try{const o=gt(e,s);return o.success?{value:o.data}:{issues:o.error?.issues}}catch{return yt(e,s).then(i=>i.success?{value:i.data}:{issues:i.error?.issues})}},vendor:"zod",version:1}}),Ir=T("$ZodString",(e,t)=>{S.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??wr(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),vr=T("$ZodNumber",(e,t)=>{S.init(e,t),e._zod.pattern=e._zod.bag.pattern??br,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}const s=n.value;if(typeof s=="number"&&!Number.isNaN(s)&&Number.isFinite(s))return n;const o=typeof s=="number"?Number.isNaN(s)?"NaN":Number.isFinite(s)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:s,inst:e,...o?{received:o}:{}}),n}}),Er=T("$ZodBigInt",(e,t)=>{S.init(e,t),e._zod.pattern=_r,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=BigInt(n.value)}catch{}return typeof n.value=="bigint"||n.issues.push({expected:"bigint",code:"invalid_type",input:n.value,inst:e}),n}}),Sr=T("$ZodUnknown",(e,t)=>{S.init(e,t),e._zod.parse=n=>n});function Be(e,t,n){e.issues.length&&t.issues.push(...W(n,e.issues)),t.value[n]=e.value}const Cr=T("$ZodArray",(e,t)=>{S.init(e,t),e._zod.parse=(n,r)=>{const s=n.value;if(!Array.isArray(s))return n.issues.push({expected:"array",code:"invalid_type",input:s,inst:e}),n;n.value=Array(s.length);const o=[];for(let i=0;i<s.length;i++){const a=s[i],c=t.element._zod.run({value:a,issues:[]},r);c instanceof Promise?o.push(c.then(l=>Be(l,n,i))):Be(c,n,i)}return o.length?Promise.all(o).then(()=>n):n}});function oe(e,t,n){e.issues.length&&t.issues.push(...W(n,e.issues)),t.value[n]=e.value}function Re(e,t,n,r){e.issues.length?r[n]===void 0?n in r?t.value[n]=void 0:t.value[n]=e.value:t.issues.push(...W(n,e.issues)):e.value===void 0?n in r&&(t.value[n]=void 0):t.value[n]=e.value}const xr=T("$ZodObject",(e,t)=>{S.init(e,t);const n=Ce(()=>{const u=Object.keys(t.shape);for(const f of u)if(!(t.shape[f]instanceof S))throw new Error(`Invalid element at key "${f}": expected a Zod schema`);const d=dr(t.shape);return{shape:t.shape,keys:u,keySet:new Set(u),numKeys:u.length,optionalKeys:new Set(d)}});R(e._zod,"propValues",()=>{const u=t.shape,d={};for(const f in u){const m=u[f]._zod;if(m.values){d[f]??(d[f]=new Set);for(const p of m.values)d[f].add(p)}}return d});const r=u=>{const d=new Tr(["shape","payload","ctx"]),f=n.value,m=w=>{const b=X(w);return`shape[${b}]._zod.run({ value: input[${b}], issues: [] }, ctx)`};d.write("const input = payload.value;");const p=Object.create(null);let y=0;for(const w of f.keys)p[w]=`key_${y++}`;d.write("const newResult = {}");for(const w of f.keys)if(f.optionalKeys.has(w)){const b=p[w];d.write(`const ${b} = ${m(w)};`);const k=X(w);d.write(`
|
|
5
5
|
if (${b}.issues.length) {
|
|
@@ -24,4 +24,4 @@ import{defineChain as re,getCachedChain as te}from"./utils-CozXUO91.js";import{b
|
|
|
24
24
|
if (${b}.issues.length) payload.issues = payload.issues.concat(${b}.issues.map(iss => ({
|
|
25
25
|
...iss,
|
|
26
26
|
path: iss.path ? [${X(w)}, ...iss.path] : [${X(w)}]
|
|
27
|
-
})));`),d.write(`newResult[${X(w)}] = ${b}.value`)}d.write("payload.value = newResult;"),d.write("return payload;");const g=d.compile();return(w,b)=>g(u,w,b)};let s;const o=ce,i=!lt.jitless,c=i&&or.value,l=t.catchall;let h;e._zod.parse=(u,d)=>{h??(h=n.value);const f=u.value;if(!o(f))return u.issues.push({expected:"object",code:"invalid_type",input:f,inst:e}),u;const m=[];if(i&&c&&d?.async===!1&&d.jitless!==!0)s||(s=r(t.shape)),u=s(u,d);else{u.value={};const b=h.shape;for(const k of h.keys){const B=b[k],N=B._zod.run({value:f[k],issues:[]},d),$=B._zod.optin==="optional"&&B._zod.optout==="optional";N instanceof Promise?m.push(N.then(H=>$?Re(H,u,k,f):oe(H,u,k))):$?Re(N,u,k,f):oe(N,u,k)}}if(!l)return m.length?Promise.all(m).then(()=>u):u;const p=[],y=h.keySet,g=l._zod,w=g.def.type;for(const b of Object.keys(f)){if(y.has(b))continue;if(w==="never"){p.push(b);continue}const k=g.run({value:f[b],issues:[]},d);k instanceof Promise?m.push(k.then(B=>oe(B,u,b))):oe(k,u,b)}return p.length&&u.issues.push({code:"unrecognized_keys",keys:p,input:f,inst:e}),m.length?Promise.all(m).then(()=>u):u}});function Ne(e,t,n,r){for(const s of e)if(s.issues.length===0)return t.value=s.value,t;return t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(s=>s.issues.map(o=>Q(o,r,J())))}),t}const $r=T("$ZodUnion",(e,t)=>{S.init(e,t),R(e._zod,"optin",()=>t.options.some(n=>n._zod.optin==="optional")?"optional":void 0),R(e._zod,"optout",()=>t.options.some(n=>n._zod.optout==="optional")?"optional":void 0),R(e._zod,"values",()=>{if(t.options.every(n=>n._zod.values))return new Set(t.options.flatMap(n=>Array.from(n._zod.values)))}),R(e._zod,"pattern",()=>{if(t.options.every(n=>n._zod.pattern)){const n=t.options.map(r=>r._zod.pattern);return new RegExp(`^(${n.map(r=>ft(r.source)).join("|")})$`)}}),e._zod.parse=(n,r)=>{let s=!1;const o=[];for(const i of t.options){const a=i._zod.run({value:n.value,issues:[]},r);if(a instanceof Promise)o.push(a),s=!0;else{if(a.issues.length===0)return a;o.push(a)}}return s?Promise.all(o).then(i=>Ne(i,n,e,r)):Ne(o,n,e,r)}}),Or=T("$ZodDiscriminatedUnion",(e,t)=>{$r.init(e,t);const n=e._zod.parse;R(e._zod,"propValues",()=>{const s={};for(const o of t.options){const i=o._zod.propValues;if(!i||Object.keys(i).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(o)}"`);for(const[a,c]of Object.entries(i)){s[a]||(s[a]=new Set);for(const l of c)s[a].add(l)}}return s});const r=Ce(()=>{const s=t.options,o=new Map;for(const i of s){const a=i._zod.propValues[t.discriminator];if(!a||a.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(i)}"`);for(const c of a){if(o.has(c))throw new Error(`Duplicate discriminator value "${String(c)}"`);o.set(c,i)}}return o});e._zod.parse=(s,o)=>{const i=s.value;if(!ce(i))return s.issues.push({code:"invalid_type",expected:"object",input:i,inst:e}),s;const a=r.value.get(i?.[t.discriminator]);return a?a._zod.run(s,o):t.unionFallback?n(s,o):(s.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",input:i,path:[t.discriminator],inst:e}),s)}}),Pr=T("$ZodRecord",(e,t)=>{S.init(e,t),e._zod.parse=(n,r)=>{const s=n.value;if(!ir(s))return n.issues.push({expected:"record",code:"invalid_type",input:s,inst:e}),n;const o=[];if(t.keyType._zod.values){const i=t.keyType._zod.values;n.value={};for(const c of i)if(typeof c=="string"||typeof c=="number"||typeof c=="symbol"){const l=t.valueType._zod.run({value:s[c],issues:[]},r);l instanceof Promise?o.push(l.then(h=>{h.issues.length&&n.issues.push(...W(c,h.issues)),n.value[c]=h.value})):(l.issues.length&&n.issues.push(...W(c,l.issues)),n.value[c]=l.value)}let a;for(const c in s)i.has(c)||(a=a??[],a.push(c));a&&a.length>0&&n.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:a})}else{n.value={};for(const i of Reflect.ownKeys(s)){if(i==="__proto__")continue;const a=t.keyType._zod.run({value:i,issues:[]},r);if(a instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(a.issues.length){n.issues.push({origin:"record",code:"invalid_key",issues:a.issues.map(l=>Q(l,r,J())),input:i,path:[i],inst:e}),n.value[a.value]=a.value;continue}const c=t.valueType._zod.run({value:s[i],issues:[]},r);c instanceof Promise?o.push(c.then(l=>{l.issues.length&&n.issues.push(...W(i,l.issues)),n.value[a.value]=l.value})):(c.issues.length&&n.issues.push(...W(i,c.issues)),n.value[a.value]=c.value)}}return o.length?Promise.all(o).then(()=>n):n}}),Dr=T("$ZodEnum",(e,t)=>{S.init(e,t);const n=nr(t.entries);e._zod.values=new Set(n),e._zod.pattern=new RegExp(`^(${n.filter(r=>ar.has(typeof r)).map(r=>typeof r=="string"?mt(r):r.toString()).join("|")})$`),e._zod.parse=(r,s)=>{const o=r.value;return e._zod.values.has(o)||r.issues.push({code:"invalid_value",values:n,input:o,inst:e}),r}}),zr=T("$ZodLiteral",(e,t)=>{S.init(e,t),e._zod.values=new Set(t.values),e._zod.pattern=new RegExp(`^(${t.values.map(n=>typeof n=="string"?mt(n):n?n.toString():String(n)).join("|")})$`),e._zod.parse=(n,r)=>{const s=n.value;return e._zod.values.has(s)||n.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),n}}),Br=T("$ZodOptional",(e,t)=>{S.init(e,t),e._zod.optin="optional",e._zod.optout="optional",R(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),R(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${ft(n.source)})?$`):void 0}),e._zod.parse=(n,r)=>t.innerType._zod.optin==="optional"?t.innerType._zod.run(n,r):n.value===void 0?n:t.innerType._zod.run(n,r)}),Rr=T("$ZodCustom",(e,t)=>{kr.init(e,t),S.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=n=>{const r=n.value,s=t.fn(r);if(s instanceof Promise)return s.then(o=>Ue(o,n,r,e));Ue(s,n,r,e)}});function Ue(e,t,n,r){if(!e){const s={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(s.params=r._zod.def.params),t.issues.push(ur(s))}}function Nr(e,t){return new e({type:"string",...O(t)})}function Ur(e,t){return new e({type:"number",checks:[],...O(t)})}function jr(e,t){return new e({type:"number",coerce:!0,checks:[],...O(t)})}function Lr(e,t){return new e({type:"bigint",coerce:!0,...O(t)})}function Mr(e){return new e({type:"unknown"})}function Fr(e,t,n){return new e({type:"custom",check:"custom",fn:t,...O(n)})}const x=T("ZodMiniType",(e,t)=>{if(!e._zod)throw new Error("Uninitialized schema in ZodMiniType.");S.init(e,t),e.def=t,e.parse=(n,r)=>hr(e,n,r,{callee:e.parse}),e.safeParse=(n,r)=>gt(e,n,r),e.parseAsync=async(n,r)=>pr(e,n,r,{callee:e.parseAsync}),e.safeParseAsync=async(n,r)=>yt(e,n,r),e.check=(...n)=>e.clone({...t,checks:[...t.checks??[],...n.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),e.clone=(n,r)=>cr(e,n,r),e.brand=()=>e,e.register=(n,r)=>(n.add(e,r),e)}),qr=T("ZodMiniString",(e,t)=>{Ir.init(e,t),x.init(e,t)});function E(e){return Nr(qr,e)}const wt=T("ZodMiniNumber",(e,t)=>{vr.init(e,t),x.init(e,t)});function Hr(e){return Ur(wt,e)}const Wr=T("ZodMiniBigInt",(e,t)=>{Er.init(e,t),x.init(e,t)}),Vr=T("ZodMiniUnknown",(e,t)=>{Sr.init(e,t),x.init(e,t)});function _t(){return Mr(Vr)}const Zr=T("ZodMiniArray",(e,t)=>{Cr.init(e,t),x.init(e,t)});function Kr(e,t){return new Zr({type:"array",element:e,...O(t)})}const Gr=T("ZodMiniObject",(e,t)=>{xr.init(e,t),x.init(e,t),R(e,"shape",()=>t.shape)});function D(e,t){const n={type:"object",get shape(){return sr(this,"shape",{...e}),this.shape},...O(t)};return new Gr(n)}const Jr=T("ZodMiniDiscriminatedUnion",(e,t)=>{Or.init(e,t),x.init(e,t)});function xe(e,t,n){return new Jr({type:"union",options:t,discriminator:e,...O(n)})}const Qr=T("ZodMiniRecord",(e,t)=>{Pr.init(e,t),x.init(e,t)});function Yr(e,t,n){return new Qr({type:"record",keyType:e,valueType:t,...O(n)})}const Xr=T("ZodMiniEnum",(e,t)=>{Dr.init(e,t),x.init(e,t)});function be(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new Xr({type:"enum",entries:n,...O(t)})}const es=T("ZodMiniLiteral",(e,t)=>{zr.init(e,t),x.init(e,t)});function M(e,t){return new es({type:"literal",values:Array.isArray(e)?e:[e],...O(t)})}const ts=T("ZodMiniOptional",(e,t)=>{Br.init(e,t),x.init(e,t)});function K(e){return new ts({type:"optional",innerType:e})}const ns=T("ZodMiniCustom",(e,t)=>{Rr.init(e,t),x.init(e,t)});function bt(e,t={}){return Fr(ns,e,t)}function ee(e){return jr(wt,e)}function ke(e){return Lr(Wr,e)}const kt=E().check(bt(de,{message:"Invalid hex string"})),G=E().check(bt(Ve,{message:"Invalid address"})),Te=D({address:G,chainId:ee(),decimals:ee(),iconUri:K(E()),name:E(),priceUsd:ee(),symbol:E()}),rs=xe("version",[D({data:D({}),type:M("pay.onchain-transaction"),version:M(1)}),D({data:D({action:be(["TRANSFER","BUY","SELL"]),clientId:E(),destinationAmount:ke(),destinationToken:Te,developerFeeBps:ee(),developerFeeRecipient:G,originAmount:ke(),originToken:Te,paymentId:E(),paymentLinkId:K(E()),purchaseData:K(Yr(E(),_t())),receiver:G,sender:G,status:be(["PENDING","FAILED","COMPLETED"]),transactions:Kr(D({chainId:ee(),transactionHash:kt})),type:E()}),type:M("pay.onchain-transaction"),version:M(2)})]),ss=xe("version",[D({data:D({}),type:M("pay.onramp-transaction"),version:M(1)}),D({data:D({amount:ke(),currency:E(),currencyAmount:Hr(),id:E(),onramp:E(),paymentLinkId:K(E()),purchaseData:_t(),receiver:G,sender:K(G),status:be(["PENDING","COMPLETED","FAILED"]),token:Te,transactionHash:K(kt)}),type:M("pay.onramp-transaction"),version:M(2)})]),os=xe("type",[rs,ss]);async function Tt(e,t,n,r=300,s){const o=t["x-payload-signature"]||t["x-pay-signature"],i=t["x-timestamp"]||t["x-pay-timestamp"];if(!o||!i)throw new Error("Missing required webhook headers: signature or timestamp");const a=Math.floor(Date.now()/1e3),c=Number.parseInt(i,10),l=Math.abs(a-c);if(l>r)throw new Error(`Webhook timestamp is too old. Difference: ${l}s, tolerance: ${r}s`);const h=new TextEncoder,u=await crypto.subtle.importKey("raw",h.encode(n),{hash:"SHA-256",name:"HMAC"},!1,["sign"]),d=await crypto.subtle.sign("HMAC",u,h.encode(`${i}.${e}`));if(Array.from(new Uint8Array(d)).map(y=>y.toString(16).padStart(2,"0")).join("")!==o)throw new Error("Invalid webhook signature");let m;try{m=JSON.parse(e)}catch{throw new Error("Invalid webhook payload: not valid JSON")}const p=os.parse(m);if(p.version===1)throw new Error("Invalid webhook payload: version 1 is no longer supported, please upgrade to webhook version 2.");if(s){if(s.receiverAddress&&p.data.receiver.toLowerCase()!==s.receiverAddress.toLowerCase())throw new Error(`Verification Failed: receiverAddress mismatch, Expected: ${s.receiverAddress}, Received: ${p.data.receiver}`);if(s.destinationTokenAddress){if("destinationToken"in p.data){if(p.data.destinationToken.address.toLowerCase()!==s.destinationTokenAddress.toLowerCase())throw new Error(`Verification Failed: destinationTokenAddress mismatch, Expected: ${s.destinationTokenAddress}, Received: ${p.data.destinationToken.address}`)}else if("onramp"in p.data&&p.data.token.address.toLowerCase()!==s.destinationTokenAddress.toLowerCase())throw new Error(`Verification Failed: destinationTokenAddress mismatch, Expected: ${s.destinationTokenAddress}, Received: ${p.data.token.address}`)}if(s.destinationChainId){if("destinationToken"in p.data){if(p.data.destinationToken.chainId!==s.destinationChainId)throw new Error(`Verification Failed: destinationChainId mismatch, Expected: ${s.destinationChainId}, Received: ${p.data.destinationToken.chainId}`)}else if("onramp"in p.data&&p.data.token.chainId!==s.destinationChainId)throw new Error(`Verification Failed: destinationChainId mismatch, Expected: ${s.destinationChainId}, Received: ${p.data.token.chainId}`)}if(s.minDestinationAmount){if("destinationAmount"in p.data){if(p.data.destinationAmount<s.minDestinationAmount)throw new Error(`Verification Failed: minDestinationAmount, Expected minimum amount to be ${s.minDestinationAmount}, Received: ${p.data.destinationAmount}`)}else if("onramp"in p.data&&p.data.amount<s.minDestinationAmount)throw new Error(`Verification Failed: minDestinationAmount, Expected minimum amount to be ${s.minDestinationAmount}, Received: ${p.data.amount}`)}}return p}const is=Object.freeze(Object.defineProperty({__proto__:null,parse:Tt},Symbol.toStringTag,{value:"Module"})),as=Object.freeze(Object.defineProperty({__proto__:null,Buy:Zn,Onramp:Qn,Sell:Xn,Transfer:tr,Webhook:is,chains:Kn,parse:Tt,status:dt,tokens:er},Symbol.toStringTag,{value:"Module"}));function cs(e,t,n,r){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,n,r);const s=BigInt(32),o=BigInt(4294967295),i=Number(n>>s&o),a=Number(n&o),c=r?4:0,l=r?0:4;e.setUint32(t+c,i,r),e.setUint32(t+l,a,r)}function ds(e,t,n){return e&t^~e&n}function us(e,t,n){return e&t^e&n^t&n}class ls extends Ut{constructor(t,n,r,s){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=n,this.padOffset=r,this.isLE=s,this.buffer=new Uint8Array(t),this.view=fe(this.buffer)}update(t){Pe(this);const{view:n,buffer:r,blockLen:s}=this;t=jt(t);const o=t.length;for(let i=0;i<o;){const a=Math.min(s-this.pos,o-i);if(a===s){const c=fe(t);for(;s<=o-i;i+=s)this.process(c,i);continue}r.set(t.subarray(i,i+a),this.pos),this.pos+=a,i+=a,this.pos===s&&(this.process(n,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){Pe(this),Lt(t,this),this.finished=!0;const{buffer:n,view:r,blockLen:s,isLE:o}=this;let{pos:i}=this;n[i++]=128,this.buffer.subarray(i).fill(0),this.padOffset>s-i&&(this.process(r,0),i=0);for(let u=i;u<s;u++)n[u]=0;cs(r,s-8,BigInt(this.length*8),o),this.process(r,0);const a=fe(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=c/4,h=this.get();if(l>h.length)throw new Error("_sha2: outputLen bigger than state");for(let u=0;u<l;u++)a.setUint32(4*u,h[u],o)}digest(){const{buffer:t,outputLen:n}=this;this.digestInto(t);const r=t.slice(0,n);return this.destroy(),r}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:n,buffer:r,length:s,finished:o,destroyed:i,pos:a}=this;return t.length=s,t.pos=a,t.finished=o,t.destroyed=i,s%n&&t.buffer.set(r),t}}const fs=new Uint32Array([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]),U=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),j=new Uint32Array(64);class hs extends ls{constructor(t=32){super(64,t,8,!1),this.A=U[0]|0,this.B=U[1]|0,this.C=U[2]|0,this.D=U[3]|0,this.E=U[4]|0,this.F=U[5]|0,this.G=U[6]|0,this.H=U[7]|0}get(){const{A:t,B:n,C:r,D:s,E:o,F:i,G:a,H:c}=this;return[t,n,r,s,o,i,a,c]}set(t,n,r,s,o,i,a,c){this.A=t|0,this.B=n|0,this.C=r|0,this.D=s|0,this.E=o|0,this.F=i|0,this.G=a|0,this.H=c|0}process(t,n){for(let u=0;u<16;u++,n+=4)j[u]=t.getUint32(n,!1);for(let u=16;u<64;u++){const d=j[u-15],f=j[u-2],m=P(d,7)^P(d,18)^d>>>3,p=P(f,17)^P(f,19)^f>>>10;j[u]=p+j[u-7]+m+j[u-16]|0}let{A:r,B:s,C:o,D:i,E:a,F:c,G:l,H:h}=this;for(let u=0;u<64;u++){const d=P(a,6)^P(a,11)^P(a,25),f=h+d+ds(a,c,l)+fs[u]+j[u]|0,p=(P(r,2)^P(r,13)^P(r,22))+us(r,s,o)|0;h=l,l=c,c=a,a=i+f|0,i=o,o=s,s=r,r=f+p|0}r=r+this.A|0,s=s+this.B|0,o=o+this.C|0,i=i+this.D|0,a=a+this.E|0,c=c+this.F|0,l=l+this.G|0,h=h+this.H|0,this.set(r,s,o,i,a,c,l,h)}roundClean(){j.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const ms=Mt(()=>new hs);function At(e,t){const n=ms(de(e,{strict:!1})?Je(e):e);return t==="bytes"?n:Qe(n)}const me=new Bt(4096);function ps(e){if(me.has(e))return me.get(e);const t=At(Ze(e)).slice(2,34);return me.set(e,t),t}function gs(e){const{clientId:t,secretKey:n,...r}=e;let s=t;if(n)if(Rt(n)){if(!t)throw new Error("clientId must be provided when using a JWT secretKey")}else s=t??ps(n);if(!s)throw new Error("clientId or secretKey must be provided");return{...r,clientId:s,secretKey:n}}const ys={bodySerializer:e=>JSON.stringify(e,(t,n)=>typeof n=="bigint"?n.toString():n)},ws=async(e,t)=>{const n=typeof t=="function"?await t(e):t;if(n)return e.scheme==="bearer"?`Bearer ${n}`:e.scheme==="basic"?`Basic ${btoa(n)}`:n},_s=e=>{switch(e){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},bs=e=>{switch(e){case"form":return",";case"pipeDelimited":return"|";case"spaceDelimited":return"%20";default:return","}},ks=e=>{switch(e){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},It=({allowReserved:e,explode:t,name:n,style:r,value:s})=>{if(!t){const a=(e?s:s.map(c=>encodeURIComponent(c))).join(bs(r));switch(r){case"label":return`.${a}`;case"matrix":return`;${n}=${a}`;case"simple":return a;default:return`${n}=${a}`}}const o=_s(r),i=s.map(a=>r==="label"||r==="simple"?e?a:encodeURIComponent(a):le({allowReserved:e,name:n,value:a})).join(o);return r==="label"||r==="matrix"?o+i:i},le=({allowReserved:e,name:t,value:n})=>{if(n==null)return"";if(typeof n=="object")throw new Error("Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.");return`${t}=${e?n:encodeURIComponent(n)}`},vt=({allowReserved:e,explode:t,name:n,style:r,value:s,valueOnly:o})=>{if(s instanceof Date)return o?s.toISOString():`${n}=${s.toISOString()}`;if(r!=="deepObject"&&!t){let c=[];Object.entries(s).forEach(([h,u])=>{c=[...c,h,e?u:encodeURIComponent(u)]});const l=c.join(",");switch(r){case"form":return`${n}=${l}`;case"label":return`.${l}`;case"matrix":return`;${n}=${l}`;default:return l}}const i=ks(r),a=Object.entries(s).map(([c,l])=>le({allowReserved:e,name:r==="deepObject"?`${n}[${c}]`:c,value:l})).join(i);return r==="label"||r==="matrix"?i+a:a},Ts=/\{[^{}]+\}/g,As=({path:e,url:t})=>{let n=t;const r=t.match(Ts);if(r)for(const s of r){let o=!1,i=s.substring(1,s.length-1),a="simple";i.endsWith("*")&&(o=!0,i=i.substring(0,i.length-1)),i.startsWith(".")?(i=i.substring(1),a="label"):i.startsWith(";")&&(i=i.substring(1),a="matrix");const c=e[i];if(c==null)continue;if(Array.isArray(c)){n=n.replace(s,It({explode:o,name:i,style:a,value:c}));continue}if(typeof c=="object"){n=n.replace(s,vt({explode:o,name:i,style:a,value:c,valueOnly:!0}));continue}if(a==="matrix"){n=n.replace(s,`;${le({name:i,value:c})}`);continue}const l=encodeURIComponent(a==="label"?`.${c}`:c);n=n.replace(s,l)}return n},Et=({allowReserved:e,array:t,object:n}={})=>s=>{const o=[];if(s&&typeof s=="object")for(const i in s){const a=s[i];if(a!=null)if(Array.isArray(a)){const c=It({allowReserved:e,explode:!0,name:i,style:"form",value:a,...t});c&&o.push(c)}else if(typeof a=="object"){const c=vt({allowReserved:e,explode:!0,name:i,style:"deepObject",value:a,...n});c&&o.push(c)}else{const c=le({allowReserved:e,name:i,value:a});c&&o.push(c)}}return o.join("&")},Is=e=>{if(!e)return"stream";const t=e.split(";")[0]?.trim();if(t){if(t.startsWith("application/json")||t.endsWith("+json"))return"json";if(t==="multipart/form-data")return"formData";if(["application/","audio/","image/","video/"].some(n=>t.startsWith(n)))return"blob";if(t.startsWith("text/"))return"text"}},vs=async({security:e,...t})=>{for(const n of e){const r=await ws(n,t.auth);if(!r)continue;const s=n.name??"Authorization";switch(n.in){case"query":t.query||(t.query={}),t.query[s]=r;break;case"cookie":t.headers.append("Cookie",`${s}=${r}`);break;case"header":default:t.headers.set(s,r);break}return}},je=e=>Es({baseUrl:e.baseUrl,path:e.path,query:e.query,querySerializer:typeof e.querySerializer=="function"?e.querySerializer:Et(e.querySerializer),url:e.url}),Es=({baseUrl:e,path:t,query:n,querySerializer:r,url:s})=>{const o=s.startsWith("/")?s:`/${s}`;let i=(e??"")+o;t&&(i=As({path:t,url:i}));let a=n?r(n):"";return a.startsWith("?")&&(a=a.substring(1)),a&&(i+=`?${a}`),i},Le=(e,t)=>{const n={...e,...t};return n.baseUrl?.endsWith("/")&&(n.baseUrl=n.baseUrl.substring(0,n.baseUrl.length-1)),n.headers=St(e.headers,t.headers),n},St=(...e)=>{const t=new Headers;for(const n of e){if(!n||typeof n!="object")continue;const r=n instanceof Headers?n.entries():Object.entries(n);for(const[s,o]of r)if(o===null)t.delete(s);else if(Array.isArray(o))for(const i of o)t.append(s,i);else o!==void 0&&t.set(s,typeof o=="object"?JSON.stringify(o):o)}return t};class pe{constructor(){Object.defineProperty(this,"_fns",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._fns=[]}clear(){this._fns=[]}getInterceptorIndex(t){return typeof t=="number"?this._fns[t]?t:-1:this._fns.indexOf(t)}exists(t){const n=this.getInterceptorIndex(t);return!!this._fns[n]}eject(t){const n=this.getInterceptorIndex(t);this._fns[n]&&(this._fns[n]=null)}update(t,n){const r=this.getInterceptorIndex(t);return this._fns[r]?(this._fns[r]=n,t):!1}use(t){return this._fns=[...this._fns,t],this._fns.length-1}}const Ss=()=>({error:new pe,request:new pe,response:new pe}),Cs=Et({allowReserved:!1,array:{explode:!0,style:"form"},object:{explode:!0,style:"deepObject"}}),xs={"Content-Type":"application/json"},Ct=(e={})=>({...ys,headers:xs,parseAs:"auto",querySerializer:Cs,...e}),$s=(e={})=>{let t=Le(Ct(),e);const n=()=>({...t}),r=i=>(t=Le(t,i),n()),s=Ss(),o=async i=>{const a={...t,...i,fetch:i.fetch??t.fetch??globalThis.fetch,headers:St(t.headers,i.headers)};a.security&&await vs({...a,security:a.security}),a.body&&a.bodySerializer&&(a.body=a.bodySerializer(a.body)),(a.body===void 0||a.body==="")&&a.headers.delete("Content-Type");const c=je(a),l={redirect:"follow",...a};let h=new Request(c,l);for(const y of s.request._fns)y&&(h=await y(h,a));const u=a.fetch;let d=await u(h);for(const y of s.response._fns)y&&(d=await y(d,h,a));const f={request:h,response:d};if(d.ok){if(d.status===204||d.headers.get("Content-Length")==="0")return a.responseStyle==="data"?{}:{data:{},...f};const y=(a.parseAs==="auto"?Is(d.headers.get("Content-Type")):a.parseAs)??"json";let g;switch(y){case"arrayBuffer":case"blob":case"formData":case"json":case"text":g=await d[y]();break;case"stream":return a.responseStyle==="data"?d.body:{data:d.body,...f}}return y==="json"&&(a.responseValidator&&await a.responseValidator(g),a.responseTransformer&&(g=await a.responseTransformer(g))),a.responseStyle==="data"?g:{data:g,...f}}let m=await d.text();try{m=JSON.parse(m)}catch{}let p=m;for(const y of s.error._fns)y&&(p=await y(m,d,h,a));if(p=p||{},a.throwOnError)throw p;return a.responseStyle==="data"?void 0:{error:p,...f}};return{buildUrl:je,connect:i=>o({...i,method:"CONNECT"}),delete:i=>o({...i,method:"DELETE"}),get:i=>o({...i,method:"GET"}),getConfig:n,head:i=>o({...i,method:"HEAD"}),interceptors:s,options:i=>o({...i,method:"OPTIONS"}),patch:i=>o({...i,method:"PATCH"}),post:i=>o({...i,method:"POST"}),put:i=>o({...i,method:"PUT"}),request:o,setConfig:r,trace:i=>o({...i,method:"TRACE"})}},Y=$s(Ct({baseUrl:"https://engine.thirdweb.com"})),Os=e=>(e.client??Y).post({security:[{name:"x-secret-key",type:"apiKey"}],url:"/v1/write/transaction",...e,headers:{"Content-Type":"application/json",...e.headers}}),Ps=e=>(e.client??Y).post({security:[{name:"x-secret-key",type:"apiKey"}],url:"/v1/sign/message",...e,headers:{"Content-Type":"application/json",...e.headers}}),Ds=e=>(e.client??Y).post({security:[{name:"x-secret-key",type:"apiKey"}],url:"/v1/sign/typed-data",...e,headers:{"Content-Type":"application/json",...e.headers}}),zs=e=>(e?.client??Y).get({security:[{name:"x-secret-key",type:"apiKey"}],url:"/v1/accounts",...e}),Bs=e=>(e?.client??Y).post({security:[{name:"x-secret-key",type:"apiKey"}],url:"/v1/accounts",...e,headers:{"Content-Type":"application/json",...e?.headers}}),xt=e=>(e?.client??Y).post({security:[{name:"x-secret-key",type:"apiKey"}],url:"/v1/transactions/search",...e,headers:{"Content-Type":"application/json",...e?.headers}});function Me(e){return"result"in e}const{stringify:Fe}=await q("viem");async function Rs(e){const{client:t,label:n}=e,r=await Bs({baseUrl:v("engineCloud"),body:{label:n},bodySerializer:Fe,fetch:I(t)});if(r.error)throw new Error(`Error creating server wallet with label ${n}: ${Fe(r.error)}`);const s=r.data?.result;if(!s)throw new Error(`No server wallet created with label ${n}`);return s}async function $t(e){const{client:t,transactionId:n}=e,r=await xt({baseUrl:v("engineCloud"),body:{filters:[{field:"id",operation:"OR",values:[n]}]},bodySerializer:A,fetch:I(t)});if(r.error)throw new Error(`Error searching for transaction ${n}: ${A(r.error)}`);const s=r.data?.result?.transactions?.[0];if(!s)throw new Error(`Transaction ${n} not found`);return{...s.executionResult,cancelledAt:s.cancelledAt,chain:te(Number(s.chainId)),confirmedAt:s.confirmedAt,createdAt:s.createdAt,from:s.from??void 0,id:s.id}}const{stringify:qe}=await q("viem");async function Ns(e){const{client:t}=e,n=await zs({baseUrl:v("engineCloud"),bodySerializer:qe,fetch:I(t),query:{limit:e.limit,page:e.page}});if(n.error)throw new Error(`Error listing server wallets: ${qe(n.error)}`);const r=n.data?.result;if(!r)throw new Error("No server wallets found");return r}async function Us(e){const{client:t,filters:n,pageSize:r=100,page:s=1}=e,o=await xt({baseUrl:v("engineCloud"),body:{filters:n,limit:r,page:s},bodySerializer:A,fetch:I(t)});if(o.error)throw new Error(`Error searching for transaction with filters ${A(n)}: ${A(o.error)}`);const i=o.data?.result;if(!i)throw new Error(`No transactions found with filters ${A(n)}`);return i}const{stringify:He}=await q("viem");async function Ae(e){const t=Date.now(),n=e.timeoutInSeconds?e.timeoutInSeconds*1e3:5*60*1e3;for(;Date.now()-t<n;){const r=await $t(e);switch(r.status){case"FAILED":throw new Error(`Transaction failed: ${He(r.error)||"Unknown error"}`);case"CONFIRMED":{if((r&&"onchainStatus"in r?r.onchainStatus:null)==="REVERTED"){const i="revertData"in r?r.revertData:void 0;throw new Error(`Transaction reverted: ${i?.errorName||"unknown error"} ${i?.errorArgs?He(i.errorArgs):""} - ${r.transactionHash?r.transactionHash:""}`)}return{chain:r.chain,client:e.client,transactionHash:r.transactionHash}}default:await new Promise(o=>setTimeout(o,1e3))}}throw new Error(`Transaction timed out after ${n/1e3} seconds`)}function js(e){const{client:t,vaultAccessToken:n,address:r,chain:s,executionOptions:o}=e,i=n?{"x-vault-access-token":n}:{},a=u=>{if(!o)return{chainId:u,from:r,type:"auto"};switch(o.type){case"auto":return{chainId:u,from:r,type:"auto"};case"ERC4337":return{...o,chainId:u,type:"ERC4337"};case"EOA":return{chainId:u,from:r,type:"EOA"};case"EIP7702":return{...o,chainId:u,type:"EIP7702"}}},c=u=>{if(!u)return{from:r,type:"EOA"};if(!o)return{chainId:u,from:r,type:"auto"};switch(o.type){case"ERC4337":return{chainId:u,...o,type:"ERC4337"};case"auto":return{chainId:u,from:r,type:"auto"};case"EIP7702":case"EOA":return{chainId:u,from:r,type:"EOA"}}},l=async u=>{if(u.length===0)throw new Error("No transactions to enqueue");const d=u[0];if(!d)throw new Error("No transactions to enqueue");const f=d.chainId;for(let g=1;g<u.length;g++)if(u[g]?.chainId!==f)throw new Error(`All transactions in batch must be on the same chain. Expected ${f}, got ${u[g]?.chainId} at index ${g}`);const m={executionOptions:a(f),params:u.map(g=>({data:g.data,to:g.to,gasLimit:g.gas?Number(g.gas):void 0,value:g.value?.toString()}))},p=await Os({baseUrl:v("engineCloud"),body:m,bodySerializer:A,fetch:I(t),headers:i});if(p.error)throw new Error(`Error sending transaction: ${A(p.error)}`);const y=p.data?.result;if(!y)throw new Error("No data returned from engine");return y.transactions.map(g=>g.id)};return{address:o?.type==="ERC4337"&&o.smartAccountAddress?o.smartAccountAddress:r,enqueueBatchTransaction:async u=>{const d=[];for(const p of u.transactions){const[y,g,w]=await Promise.all([p.to?L(p.to):null,ie(p),p.value?L(p.value):null]);d.push({chainId:p.chain.id,data:g,to:y??void 0,value:w??void 0})}const m=(await l(d))[0];if(!m)throw new Error("No transactionId returned from engine");return{transactionId:m}},enqueueTransaction:async u=>{let d;if(u.simulate)d=await Xe({transaction:u.transaction,from:r});else{const[p,y,g]=await Promise.all([u.transaction.to?L(u.transaction.to):null,ie(u.transaction),u.transaction.value?L(u.transaction.value):null]);d={chainId:u.transaction.chain.id,data:y,to:p??void 0,value:g??void 0}}const m=(await l([d]))[0];if(!m)throw new Error("No transactionId returned from engine");return{transactionId:m}},sendBatchTransaction:async u=>{const f=(await l(u))[0];if(!f)throw new Error("No transactionId returned from engine");return Ae({client:t,transactionId:f})},sendTransaction:async u=>{const f=(await l([u]))[0];if(!f)throw new Error("No transactionId returned from engine");return Ae({client:t,transactionId:f})},signMessage:async u=>{const{message:d,chainId:f}=u;let m,p=!1;typeof d=="string"?m=d:(m=Ye(d.raw),p=!0);const y=f||s?.id;if(!y)throw new Error("Chain ID is required for signing messages");const g=await Ps({baseUrl:v("engineCloud"),body:{params:[{format:p?"hex":"text",message:m}],signingOptions:c(y)},bodySerializer:A,fetch:I(t),headers:i});if(g.error)throw new Error(`Error signing message: ${A(g.error)}`);const w=g.data?.result[0];if(w&&Me(w))return w.result.signature;throw new Error(`Failed to sign message: ${A(w?.error)||"Unknown error"}`)},signTypedData:async u=>{const d=s?.id;if(!d)throw new Error("Chain ID is required for signing messages");const f=await Ds({baseUrl:v("engineCloud"),body:{params:[u],signingOptions:c(d)},bodySerializer:A,fetch:I(t),headers:i});if(f.error)throw new Error(`Error signing message: ${A(f.error)}`);const m=f.data?.result[0];if(m&&Me(m))return m.result.signature;throw new Error(`Failed to sign message: ${A(m?.error)||"Unknown error"}`)}}}const Ls=Object.freeze(Object.defineProperty({__proto__:null,createServerWallet:Rs,getServerWallets:Ns,getTransactionStatus:$t,searchTransactions:Us,serverWallet:js,waitForTransactionHash:Ae},Symbol.toStringTag,{value:"Module"}));async function $e(e){const[{getV1EventsByContractAddress:t},{getThirdwebDomains:n},{getClientFetch:r},{assertInsightEnabled:s},{stringify:o}]=await Promise.all([_(()=>import("./thirdweb-CHfVLLbM.js"),[]),_(()=>import("./withCache-DYumIHzL.js").then(m=>m.e),[]),_(()=>import("./withCache-DYumIHzL.js").then(m=>m.f),[]),_(()=>import("./common-D37S_OFt.js"),__vite__mapDeps([0,1,2])),_(()=>import("./json-BHzNJmTy.js"),[])]),{client:i,chains:a,contractAddress:c,event:l,queryOptions:h,decodeLogs:u}=e;await s(a);const d={chain:a.map(m=>m.id),decode:u,limit:100};l&&(d.filter_topic_0=l.topics[0],d.filter_topic_1=l.topics[1],d.filter_topic_2=l.topics[2],d.filter_topic_3=l.topics[3]);const f=await t({baseUrl:`https://${n().insight}`,fetch:r(i),path:{contractAddress:c},query:{...d,...h}});if(f.error)throw new Error(`${f.response.status} ${f.response.statusText} - ${f.error?o(f.error):"Unknown error"}`);return f.data?.data??[]}async function Ms(e){const[{getV1Nfts:t},{getThirdwebDomains:n},{getClientFetch:r},{assertInsightEnabled:s},{stringify:o}]=await Promise.all([_(()=>import("./thirdweb-CHfVLLbM.js"),[]),_(()=>import("./withCache-DYumIHzL.js").then(m=>m.e),[]),_(()=>import("./withCache-DYumIHzL.js").then(m=>m.f),[]),_(()=>import("./common-D37S_OFt.js"),__vite__mapDeps([0,1,2])),_(()=>import("./index-HwVh-q7L.js"),__vite__mapDeps([3,4,5,6,7,8,9,10,11,2,12]))]),{client:i,chains:a,ownerAddress:c,contractAddresses:l,queryOptions:h}=e;await s(a);const u={chain:a.map(m=>m.id),limit:50,owner_address:[c],contract_address:l||void 0},d=await t({baseUrl:`https://${n().insight}`,fetch:r(i),query:{...u,...h}});if(d.error)throw new Error(`${d.response.status} ${d.response.statusText} - ${d.error?o(d.error):"Unknown error"}`);return(await Oe(d.data?.data??[],i,c)).map(m=>({...m,quantityOwned:m.quantityOwned??1n}))}async function Fs(e){const[{getV1NftsByContractAddress:t},{getThirdwebDomains:n},{getClientFetch:r},{assertInsightEnabled:s},{stringify:o}]=await Promise.all([_(()=>import("./thirdweb-CHfVLLbM.js"),[]),_(()=>import("./withCache-DYumIHzL.js").then(f=>f.e),[]),_(()=>import("./withCache-DYumIHzL.js").then(f=>f.f),[]),_(()=>import("./common-D37S_OFt.js"),__vite__mapDeps([0,1,2])),_(()=>import("./json-BHzNJmTy.js"),[])]),{client:i,chains:a,contractAddress:c,includeOwners:l=!0,queryOptions:h}=e,u={chain:a.map(f=>f.id),include_owners:l===!0?"true":"false",limit:50};await s(a);const d=await t({baseUrl:`https://${n().insight}`,fetch:r(i),path:{contract_address:c},query:{...u,...h}});if(d.error)throw new Error(`${d.response.status} ${d.response.statusText} - ${d.error?o(d.error):"Unknown error"}`);return Oe(d.data?.data??[],i)}async function qs(e){const[{getV1NftsByContractAddressByTokenId:t},{getThirdwebDomains:n},{getClientFetch:r},{assertInsightEnabled:s},{stringify:o}]=await Promise.all([_(()=>import("./thirdweb-CHfVLLbM.js"),[]),_(()=>import("./withCache-DYumIHzL.js").then(p=>p.e),[]),_(()=>import("./withCache-DYumIHzL.js").then(p=>p.f),[]),_(()=>import("./common-D37S_OFt.js"),__vite__mapDeps([0,1,2])),_(()=>import("./json-BHzNJmTy.js"),[])]),{client:i,chain:a,contractAddress:c,tokenId:l,includeOwners:h=!0,queryOptions:u}=e;await s([a]);const d={chain_id:[a.id],include_owners:h===!0?"true":"false"},f=await t({baseUrl:`https://${n().insight}`,fetch:r(i),path:{contract_address:c,token_id:l.toString()},query:{...d,...u}});if(f.error)throw new Error(`${f.response.status} ${f.response.statusText} - ${f.error?o(f.error):"Unknown error"}`);return(await Oe(f.data?.data??[],i))?.[0]}async function Oe(e,t,n){const[{parseNFT:r},{totalSupply:s}]=await Promise.all([_(()=>import("./parseNft-CxF6cVbB.js"),__vite__mapDeps([13,6,1,2,8,9,10,11,12])),_(()=>import("./totalSupply-CjCaaPZD.js"),__vite__mapDeps([14,9,15,10,2,6,16,17,1,12,11,8,18,19]))]);return await Promise.all(e.map(async o=>{let i;const{contract:a,extra_metadata:c,collection:l,metadata_url:h,chain_id:u,token_id:d,status:f,balance:m,token_type:p,...y}=o;let g=y,w=n?[F(n)]:void 0;if("owner_addresses"in y){const{owner_addresses:k,...B}=y;g=B,w=w??k?.map(N=>F(N))}const b=Ot({attributes:o.extra_metadata?.attributes??void 0,image:o.image_url,uri:o.metadata_url??"",...g});if(a?.type==="erc1155"){const k=await s({contract:ne({address:a.address,chain:te(a.chain_id),client:t}),id:BigInt(d)}).catch(()=>0n);i=r(b,{chainId:a?.chain_id??0,owner:w?.[0],supply:k,tokenAddress:a?.address??"",tokenId:BigInt(d),tokenUri:Ie(h)??"",type:"ERC1155"})}else i=r(b,{chainId:a?.chain_id??0,owner:w?.[0],tokenAddress:a?.address??"",tokenId:BigInt(d),tokenUri:Ie(h)??"",type:"ERC721"});return{...i,...a?.type==="erc1155"?{quantityOwned:m?BigInt(m):void 0}:{}}}))}function Ot(e){if(typeof e!="object"||e===null)return e;for(const t in e)typeof e[t]=="string"?e[t]=Ie(e[t]):Ot(e[t]);return e}function Ie(e){if(!e||typeof e!="string")return e;try{const t=new URL(e);if(t.host.endsWith(".ipfscdn.io")){const n=t.pathname.split("/"),r=n.findIndex(o=>o==="ipfs");if(r===-1)return e;const s=n.slice(r+1).join("/");return s?`ipfs://${s}`:e}}catch{return e}return e}async function Hs(e){const[{getV1Tokens:t},{getThirdwebDomains:n},{getClientFetch:r},{assertInsightEnabled:s},{stringify:o}]=await Promise.all([_(()=>import("./thirdweb-CHfVLLbM.js"),[]),_(()=>import("./withCache-DYumIHzL.js").then(f=>f.e),[]),_(()=>import("./withCache-DYumIHzL.js").then(f=>f.f),[]),_(()=>import("./common-D37S_OFt.js"),__vite__mapDeps([0,1,2])),_(()=>import("./json-BHzNJmTy.js"),[])]),{client:i,chains:a,ownerAddress:c,tokenAddresses:l,queryOptions:h}=e;await s(a);const u={chain_id:a.length>0?a.map(f=>f.id):[1],include_native:"true",include_spam:"false",limit:50,metadata:"true",owner_address:[c],token_address:l||void 0,sort_by:"balance",sort_order:"desc"},d=await t({baseUrl:`https://${n().insight}`,fetch:r(i),query:{...u,...h}});if(d.error)throw new Error(`${d.response.status} ${d.response.statusText} - ${d.error?o(d.error):"Unknown error"}`);return Ws(d.data?.data??[])}async function Ws(e){const{toTokens:t}=await _(async()=>{const{toTokens:n}=await import("./fee-data-DBS1-uI-.js").then(r=>r.u);return{toTokens:n}},__vite__mapDeps([16,9,10,17,1,2,12,11]));return e.map(n=>{const r=n.decimals??18,s=BigInt(n.balance);return{chainId:n.chain_id,decimals:r,displayValue:t(s,r),name:n.name??"",symbol:n.symbol??"",tokenAddress:n.token_address,value:s}})}async function Vs(e){const[{getV1WalletsByWalletAddressTransactions:t},{getThirdwebDomains:n},{getClientFetch:r},{assertInsightEnabled:s},{stringify:o}]=await Promise.all([_(()=>import("./thirdweb-CHfVLLbM.js"),[]),_(()=>import("./withCache-DYumIHzL.js").then(f=>f.e),[]),_(()=>import("./withCache-DYumIHzL.js").then(f=>f.f),[]),_(()=>import("./common-D37S_OFt.js"),__vite__mapDeps([0,1,2])),_(()=>import("./json-BHzNJmTy.js"),[])]);await s(e.chains);const i=Math.floor((Date.now()-3*30*24*60*60*1e3)/1e3),{client:a,walletAddress:c,chains:l,queryOptions:h}=e,u={chain:l.map(f=>f.id),filter_block_timestamp_gte:i,limit:100},d=await t({baseUrl:`https://${n().insight}`,fetch:r(a),path:{wallet_address:c},query:{...u,...h}});if(d.error)throw new Error(`${d.response.status} ${d.response.statusText} - ${d.error?o(d.error):"Unknown error"}`);return d.data.data||[]}const Zs=Object.freeze(Object.defineProperty({__proto__:null,getContractEvents:$e,getContractNFTs:Fs,getNFT:qs,getOwnedNFTs:Ms,getOwnedTokens:Hs,getTransactions:Vs},Symbol.toStringTag,{value:"Module"})),{formatBlock:Ks}=await q("viem");async function Gs(e,t){const n=t.includeTransactions??!1,r=await e({method:"eth_getBlockByHash",params:[t.blockHash,n]});if(!r)throw new Error("Block not found");return Ks(r)}const{formatLog:Js}=await q("viem");async function ve(e,t={}){const n=t.topics??[];let r;if(t.blockHash){const s={blockHash:t.blockHash,topics:n};t.address&&(s.address=F(t.address)),r=await e({method:"eth_getLogs",params:[s]})}else{const s={topics:n};t.address&&(s.address=t.address),t.fromBlock&&(s.fromBlock=typeof t.fromBlock=="bigint"?Z(t.fromBlock):t.fromBlock),t.toBlock&&(s.toBlock=typeof t.toBlock=="bigint"?Z(t.toBlock):t.toBlock),r=await e({method:"eth_getLogs",params:[s]})}return r.map(s=>Js(s))}const{formatTransaction:Qs}=await q("viem");async function Ys(e,t){const n=await e({method:"eth_getTransactionByHash",params:[t.hash]});if(!n)throw new Error("Transaction not found.");return Qs(n)}const{formatLog:Xs}=await q("viem");async function Pt(e){const{contract:t,events:n,blockRange:r,useIndexer:s=!0,...o}=e,i=Se(t);if(o.blockHash&&(r||o.fromBlock||o.toBlock))throw new Error("Cannot specify blockHash and range simultaneously,");const a=await st(i);if(r){const{fromBlock:d,toBlock:f}=o;if(d!==void 0&&f!==void 0&&BigInt(f)-BigInt(d)!==BigInt(r))throw new Error("Incompatible blockRange with specified fromBlock and toBlock. Please only define fromBlock or toBlock when specifying blockRange.");d!==void 0?o.toBlock=BigInt(d)+BigInt(r)-1n:f!==void 0?o.fromBlock=BigInt(f)-BigInt(r)+1n:(o.toBlock=a,o.fromBlock=a-BigInt(r)+1n)}let c=n??[];if(!n?.length&&t){if(s){const d=await $e({chains:[t.chain],client:t.client,contractAddress:t.address,decodeLogs:!0,queryOptions:{filter_block_hash:o.blockHash,filter_block_number_gte:o.fromBlock,filter_block_number_lte:o.toBlock,limit:500}}).catch(()=>null);if(d)return Dt(d)}t.abi?.length?c=t.abi.filter(De).map(d=>ye({signature:d})):c=(await Ke(t)).filter(De).map(f=>ye({signature:f}))}const l=n&&n.length>0?n.map(d=>({...o,address:F(t.address),topics:d.topics})):[{...o,address:F(t.address)}];let h=[];if(s)try{h=await Promise.all(l.map(d=>eo({contract:t,params:d})))}catch(d){console.warn("Error fetching from insight, falling back to rpc",d),h=await Promise.all(l.map(f=>ve(i,f)))}else h=await Promise.all(l.map(d=>ve(i,d)));const u=h.flat().sort((d,f)=>Number((d.blockNumber??0n)-(f.blockNumber??0n)));return et({events:c,logs:u})}async function eo(e){const{params:t,contract:n}=e,r=typeof t.fromBlock=="bigint"?Number(t.fromBlock):void 0,s=typeof t.toBlock=="bigint"?Number(t.toBlock):void 0,o=await $e({chains:[n.chain],client:n.client,contractAddress:n.address,queryOptions:{filter_block_hash:t.blockHash,filter_block_number_gte:r,filter_block_number_lte:s,filter_topic_0:t.topics?.[0],filter_topic_1:t.topics?.[1],filter_topic_2:t.topics?.[2],filter_topic_3:t.topics?.[3],limit:500}});return Dt(o)}function Dt(e){return e.map(n=>({address:n.address,blockHash:n.block_hash,blockNumber:Z(Number(n.block_number)),blockTimestamp:n.block_timestamp,chainId:n.chain_id,data:n.data,logIndex:Z(n.log_index),topics:n.topics,transactionHash:n.transaction_hash,transactionIndex:Z(n.transaction_index),...n.decoded?{args:{...n.decoded.indexed_params,...n.decoded.non_indexed_params},eventName:n.decoded.name}:{}})).map(n=>Xs(n)).sort((n,r)=>Number((n.blockNumber??0n)-(r.blockNumber??0n)))}async function to(e,t){const n=t.retries,r=t.delay;let s=null;for(let o=0;o<n;o++)try{return await e()}catch(i){s=i,await new Promise(a=>setTimeout(a,r))}throw s}function no(e){return ot({...e.contract,latestBlockNumber:e.latestBlockNumber,onNewBlockNumber:async t=>{const n=await to(async()=>Pt({...e,fromBlock:t,toBlock:t,useIndexer:!1}),{delay:500,retries:3});n.length&&e.onEvents(n)}})}const ro=()=>{const e=Nt().pay;return e.startsWith("localhost")?`http://${e}`:`https://${e}`},so=()=>`${ro()}/buy-with-crypto/history/v1`;async function oo(e){try{const t=new URLSearchParams;t.append("walletAddress",e.walletAddress),t.append("start",e.start.toString()),t.append("count",e.count.toString());const n=t.toString(),r=`${so()}?${n}`,s=await I(e.client)(r);if(!s.ok){const i=await s.text().catch(()=>null);throw new Error(`HTTP error! status: ${s.status} - ${s.statusText}: ${i||"unknown error"}`)}return(await s.json()).result}catch(t){throw new Error(`Fetch failed: ${t}`)}}const io=[Un.id,jn.id,Ln.id,Mn.id,Fn.id,qn.id,34443,919,42220,44787,204,5611];async function ao(e){if(e.id===1337||e.id===31337)return!1;if(io.includes(e.id))return!0;try{const{getChainMetadata:t}=await _(async()=>{const{getChainMetadata:r}=await import("./utils-CozXUO91.js");return{getChainMetadata:r}},__vite__mapDeps([1,2]));return(await t(e)).stackType==="optimism_bedrock"}catch{return!1}}async function co(e){const{transaction:t}=e,n=e.from??e.account?.address??void 0,r=await L(t.gas)||await Ge({from:n,transaction:t}),s=await Cn(t.client,t.chain),o=s.maxFeePerGas||s.gasPrice;if(o===void 0)throw new Error(`Unable to determine gas price for chain ${t.chain.id}`);let i;if(await ao(t.chain)){const{estimateL1Fee:c}=await _(async()=>{const{estimateL1Fee:l}=await import("./estimate-l1-fee-C2ptcVct.js");return{estimateL1Fee:l}},__vite__mapDeps([20,8,6,9,10,11,2,12,15,16,17,1,18]));i=await c({transaction:t})}else i=0n;const a=r*o+i;return{ether:it(a),wei:a}}async function uo(e){try{const t=await(async()=>{if(e.toAmount){const l=ne({address:e.toTokenAddress,chain:te(e.toChainId),client:e.client}),h=l.address.toLowerCase()===Ee?18:await _e({contract:l}),u=we(e.toAmount,h);return at({amount:u,client:e.client,destinationChainId:e.toChainId,destinationTokenAddress:e.toTokenAddress,originChainId:e.fromChainId,originTokenAddress:e.fromTokenAddress,paymentLinkId:e.paymentLinkId,purchaseData:e.purchaseData,receiver:e.toAddress,sender:e.fromAddress})}else if(e.fromAmount){const l=ne({address:e.fromTokenAddress,chain:te(e.fromChainId),client:e.client}),h=await _e({contract:l}),u=we(e.fromAmount,h);return ct({amount:u,client:e.client,destinationChainId:e.toChainId,destinationTokenAddress:e.toTokenAddress,originChainId:e.fromChainId,originTokenAddress:e.fromTokenAddress,paymentLinkId:e.paymentLinkId,purchaseData:e.purchaseData,receiver:e.toAddress,sender:e.fromAddress})}throw new Error("Invalid quote request, must provide either `fromAmount` or `toAmount`")})(),n=t.steps[0];if(!n)throw new Error("This quote is incompatible with getBuyWithCryptoQuote. Please use Bridge.Buy.prepare instead.");const r=n.transactions.filter(l=>l.action==="approval");if(r.length>1)throw new Error("This quote is incompatible with getBuyWithCryptoQuote. Please use Bridge.Buy.prepare instead.");const s=r[0],o=n.transactions.filter(l=>l.action!=="approval");if(o.length>1)throw new Error("This quote is incompatible with getBuyWithCryptoQuote. Please use Bridge.Buy.prepare instead.");const i=o[0];if(!i)throw new Error("This quote is incompatible with getBuyWithCryptoQuote. Please use Bridge.Buy.prepare instead.");let a;if(s){const l=tt(["function approve(address spender, uint256 amount)"]),[h,u]=nt(l,s.data);a={amountWei:u.toString(),chainId:n.originToken.chainId,spenderAddress:h,tokenAddress:n.originToken.address}}return{approvalData:a,client:e.client,paymentTokens:[{amount:C(t.originAmount,n.originToken.decimals).toString(),amountUSDCents:Number(C(t.originAmount,n.originToken.decimals))*(n.originToken.prices.USD||0)*100,amountWei:t.originAmount.toString(),token:{chainId:n.originToken.chainId,decimals:n.originToken.decimals,name:n.originToken.name,priceUSDCents:(n.originToken.prices.USD||0)*100,symbol:n.originToken.symbol,tokenAddress:n.originToken.address}}],processingFees:[{amount:"0",amountUSDCents:0,amountWei:"0",token:{chainId:n.originToken.chainId,decimals:n.originToken.decimals,name:n.originToken.name,priceUSDCents:(n.originToken.prices.USD||0)*100,symbol:n.originToken.symbol,tokenAddress:n.originToken.address}}],swapDetails:{estimated:{durationSeconds:n.estimatedExecutionTimeMs/1e3,feesUSDCents:0,fromAmountUSDCents:Number(C(t.originAmount,n.originToken.decimals))*(n.originToken.prices.USD||0)*100,gasCostUSDCents:0,slippageBPS:0,toAmountMinUSDCents:Number(C(t.destinationAmount,n.destinationToken.decimals))*(n.destinationToken.prices.USD||0)*100,toAmountUSDCents:Number(C(t.destinationAmount,n.destinationToken.decimals))*(n.destinationToken.prices.USD||0)*100},fromAddress:t.intent.sender,fromAmount:C(t.originAmount,n.originToken.decimals).toString(),fromAmountWei:t.originAmount.toString(),fromToken:{chainId:n.originToken.chainId,decimals:n.originToken.decimals,name:n.originToken.name,priceUSDCents:(n.originToken.prices.USD||0)*100,symbol:n.originToken.symbol,tokenAddress:n.originToken.address},maxSlippageBPS:0,toAddress:t.intent.receiver,toAmount:C(t.destinationAmount,n.destinationToken.decimals).toString(),toAmountMin:C(t.destinationAmount,n.destinationToken.decimals).toString(),toAmountMinWei:t.destinationAmount.toString(),toAmountWei:t.destinationAmount.toString(),toToken:{chainId:n.destinationToken.chainId,decimals:n.destinationToken.decimals,name:n.destinationToken.name,priceUSDCents:(n.destinationToken.prices.USD||0)*100,symbol:n.destinationToken.symbol,tokenAddress:n.destinationToken.address}},transactionRequest:{...i,extraGas:50000n}}}catch(t){throw console.error("Error getting buy with crypto quote",t),t}}async function lo(e){try{if(!e.transactionHash)throw new Error("Transaction hash is required");const t=await dt({chainId:e.chainId,client:e.client,transactionHash:e.transactionHash});switch(t.status){case"COMPLETED":{const n=t.transactions?.find(s=>s.chainId===e.chainId),r=t.transactions?.find(s=>s.chainId!==e.chainId);return ge({destinationAmount:t.destinationAmount,destinationChainId:t.destinationChainId,destinationToken:t.destinationToken,destinationTokenAddress:t.destinationTokenAddress,destinationTransaction:r,originAmount:t.originAmount,originChainId:t.originChainId,originToken:t.originToken,originTokenAddress:t.originTokenAddress,originTransaction:n,paymentId:t.paymentId,purchaseData:t.purchaseData,receiver:t.receiver,sender:t.sender,status:t.status})}case"PENDING":return ge({destinationChainId:t.destinationChainId,destinationToken:t.destinationToken,destinationTokenAddress:t.destinationTokenAddress,originAmount:t.originAmount,originChainId:t.originChainId,originToken:t.originToken,originTokenAddress:t.originTokenAddress,paymentId:t.paymentId,purchaseData:t.purchaseData,receiver:t.receiver,sender:t.sender,status:t.status});case"FAILED":{const n=t.transactions?.find(s=>s.chainId===e.chainId),r=t.transactions?.find(s=>s.chainId!==e.chainId);return ge({destinationChainId:0,destinationToken:void 0,destinationTokenAddress:"",destinationTransaction:r,originAmount:BigInt(0),originChainId:0,originToken:void 0,originTokenAddress:"",originTransaction:n,paymentId:"",purchaseData:t.purchaseData,receiver:"",sender:"",status:t.status})}default:return{status:"NOT_FOUND"}}}catch(t){throw console.error("Fetch error:",t),new Error(`Fetch failed: ${t}`)}}function ge(e){const{originTransaction:t,destinationTransaction:n,status:r,purchaseData:s,originAmount:o,destinationAmount:i,originTokenAddress:a,destinationTokenAddress:c,originChainId:l,destinationChainId:h,sender:u,receiver:d,originToken:f,destinationToken:m}=e;return{bridge:"STARPORT",destination:{amount:m?V(i??BigInt(0),m.decimals).toString():"",amountUSDCents:0,amountWei:i?.toString()??"",completedAt:new Date().toISOString(),explorerLink:"",token:{chainId:h,decimals:m?.decimals??18,name:m?.name??"",priceUSDCents:0,symbol:m?.symbol??"",tokenAddress:c},transactionHash:n?.transactionHash??""},fromAddress:u,purchaseData:s,quote:{createdAt:new Date().toISOString(),estimated:{durationSeconds:0,feesUSDCents:0,fromAmountUSDCents:0,gasCostUSDCents:0,slippageBPS:0,toAmountMinUSDCents:0,toAmountUSDCents:0},fromAmount:f?V(o,f.decimals).toString():"",fromAmountWei:o.toString(),fromToken:{chainId:l,decimals:f?.decimals??18,name:f?.name??"",priceUSDCents:0,symbol:f?.symbol??"",tokenAddress:a},toAmount:m&&i?V(i,m.decimals).toString():"",toAmountMin:m?V(i??BigInt(0),m.decimals).toString():"",toAmountMinWei:i?i.toString():"",toAmountWei:i?i.toString():"",toToken:{chainId:h,decimals:m?.decimals??18,name:m?.name??"",priceUSDCents:0,symbol:m?.symbol??"",tokenAddress:c}},source:{amount:f?V(o,f.decimals).toString():"",amountUSDCents:0,amountWei:o.toString(),completedAt:new Date().toISOString(),explorerLink:"",token:{chainId:l,decimals:f?.decimals??18,name:f?.name??"",priceUSDCents:0,symbol:f?.symbol??"",tokenAddress:a},transactionHash:t?.transactionHash??""},status:r,subStatus:r==="COMPLETED"?"SUCCESS":"NONE",swapType:t?.chainId===n?.chainId?"SAME_CHAIN":"CROSS_CHAIN",toAddress:d}}async function fo(e){try{const t=ne({address:e.tokenAddress,chain:te(e.chainId),client:e.client}),n=t.address.toLowerCase()===Ee?18:await _e({contract:t}),r=we(e.amount,n),s=await ut({amount:r,chainId:e.chainId,client:e.client,feePayer:e.feePayer,paymentLinkId:e.paymentLinkId,purchaseData:e.purchaseData,receiver:e.toAddress,sender:e.fromAddress,tokenAddress:e.tokenAddress}),o=s.steps[0];if(!o)throw new Error("This quote is incompatible with getBuyWithCryptoTransfer. Please use Bridge.Transfer.prepare instead.");const i=o.transactions.filter(d=>d.action==="approval");if(i.length>1)throw new Error("This quote is incompatible with getBuyWithCryptoTransfer. Please use Bridge.Transfer.prepare instead.");const a=i[0];let c;if(a){const d=tt(["function approve(address spender, uint256 amount)"]),[f,m]=nt(d,a.data);c={amountWei:m.toString(),chainId:o.originToken.chainId,spenderAddress:f,tokenAddress:o.originToken.address}}const l=o.transactions.filter(d=>d.action!=="approval");if(l.length>1)throw new Error("This quote is incompatible with getBuyWithCryptoTransfer. Please use Bridge.Transfer.prepare instead.");const h=l[0];if(!h)throw new Error("This quote is incompatible with getBuyWithCryptoTransfer. Please use Bridge.Transfer.prepare instead.");return{approvalData:c,client:e.client,estimatedGasCostUSDCents:0,fromAddress:e.fromAddress,paymentToken:{amount:C(s.originAmount,o.originToken.decimals).toString(),amountUSDCents:Number(C(s.originAmount,o.originToken.decimals))*(o.originToken.prices.USD||0)*100,amountWei:s.originAmount.toString(),token:{chainId:o.originToken.chainId,decimals:o.originToken.decimals,name:o.originToken.name,priceUSDCents:(o.originToken.prices.USD||0)*100,symbol:o.originToken.symbol,tokenAddress:o.originToken.address}},processingFee:{amount:e.feePayer==="sender"?C(s.originAmount-s.destinationAmount,o.originToken.decimals).toString():"0",amountUSDCents:e.feePayer==="sender"?Number(C(s.originAmount-s.destinationAmount,o.originToken.decimals))*(o.originToken.prices.USD||0)*100:0,amountWei:e.feePayer==="sender"?(s.originAmount-s.destinationAmount).toString():"0",token:{chainId:o.originToken.chainId,decimals:o.originToken.decimals,name:o.originToken.name,priceUSDCents:(o.originToken.prices.USD||0)*100,symbol:o.originToken.symbol,tokenAddress:o.originToken.address}},toAddress:e.toAddress,transactionRequest:{...h,extraGas:50000n}}}catch(t){throw console.error("Error getting buy with crypto transfer",t),t}}const{decodeAbiParameters:ho,formatTransactionRequest:mo}=await q("viem");async function po(e){const[t,n,r,s]=await Promise.all([ie(e.transaction),L(e.transaction.to),L(e.transaction.accessList),L(e.transaction.value)]),o=e.from??e.account?.address??void 0,i=mo({accessList:r,data:t,from:o?F(o):void 0,to:n?F(n):void 0,value:s}),a=Se(e.transaction);try{const c=await rt(a,i);if(!e.transaction.__preparedMethod)return c;const l=await e.transaction.__preparedMethod(),h=ho(l[2],c);return Array.isArray(h)&&h.length===1?h[0]:h}catch(c){throw await Ft({contract:e.transaction.__contract,error:c,fromAddress:o})}}function go(e){return async t=>{if(typeof e=="string"&&e.startsWith("function "))return nn(e);const r=(t.abi?.length?t.abi:await Ke(t)).find(s=>s.type!=="function"?!1:s.name===e);if(!r)throw new Error(`could not find function with name "${e}" in abi`);return r}}function yo(e){return typeof e=="object"&&e!==null}function We(e,t=[]){return yo(e)&&t.every(n=>n in e)}function wo(e){return We(e,["__contract"])&&We(e.__contract,["address","chain"])&&typeof e.__contract.address=="string"}async function _o({address:e,signature:t,client:n,chain:r,accountFactory:s,message:o,domain:i,primaryType:a,types:c}){const l=rn({domain:i,message:o,primaryType:a,types:c});if(!de(t))return!1;try{if(sn({payload:l,signature:on(t)}).toLowerCase()===e.toLowerCase())return!0}catch{}return an({accountFactory:s,address:e,chain:r,client:n,hash:l,signature:t})}async function bo(e){const{account:t,request:n}=e;if(typeof t.signAuthorization>"u")throw new Error("This account type does not yet support signing EIP-7702 authorizations");return t.signAuthorization(n)}const Lo=Object.freeze(Object.defineProperty({__proto__:null,ADDRESS_ZERO:ze,Bridge:as,Engine:Ls,Insight:Zs,NATIVE_TOKEN_ADDRESS:Ee,ZERO_ADDRESS:ze,boolToBytes:qt,boolToHex:Kt,bytesToBigInt:cn,bytesToBool:dn,bytesToNumber:un,bytesToString:ln,concatHex:fn,createThirdwebClient:gs,defineChain:re,deploySmartAccount:hn,encode:ie,estimateGas:Ge,estimateGasCost:co,eth_blockNumber:st,eth_call:rt,eth_estimateGas:Sn,eth_gasPrice:xn,eth_getBalance:mn,eth_getBlockByHash:Gs,eth_getBlockByNumber:$n,eth_getCode:pn,eth_getLogs:ve,eth_getStorageAt:Rn,eth_getTransactionByHash:Ys,eth_getTransactionCount:Nn,eth_getTransactionReceipt:vn,eth_maxPriorityFeePerGas:On,eth_sendRawTransaction:gn,fromBytes:yn,fromGwei:Pn,fromHex:Gt,getAddress:F,getBuyWithCryptoHistory:oo,getBuyWithCryptoQuote:uo,getBuyWithCryptoStatus:lo,getBuyWithCryptoTransfer:fo,getContract:ne,getContractEvents:Pt,getGasPrice:Dn,getRpcClient:Se,getUser:wn,hexToBigInt:Jt,hexToBool:Qt,hexToBytes:Ht,hexToNumber:Yt,hexToString:Xt,hexToUint8Array:Je,isAddress:Ve,isBaseTransactionOptions:wo,isHex:de,keccak256:Wt,numberToBytes:Vt,numberToHex:Z,padHex:en,parseEventLogs:et,prepareContractCall:_n,prepareEvent:ye,prepareTransaction:bn,readContract:kn,resolveMethod:go,sendAndConfirmTransaction:Hn,sendBatchTransaction:Wn,sendTransaction:Tn,serializeTransaction:An,sha256:At,signAuthorization:bo,signTransaction:In,simulateTransaction:po,stringToBytes:Ze,stringToHex:tn,toBytes:Zt,toEther:it,toHex:Ye,toSerializableTransaction:Xe,toTokens:V,toUnits:zn,toWei:Bn,uint8ArrayToHex:Qe,verifyTypedData:_o,waitForReceipt:En,watchBlockNumber:ot,watchContractEvents:no},Symbol.toStringTag,{value:"Module"}));export{qs as g,Lo as t};
|
|
27
|
+
})));`),d.write(`newResult[${X(w)}] = ${b}.value`)}d.write("payload.value = newResult;"),d.write("return payload;");const g=d.compile();return(w,b)=>g(u,w,b)};let s;const o=ce,i=!lt.jitless,c=i&&or.value,l=t.catchall;let h;e._zod.parse=(u,d)=>{h??(h=n.value);const f=u.value;if(!o(f))return u.issues.push({expected:"object",code:"invalid_type",input:f,inst:e}),u;const m=[];if(i&&c&&d?.async===!1&&d.jitless!==!0)s||(s=r(t.shape)),u=s(u,d);else{u.value={};const b=h.shape;for(const k of h.keys){const B=b[k],N=B._zod.run({value:f[k],issues:[]},d),$=B._zod.optin==="optional"&&B._zod.optout==="optional";N instanceof Promise?m.push(N.then(H=>$?Re(H,u,k,f):oe(H,u,k))):$?Re(N,u,k,f):oe(N,u,k)}}if(!l)return m.length?Promise.all(m).then(()=>u):u;const p=[],y=h.keySet,g=l._zod,w=g.def.type;for(const b of Object.keys(f)){if(y.has(b))continue;if(w==="never"){p.push(b);continue}const k=g.run({value:f[b],issues:[]},d);k instanceof Promise?m.push(k.then(B=>oe(B,u,b))):oe(k,u,b)}return p.length&&u.issues.push({code:"unrecognized_keys",keys:p,input:f,inst:e}),m.length?Promise.all(m).then(()=>u):u}});function Ne(e,t,n,r){for(const s of e)if(s.issues.length===0)return t.value=s.value,t;return t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(s=>s.issues.map(o=>Q(o,r,J())))}),t}const $r=T("$ZodUnion",(e,t)=>{S.init(e,t),R(e._zod,"optin",()=>t.options.some(n=>n._zod.optin==="optional")?"optional":void 0),R(e._zod,"optout",()=>t.options.some(n=>n._zod.optout==="optional")?"optional":void 0),R(e._zod,"values",()=>{if(t.options.every(n=>n._zod.values))return new Set(t.options.flatMap(n=>Array.from(n._zod.values)))}),R(e._zod,"pattern",()=>{if(t.options.every(n=>n._zod.pattern)){const n=t.options.map(r=>r._zod.pattern);return new RegExp(`^(${n.map(r=>ft(r.source)).join("|")})$`)}}),e._zod.parse=(n,r)=>{let s=!1;const o=[];for(const i of t.options){const a=i._zod.run({value:n.value,issues:[]},r);if(a instanceof Promise)o.push(a),s=!0;else{if(a.issues.length===0)return a;o.push(a)}}return s?Promise.all(o).then(i=>Ne(i,n,e,r)):Ne(o,n,e,r)}}),Or=T("$ZodDiscriminatedUnion",(e,t)=>{$r.init(e,t);const n=e._zod.parse;R(e._zod,"propValues",()=>{const s={};for(const o of t.options){const i=o._zod.propValues;if(!i||Object.keys(i).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(o)}"`);for(const[a,c]of Object.entries(i)){s[a]||(s[a]=new Set);for(const l of c)s[a].add(l)}}return s});const r=Ce(()=>{const s=t.options,o=new Map;for(const i of s){const a=i._zod.propValues[t.discriminator];if(!a||a.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(i)}"`);for(const c of a){if(o.has(c))throw new Error(`Duplicate discriminator value "${String(c)}"`);o.set(c,i)}}return o});e._zod.parse=(s,o)=>{const i=s.value;if(!ce(i))return s.issues.push({code:"invalid_type",expected:"object",input:i,inst:e}),s;const a=r.value.get(i?.[t.discriminator]);return a?a._zod.run(s,o):t.unionFallback?n(s,o):(s.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",input:i,path:[t.discriminator],inst:e}),s)}}),Pr=T("$ZodRecord",(e,t)=>{S.init(e,t),e._zod.parse=(n,r)=>{const s=n.value;if(!ir(s))return n.issues.push({expected:"record",code:"invalid_type",input:s,inst:e}),n;const o=[];if(t.keyType._zod.values){const i=t.keyType._zod.values;n.value={};for(const c of i)if(typeof c=="string"||typeof c=="number"||typeof c=="symbol"){const l=t.valueType._zod.run({value:s[c],issues:[]},r);l instanceof Promise?o.push(l.then(h=>{h.issues.length&&n.issues.push(...W(c,h.issues)),n.value[c]=h.value})):(l.issues.length&&n.issues.push(...W(c,l.issues)),n.value[c]=l.value)}let a;for(const c in s)i.has(c)||(a=a??[],a.push(c));a&&a.length>0&&n.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:a})}else{n.value={};for(const i of Reflect.ownKeys(s)){if(i==="__proto__")continue;const a=t.keyType._zod.run({value:i,issues:[]},r);if(a instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(a.issues.length){n.issues.push({origin:"record",code:"invalid_key",issues:a.issues.map(l=>Q(l,r,J())),input:i,path:[i],inst:e}),n.value[a.value]=a.value;continue}const c=t.valueType._zod.run({value:s[i],issues:[]},r);c instanceof Promise?o.push(c.then(l=>{l.issues.length&&n.issues.push(...W(i,l.issues)),n.value[a.value]=l.value})):(c.issues.length&&n.issues.push(...W(i,c.issues)),n.value[a.value]=c.value)}}return o.length?Promise.all(o).then(()=>n):n}}),Dr=T("$ZodEnum",(e,t)=>{S.init(e,t);const n=nr(t.entries);e._zod.values=new Set(n),e._zod.pattern=new RegExp(`^(${n.filter(r=>ar.has(typeof r)).map(r=>typeof r=="string"?mt(r):r.toString()).join("|")})$`),e._zod.parse=(r,s)=>{const o=r.value;return e._zod.values.has(o)||r.issues.push({code:"invalid_value",values:n,input:o,inst:e}),r}}),zr=T("$ZodLiteral",(e,t)=>{S.init(e,t),e._zod.values=new Set(t.values),e._zod.pattern=new RegExp(`^(${t.values.map(n=>typeof n=="string"?mt(n):n?n.toString():String(n)).join("|")})$`),e._zod.parse=(n,r)=>{const s=n.value;return e._zod.values.has(s)||n.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),n}}),Br=T("$ZodOptional",(e,t)=>{S.init(e,t),e._zod.optin="optional",e._zod.optout="optional",R(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),R(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${ft(n.source)})?$`):void 0}),e._zod.parse=(n,r)=>t.innerType._zod.optin==="optional"?t.innerType._zod.run(n,r):n.value===void 0?n:t.innerType._zod.run(n,r)}),Rr=T("$ZodCustom",(e,t)=>{kr.init(e,t),S.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=n=>{const r=n.value,s=t.fn(r);if(s instanceof Promise)return s.then(o=>Ue(o,n,r,e));Ue(s,n,r,e)}});function Ue(e,t,n,r){if(!e){const s={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(s.params=r._zod.def.params),t.issues.push(ur(s))}}function Nr(e,t){return new e({type:"string",...O(t)})}function Ur(e,t){return new e({type:"number",checks:[],...O(t)})}function jr(e,t){return new e({type:"number",coerce:!0,checks:[],...O(t)})}function Lr(e,t){return new e({type:"bigint",coerce:!0,...O(t)})}function Mr(e){return new e({type:"unknown"})}function Fr(e,t,n){return new e({type:"custom",check:"custom",fn:t,...O(n)})}const x=T("ZodMiniType",(e,t)=>{if(!e._zod)throw new Error("Uninitialized schema in ZodMiniType.");S.init(e,t),e.def=t,e.parse=(n,r)=>hr(e,n,r,{callee:e.parse}),e.safeParse=(n,r)=>gt(e,n,r),e.parseAsync=async(n,r)=>pr(e,n,r,{callee:e.parseAsync}),e.safeParseAsync=async(n,r)=>yt(e,n,r),e.check=(...n)=>e.clone({...t,checks:[...t.checks??[],...n.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),e.clone=(n,r)=>cr(e,n,r),e.brand=()=>e,e.register=(n,r)=>(n.add(e,r),e)}),qr=T("ZodMiniString",(e,t)=>{Ir.init(e,t),x.init(e,t)});function E(e){return Nr(qr,e)}const wt=T("ZodMiniNumber",(e,t)=>{vr.init(e,t),x.init(e,t)});function Hr(e){return Ur(wt,e)}const Wr=T("ZodMiniBigInt",(e,t)=>{Er.init(e,t),x.init(e,t)}),Vr=T("ZodMiniUnknown",(e,t)=>{Sr.init(e,t),x.init(e,t)});function _t(){return Mr(Vr)}const Zr=T("ZodMiniArray",(e,t)=>{Cr.init(e,t),x.init(e,t)});function Kr(e,t){return new Zr({type:"array",element:e,...O(t)})}const Gr=T("ZodMiniObject",(e,t)=>{xr.init(e,t),x.init(e,t),R(e,"shape",()=>t.shape)});function D(e,t){const n={type:"object",get shape(){return sr(this,"shape",{...e}),this.shape},...O(t)};return new Gr(n)}const Jr=T("ZodMiniDiscriminatedUnion",(e,t)=>{Or.init(e,t),x.init(e,t)});function xe(e,t,n){return new Jr({type:"union",options:t,discriminator:e,...O(n)})}const Qr=T("ZodMiniRecord",(e,t)=>{Pr.init(e,t),x.init(e,t)});function Yr(e,t,n){return new Qr({type:"record",keyType:e,valueType:t,...O(n)})}const Xr=T("ZodMiniEnum",(e,t)=>{Dr.init(e,t),x.init(e,t)});function be(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new Xr({type:"enum",entries:n,...O(t)})}const es=T("ZodMiniLiteral",(e,t)=>{zr.init(e,t),x.init(e,t)});function M(e,t){return new es({type:"literal",values:Array.isArray(e)?e:[e],...O(t)})}const ts=T("ZodMiniOptional",(e,t)=>{Br.init(e,t),x.init(e,t)});function K(e){return new ts({type:"optional",innerType:e})}const ns=T("ZodMiniCustom",(e,t)=>{Rr.init(e,t),x.init(e,t)});function bt(e,t={}){return Fr(ns,e,t)}function ee(e){return jr(wt,e)}function ke(e){return Lr(Wr,e)}const kt=E().check(bt(de,{message:"Invalid hex string"})),G=E().check(bt(Ve,{message:"Invalid address"})),Te=D({address:G,chainId:ee(),decimals:ee(),iconUri:K(E()),name:E(),priceUsd:ee(),symbol:E()}),rs=xe("version",[D({data:D({}),type:M("pay.onchain-transaction"),version:M(1)}),D({data:D({action:be(["TRANSFER","BUY","SELL"]),clientId:E(),destinationAmount:ke(),destinationToken:Te,developerFeeBps:ee(),developerFeeRecipient:G,originAmount:ke(),originToken:Te,paymentId:E(),paymentLinkId:K(E()),purchaseData:K(Yr(E(),_t())),receiver:G,sender:G,status:be(["PENDING","FAILED","COMPLETED"]),transactions:Kr(D({chainId:ee(),transactionHash:kt})),type:E()}),type:M("pay.onchain-transaction"),version:M(2)})]),ss=xe("version",[D({data:D({}),type:M("pay.onramp-transaction"),version:M(1)}),D({data:D({amount:ke(),currency:E(),currencyAmount:Hr(),id:E(),onramp:E(),paymentLinkId:K(E()),purchaseData:_t(),receiver:G,sender:K(G),status:be(["PENDING","COMPLETED","FAILED"]),token:Te,transactionHash:K(kt)}),type:M("pay.onramp-transaction"),version:M(2)})]),os=xe("type",[rs,ss]);async function Tt(e,t,n,r=300,s){const o=t["x-payload-signature"]||t["x-pay-signature"],i=t["x-timestamp"]||t["x-pay-timestamp"];if(!o||!i)throw new Error("Missing required webhook headers: signature or timestamp");const a=Math.floor(Date.now()/1e3),c=Number.parseInt(i,10),l=Math.abs(a-c);if(l>r)throw new Error(`Webhook timestamp is too old. Difference: ${l}s, tolerance: ${r}s`);const h=new TextEncoder,u=await crypto.subtle.importKey("raw",h.encode(n),{hash:"SHA-256",name:"HMAC"},!1,["sign"]),d=await crypto.subtle.sign("HMAC",u,h.encode(`${i}.${e}`));if(Array.from(new Uint8Array(d)).map(y=>y.toString(16).padStart(2,"0")).join("")!==o)throw new Error("Invalid webhook signature");let m;try{m=JSON.parse(e)}catch{throw new Error("Invalid webhook payload: not valid JSON")}const p=os.parse(m);if(p.version===1)throw new Error("Invalid webhook payload: version 1 is no longer supported, please upgrade to webhook version 2.");if(s){if(s.receiverAddress&&p.data.receiver.toLowerCase()!==s.receiverAddress.toLowerCase())throw new Error(`Verification Failed: receiverAddress mismatch, Expected: ${s.receiverAddress}, Received: ${p.data.receiver}`);if(s.destinationTokenAddress){if("destinationToken"in p.data){if(p.data.destinationToken.address.toLowerCase()!==s.destinationTokenAddress.toLowerCase())throw new Error(`Verification Failed: destinationTokenAddress mismatch, Expected: ${s.destinationTokenAddress}, Received: ${p.data.destinationToken.address}`)}else if("onramp"in p.data&&p.data.token.address.toLowerCase()!==s.destinationTokenAddress.toLowerCase())throw new Error(`Verification Failed: destinationTokenAddress mismatch, Expected: ${s.destinationTokenAddress}, Received: ${p.data.token.address}`)}if(s.destinationChainId){if("destinationToken"in p.data){if(p.data.destinationToken.chainId!==s.destinationChainId)throw new Error(`Verification Failed: destinationChainId mismatch, Expected: ${s.destinationChainId}, Received: ${p.data.destinationToken.chainId}`)}else if("onramp"in p.data&&p.data.token.chainId!==s.destinationChainId)throw new Error(`Verification Failed: destinationChainId mismatch, Expected: ${s.destinationChainId}, Received: ${p.data.token.chainId}`)}if(s.minDestinationAmount){if("destinationAmount"in p.data){if(p.data.destinationAmount<s.minDestinationAmount)throw new Error(`Verification Failed: minDestinationAmount, Expected minimum amount to be ${s.minDestinationAmount}, Received: ${p.data.destinationAmount}`)}else if("onramp"in p.data&&p.data.amount<s.minDestinationAmount)throw new Error(`Verification Failed: minDestinationAmount, Expected minimum amount to be ${s.minDestinationAmount}, Received: ${p.data.amount}`)}}return p}const is=Object.freeze(Object.defineProperty({__proto__:null,parse:Tt},Symbol.toStringTag,{value:"Module"})),as=Object.freeze(Object.defineProperty({__proto__:null,Buy:Zn,Onramp:Qn,Sell:Xn,Transfer:tr,Webhook:is,chains:Kn,parse:Tt,status:dt,tokens:er},Symbol.toStringTag,{value:"Module"}));function cs(e,t,n,r){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,n,r);const s=BigInt(32),o=BigInt(4294967295),i=Number(n>>s&o),a=Number(n&o),c=r?4:0,l=r?0:4;e.setUint32(t+c,i,r),e.setUint32(t+l,a,r)}function ds(e,t,n){return e&t^~e&n}function us(e,t,n){return e&t^e&n^t&n}class ls extends Ut{constructor(t,n,r,s){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=n,this.padOffset=r,this.isLE=s,this.buffer=new Uint8Array(t),this.view=fe(this.buffer)}update(t){Pe(this);const{view:n,buffer:r,blockLen:s}=this;t=jt(t);const o=t.length;for(let i=0;i<o;){const a=Math.min(s-this.pos,o-i);if(a===s){const c=fe(t);for(;s<=o-i;i+=s)this.process(c,i);continue}r.set(t.subarray(i,i+a),this.pos),this.pos+=a,i+=a,this.pos===s&&(this.process(n,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){Pe(this),Lt(t,this),this.finished=!0;const{buffer:n,view:r,blockLen:s,isLE:o}=this;let{pos:i}=this;n[i++]=128,this.buffer.subarray(i).fill(0),this.padOffset>s-i&&(this.process(r,0),i=0);for(let u=i;u<s;u++)n[u]=0;cs(r,s-8,BigInt(this.length*8),o),this.process(r,0);const a=fe(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=c/4,h=this.get();if(l>h.length)throw new Error("_sha2: outputLen bigger than state");for(let u=0;u<l;u++)a.setUint32(4*u,h[u],o)}digest(){const{buffer:t,outputLen:n}=this;this.digestInto(t);const r=t.slice(0,n);return this.destroy(),r}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:n,buffer:r,length:s,finished:o,destroyed:i,pos:a}=this;return t.length=s,t.pos=a,t.finished=o,t.destroyed=i,s%n&&t.buffer.set(r),t}}const fs=new Uint32Array([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]),U=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),j=new Uint32Array(64);class hs extends ls{constructor(t=32){super(64,t,8,!1),this.A=U[0]|0,this.B=U[1]|0,this.C=U[2]|0,this.D=U[3]|0,this.E=U[4]|0,this.F=U[5]|0,this.G=U[6]|0,this.H=U[7]|0}get(){const{A:t,B:n,C:r,D:s,E:o,F:i,G:a,H:c}=this;return[t,n,r,s,o,i,a,c]}set(t,n,r,s,o,i,a,c){this.A=t|0,this.B=n|0,this.C=r|0,this.D=s|0,this.E=o|0,this.F=i|0,this.G=a|0,this.H=c|0}process(t,n){for(let u=0;u<16;u++,n+=4)j[u]=t.getUint32(n,!1);for(let u=16;u<64;u++){const d=j[u-15],f=j[u-2],m=P(d,7)^P(d,18)^d>>>3,p=P(f,17)^P(f,19)^f>>>10;j[u]=p+j[u-7]+m+j[u-16]|0}let{A:r,B:s,C:o,D:i,E:a,F:c,G:l,H:h}=this;for(let u=0;u<64;u++){const d=P(a,6)^P(a,11)^P(a,25),f=h+d+ds(a,c,l)+fs[u]+j[u]|0,p=(P(r,2)^P(r,13)^P(r,22))+us(r,s,o)|0;h=l,l=c,c=a,a=i+f|0,i=o,o=s,s=r,r=f+p|0}r=r+this.A|0,s=s+this.B|0,o=o+this.C|0,i=i+this.D|0,a=a+this.E|0,c=c+this.F|0,l=l+this.G|0,h=h+this.H|0,this.set(r,s,o,i,a,c,l,h)}roundClean(){j.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const ms=Mt(()=>new hs);function At(e,t){const n=ms(de(e,{strict:!1})?Je(e):e);return t==="bytes"?n:Qe(n)}const me=new Bt(4096);function ps(e){if(me.has(e))return me.get(e);const t=At(Ze(e)).slice(2,34);return me.set(e,t),t}function gs(e){const{clientId:t,secretKey:n,...r}=e;let s=t;if(n)if(Rt(n)){if(!t)throw new Error("clientId must be provided when using a JWT secretKey")}else s=t??ps(n);if(!s)throw new Error("clientId or secretKey must be provided");return{...r,clientId:s,secretKey:n}}const ys={bodySerializer:e=>JSON.stringify(e,(t,n)=>typeof n=="bigint"?n.toString():n)},ws=async(e,t)=>{const n=typeof t=="function"?await t(e):t;if(n)return e.scheme==="bearer"?`Bearer ${n}`:e.scheme==="basic"?`Basic ${btoa(n)}`:n},_s=e=>{switch(e){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},bs=e=>{switch(e){case"form":return",";case"pipeDelimited":return"|";case"spaceDelimited":return"%20";default:return","}},ks=e=>{switch(e){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},It=({allowReserved:e,explode:t,name:n,style:r,value:s})=>{if(!t){const a=(e?s:s.map(c=>encodeURIComponent(c))).join(bs(r));switch(r){case"label":return`.${a}`;case"matrix":return`;${n}=${a}`;case"simple":return a;default:return`${n}=${a}`}}const o=_s(r),i=s.map(a=>r==="label"||r==="simple"?e?a:encodeURIComponent(a):le({allowReserved:e,name:n,value:a})).join(o);return r==="label"||r==="matrix"?o+i:i},le=({allowReserved:e,name:t,value:n})=>{if(n==null)return"";if(typeof n=="object")throw new Error("Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.");return`${t}=${e?n:encodeURIComponent(n)}`},vt=({allowReserved:e,explode:t,name:n,style:r,value:s,valueOnly:o})=>{if(s instanceof Date)return o?s.toISOString():`${n}=${s.toISOString()}`;if(r!=="deepObject"&&!t){let c=[];Object.entries(s).forEach(([h,u])=>{c=[...c,h,e?u:encodeURIComponent(u)]});const l=c.join(",");switch(r){case"form":return`${n}=${l}`;case"label":return`.${l}`;case"matrix":return`;${n}=${l}`;default:return l}}const i=ks(r),a=Object.entries(s).map(([c,l])=>le({allowReserved:e,name:r==="deepObject"?`${n}[${c}]`:c,value:l})).join(i);return r==="label"||r==="matrix"?i+a:a},Ts=/\{[^{}]+\}/g,As=({path:e,url:t})=>{let n=t;const r=t.match(Ts);if(r)for(const s of r){let o=!1,i=s.substring(1,s.length-1),a="simple";i.endsWith("*")&&(o=!0,i=i.substring(0,i.length-1)),i.startsWith(".")?(i=i.substring(1),a="label"):i.startsWith(";")&&(i=i.substring(1),a="matrix");const c=e[i];if(c==null)continue;if(Array.isArray(c)){n=n.replace(s,It({explode:o,name:i,style:a,value:c}));continue}if(typeof c=="object"){n=n.replace(s,vt({explode:o,name:i,style:a,value:c,valueOnly:!0}));continue}if(a==="matrix"){n=n.replace(s,`;${le({name:i,value:c})}`);continue}const l=encodeURIComponent(a==="label"?`.${c}`:c);n=n.replace(s,l)}return n},Et=({allowReserved:e,array:t,object:n}={})=>s=>{const o=[];if(s&&typeof s=="object")for(const i in s){const a=s[i];if(a!=null)if(Array.isArray(a)){const c=It({allowReserved:e,explode:!0,name:i,style:"form",value:a,...t});c&&o.push(c)}else if(typeof a=="object"){const c=vt({allowReserved:e,explode:!0,name:i,style:"deepObject",value:a,...n});c&&o.push(c)}else{const c=le({allowReserved:e,name:i,value:a});c&&o.push(c)}}return o.join("&")},Is=e=>{if(!e)return"stream";const t=e.split(";")[0]?.trim();if(t){if(t.startsWith("application/json")||t.endsWith("+json"))return"json";if(t==="multipart/form-data")return"formData";if(["application/","audio/","image/","video/"].some(n=>t.startsWith(n)))return"blob";if(t.startsWith("text/"))return"text"}},vs=async({security:e,...t})=>{for(const n of e){const r=await ws(n,t.auth);if(!r)continue;const s=n.name??"Authorization";switch(n.in){case"query":t.query||(t.query={}),t.query[s]=r;break;case"cookie":t.headers.append("Cookie",`${s}=${r}`);break;case"header":default:t.headers.set(s,r);break}return}},je=e=>Es({baseUrl:e.baseUrl,path:e.path,query:e.query,querySerializer:typeof e.querySerializer=="function"?e.querySerializer:Et(e.querySerializer),url:e.url}),Es=({baseUrl:e,path:t,query:n,querySerializer:r,url:s})=>{const o=s.startsWith("/")?s:`/${s}`;let i=(e??"")+o;t&&(i=As({path:t,url:i}));let a=n?r(n):"";return a.startsWith("?")&&(a=a.substring(1)),a&&(i+=`?${a}`),i},Le=(e,t)=>{const n={...e,...t};return n.baseUrl?.endsWith("/")&&(n.baseUrl=n.baseUrl.substring(0,n.baseUrl.length-1)),n.headers=St(e.headers,t.headers),n},St=(...e)=>{const t=new Headers;for(const n of e){if(!n||typeof n!="object")continue;const r=n instanceof Headers?n.entries():Object.entries(n);for(const[s,o]of r)if(o===null)t.delete(s);else if(Array.isArray(o))for(const i of o)t.append(s,i);else o!==void 0&&t.set(s,typeof o=="object"?JSON.stringify(o):o)}return t};class pe{constructor(){Object.defineProperty(this,"_fns",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this._fns=[]}clear(){this._fns=[]}getInterceptorIndex(t){return typeof t=="number"?this._fns[t]?t:-1:this._fns.indexOf(t)}exists(t){const n=this.getInterceptorIndex(t);return!!this._fns[n]}eject(t){const n=this.getInterceptorIndex(t);this._fns[n]&&(this._fns[n]=null)}update(t,n){const r=this.getInterceptorIndex(t);return this._fns[r]?(this._fns[r]=n,t):!1}use(t){return this._fns=[...this._fns,t],this._fns.length-1}}const Ss=()=>({error:new pe,request:new pe,response:new pe}),Cs=Et({allowReserved:!1,array:{explode:!0,style:"form"},object:{explode:!0,style:"deepObject"}}),xs={"Content-Type":"application/json"},Ct=(e={})=>({...ys,headers:xs,parseAs:"auto",querySerializer:Cs,...e}),$s=(e={})=>{let t=Le(Ct(),e);const n=()=>({...t}),r=i=>(t=Le(t,i),n()),s=Ss(),o=async i=>{const a={...t,...i,fetch:i.fetch??t.fetch??globalThis.fetch,headers:St(t.headers,i.headers)};a.security&&await vs({...a,security:a.security}),a.body&&a.bodySerializer&&(a.body=a.bodySerializer(a.body)),(a.body===void 0||a.body==="")&&a.headers.delete("Content-Type");const c=je(a),l={redirect:"follow",...a};let h=new Request(c,l);for(const y of s.request._fns)y&&(h=await y(h,a));const u=a.fetch;let d=await u(h);for(const y of s.response._fns)y&&(d=await y(d,h,a));const f={request:h,response:d};if(d.ok){if(d.status===204||d.headers.get("Content-Length")==="0")return a.responseStyle==="data"?{}:{data:{},...f};const y=(a.parseAs==="auto"?Is(d.headers.get("Content-Type")):a.parseAs)??"json";let g;switch(y){case"arrayBuffer":case"blob":case"formData":case"json":case"text":g=await d[y]();break;case"stream":return a.responseStyle==="data"?d.body:{data:d.body,...f}}return y==="json"&&(a.responseValidator&&await a.responseValidator(g),a.responseTransformer&&(g=await a.responseTransformer(g))),a.responseStyle==="data"?g:{data:g,...f}}let m=await d.text();try{m=JSON.parse(m)}catch{}let p=m;for(const y of s.error._fns)y&&(p=await y(m,d,h,a));if(p=p||{},a.throwOnError)throw p;return a.responseStyle==="data"?void 0:{error:p,...f}};return{buildUrl:je,connect:i=>o({...i,method:"CONNECT"}),delete:i=>o({...i,method:"DELETE"}),get:i=>o({...i,method:"GET"}),getConfig:n,head:i=>o({...i,method:"HEAD"}),interceptors:s,options:i=>o({...i,method:"OPTIONS"}),patch:i=>o({...i,method:"PATCH"}),post:i=>o({...i,method:"POST"}),put:i=>o({...i,method:"PUT"}),request:o,setConfig:r,trace:i=>o({...i,method:"TRACE"})}},Y=$s(Ct({baseUrl:"https://engine.thirdweb.com"})),Os=e=>(e.client??Y).post({security:[{name:"x-secret-key",type:"apiKey"}],url:"/v1/write/transaction",...e,headers:{"Content-Type":"application/json",...e.headers}}),Ps=e=>(e.client??Y).post({security:[{name:"x-secret-key",type:"apiKey"}],url:"/v1/sign/message",...e,headers:{"Content-Type":"application/json",...e.headers}}),Ds=e=>(e.client??Y).post({security:[{name:"x-secret-key",type:"apiKey"}],url:"/v1/sign/typed-data",...e,headers:{"Content-Type":"application/json",...e.headers}}),zs=e=>(e?.client??Y).get({security:[{name:"x-secret-key",type:"apiKey"}],url:"/v1/accounts",...e}),Bs=e=>(e?.client??Y).post({security:[{name:"x-secret-key",type:"apiKey"}],url:"/v1/accounts",...e,headers:{"Content-Type":"application/json",...e?.headers}}),xt=e=>(e?.client??Y).post({security:[{name:"x-secret-key",type:"apiKey"}],url:"/v1/transactions/search",...e,headers:{"Content-Type":"application/json",...e?.headers}});function Me(e){return"result"in e}const{stringify:Fe}=await q("viem");async function Rs(e){const{client:t,label:n}=e,r=await Bs({baseUrl:v("engineCloud"),body:{label:n},bodySerializer:Fe,fetch:I(t)});if(r.error)throw new Error(`Error creating server wallet with label ${n}: ${Fe(r.error)}`);const s=r.data?.result;if(!s)throw new Error(`No server wallet created with label ${n}`);return s}async function $t(e){const{client:t,transactionId:n}=e,r=await xt({baseUrl:v("engineCloud"),body:{filters:[{field:"id",operation:"OR",values:[n]}]},bodySerializer:A,fetch:I(t)});if(r.error)throw new Error(`Error searching for transaction ${n}: ${A(r.error)}`);const s=r.data?.result?.transactions?.[0];if(!s)throw new Error(`Transaction ${n} not found`);return{...s.executionResult,cancelledAt:s.cancelledAt,chain:te(Number(s.chainId)),confirmedAt:s.confirmedAt,createdAt:s.createdAt,from:s.from??void 0,id:s.id}}const{stringify:qe}=await q("viem");async function Ns(e){const{client:t}=e,n=await zs({baseUrl:v("engineCloud"),bodySerializer:qe,fetch:I(t),query:{limit:e.limit,page:e.page}});if(n.error)throw new Error(`Error listing server wallets: ${qe(n.error)}`);const r=n.data?.result;if(!r)throw new Error("No server wallets found");return r}async function Us(e){const{client:t,filters:n,pageSize:r=100,page:s=1}=e,o=await xt({baseUrl:v("engineCloud"),body:{filters:n,limit:r,page:s},bodySerializer:A,fetch:I(t)});if(o.error)throw new Error(`Error searching for transaction with filters ${A(n)}: ${A(o.error)}`);const i=o.data?.result;if(!i)throw new Error(`No transactions found with filters ${A(n)}`);return i}const{stringify:He}=await q("viem");async function Ae(e){const t=Date.now(),n=e.timeoutInSeconds?e.timeoutInSeconds*1e3:5*60*1e3;for(;Date.now()-t<n;){const r=await $t(e);switch(r.status){case"FAILED":throw new Error(`Transaction failed: ${He(r.error)||"Unknown error"}`);case"CONFIRMED":{if((r&&"onchainStatus"in r?r.onchainStatus:null)==="REVERTED"){const i="revertData"in r?r.revertData:void 0;throw new Error(`Transaction reverted: ${i?.errorName||"unknown error"} ${i?.errorArgs?He(i.errorArgs):""} - ${r.transactionHash?r.transactionHash:""}`)}return{chain:r.chain,client:e.client,transactionHash:r.transactionHash}}default:await new Promise(o=>setTimeout(o,1e3))}}throw new Error(`Transaction timed out after ${n/1e3} seconds`)}function js(e){const{client:t,vaultAccessToken:n,address:r,chain:s,executionOptions:o}=e,i=n?{"x-vault-access-token":n}:{},a=u=>{if(!o)return{chainId:u,from:r,type:"auto"};switch(o.type){case"auto":return{chainId:u,from:r,type:"auto"};case"ERC4337":return{...o,chainId:u,type:"ERC4337"};case"EOA":return{chainId:u,from:r,type:"EOA"};case"EIP7702":return{...o,chainId:u,type:"EIP7702"}}},c=u=>{if(!u)return{from:r,type:"EOA"};if(!o)return{chainId:u,from:r,type:"auto"};switch(o.type){case"ERC4337":return{chainId:u,...o,type:"ERC4337"};case"auto":return{chainId:u,from:r,type:"auto"};case"EIP7702":case"EOA":return{chainId:u,from:r,type:"EOA"}}},l=async u=>{if(u.length===0)throw new Error("No transactions to enqueue");const d=u[0];if(!d)throw new Error("No transactions to enqueue");const f=d.chainId;for(let g=1;g<u.length;g++)if(u[g]?.chainId!==f)throw new Error(`All transactions in batch must be on the same chain. Expected ${f}, got ${u[g]?.chainId} at index ${g}`);const m={executionOptions:a(f),params:u.map(g=>({data:g.data,to:g.to,gasLimit:g.gas?Number(g.gas):void 0,value:g.value?.toString()}))},p=await Os({baseUrl:v("engineCloud"),body:m,bodySerializer:A,fetch:I(t),headers:i});if(p.error)throw new Error(`Error sending transaction: ${A(p.error)}`);const y=p.data?.result;if(!y)throw new Error("No data returned from engine");return y.transactions.map(g=>g.id)};return{address:o?.type==="ERC4337"&&o.smartAccountAddress?o.smartAccountAddress:r,enqueueBatchTransaction:async u=>{const d=[];for(const p of u.transactions){const[y,g,w]=await Promise.all([p.to?L(p.to):null,ie(p),p.value?L(p.value):null]);d.push({chainId:p.chain.id,data:g,to:y??void 0,value:w??void 0})}const m=(await l(d))[0];if(!m)throw new Error("No transactionId returned from engine");return{transactionId:m}},enqueueTransaction:async u=>{let d;if(u.simulate)d=await Xe({transaction:u.transaction,from:r});else{const[p,y,g]=await Promise.all([u.transaction.to?L(u.transaction.to):null,ie(u.transaction),u.transaction.value?L(u.transaction.value):null]);d={chainId:u.transaction.chain.id,data:y,to:p??void 0,value:g??void 0}}const m=(await l([d]))[0];if(!m)throw new Error("No transactionId returned from engine");return{transactionId:m}},sendBatchTransaction:async u=>{const f=(await l(u))[0];if(!f)throw new Error("No transactionId returned from engine");return Ae({client:t,transactionId:f})},sendTransaction:async u=>{const f=(await l([u]))[0];if(!f)throw new Error("No transactionId returned from engine");return Ae({client:t,transactionId:f})},signMessage:async u=>{const{message:d,chainId:f}=u;let m,p=!1;typeof d=="string"?m=d:(m=Ye(d.raw),p=!0);const y=f||s?.id;if(!y)throw new Error("Chain ID is required for signing messages");const g=await Ps({baseUrl:v("engineCloud"),body:{params:[{format:p?"hex":"text",message:m}],signingOptions:c(y)},bodySerializer:A,fetch:I(t),headers:i});if(g.error)throw new Error(`Error signing message: ${A(g.error)}`);const w=g.data?.result[0];if(w&&Me(w))return w.result.signature;throw new Error(`Failed to sign message: ${A(w?.error)||"Unknown error"}`)},signTypedData:async u=>{const d=s?.id;if(!d)throw new Error("Chain ID is required for signing messages");const f=await Ds({baseUrl:v("engineCloud"),body:{params:[u],signingOptions:c(d)},bodySerializer:A,fetch:I(t),headers:i});if(f.error)throw new Error(`Error signing message: ${A(f.error)}`);const m=f.data?.result[0];if(m&&Me(m))return m.result.signature;throw new Error(`Failed to sign message: ${A(m?.error)||"Unknown error"}`)}}}const Ls=Object.freeze(Object.defineProperty({__proto__:null,createServerWallet:Rs,getServerWallets:Ns,getTransactionStatus:$t,searchTransactions:Us,serverWallet:js,waitForTransactionHash:Ae},Symbol.toStringTag,{value:"Module"}));async function $e(e){const[{getV1EventsByContractAddress:t},{getThirdwebDomains:n},{getClientFetch:r},{assertInsightEnabled:s},{stringify:o}]=await Promise.all([_(()=>import("./thirdweb-CHfVLLbM.js"),[]),_(()=>import("./withCache-DYumIHzL.js").then(m=>m.e),[]),_(()=>import("./withCache-DYumIHzL.js").then(m=>m.f),[]),_(()=>import("./common-D37S_OFt.js"),__vite__mapDeps([0,1,2])),_(()=>import("./json-BHzNJmTy.js"),[])]),{client:i,chains:a,contractAddress:c,event:l,queryOptions:h,decodeLogs:u}=e;await s(a);const d={chain:a.map(m=>m.id),decode:u,limit:100};l&&(d.filter_topic_0=l.topics[0],d.filter_topic_1=l.topics[1],d.filter_topic_2=l.topics[2],d.filter_topic_3=l.topics[3]);const f=await t({baseUrl:`https://${n().insight}`,fetch:r(i),path:{contractAddress:c},query:{...d,...h}});if(f.error)throw new Error(`${f.response.status} ${f.response.statusText} - ${f.error?o(f.error):"Unknown error"}`);return f.data?.data??[]}async function Ms(e){const[{getV1Nfts:t},{getThirdwebDomains:n},{getClientFetch:r},{assertInsightEnabled:s},{stringify:o}]=await Promise.all([_(()=>import("./thirdweb-CHfVLLbM.js"),[]),_(()=>import("./withCache-DYumIHzL.js").then(m=>m.e),[]),_(()=>import("./withCache-DYumIHzL.js").then(m=>m.f),[]),_(()=>import("./common-D37S_OFt.js"),__vite__mapDeps([0,1,2])),_(()=>import("./index-ww85HWCV.js"),__vite__mapDeps([3,4,5,6,7,8,9,10,11,2,12]))]),{client:i,chains:a,ownerAddress:c,contractAddresses:l,queryOptions:h}=e;await s(a);const u={chain:a.map(m=>m.id),limit:50,owner_address:[c],contract_address:l||void 0},d=await t({baseUrl:`https://${n().insight}`,fetch:r(i),query:{...u,...h}});if(d.error)throw new Error(`${d.response.status} ${d.response.statusText} - ${d.error?o(d.error):"Unknown error"}`);return(await Oe(d.data?.data??[],i,c)).map(m=>({...m,quantityOwned:m.quantityOwned??1n}))}async function Fs(e){const[{getV1NftsByContractAddress:t},{getThirdwebDomains:n},{getClientFetch:r},{assertInsightEnabled:s},{stringify:o}]=await Promise.all([_(()=>import("./thirdweb-CHfVLLbM.js"),[]),_(()=>import("./withCache-DYumIHzL.js").then(f=>f.e),[]),_(()=>import("./withCache-DYumIHzL.js").then(f=>f.f),[]),_(()=>import("./common-D37S_OFt.js"),__vite__mapDeps([0,1,2])),_(()=>import("./json-BHzNJmTy.js"),[])]),{client:i,chains:a,contractAddress:c,includeOwners:l=!0,queryOptions:h}=e,u={chain:a.map(f=>f.id),include_owners:l===!0?"true":"false",limit:50};await s(a);const d=await t({baseUrl:`https://${n().insight}`,fetch:r(i),path:{contract_address:c},query:{...u,...h}});if(d.error)throw new Error(`${d.response.status} ${d.response.statusText} - ${d.error?o(d.error):"Unknown error"}`);return Oe(d.data?.data??[],i)}async function qs(e){const[{getV1NftsByContractAddressByTokenId:t},{getThirdwebDomains:n},{getClientFetch:r},{assertInsightEnabled:s},{stringify:o}]=await Promise.all([_(()=>import("./thirdweb-CHfVLLbM.js"),[]),_(()=>import("./withCache-DYumIHzL.js").then(p=>p.e),[]),_(()=>import("./withCache-DYumIHzL.js").then(p=>p.f),[]),_(()=>import("./common-D37S_OFt.js"),__vite__mapDeps([0,1,2])),_(()=>import("./json-BHzNJmTy.js"),[])]),{client:i,chain:a,contractAddress:c,tokenId:l,includeOwners:h=!0,queryOptions:u}=e;await s([a]);const d={chain_id:[a.id],include_owners:h===!0?"true":"false"},f=await t({baseUrl:`https://${n().insight}`,fetch:r(i),path:{contract_address:c,token_id:l.toString()},query:{...d,...u}});if(f.error)throw new Error(`${f.response.status} ${f.response.statusText} - ${f.error?o(f.error):"Unknown error"}`);return(await Oe(f.data?.data??[],i))?.[0]}async function Oe(e,t,n){const[{parseNFT:r},{totalSupply:s}]=await Promise.all([_(()=>import("./parseNft-Buclbv5Y.js"),__vite__mapDeps([13,6,1,2,8,9,10,11,12])),_(()=>import("./totalSupply-DNIfxfBv.js"),__vite__mapDeps([14,9,15,10,2,6,16,17,1,12,11,8,18,19]))]);return await Promise.all(e.map(async o=>{let i;const{contract:a,extra_metadata:c,collection:l,metadata_url:h,chain_id:u,token_id:d,status:f,balance:m,token_type:p,...y}=o;let g=y,w=n?[F(n)]:void 0;if("owner_addresses"in y){const{owner_addresses:k,...B}=y;g=B,w=w??k?.map(N=>F(N))}const b=Ot({attributes:o.extra_metadata?.attributes??void 0,image:o.image_url,uri:o.metadata_url??"",...g});if(a?.type==="erc1155"){const k=await s({contract:ne({address:a.address,chain:te(a.chain_id),client:t}),id:BigInt(d)}).catch(()=>0n);i=r(b,{chainId:a?.chain_id??0,owner:w?.[0],supply:k,tokenAddress:a?.address??"",tokenId:BigInt(d),tokenUri:Ie(h)??"",type:"ERC1155"})}else i=r(b,{chainId:a?.chain_id??0,owner:w?.[0],tokenAddress:a?.address??"",tokenId:BigInt(d),tokenUri:Ie(h)??"",type:"ERC721"});return{...i,...a?.type==="erc1155"?{quantityOwned:m?BigInt(m):void 0}:{}}}))}function Ot(e){if(typeof e!="object"||e===null)return e;for(const t in e)typeof e[t]=="string"?e[t]=Ie(e[t]):Ot(e[t]);return e}function Ie(e){if(!e||typeof e!="string")return e;try{const t=new URL(e);if(t.host.endsWith(".ipfscdn.io")){const n=t.pathname.split("/"),r=n.findIndex(o=>o==="ipfs");if(r===-1)return e;const s=n.slice(r+1).join("/");return s?`ipfs://${s}`:e}}catch{return e}return e}async function Hs(e){const[{getV1Tokens:t},{getThirdwebDomains:n},{getClientFetch:r},{assertInsightEnabled:s},{stringify:o}]=await Promise.all([_(()=>import("./thirdweb-CHfVLLbM.js"),[]),_(()=>import("./withCache-DYumIHzL.js").then(f=>f.e),[]),_(()=>import("./withCache-DYumIHzL.js").then(f=>f.f),[]),_(()=>import("./common-D37S_OFt.js"),__vite__mapDeps([0,1,2])),_(()=>import("./json-BHzNJmTy.js"),[])]),{client:i,chains:a,ownerAddress:c,tokenAddresses:l,queryOptions:h}=e;await s(a);const u={chain_id:a.length>0?a.map(f=>f.id):[1],include_native:"true",include_spam:"false",limit:50,metadata:"true",owner_address:[c],token_address:l||void 0,sort_by:"balance",sort_order:"desc"},d=await t({baseUrl:`https://${n().insight}`,fetch:r(i),query:{...u,...h}});if(d.error)throw new Error(`${d.response.status} ${d.response.statusText} - ${d.error?o(d.error):"Unknown error"}`);return Ws(d.data?.data??[])}async function Ws(e){const{toTokens:t}=await _(async()=>{const{toTokens:n}=await import("./fee-data-BCMgs11D.js").then(r=>r.u);return{toTokens:n}},__vite__mapDeps([16,9,10,17,1,2,12,11]));return e.map(n=>{const r=n.decimals??18,s=BigInt(n.balance);return{chainId:n.chain_id,decimals:r,displayValue:t(s,r),name:n.name??"",symbol:n.symbol??"",tokenAddress:n.token_address,value:s}})}async function Vs(e){const[{getV1WalletsByWalletAddressTransactions:t},{getThirdwebDomains:n},{getClientFetch:r},{assertInsightEnabled:s},{stringify:o}]=await Promise.all([_(()=>import("./thirdweb-CHfVLLbM.js"),[]),_(()=>import("./withCache-DYumIHzL.js").then(f=>f.e),[]),_(()=>import("./withCache-DYumIHzL.js").then(f=>f.f),[]),_(()=>import("./common-D37S_OFt.js"),__vite__mapDeps([0,1,2])),_(()=>import("./json-BHzNJmTy.js"),[])]);await s(e.chains);const i=Math.floor((Date.now()-3*30*24*60*60*1e3)/1e3),{client:a,walletAddress:c,chains:l,queryOptions:h}=e,u={chain:l.map(f=>f.id),filter_block_timestamp_gte:i,limit:100},d=await t({baseUrl:`https://${n().insight}`,fetch:r(a),path:{wallet_address:c},query:{...u,...h}});if(d.error)throw new Error(`${d.response.status} ${d.response.statusText} - ${d.error?o(d.error):"Unknown error"}`);return d.data.data||[]}const Zs=Object.freeze(Object.defineProperty({__proto__:null,getContractEvents:$e,getContractNFTs:Fs,getNFT:qs,getOwnedNFTs:Ms,getOwnedTokens:Hs,getTransactions:Vs},Symbol.toStringTag,{value:"Module"})),{formatBlock:Ks}=await q("viem");async function Gs(e,t){const n=t.includeTransactions??!1,r=await e({method:"eth_getBlockByHash",params:[t.blockHash,n]});if(!r)throw new Error("Block not found");return Ks(r)}const{formatLog:Js}=await q("viem");async function ve(e,t={}){const n=t.topics??[];let r;if(t.blockHash){const s={blockHash:t.blockHash,topics:n};t.address&&(s.address=F(t.address)),r=await e({method:"eth_getLogs",params:[s]})}else{const s={topics:n};t.address&&(s.address=t.address),t.fromBlock&&(s.fromBlock=typeof t.fromBlock=="bigint"?Z(t.fromBlock):t.fromBlock),t.toBlock&&(s.toBlock=typeof t.toBlock=="bigint"?Z(t.toBlock):t.toBlock),r=await e({method:"eth_getLogs",params:[s]})}return r.map(s=>Js(s))}const{formatTransaction:Qs}=await q("viem");async function Ys(e,t){const n=await e({method:"eth_getTransactionByHash",params:[t.hash]});if(!n)throw new Error("Transaction not found.");return Qs(n)}const{formatLog:Xs}=await q("viem");async function Pt(e){const{contract:t,events:n,blockRange:r,useIndexer:s=!0,...o}=e,i=Se(t);if(o.blockHash&&(r||o.fromBlock||o.toBlock))throw new Error("Cannot specify blockHash and range simultaneously,");const a=await st(i);if(r){const{fromBlock:d,toBlock:f}=o;if(d!==void 0&&f!==void 0&&BigInt(f)-BigInt(d)!==BigInt(r))throw new Error("Incompatible blockRange with specified fromBlock and toBlock. Please only define fromBlock or toBlock when specifying blockRange.");d!==void 0?o.toBlock=BigInt(d)+BigInt(r)-1n:f!==void 0?o.fromBlock=BigInt(f)-BigInt(r)+1n:(o.toBlock=a,o.fromBlock=a-BigInt(r)+1n)}let c=n??[];if(!n?.length&&t){if(s){const d=await $e({chains:[t.chain],client:t.client,contractAddress:t.address,decodeLogs:!0,queryOptions:{filter_block_hash:o.blockHash,filter_block_number_gte:o.fromBlock,filter_block_number_lte:o.toBlock,limit:500}}).catch(()=>null);if(d)return Dt(d)}t.abi?.length?c=t.abi.filter(De).map(d=>ye({signature:d})):c=(await Ke(t)).filter(De).map(f=>ye({signature:f}))}const l=n&&n.length>0?n.map(d=>({...o,address:F(t.address),topics:d.topics})):[{...o,address:F(t.address)}];let h=[];if(s)try{h=await Promise.all(l.map(d=>eo({contract:t,params:d})))}catch(d){console.warn("Error fetching from insight, falling back to rpc",d),h=await Promise.all(l.map(f=>ve(i,f)))}else h=await Promise.all(l.map(d=>ve(i,d)));const u=h.flat().sort((d,f)=>Number((d.blockNumber??0n)-(f.blockNumber??0n)));return et({events:c,logs:u})}async function eo(e){const{params:t,contract:n}=e,r=typeof t.fromBlock=="bigint"?Number(t.fromBlock):void 0,s=typeof t.toBlock=="bigint"?Number(t.toBlock):void 0,o=await $e({chains:[n.chain],client:n.client,contractAddress:n.address,queryOptions:{filter_block_hash:t.blockHash,filter_block_number_gte:r,filter_block_number_lte:s,filter_topic_0:t.topics?.[0],filter_topic_1:t.topics?.[1],filter_topic_2:t.topics?.[2],filter_topic_3:t.topics?.[3],limit:500}});return Dt(o)}function Dt(e){return e.map(n=>({address:n.address,blockHash:n.block_hash,blockNumber:Z(Number(n.block_number)),blockTimestamp:n.block_timestamp,chainId:n.chain_id,data:n.data,logIndex:Z(n.log_index),topics:n.topics,transactionHash:n.transaction_hash,transactionIndex:Z(n.transaction_index),...n.decoded?{args:{...n.decoded.indexed_params,...n.decoded.non_indexed_params},eventName:n.decoded.name}:{}})).map(n=>Xs(n)).sort((n,r)=>Number((n.blockNumber??0n)-(r.blockNumber??0n)))}async function to(e,t){const n=t.retries,r=t.delay;let s=null;for(let o=0;o<n;o++)try{return await e()}catch(i){s=i,await new Promise(a=>setTimeout(a,r))}throw s}function no(e){return ot({...e.contract,latestBlockNumber:e.latestBlockNumber,onNewBlockNumber:async t=>{const n=await to(async()=>Pt({...e,fromBlock:t,toBlock:t,useIndexer:!1}),{delay:500,retries:3});n.length&&e.onEvents(n)}})}const ro=()=>{const e=Nt().pay;return e.startsWith("localhost")?`http://${e}`:`https://${e}`},so=()=>`${ro()}/buy-with-crypto/history/v1`;async function oo(e){try{const t=new URLSearchParams;t.append("walletAddress",e.walletAddress),t.append("start",e.start.toString()),t.append("count",e.count.toString());const n=t.toString(),r=`${so()}?${n}`,s=await I(e.client)(r);if(!s.ok){const i=await s.text().catch(()=>null);throw new Error(`HTTP error! status: ${s.status} - ${s.statusText}: ${i||"unknown error"}`)}return(await s.json()).result}catch(t){throw new Error(`Fetch failed: ${t}`)}}const io=[Un.id,jn.id,Ln.id,Mn.id,Fn.id,qn.id,34443,919,42220,44787,204,5611];async function ao(e){if(e.id===1337||e.id===31337)return!1;if(io.includes(e.id))return!0;try{const{getChainMetadata:t}=await _(async()=>{const{getChainMetadata:r}=await import("./utils-CozXUO91.js");return{getChainMetadata:r}},__vite__mapDeps([1,2]));return(await t(e)).stackType==="optimism_bedrock"}catch{return!1}}async function co(e){const{transaction:t}=e,n=e.from??e.account?.address??void 0,r=await L(t.gas)||await Ge({from:n,transaction:t}),s=await Cn(t.client,t.chain),o=s.maxFeePerGas||s.gasPrice;if(o===void 0)throw new Error(`Unable to determine gas price for chain ${t.chain.id}`);let i;if(await ao(t.chain)){const{estimateL1Fee:c}=await _(async()=>{const{estimateL1Fee:l}=await import("./estimate-l1-fee-B90S_dRF.js");return{estimateL1Fee:l}},__vite__mapDeps([20,8,6,9,10,11,2,12,15,16,17,1,18]));i=await c({transaction:t})}else i=0n;const a=r*o+i;return{ether:it(a),wei:a}}async function uo(e){try{const t=await(async()=>{if(e.toAmount){const l=ne({address:e.toTokenAddress,chain:te(e.toChainId),client:e.client}),h=l.address.toLowerCase()===Ee?18:await _e({contract:l}),u=we(e.toAmount,h);return at({amount:u,client:e.client,destinationChainId:e.toChainId,destinationTokenAddress:e.toTokenAddress,originChainId:e.fromChainId,originTokenAddress:e.fromTokenAddress,paymentLinkId:e.paymentLinkId,purchaseData:e.purchaseData,receiver:e.toAddress,sender:e.fromAddress})}else if(e.fromAmount){const l=ne({address:e.fromTokenAddress,chain:te(e.fromChainId),client:e.client}),h=await _e({contract:l}),u=we(e.fromAmount,h);return ct({amount:u,client:e.client,destinationChainId:e.toChainId,destinationTokenAddress:e.toTokenAddress,originChainId:e.fromChainId,originTokenAddress:e.fromTokenAddress,paymentLinkId:e.paymentLinkId,purchaseData:e.purchaseData,receiver:e.toAddress,sender:e.fromAddress})}throw new Error("Invalid quote request, must provide either `fromAmount` or `toAmount`")})(),n=t.steps[0];if(!n)throw new Error("This quote is incompatible with getBuyWithCryptoQuote. Please use Bridge.Buy.prepare instead.");const r=n.transactions.filter(l=>l.action==="approval");if(r.length>1)throw new Error("This quote is incompatible with getBuyWithCryptoQuote. Please use Bridge.Buy.prepare instead.");const s=r[0],o=n.transactions.filter(l=>l.action!=="approval");if(o.length>1)throw new Error("This quote is incompatible with getBuyWithCryptoQuote. Please use Bridge.Buy.prepare instead.");const i=o[0];if(!i)throw new Error("This quote is incompatible with getBuyWithCryptoQuote. Please use Bridge.Buy.prepare instead.");let a;if(s){const l=tt(["function approve(address spender, uint256 amount)"]),[h,u]=nt(l,s.data);a={amountWei:u.toString(),chainId:n.originToken.chainId,spenderAddress:h,tokenAddress:n.originToken.address}}return{approvalData:a,client:e.client,paymentTokens:[{amount:C(t.originAmount,n.originToken.decimals).toString(),amountUSDCents:Number(C(t.originAmount,n.originToken.decimals))*(n.originToken.prices.USD||0)*100,amountWei:t.originAmount.toString(),token:{chainId:n.originToken.chainId,decimals:n.originToken.decimals,name:n.originToken.name,priceUSDCents:(n.originToken.prices.USD||0)*100,symbol:n.originToken.symbol,tokenAddress:n.originToken.address}}],processingFees:[{amount:"0",amountUSDCents:0,amountWei:"0",token:{chainId:n.originToken.chainId,decimals:n.originToken.decimals,name:n.originToken.name,priceUSDCents:(n.originToken.prices.USD||0)*100,symbol:n.originToken.symbol,tokenAddress:n.originToken.address}}],swapDetails:{estimated:{durationSeconds:n.estimatedExecutionTimeMs/1e3,feesUSDCents:0,fromAmountUSDCents:Number(C(t.originAmount,n.originToken.decimals))*(n.originToken.prices.USD||0)*100,gasCostUSDCents:0,slippageBPS:0,toAmountMinUSDCents:Number(C(t.destinationAmount,n.destinationToken.decimals))*(n.destinationToken.prices.USD||0)*100,toAmountUSDCents:Number(C(t.destinationAmount,n.destinationToken.decimals))*(n.destinationToken.prices.USD||0)*100},fromAddress:t.intent.sender,fromAmount:C(t.originAmount,n.originToken.decimals).toString(),fromAmountWei:t.originAmount.toString(),fromToken:{chainId:n.originToken.chainId,decimals:n.originToken.decimals,name:n.originToken.name,priceUSDCents:(n.originToken.prices.USD||0)*100,symbol:n.originToken.symbol,tokenAddress:n.originToken.address},maxSlippageBPS:0,toAddress:t.intent.receiver,toAmount:C(t.destinationAmount,n.destinationToken.decimals).toString(),toAmountMin:C(t.destinationAmount,n.destinationToken.decimals).toString(),toAmountMinWei:t.destinationAmount.toString(),toAmountWei:t.destinationAmount.toString(),toToken:{chainId:n.destinationToken.chainId,decimals:n.destinationToken.decimals,name:n.destinationToken.name,priceUSDCents:(n.destinationToken.prices.USD||0)*100,symbol:n.destinationToken.symbol,tokenAddress:n.destinationToken.address}},transactionRequest:{...i,extraGas:50000n}}}catch(t){throw console.error("Error getting buy with crypto quote",t),t}}async function lo(e){try{if(!e.transactionHash)throw new Error("Transaction hash is required");const t=await dt({chainId:e.chainId,client:e.client,transactionHash:e.transactionHash});switch(t.status){case"COMPLETED":{const n=t.transactions?.find(s=>s.chainId===e.chainId),r=t.transactions?.find(s=>s.chainId!==e.chainId);return ge({destinationAmount:t.destinationAmount,destinationChainId:t.destinationChainId,destinationToken:t.destinationToken,destinationTokenAddress:t.destinationTokenAddress,destinationTransaction:r,originAmount:t.originAmount,originChainId:t.originChainId,originToken:t.originToken,originTokenAddress:t.originTokenAddress,originTransaction:n,paymentId:t.paymentId,purchaseData:t.purchaseData,receiver:t.receiver,sender:t.sender,status:t.status})}case"PENDING":return ge({destinationChainId:t.destinationChainId,destinationToken:t.destinationToken,destinationTokenAddress:t.destinationTokenAddress,originAmount:t.originAmount,originChainId:t.originChainId,originToken:t.originToken,originTokenAddress:t.originTokenAddress,paymentId:t.paymentId,purchaseData:t.purchaseData,receiver:t.receiver,sender:t.sender,status:t.status});case"FAILED":{const n=t.transactions?.find(s=>s.chainId===e.chainId),r=t.transactions?.find(s=>s.chainId!==e.chainId);return ge({destinationChainId:0,destinationToken:void 0,destinationTokenAddress:"",destinationTransaction:r,originAmount:BigInt(0),originChainId:0,originToken:void 0,originTokenAddress:"",originTransaction:n,paymentId:"",purchaseData:t.purchaseData,receiver:"",sender:"",status:t.status})}default:return{status:"NOT_FOUND"}}}catch(t){throw console.error("Fetch error:",t),new Error(`Fetch failed: ${t}`)}}function ge(e){const{originTransaction:t,destinationTransaction:n,status:r,purchaseData:s,originAmount:o,destinationAmount:i,originTokenAddress:a,destinationTokenAddress:c,originChainId:l,destinationChainId:h,sender:u,receiver:d,originToken:f,destinationToken:m}=e;return{bridge:"STARPORT",destination:{amount:m?V(i??BigInt(0),m.decimals).toString():"",amountUSDCents:0,amountWei:i?.toString()??"",completedAt:new Date().toISOString(),explorerLink:"",token:{chainId:h,decimals:m?.decimals??18,name:m?.name??"",priceUSDCents:0,symbol:m?.symbol??"",tokenAddress:c},transactionHash:n?.transactionHash??""},fromAddress:u,purchaseData:s,quote:{createdAt:new Date().toISOString(),estimated:{durationSeconds:0,feesUSDCents:0,fromAmountUSDCents:0,gasCostUSDCents:0,slippageBPS:0,toAmountMinUSDCents:0,toAmountUSDCents:0},fromAmount:f?V(o,f.decimals).toString():"",fromAmountWei:o.toString(),fromToken:{chainId:l,decimals:f?.decimals??18,name:f?.name??"",priceUSDCents:0,symbol:f?.symbol??"",tokenAddress:a},toAmount:m&&i?V(i,m.decimals).toString():"",toAmountMin:m?V(i??BigInt(0),m.decimals).toString():"",toAmountMinWei:i?i.toString():"",toAmountWei:i?i.toString():"",toToken:{chainId:h,decimals:m?.decimals??18,name:m?.name??"",priceUSDCents:0,symbol:m?.symbol??"",tokenAddress:c}},source:{amount:f?V(o,f.decimals).toString():"",amountUSDCents:0,amountWei:o.toString(),completedAt:new Date().toISOString(),explorerLink:"",token:{chainId:l,decimals:f?.decimals??18,name:f?.name??"",priceUSDCents:0,symbol:f?.symbol??"",tokenAddress:a},transactionHash:t?.transactionHash??""},status:r,subStatus:r==="COMPLETED"?"SUCCESS":"NONE",swapType:t?.chainId===n?.chainId?"SAME_CHAIN":"CROSS_CHAIN",toAddress:d}}async function fo(e){try{const t=ne({address:e.tokenAddress,chain:te(e.chainId),client:e.client}),n=t.address.toLowerCase()===Ee?18:await _e({contract:t}),r=we(e.amount,n),s=await ut({amount:r,chainId:e.chainId,client:e.client,feePayer:e.feePayer,paymentLinkId:e.paymentLinkId,purchaseData:e.purchaseData,receiver:e.toAddress,sender:e.fromAddress,tokenAddress:e.tokenAddress}),o=s.steps[0];if(!o)throw new Error("This quote is incompatible with getBuyWithCryptoTransfer. Please use Bridge.Transfer.prepare instead.");const i=o.transactions.filter(d=>d.action==="approval");if(i.length>1)throw new Error("This quote is incompatible with getBuyWithCryptoTransfer. Please use Bridge.Transfer.prepare instead.");const a=i[0];let c;if(a){const d=tt(["function approve(address spender, uint256 amount)"]),[f,m]=nt(d,a.data);c={amountWei:m.toString(),chainId:o.originToken.chainId,spenderAddress:f,tokenAddress:o.originToken.address}}const l=o.transactions.filter(d=>d.action!=="approval");if(l.length>1)throw new Error("This quote is incompatible with getBuyWithCryptoTransfer. Please use Bridge.Transfer.prepare instead.");const h=l[0];if(!h)throw new Error("This quote is incompatible with getBuyWithCryptoTransfer. Please use Bridge.Transfer.prepare instead.");return{approvalData:c,client:e.client,estimatedGasCostUSDCents:0,fromAddress:e.fromAddress,paymentToken:{amount:C(s.originAmount,o.originToken.decimals).toString(),amountUSDCents:Number(C(s.originAmount,o.originToken.decimals))*(o.originToken.prices.USD||0)*100,amountWei:s.originAmount.toString(),token:{chainId:o.originToken.chainId,decimals:o.originToken.decimals,name:o.originToken.name,priceUSDCents:(o.originToken.prices.USD||0)*100,symbol:o.originToken.symbol,tokenAddress:o.originToken.address}},processingFee:{amount:e.feePayer==="sender"?C(s.originAmount-s.destinationAmount,o.originToken.decimals).toString():"0",amountUSDCents:e.feePayer==="sender"?Number(C(s.originAmount-s.destinationAmount,o.originToken.decimals))*(o.originToken.prices.USD||0)*100:0,amountWei:e.feePayer==="sender"?(s.originAmount-s.destinationAmount).toString():"0",token:{chainId:o.originToken.chainId,decimals:o.originToken.decimals,name:o.originToken.name,priceUSDCents:(o.originToken.prices.USD||0)*100,symbol:o.originToken.symbol,tokenAddress:o.originToken.address}},toAddress:e.toAddress,transactionRequest:{...h,extraGas:50000n}}}catch(t){throw console.error("Error getting buy with crypto transfer",t),t}}const{decodeAbiParameters:ho,formatTransactionRequest:mo}=await q("viem");async function po(e){const[t,n,r,s]=await Promise.all([ie(e.transaction),L(e.transaction.to),L(e.transaction.accessList),L(e.transaction.value)]),o=e.from??e.account?.address??void 0,i=mo({accessList:r,data:t,from:o?F(o):void 0,to:n?F(n):void 0,value:s}),a=Se(e.transaction);try{const c=await rt(a,i);if(!e.transaction.__preparedMethod)return c;const l=await e.transaction.__preparedMethod(),h=ho(l[2],c);return Array.isArray(h)&&h.length===1?h[0]:h}catch(c){throw await Ft({contract:e.transaction.__contract,error:c,fromAddress:o})}}function go(e){return async t=>{if(typeof e=="string"&&e.startsWith("function "))return nn(e);const r=(t.abi?.length?t.abi:await Ke(t)).find(s=>s.type!=="function"?!1:s.name===e);if(!r)throw new Error(`could not find function with name "${e}" in abi`);return r}}function yo(e){return typeof e=="object"&&e!==null}function We(e,t=[]){return yo(e)&&t.every(n=>n in e)}function wo(e){return We(e,["__contract"])&&We(e.__contract,["address","chain"])&&typeof e.__contract.address=="string"}async function _o({address:e,signature:t,client:n,chain:r,accountFactory:s,message:o,domain:i,primaryType:a,types:c}){const l=rn({domain:i,message:o,primaryType:a,types:c});if(!de(t))return!1;try{if(sn({payload:l,signature:on(t)}).toLowerCase()===e.toLowerCase())return!0}catch{}return an({accountFactory:s,address:e,chain:r,client:n,hash:l,signature:t})}async function bo(e){const{account:t,request:n}=e;if(typeof t.signAuthorization>"u")throw new Error("This account type does not yet support signing EIP-7702 authorizations");return t.signAuthorization(n)}const Lo=Object.freeze(Object.defineProperty({__proto__:null,ADDRESS_ZERO:ze,Bridge:as,Engine:Ls,Insight:Zs,NATIVE_TOKEN_ADDRESS:Ee,ZERO_ADDRESS:ze,boolToBytes:qt,boolToHex:Kt,bytesToBigInt:cn,bytesToBool:dn,bytesToNumber:un,bytesToString:ln,concatHex:fn,createThirdwebClient:gs,defineChain:re,deploySmartAccount:hn,encode:ie,estimateGas:Ge,estimateGasCost:co,eth_blockNumber:st,eth_call:rt,eth_estimateGas:Sn,eth_gasPrice:xn,eth_getBalance:mn,eth_getBlockByHash:Gs,eth_getBlockByNumber:$n,eth_getCode:pn,eth_getLogs:ve,eth_getStorageAt:Rn,eth_getTransactionByHash:Ys,eth_getTransactionCount:Nn,eth_getTransactionReceipt:vn,eth_maxPriorityFeePerGas:On,eth_sendRawTransaction:gn,fromBytes:yn,fromGwei:Pn,fromHex:Gt,getAddress:F,getBuyWithCryptoHistory:oo,getBuyWithCryptoQuote:uo,getBuyWithCryptoStatus:lo,getBuyWithCryptoTransfer:fo,getContract:ne,getContractEvents:Pt,getGasPrice:Dn,getRpcClient:Se,getUser:wn,hexToBigInt:Jt,hexToBool:Qt,hexToBytes:Ht,hexToNumber:Yt,hexToString:Xt,hexToUint8Array:Je,isAddress:Ve,isBaseTransactionOptions:wo,isHex:de,keccak256:Wt,numberToBytes:Vt,numberToHex:Z,padHex:en,parseEventLogs:et,prepareContractCall:_n,prepareEvent:ye,prepareTransaction:bn,readContract:kn,resolveMethod:go,sendAndConfirmTransaction:Hn,sendBatchTransaction:Wn,sendTransaction:Tn,serializeTransaction:An,sha256:At,signAuthorization:bo,signTransaction:In,simulateTransaction:po,stringToBytes:Ze,stringToHex:tn,toBytes:Zt,toEther:it,toHex:Ye,toSerializableTransaction:Xe,toTokens:V,toUnits:zn,toWei:Bn,uint8ArrayToHex:Qe,verifyTypedData:_o,waitForReceipt:En,watchBlockNumber:ot,watchContractEvents:no},Symbol.toStringTag,{value:"Module"}));export{qs as g,Lo as t};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{w as t}from"./core-
|
|
1
|
+
import{w as t}from"./core-iy2F1EJT.js";const l=t`<svg width="14" height="15" viewBox="0 0 14 15" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
2
|
<path d="M7 3.71875C6.0335 3.71875 5.25 2.93525 5.25 1.96875C5.25 1.00225 6.0335 0.21875 7 0.21875C7.9665 0.21875 8.75 1.00225 8.75 1.96875C8.75 2.93525 7.9665 3.71875 7 3.71875Z" fill="#949E9E"/>
|
|
3
3
|
<path d="M7 8.96875C6.0335 8.96875 5.25 8.18525 5.25 7.21875C5.25 6.25225 6.0335 5.46875 7 5.46875C7.9665 5.46875 8.75 6.25225 8.75 7.21875C8.75 8.18525 7.9665 8.96875 7 8.96875Z" fill="#949E9E"/>
|
|
4
4
|
<path d="M5.25 12.4688C5.25 13.4352 6.0335 14.2187 7 14.2187C7.9665 14.2187 8.75 13.4352 8.75 12.4688C8.75 11.5023 7.9665 10.7188 7 10.7188C6.0335 10.7188 5.25 11.5023 5.25 12.4688Z" fill="#949E9E"/>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{importShared as n}from"./__federation_fn_import-
|
|
1
|
+
import{importShared as n}from"./__federation_fn_import-D82-s3kA.js";import{e as a,r as c}from"./signing-TLGj9K79.js";import{d}from"./detectExtension-DQNsMd7m.js";const{decodeAbiParameters:i}=await n("viem"),e="0xbd85b039",o=[{name:"id",type:"uint256"}],r=[{type:"uint256"}];function l(t){return d({availableSelectors:t,method:[e,o,r]})}function p(t){return a(o,[t.id])}function S(t){return e+p(t).slice(2)}function f(t){return i(r,t)[0]}async function y(t){return c({contract:t.contract,method:[e,o,r],params:[t.id]})}export{e as FN_SELECTOR,f as decodeTotalSupplyResult,S as encodeTotalSupply,p as encodeTotalSupplyParams,l as isTotalSupplySupported,y as totalSupply};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{w as l}from"./core-
|
|
1
|
+
import{w as l}from"./core-iy2F1EJT.js";const i=l`<svg fill="none" viewBox="0 0 40 40">
|
|
2
2
|
<g clip-path="url(#a)">
|
|
3
3
|
<g clip-path="url(#b)">
|
|
4
4
|
<circle cx="20" cy="19.89" r="20" fill="#5A3E85" />
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{w as o}from"./core-
|
|
1
|
+
import{w as o}from"./core-iy2F1EJT.js";const c=o`<svg fill="none" viewBox="0 0 16 16">
|
|
2
2
|
<path
|
|
3
3
|
fill="currentColor"
|
|
4
4
|
d="m14.36 4.74.01.42c0 4.34-3.3 9.34-9.34 9.34A9.3 9.3 0 0 1 0 13.03a6.6 6.6 0 0 0 4.86-1.36 3.29 3.29 0 0 1-3.07-2.28c.5.1 1 .07 1.48-.06A3.28 3.28 0 0 1 .64 6.11v-.04c.46.26.97.4 1.49.41A3.29 3.29 0 0 1 1.11 2.1a9.32 9.32 0 0 0 6.77 3.43 3.28 3.28 0 0 1 5.6-3 6.59 6.59 0 0 0 2.08-.8 3.3 3.3 0 0 1-1.45 1.82A6.53 6.53 0 0 0 16 3.04c-.44.66-1 1.23-1.64 1.7Z"
|