@dcl/account-site 6.6.0 → 6.7.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/{CoinbaseSDKConnection-CZn10zuo.js → CoinbaseSDKConnection-BXH9O0nE.js} +1 -1
- package/assets/{ConstantsUtil-CCWoPq6v.js → ConstantsUtil-BBWopuyF.js} +1 -1
- package/assets/{ExchangeController-DAvkG56a.js → ExchangeController-CA0zj_3w.js} +1 -1
- package/assets/{HelpersUtil-UXuUdUo1.js → HelpersUtil-DSbuW6K9.js} +1 -1
- package/assets/{InAppWalletConnectUI-ja-gHAVb.js → InAppWalletConnectUI-4CWClaVJ.js} +1 -1
- package/assets/{NetworkUtil-Dyezb5_Z.js → NetworkUtil-Ci2WRYQ5.js} +1 -1
- package/assets/{QRCodeRenderer-DVWfONfS.js → QRCodeRenderer-BcVfSFm_.js} +1 -1
- package/assets/{SwapController-B9nvNG09.js → SwapController-Czs5wFSm.js} +1 -1
- package/assets/{ThirdwebWalletManager-8fp4vDZ-.js → ThirdwebWalletManager-_8PV4raS.js} +14 -14
- package/assets/{biconomy-DsiBpaqb.js → biconomy-BthTiVNA.js} +1 -1
- package/assets/{biconomy-CAg5-Rne.js → biconomy-Ct9DAkvL.js} +1 -1
- package/assets/{ccip-CvLc3NhE.js → ccip-C-GSKBZ0.js} +1 -1
- package/assets/{ccip-BOSG5Xf7.js → ccip-COdWpT3c.js} +1 -1
- package/assets/{ccip-Omot5-KO.js → ccip-PybIhCr_.js} +1 -1
- package/assets/{chains-hQBCRSBK.js → chains-DU-Pa0Wz.js} +1 -1
- package/assets/{common-C1bFpXXr.js → common-DttAkYAP.js} +1 -1
- package/assets/{common-BP_lAyVn.js → common-FBNyPNTr.js} +1 -1
- package/assets/concat-hex-DeWBGZEs.js +1 -0
- package/assets/{controller-7UvIet0s.js → controller-CYBQ4arf.js} +2 -2
- package/assets/{controller-BbSNXeiw.js → controller-cVVmP7jI.js} +2 -2
- package/assets/{data-capture-CDbYPi0B.js → data-capture-BxMZh5-c.js} +1 -1
- package/assets/{decimals-jrUfo404.js → decimals-C88RWTdk.js} +1 -1
- package/assets/decimals-CDYEp2UZ.js +1 -0
- package/assets/{detectExtension-B-qw64Pc.js → detectExtension-C1-4KxEP.js} +1 -1
- package/assets/{detectExtension-BHy0tx26.js → detectExtension-DaHwTBEl.js} +1 -1
- package/assets/{email-CBQ_fEcd.js → email-CykYjBAl.js} +1 -1
- package/assets/{embedded-wallet-BpNjQ35t.js → embedded-wallet-uXcj1MHn.js} +1 -1
- package/assets/{engine-Bxq9XExo.js → engine--65dr3zr.js} +1 -1
- package/assets/{engine-DBZbir_a.js → engine-CrmGAvB-.js} +1 -1
- package/assets/{estimate-l1-fee-0EMQlb1T.js → estimate-l1-fee-BXqjzhsB.js} +1 -1
- package/assets/{estimate-l1-fee-gKGPhwem.js → estimate-l1-fee-C8QcwjpU.js} +1 -1
- package/assets/eth_estimateGas-BLq5fjmK.js +1 -0
- package/assets/eth_estimateGas-CxVJfDAv.js +1 -0
- package/assets/{eth_getStorageAt-BFNcSJRC.js → eth_getStorageAt-BdHAJUde.js} +1 -1
- package/assets/eth_getTransactionCount-BRhOgzit.js +1 -0
- package/assets/{eth_getTransactionCount-Dcc1nhjw.js → eth_getTransactionCount-uA-BuCYb.js} +1 -1
- package/assets/{ethereum-CWr8QmFu.js → ethereum-G9jle5Re.js} +1 -1
- package/assets/{extractIPFS-BsYIuiLm.js → extractIPFS-CO52kZTe.js} +1 -1
- package/assets/{extractIPFS-Ch4Gc35N.js → extractIPFS-EXk4RS2j.js} +1 -1
- package/assets/{features-CmIs_0JR.js → features-ulzbeUt3.js} +1 -1
- package/assets/{fetchTokenMetadata-DrJFAm_P.js → fetchTokenMetadata-CVbxD3VO.js} +2 -2
- package/assets/{fetchTokenMetadata-BKap4LV_.js → fetchTokenMetadata-Cjc5LBLb.js} +2 -2
- package/assets/{fortmatic-YfMk-BEE.js → fortmatic-C9YVBZGp.js} +1 -1
- package/assets/{get-ecosystem-wallet-info-DU9z8SfE.js → get-ecosystem-wallet-info-C2g4DCWw.js} +1 -1
- package/assets/{get-ecosystem-wallet-info-DGKFMj5P.js → get-ecosystem-wallet-info-XD5a_-7n.js} +1 -1
- package/assets/{getBalance-De76iO5T.js → getBalance-ChIaoun9.js} +1 -1
- package/assets/{getBalance-DnrxzxOV.js → getBalance-Cv-UhnqE.js} +2 -2
- package/assets/{getCurrencyMetadata-BDUn1sRt.js → getCurrencyMetadata-BIDrkcKc.js} +2 -2
- package/assets/{getInstalledModules-CDg0iuO4.js → getInstalledModules-CXC5NsJK.js} +1 -1
- package/assets/{getInstalledModules-pAhupAGP.js → getInstalledModules-DSkh5stL.js} +1 -1
- package/assets/{getNFT-DHMnJTqW.js → getNFT-B1GRYjXJ.js} +1 -1
- package/assets/{getNFT-Dmgig0jB.js → getNFT-BAV0GrVn.js} +2 -2
- package/assets/{getNFT-BBil6owX.js → getNFT-BH7A6Hpm.js} +2 -2
- package/assets/{getNFT-B0m3jfoJ.js → getNFT-CzmG4M0Z.js} +1 -1
- package/assets/{hashTypedData-CFE7S7Af.js → hashTypedData-LY3QUtcD.js} +1 -1
- package/assets/{if-defined-Cf2AacYL.js → if-defined-DDCgUiYp.js} +1 -1
- package/assets/{in-app-wallet-calls-BcCtZJWh.js → in-app-wallet-calls--nglUDgv.js} +1 -1
- package/assets/{in-app-wallet-calls-DkDeM4Ux.js → in-app-wallet-calls-n-b5hova.js} +1 -1
- package/assets/{index-fXUdFiUC.js → index-4dpS6N-D.js} +1 -1
- package/assets/{index-DFwjqP80.js → index-6V9vuvkP.js} +1 -1
- package/assets/{index-CzwFqL20.js → index-B1poDi8U.js} +1 -1
- package/assets/{index-C2_PMI0d.js → index-BFCvu-SQ.js} +1 -1
- package/assets/{index-DAiWSMFC.css → index-BGvsmbMC.css} +3 -3
- package/assets/{index-CYmaTgjV.js → index-Bef3mmzY.js} +1 -1
- package/assets/{index-4kM1zjnS.js → index-BmyXTXyN.js} +1 -1
- package/assets/{index-CLEQ0hOn.js → index-BoV3Hrjy.js} +1 -1
- package/assets/{index-FfyQsjIX.js → index-Bp09MjvQ.js} +1 -1
- package/assets/{index-hu38SAQP.js → index-C8X0edSR.js} +2 -2
- package/assets/{index-CTPexb85.js → index-C9kcmpvP.js} +83 -83
- package/assets/{index-AQDuAtLD.js → index-CGZLkuWn.js} +1 -1
- package/assets/{index-2bKn2TSE.js → index-CMJ_znKB.js} +1 -1
- package/assets/{index-_D0X6y83.js → index-CP8kDNsr.js} +1 -1
- package/assets/{index-C4PACRDN.js → index-CQCjMzl4.js} +1 -1
- package/assets/{index-Darq-_2v.js → index-CQCqaGUZ.js} +1 -1
- package/assets/{index-BOfv99jb.js → index-CQW4u1WI.js} +1 -1
- package/assets/{index-iYxKn0Oc.js → index-CnyP_n54.js} +1 -1
- package/assets/{index-D5Bu0E_X.js → index-Cp3T7PGa.js} +2 -2
- package/assets/{index-BiJBjAq_.js → index-Cq3j3T6G.js} +1 -1
- package/assets/{index-M-NNRPW4.js → index-CsvMexRW.js} +1 -1
- package/assets/{index-B5HUu6ls.js → index-CvAs0GYP.js} +1 -1
- package/assets/{index-TCzvey27.js → index-CyiA1q8T.js} +4 -4
- package/assets/{index-C1ZzIDiM.js → index-D-Ot-Uy8.js} +1 -1
- package/assets/{index-D0ni6GfK.js → index-D2hB4T2W.js} +1 -1
- package/assets/{index-4AMDJXW8.js → index-D338ESwc.js} +1 -1
- package/assets/{index-BcyyjPYQ.js → index-D8hwIfIc.js} +1 -1
- package/assets/{index-ClFb4Tcz.js → index-DF_yMqfP.js} +1 -1
- package/assets/{index-B5OgRpRK.js → index-DQ09NiWi.js} +1 -1
- package/assets/{index-CcA5U3oD.js → index-DYAskdJA.js} +1 -1
- package/assets/{index-CY1hRSE1.js → index-Db5dD53h.js} +1 -1
- package/assets/{index-DoVKEDtC.js → index-DiIjEJ0_.js} +1 -1
- package/assets/{index-BgpgK5zX.js → index-DlXwok7s.js} +1 -1
- package/assets/{index-CbL1z9m0.js → index-Dmgfza45.js} +1 -1
- package/assets/{index-CTLEIK7D.js → index-Dn7EsoTj.js} +1 -1
- package/assets/{index-BDYX4pI8.js → index-Dn7k_DQ8.js} +1 -1
- package/assets/{index-DPPAEOk2.js → index-DpeV9Wam.js} +1 -1
- package/assets/{index-CDV_dpO4.js → index-DrDz7oQI.js} +1 -1
- package/assets/{index-CcFgdqWi.js → index-DrMbiZ0i.js} +1 -1
- package/assets/{index-CyjdNVAU.js → index-DsUVe2Dc.js} +1 -1
- package/assets/{index-BblrtGZs.js → index-FICjNWjt.js} +1 -1
- package/assets/{index-CzhN2xH6.js → index-IdBnFbaK.js} +1 -1
- package/assets/{index-xyaiuxIf.js → index-J_VvzvhB.js} +1 -1
- package/assets/{index-BF2AsK0R.js → index-_RP5sd-t.js} +1 -1
- package/assets/{index-DFWtng-H.js → index-dU7YfzFY.js} +1 -1
- package/assets/{index-CFFw5g7T.js → index-pMedPHw2.js} +2 -2
- package/assets/{index-BNPmCVUF.js → index-x7hxyH5-.js} +1 -1
- package/assets/{index-vC3WND5c.js → index-zeKYF1_9.js} +2 -2
- package/assets/{index.es-CxEKWgLB.js → index.es-BnBQYKMl.js} +1 -1
- package/assets/{index.es-gA_UXXxQ.js → index.es-D0_25Oh-.js} +1 -1
- package/assets/{index.es-CiDQXtto.js → index.es-Dv1hs6Y0.js} +1 -1
- package/assets/{index.es-Ctfyd2a4.js → index.es-arQDsOy9.js} +1 -1
- package/assets/{native-DIXXjgvG.js → native-DlthNI6_.js} +1 -1
- package/assets/{networks-DS3ZsJHp.js → networks-v--tvMC_.js} +1 -1
- package/assets/{onramp-BrCtcXHK.js → onramp-EDzrY1eM.js} +1 -1
- package/assets/{openzeppelin-BJbCajkn.js → openzeppelin-B8M9vXqD.js} +1 -1
- package/assets/{openzeppelin-DBm5cWZy.js → openzeppelin-Dimjiuxs.js} +1 -1
- package/assets/{ownerOf-CJw5i5sY.js → ownerOf-3vffreXZ.js} +1 -1
- package/assets/{ownerOf-BXifbKa_.js → ownerOf-BjvDIwi2.js} +1 -1
- package/assets/{parseNft-CKnRi_6q.js → parseNft-bgONNYbj.js} +2 -2
- package/assets/{parseSignature-BLWHgs4m.js → parseSignature-BC-PtSTA.js} +3 -3
- package/assets/{parseSignature-DdX47xNk.js → parseSignature-RSoun7s3.js} +3 -3
- package/assets/{pay-with-exchange-CyOggPbb.js → pay-with-exchange-Vox1cIBi.js} +1 -1
- package/assets/{qr-overlay-D95UBGA6.js → qr-overlay-C6PNFBky.js} +1 -1
- package/assets/{qr-overlay-JyAOpwrY.js → qr-overlay-MsxABgTz.js} +1 -1
- package/assets/{receive-ZcLdb8Ck.js → receive-C8W6quVv.js} +1 -1
- package/assets/{ref-BvyvP27w.js → ref-C8ELo-FX.js} +1 -1
- package/assets/{resolveImplementation-Dpsv_sj3.js → resolveImplementation-Be5g9Og6.js} +1 -1
- package/assets/{resolveImplementation-CqZPAWh1.js → resolveImplementation-al_rhKfM.js} +1 -1
- package/assets/{rpc-D8oPKl0j.js → rpc-YBySNaPU.js} +1 -1
- package/assets/{rpc-D6TzaLpS.js → rpc-fTN6Lg8H.js} +1 -1
- package/assets/{secp256k1-BkfYhWy6.js → secp256k1-BSfltYuw.js} +1 -1
- package/assets/{secp256k1-CISac59N.js → secp256k1-DbKe55L4.js} +1 -1
- package/assets/{send-BibpFq6-.js → send-GzhOSqeF.js} +1 -1
- package/assets/{send-batch-transaction-CuvNhAx9.js → send-batch-transaction-BgQySJ-T.js} +1 -1
- package/assets/{send-batch-transaction-CzhCEKJe.js → send-batch-transaction-BvT25Mc6.js} +1 -1
- package/assets/{send-eip712-transaction-CMDvpVc6.js → send-eip712-transaction-DMiNR15g.js} +2 -2
- package/assets/{send-eip712-transaction-ChRagBhu.js → send-eip712-transaction-RxArzXsP.js} +2 -2
- package/assets/{send-gasless-transaction-T8FPx_c4.js → send-gasless-transaction-BTboOw9J.js} +2 -2
- package/assets/{send-gasless-transaction-C3x4-HC9.js → send-gasless-transaction-ma7UOPHW.js} +2 -2
- package/assets/{session-proposal-0RYS24IB.js → session-proposal-BVrALpGO.js} +1 -1
- package/assets/{session-proposal-CHgpdx11.js → session-proposal-t7OELfh-.js} +1 -1
- package/assets/{session-request-CECX27Q9.js → session-request-CklXcH9d.js} +2 -2
- package/assets/{session-request-sg5_TFjt.js → session-request-DHwHTsWb.js} +2 -2
- package/assets/{sha256-Bq0kwVlP.js → sha256-B_2-BKc1.js} +1 -1
- package/assets/{sha256-rw7X9Nhf.js → sha256-EtKFmWln.js} +1 -1
- package/assets/{signing-D7VaTtN_.js → signing-DR1diqT_.js} +5 -5
- package/assets/{signing-GeODVl1E.js → signing-Wg6dfZ-_.js} +1 -1
- package/assets/{socials-onw0PJ2H.js → socials-DSQ2wMQE.js} +1 -1
- package/assets/{swaps-DCWiSyRc.js → swaps-DOmQ-2Ov.js} +1 -1
- package/assets/switch-chain-Bwl76z8E.js +1 -0
- package/assets/{thirdweb-CXrYv9sq.js → thirdweb-CuTQabzI.js} +3 -3
- package/assets/{totalSupply-Dtpa-Rc2.js → totalSupply-CVGbD7FC.js} +1 -1
- package/assets/{totalSupply-Ww9yF8QK.js → totalSupply-Ce2t0W0d.js} +1 -1
- package/assets/{transactionReceipt-DVqqJQEo.js → transactionReceipt-DgYVdPLL.js} +1 -1
- package/assets/{transactions-lxg1tS6E.js → transactions-DB6EqQAb.js} +1 -1
- package/assets/{utils-B2dQKDW4.js → utils-CUIXWH1v.js} +1 -1
- package/assets/{verifyHash-KOquD8l_.js → verifyHash-CxE8tlN8.js} +3 -3
- package/assets/{w3m-modal-oRYZfS8_.js → w3m-modal-BJ9JlRHj.js} +1 -1
- package/assets/{wait-for-tx-receipt-BcnY3DRy.js → wait-for-tx-receipt-CdM1R_-M.js} +1 -1
- package/assets/{wallets-BBf33h4g.js → wallets-Eh21KMYV.js} +6 -6
- package/assets/{web-connector-Dv6jqMvn.js → web-connector-dtXNAwkt.js} +2 -2
- package/assets/{web-connector-CqJVeGsM.js → web-connector-i2U4xEAp.js} +3 -3
- package/assets/{zora-sepolia-Vn0MFhFe.js → zora-sepolia-BS_ncL_N.js} +1 -1
- package/index.html +2 -2
- package/package.json +3 -3
- package/assets/concat-hex-Cl3ME3Ru.js +0 -1
- package/assets/decimals-jCGLItLd.js +0 -1
- package/assets/eth_estimateGas-BU0iPlrI.js +0 -1
- package/assets/eth_estimateGas-CwwZwCM3.js +0 -1
- package/assets/eth_getTransactionCount-D53D7AEK.js +0 -1
- package/assets/switch-chain-DkFtBw41.js +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as V,w as p,aV as h,aW as C,_ as c,aX as w,aY as _,aZ as P,a_ as H,a$ as $,aE as A,b0 as E,E as T}from"./ThirdwebWalletManager-
|
|
1
|
+
import{r as V,w as p,aV as h,aW as C,_ as c,aX as w,aY as _,aZ as P,a_ as H,a$ as $,aE as A,b0 as E,E as T}from"./ThirdwebWalletManager-_8PV4raS.js";import{concatHex as F}from"./concat-hex-DeWBGZEs.js";import{p as S}from"./index-Cp3T7PGa.js";import"./index-C9kcmpvP.js";import"./store-CraP4F4Y.js";import"./webauthn.min-CGpVStYZ.js";import"./index.es-D0_25Oh-.js";import"./send-eip712-transaction-RxArzXsP.js";import"./eth_sendRawTransaction-DPdnXbFR.js";import"./sha256-EtKFmWln.js";const O="0x1626ba7e",U=[{name:"hash",type:"bytes32"},{name:"signature",type:"bytes"}],L=[{type:"bytes4"}];async function B(t){return V({contract:t.contract,method:[O,U,L],params:[t.hash,t.signature]})}const N="0x6492649264926492649264926492649264926492649264926492649264926492";function b({address:t,data:n,signature:e}){return F([p([{type:"address"},{type:"bytes"},{type:"bytes"}],[t,n,e]),N])}const k="0x1626ba7e";async function v({hash:t,signature:n,contract:e}){try{return await B({contract:e,hash:t,signature:n})===k}catch(r){return console.error("Error verifying EIP-1271 signature",r),!1}}const G=`Ethereum Signed Message:
|
|
2
2
|
`;function R(t,n){const e=typeof t=="string"?h(t):t.raw instanceof Uint8Array?t.raw:C(t.raw),r=h(`${G}${e.length}`);return c(w(r,e),n)}function j(t){const{domain:n={},message:e,primaryType:r}=t,s={EIP712Domain:_(n),...t.types};P({domain:n,message:e,primaryType:r,types:s});const a=["0x1901"];if(n&&a.push(H({domain:n,types:s})),r!=="EIP712Domain"){const i=(()=>{const o=x({data:e,primaryType:r,types:s});return c(o)})();a.push(i)}return c(w(...a.map(i=>$(i))))}function x({data:t,primaryType:n,types:e}){const r=[{type:"bytes32"}],s=[z({primaryType:n,types:e})];if(!e[n])throw new Error("Invalid types");for(const a of e[n]){const[i,o]=M({name:a.name,type:a.type,types:e,value:t[a.name]});r.push(i),s.push(o)}return p(r,s)}function z({primaryType:t,types:n}){const e=A(W({primaryType:t,types:n}));return c(e)}function W({primaryType:t,types:n}){let e="";const r=D({primaryType:t,types:n});r.delete(t);const s=[t,...Array.from(r).sort()];for(const a of s){if(!n[a])throw new Error("Invalid types");e+=`${a}(${n[a].map(({name:i,type:o})=>`${o} ${i}`).join(",")})`}return e}function D({primaryType:t,types:n},e=new Set){const r=t.match(/^\w*/u),s=r==null?void 0:r[0];if(e.has(s)||n[s]===void 0)return e;e.add(s);for(const a of n[s])D({primaryType:a.type,types:n},e);return e}function M({types:t,name:n,type:e,value:r}){if(t[e]!==void 0)return[{type:"bytes32"},c(x({data:r,primaryType:e,types:t}))];if(e==="bytes")return r=`0x${(r.length%2?"0":"")+r.slice(2)}`,[{type:"bytes32"},c(r)];if(e==="string")return[{type:"bytes32"},c(A(r))];if(e.lastIndexOf("]")===e.length-1){const s=e.slice(0,e.lastIndexOf("[")),a=r.map(i=>M({name:n,type:s,types:t,value:i}));return[{type:"bytes32"},c(p(a.map(([i])=>i),a.map(([,i])=>i)))]}return[{type:e},r]}async function ae({accountContract:t,factoryContract:n,options:e,message:r}){var f,u;const s=R(r);let a;const i=p([{type:"bytes32"}],[s]);if(a=await e.personalAccount.signTypedData({domain:{chainId:e.chain.id,name:"Account",verifyingContract:t.address,version:"1"},message:{message:i},primaryType:"AccountMessage",types:{AccountMessage:[{name:"message",type:"bytes"}]}}),await E(t)){if(await v({contract:t,hash:s,signature:a}))return a;throw new Error("Failed to verify signature")}else{const d=S({accountSalt:(f=e.overrides)==null?void 0:f.accountSalt,adminAddress:e.personalAccount.address,createAccountOverride:(u=e.overrides)==null?void 0:u.createAccount,factoryContract:n});if(!d)throw new Error("Create account override not provided");const y=await T(d);return b({address:n.address,data:y,signature:a})}}async function se({accountContract:t,factoryContract:n,options:e,typedData:r}){var u,d,y,g,l;if(((d=(u=r.domain)==null?void 0:u.verifyingContract)==null?void 0:d.toLowerCase())===((y=t.address)==null?void 0:y.toLowerCase()))return e.personalAccount.signTypedData(r);const a=j(r);let i;const o=p([{type:"bytes32"}],[a]);if(i=await e.personalAccount.signTypedData({domain:{chainId:e.chain.id,name:"Account",verifyingContract:t.address,version:"1"},message:{message:o},primaryType:"AccountMessage",types:{AccountMessage:[{name:"message",type:"bytes"}]}}),await E(t)){if(await v({contract:t,hash:a,signature:i}))return i;throw new Error("Failed to verify signature")}else{const m=S({accountSalt:(g=e.overrides)==null?void 0:g.accountSalt,adminAddress:e.personalAccount.address,createAccountOverride:(l=e.overrides)==null?void 0:l.createAccount,factoryContract:n});if(!m)throw new Error("Create account override not provided");const I=await T(m);return b({address:n.address,data:I,signature:i})}}export{ae as smartAccountSignMessage,se as smartAccountSignTypedData};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as O,l as _,y as S,O as h,L as W,R as f,d as T,m as c,a as C,P as F,u as D,C as d,o as P,E as u,G as A,S as v,Q as N,M as R,T as x}from"./index-
|
|
1
|
+
import{j as O,l as _,y as S,O as h,L as W,R as f,d as T,m as c,a as C,P as F,u as D,C as d,o as P,E as u,G as A,S as v,Q as N,M as R,T as x}from"./index-CyiA1q8T.js";import{n as j,r as l,c as I}from"./index-Dn7k_DQ8.js";import{o as $}from"./if-defined-DDCgUiYp.js";import{O as U}from"./index-IdBnFbaK.js";import{e as M}from"./index-DlXwok7s.js";import"./index-CMJ_znKB.js";import"./index-CsvMexRW.js";import{C as q}from"./ConstantsUtil-BBWopuyF.js";import"./index-J_VvzvhB.js";import"./index-DrDz7oQI.js";import"./index-CnyP_n54.js";import"./index-C9kcmpvP.js";import"./NetworkUtil-Ci2WRYQ5.js";import"./hmac-Bk4Z90TB.js";import"./index.es-D0_25Oh-.js";import"./index.es-BnBQYKMl.js";import"./ref-C8ELo-FX.js";import"./index-CQCjMzl4.js";import"./index-DsUVe2Dc.js";import"./browser-DvQJ0ksv.js";const z=O`
|
|
2
2
|
:host {
|
|
3
3
|
margin-top: ${({spacing:t})=>t[1]};
|
|
4
4
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as A,l as D,C as $,N as h,m as u,d as V,E as N,R as S,a as M,M as K,q as F,W as Q,r as W,k as q}from"./index-
|
|
1
|
+
import{j as A,l as D,C as $,N as h,m as u,d as V,E as N,R as S,a as M,M as K,q as F,W as Q,r as W,k as q}from"./index-CyiA1q8T.js";import{r as l,n as w,c as C}from"./index-Dn7k_DQ8.js";import"./index-J_VvzvhB.js";import"./index-CMJ_znKB.js";import{M as _}from"./index-dU7YfzFY.js";import"./index-D338ESwc.js";import{S as s}from"./SwapController-Czs5wFSm.js";import"./index-CnyP_n54.js";import"./index-CvAs0GYP.js";import"./index-DQ09NiWi.js";import"./index-DsUVe2Dc.js";import"./index-C9kcmpvP.js";import"./NetworkUtil-Ci2WRYQ5.js";import"./hmac-Bk4Z90TB.js";import"./index.es-D0_25Oh-.js";import"./index.es-BnBQYKMl.js";import"./index-CQCjMzl4.js";import"./if-defined-DDCgUiYp.js";import"./ref-C8ELo-FX.js";const H={numericInputKeyDown(e,t,o){const i=["Backspace","Meta","Ctrl","a","A","c","C","x","X","v","V","ArrowLeft","ArrowRight","Tab"],r=e.metaKey||e.ctrlKey,n=e.key,a=n.toLocaleLowerCase(),c=a==="a",b=a==="c",I=a==="v",U=a==="x",L=n===",",R=n===".",B=n>="0"&&n<="9";!r&&(c||b||I||U)&&e.preventDefault(),t==="0"&&!L&&!R&&n==="0"&&e.preventDefault(),t==="0"&&B&&(o(n),e.preventDefault()),(L||R)&&(t||(o("0."),e.preventDefault()),(t!=null&&t.includes(".")||t!=null&&t.includes(","))&&e.preventDefault()),!B&&!i.includes(n)&&!R&&!L&&e.preventDefault()}},G=A`
|
|
2
2
|
:host {
|
|
3
3
|
width: 100%;
|
|
4
4
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{G as n,U as e}from"./ThirdwebWalletManager-_8PV4raS.js";import"./index-C9kcmpvP.js";import"./store-CraP4F4Y.js";import"./webauthn.min-CGpVStYZ.js";import"./index.es-D0_25Oh-.js";async function s(r){var t;const{wallet:i,params:a}=r;return((t=i.getChain())==null?void 0:t.id)===n(a[0].chainId)||await i.switchChain(e(n(a[0].chainId))),"0x1"}export{s as handleSwitchChain};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/utils-
|
|
2
|
-
import{e as v,c as T,d as ee,w as St,L as Ct,h as Pt,a as Y,f as $t}from"./utils-B2dQKDW4.js";import{j as A,i as xe,o as ie,ar as Ot,as as Ue,u as Le,at as Me,C as Z,V as qe,t as Fe,x as j,w as re,g as U,b as X,au as Dt,n as F,av as zt,m as Ie,aw as Ce,ax as he,ay as We,az as Ve,aA as Ze,af as Rt,aB as He,aC as Ae,aD as me,aE as Ke,aF as Je,aG as $,aa as q,aH as Bt,aI as Ge,d as Nt,aJ as jt,aK as xt,aL as Ut,aM as Lt,aN as Mt,aO as qt,Z as Pe,aP as Ft,aQ as Wt,aR as Vt,aS as Zt,aT as Ht,W as Kt,aU as Jt,aV as Gt,v as Qt,aW as Yt,ab as Xt,aX as en,r as tn,s as nn,aY as rn,ac as on,ad as sn,aZ as an,a_ as cn,a$ as dn,b0 as un,b1 as ln,Y as fn,b2 as hn,b3 as mn,h as pn,b4 as gn,a as yn,ao as wn,b5 as _n,k as bn,b6 as kn,S as In,b7 as An,b8 as Tn,q as vn,b9 as En}from"./signing-D7VaTtN_.js";import{_ as k}from"./index-CTPexb85.js";import{a as Qe,b as Ye,e as Sn,w as Cn}from"./wait-for-tx-receipt-BcnY3DRy.js";import{eth_estimateGas as Pn}from"./eth_estimateGas-CwwZwCM3.js";import{a as Xe}from"./transactionReceipt-DVqqJQEo.js";import{e as $n}from"./eth_getStorageAt-BFNcSJRC.js";import{eth_getTransactionCount as On}from"./eth_getTransactionCount-Dcc1nhjw.js";import{decimals as pe}from"./decimals-jCGLItLd.js";import{b as Dn,a as zn,o as Rn,c as Bn,z as Nn,d as jn}from"./zora-sepolia-Vn0MFhFe.js";import{a as xn,s as Un}from"./send-batch-transaction-CzhCEKJe.js";class R 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 Ln(e){const{originChainId:t,originTokenAddress:n,destinationChainId:r,destinationTokenAddress:o,client:s,maxSteps:i}=e,a="buyAmountWei"in e?e.buyAmountWei:e.amount,c=T(s),d=new URL(`${v("bridge")}/v1/buy/quote`);d.searchParams.set("originChainId",t.toString()),d.searchParams.set("originTokenAddress",n),d.searchParams.set("destinationChainId",r.toString()),d.searchParams.set("destinationTokenAddress",o),d.searchParams.set("buyAmountWei",a.toString()),d.searchParams.set("amount",a.toString()),i&&d.searchParams.set("maxSteps",i.toString());const p=await c(d.toString());if(!p.ok){const u=await p.json();throw new R({code:u.code||"UNKNOWN_ERROR",correlationId:u.correlationId||void 0,message:u.message||p.statusText,statusCode:p.status})}const{data:f}=await p.json();return{blockNumber:f.blockNumber?BigInt(f.blockNumber):void 0,destinationAmount:BigInt(f.destinationAmount),estimatedExecutionTimeMs:f.estimatedExecutionTimeMs,intent:{amount:a,buyAmountWei:a,destinationChainId:r,destinationTokenAddress:o,originChainId:t,originTokenAddress:n},originAmount:BigInt(f.originAmount),steps:f.steps,timestamp:f.timestamp}}async function et(e){const{originChainId:t,originTokenAddress:n,destinationChainId:r,destinationTokenAddress:o,sender:s,receiver:i,client:a,amount:c,purchaseData:d,maxSteps:p,paymentLinkId:f,slippageToleranceBps:u}=e,l=T(a),h=new URL(`${v("bridge")}/v1/buy/prepare`),m=await l(h.toString(),{body:A({amount:c.toString(),buyAmountWei:c.toString(),destinationChainId:r.toString(),destinationTokenAddress:o,maxSteps:p,originChainId:t.toString(),originTokenAddress:n,paymentLinkId:f,purchaseData:d,receiver:i,sender:s,slippageToleranceBps:u}),headers:{"Content-Type":"application/json"},method:"POST"});if(!m.ok){const _=await m.json();throw new R({code:_.code||"UNKNOWN_ERROR",correlationId:_.correlationId||void 0,message:_.message||m.statusText,statusCode:m.status})}const{data:y}=await m.json();return{blockNumber:y.blockNumber?BigInt(y.blockNumber):void 0,destinationAmount:BigInt(y.destinationAmount),estimatedExecutionTimeMs:y.estimatedExecutionTimeMs,intent:{amount:c,destinationChainId:r,destinationTokenAddress:o,originChainId:t,originTokenAddress:n,receiver:i,sender:s},originAmount:BigInt(y.originAmount),steps:y.steps.map(_=>({..._,transactions:_.transactions.map(g=>({...g,chain:ee(g.chainId),client:a,value:g.value?BigInt(g.value):void 0}))})),timestamp:y.timestamp}}const Mn=Object.freeze(Object.defineProperty({__proto__:null,prepare:et,quote:Ln},Symbol.toStringTag,{value:"Module"}));async function qn(e){const{client:t}=e;return St(async()=>{const n=T(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 o=await n(r.toString());if(!o.ok){const i=await o.json();throw new R({code:i.code||"UNKNOWN_ERROR",correlationId:i.correlationId||void 0,message:i.message||o.statusText,statusCode:o.status})}const{data:s}=await o.json();return s},{cacheKey:`bridge-chains-${JSON.stringify(e)}`,cacheTime:1e3*60*60*1})}async function Fn(e){const{id:t,client:n}=e,r=T(n),o=new URL(`${v("bridge")}/v1/onramp/status`);o.searchParams.set("id",t);const s=await r(o.toString());if(!s.ok){const a=await s.json();throw new R({code:a.code||"UNKNOWN_ERROR",correlationId:a.correlationId||void 0,message:a.message||s.statusText,statusCode:s.status})}const{data:i}=await s.json();return i}async function Wn(e){const{client:t,onramp:n,chainId:r,tokenAddress:o,receiver:s,amount:i,purchaseData:a,sender:c,onrampTokenAddress:d,onrampChainId:p,currency:f,maxSteps:u,excludeChainIds:l,paymentLinkId:h,country:m}=e,y=T(t),_=`${v("bridge")}/v1/onramp/prepare`,g={chainId:Number(r),onramp:n,receiver:s,tokenAddress:o};i!==void 0&&(g.amount=i.toString()),a!==void 0&&(g.purchaseData=a),c!==void 0&&(g.sender=c),d!==void 0&&(g.onrampTokenAddress=d),p!==void 0&&(g.onrampChainId=Number(p)),f!==void 0&&(g.currency=f),u!==void 0&&(g.maxSteps=u),l!==void 0&&(g.excludeChainIds=Array.isArray(l)?l.join(","):l),h!==void 0&&(g.paymentLinkId=h),m!==void 0&&(g.country=m);const b=await y(_,{body:A(g),headers:{"Content-Type":"application/json"},method:"POST"});if(!b.ok){const P=await b.json();throw new R({code:P.code||"UNKNOWN_ERROR",correlationId:P.correlationId||void 0,message:P.message||b.statusText,statusCode:b.status})}const{data:w}=await b.json(),E=w.steps.map(P=>({...P,destinationAmount:BigInt(P.destinationAmount),originAmount:BigInt(P.originAmount),transactions:P.transactions.map(L=>({...L,chain:ee(L.chainId),client:t,value:L.value?BigInt(L.value):void 0}))})),N={...w.intent,amount:w.intent.amount?w.intent.amount:void 0};return{...w,destinationAmount:BigInt(w.destinationAmount),intent:N,steps:E}}const Vn=Object.freeze(Object.defineProperty({__proto__:null,prepare:Wn,status:Fn},Symbol.toStringTag,{value:"Module"}));async function Zn(e){const{originChainId:t,originTokenAddress:n,destinationChainId:r,destinationTokenAddress:o,amount:s,client:i,maxSteps:a}=e,c=T(i),d=new URL(`${v("bridge")}/v1/sell/quote`);d.searchParams.set("originChainId",t.toString()),d.searchParams.set("originTokenAddress",n),d.searchParams.set("destinationChainId",r.toString()),d.searchParams.set("destinationTokenAddress",o),d.searchParams.set("sellAmountWei",s.toString()),d.searchParams.set("amount",s.toString()),typeof a<"u"&&d.searchParams.set("maxSteps",a.toString());const p=await c(d.toString());if(!p.ok){const u=await p.json();throw new R({code:u.code||"UNKNOWN_ERROR",correlationId:u.correlationId||void 0,message:u.message||p.statusText,statusCode:p.status})}const{data:f}=await p.json();return{blockNumber:f.blockNumber?BigInt(f.blockNumber):void 0,destinationAmount:BigInt(f.destinationAmount),estimatedExecutionTimeMs:f.estimatedExecutionTimeMs,intent:{amount:s,destinationChainId:r,destinationTokenAddress:o,originChainId:t,originTokenAddress:n},originAmount:BigInt(f.originAmount),steps:f.steps,timestamp:f.timestamp}}async function tt(e){const{originChainId:t,originTokenAddress:n,destinationChainId:r,destinationTokenAddress:o,amount:s,sender:i,receiver:a,client:c,purchaseData:d,maxSteps:p,paymentLinkId:f,slippageToleranceBps:u}=e,l=T(c),h=new URL(`${v("bridge")}/v1/sell/prepare`),m=await l(h.toString(),{body:A({amount:s.toString(),destinationChainId:r.toString(),destinationTokenAddress:o,maxSteps:p,originChainId:t.toString(),originTokenAddress:n,paymentLinkId:f,purchaseData:d,receiver:a,sellAmountWei:s.toString(),sender:i,slippageToleranceBps:u}),headers:{"Content-Type":"application/json"},method:"POST"});if(!m.ok){const _=await m.json();throw new R({code:_.code||"UNKNOWN_ERROR",correlationId:_.correlationId||void 0,message:_.message||m.statusText,statusCode:m.status})}const{data:y}=await m.json();return{blockNumber:y.blockNumber?BigInt(y.blockNumber):void 0,destinationAmount:BigInt(y.destinationAmount),estimatedExecutionTimeMs:y.estimatedExecutionTimeMs,expiration:y.expiration,intent:{amount:s,destinationChainId:r,destinationTokenAddress:o,originChainId:t,originTokenAddress:n,purchaseData:d,receiver:a,sender:i},originAmount:BigInt(y.originAmount),steps:y.steps.map(_=>({..._,transactions:_.transactions.map(g=>({...g,chain:ee(g.chainId),client:c,value:g.value?BigInt(g.value):void 0}))})),timestamp:y.timestamp}}const Hn=Object.freeze(Object.defineProperty({__proto__:null,prepare:tt,quote:Zn},Symbol.toStringTag,{value:"Module"}));async function nt(e){const{transactionHash:t,client:n,transactionId:r}=e,o="chainId"in e?e.chainId:e.chain.id,s=T(n),i=new URL(`${v("bridge")}/v1/status`);i.searchParams.set("transactionHash",t),i.searchParams.set("chainId",o.toString()),r&&i.searchParams.set("transactionId",r);const a=await s(i.toString());if(!a.ok){const d=await a.json();throw new R({code:d.code||"UNKNOWN_ERROR",correlationId:d.correlationId||void 0,message:d.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 Kn(e){const{client:t,chainId:n,tokenAddress:r,symbol:o,name:s,limit:i,offset:a,includePrices:c,sortBy:d,query:p}=e,f=T(t),u=new URL(`${v("bridge")}/v1/tokens`);n!=null&&u.searchParams.set("chainId",n.toString()),r&&u.searchParams.set("tokenAddress",r),o&&u.searchParams.set("symbol",o),s&&u.searchParams.set("name",s),i!==void 0&&u.searchParams.set("limit",i.toString()),a!=null&&u.searchParams.set("offset",a.toString()),c!==void 0&&u.searchParams.set("includePrices",c.toString()),d!==void 0&&u.searchParams.set("sortBy",d),p!==void 0&&u.searchParams.set("query",p);const l=await f(u.toString());if(!l.ok){const m=await l.json();throw new R({code:m.code||"UNKNOWN_ERROR",correlationId:m.correlationId||void 0,message:m.message||l.statusText,statusCode:l.status})}const{data:h}=await l.json();return h}async function rt(e){const{chainId:t,tokenAddress:n,sender:r,receiver:o,client:s,amount:i,purchaseData:a,feePayer:c,paymentLinkId:d}=e,p=T(s),f=new URL(`${v("bridge")}/v1/transfer/prepare`),u=await p(f.toString(),{body:A({amount:i.toString(),chainId:t.toString(),feePayer:c,paymentLinkId:d,purchaseData:a,receiver:o,sender:r,tokenAddress:n,transferAmountWei:i.toString()}),headers:{"Content-Type":"application/json"},method:"POST"});if(!u.ok){const h=await u.json();throw new R({code:h.code||"UNKNOWN_ERROR",correlationId:h.correlationId||void 0,message:h.message||u.statusText,statusCode:u.status})}const{data:l}=await u.json();return{blockNumber:l.blockNumber?BigInt(l.blockNumber):void 0,destinationAmount:BigInt(l.destinationAmount),estimatedExecutionTimeMs:l.estimatedExecutionTimeMs,intent:{amount:i,chainId:t,feePayer:c,receiver:o,sender:r,tokenAddress:n},originAmount:BigInt(l.originAmount),steps:l.steps.map(h=>({...h,transactions:h.transactions.map(m=>({...m,chain:ee(m.chainId),client:s,value:m.value?BigInt(m.value):void 0}))})),timestamp:l.timestamp}}const Jn=Object.freeze(Object.defineProperty({__proto__:null,prepare:rt},Symbol.toStringTag,{value:"Module"}));function I(e,t,n){function r(a,c){var d;Object.defineProperty(a,"_zod",{value:a._zod??{},enumerable:!1}),(d=a._zod).traits??(d.traits=new Set),a._zod.traits.add(e),t(a,c);for(const p in i.prototype)p in a||Object.defineProperty(a,p,{value:i.prototype[p].bind(a)});a._zod.constr=i,a._zod.def=c}const o=(n==null?void 0:n.Parent)??Object;class s extends o{}Object.defineProperty(s,"name",{value:e});function i(a){var c;const d=n!=null&&n.Parent?new s:this;r(d,a),(c=d._zod).deferred??(c.deferred=[]);for(const p of d._zod.deferred)p();return d}return Object.defineProperty(i,"init",{value:r}),Object.defineProperty(i,Symbol.hasInstance,{value:a=>{var c,d;return n!=null&&n.Parent&&a instanceof n.Parent?!0:(d=(c=a==null?void 0:a._zod)==null?void 0:c.traits)==null?void 0:d.has(e)}}),Object.defineProperty(i,"name",{value:e}),i}class oe extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}const ot={};function H(e){return ot}function Gn(e){const t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,o])=>t.indexOf(+r)===-1).map(([r,o])=>o)}function Qn(e,t){return typeof t=="bigint"?t.toString():t}function Te(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function st(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function B(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 Yn(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function G(e){return JSON.stringify(e)}const it=Error.captureStackTrace?Error.captureStackTrace:(...e)=>{};function se(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const Xn=Te(()=>{var e;if(typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)!=null&&e.includes("Cloudflare")))return!1;try{const t=Function;return new t(""),!0}catch{return!1}});function er(e){if(se(e)===!1)return!1;const t=e.constructor;if(t===void 0)return!0;const n=t.prototype;return!(se(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}const tr=new Set(["string","number","symbol"]);function at(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function nr(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n!=null&&n.parent)&&(r._zod.parent=e),r}function D(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if((t==null?void 0:t.message)!==void 0){if((t==null?void 0: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 rr(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}function de(e,t=0){var n;for(let r=t;r<e.issues.length;r++)if(((n=e.issues[r])==null?void 0:n.continue)!==!0)return!0;return!1}function M(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function te(e){return typeof e=="string"?e:e==null?void 0:e.message}function K(e,t,n){var o,s,i,a,c,d;const r={...e,path:e.path??[]};if(!e.message){const p=te((i=(s=(o=e.inst)==null?void 0:o._zod.def)==null?void 0:s.error)==null?void 0:i.call(s,e))??te((a=t==null?void 0:t.error)==null?void 0:a.call(t,e))??te((c=n.customError)==null?void 0:c.call(n,e))??te((d=n.localeError)==null?void 0:d.call(n,e))??"Invalid input";r.message=p}return delete r.inst,delete r.continue,t!=null&&t.reportInput||delete r.input,r}function or(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}const ct=(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,Qn,2)},enumerable:!0})},sr=I("$ZodError",ct),ae=I("$ZodError",ct,{Parent:Error}),ir=e=>(t,n,r,o)=>{const s=r?Object.assign(r,{async:!1}):{async:!1},i=t._zod.run({value:n,issues:[]},s);if(i instanceof Promise)throw new oe;if(i.issues.length){const a=new((o==null?void 0:o.Err)??e)(i.issues.map(c=>K(c,s,H())));throw it(a,o==null?void 0:o.callee),a}return i.value},ar=ir(ae),cr=e=>async(t,n,r,o)=>{const s=r?Object.assign(r,{async:!0}):{async:!0};let i=t._zod.run({value:n,issues:[]},s);if(i instanceof Promise&&(i=await i),i.issues.length){const a=new((o==null?void 0:o.Err)??e)(i.issues.map(c=>K(c,s,H())));throw it(a,o==null?void 0:o.callee),a}return i.value},dr=cr(ae),ur=e=>(t,n,r)=>{const o=r?{...r,async:!1}:{async:!1},s=t._zod.run({value:n,issues:[]},o);if(s instanceof Promise)throw new oe;return s.issues.length?{success:!1,error:new(e??sr)(s.issues.map(i=>K(i,o,H())))}:{success:!0,data:s.value}},dt=ur(ae),lr=e=>async(t,n,r)=>{const o=r?Object.assign(r,{async:!0}):{async:!0};let s=t._zod.run({value:n,issues:[]},o);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new e(s.issues.map(i=>K(i,o,H())))}:{success:!0,data:s.value}},ut=lr(ae),fr=e=>{const t=e?`[\\s\\S]{${(e==null?void 0:e.minimum)??0},${(e==null?void 0:e.maximum)??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},hr=/^\d+n?$/,mr=/^-?\d+(?:\.\d+)?/i,pr=I("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])});class gr{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__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/utils-CUIXWH1v.js","assets/index-C9kcmpvP.js","assets/index-BGvsmbMC.css","assets/common-DttAkYAP.js","assets/signing-DR1diqT_.js","assets/index-zeKYF1_9.js","assets/parseSignature-RSoun7s3.js","assets/transactionReceipt-DgYVdPLL.js","assets/rpc-YBySNaPU.js","assets/sha256-B_2-BKc1.js","assets/hashTypedData-LY3QUtcD.js","assets/ccip-C-GSKBZ0.js","assets/parseNft-bgONNYbj.js","assets/totalSupply-CVGbD7FC.js","assets/detectExtension-C1-4KxEP.js","assets/estimate-l1-fee-BXqjzhsB.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{e as v,c as T,d as ee,w as St,L as Ct,h as Pt,a as Y,f as $t}from"./utils-CUIXWH1v.js";import{j as A,i as xe,o as ie,ar as Ot,as as Ue,u as Le,at as Me,C as Z,V as qe,t as Fe,x as j,w as re,g as U,b as X,au as Dt,n as F,av as zt,m as Ie,aw as Ce,ax as he,ay as We,az as Ve,aA as Ze,af as Rt,aB as He,aC as Ae,aD as me,aE as Ke,aF as Je,aG as $,aa as q,aH as Bt,aI as Ge,d as Nt,aJ as jt,aK as xt,aL as Ut,aM as Lt,aN as Mt,aO as qt,Z as Pe,aP as Ft,aQ as Wt,aR as Vt,aS as Zt,aT as Ht,W as Kt,aU as Jt,aV as Gt,v as Qt,aW as Yt,ab as Xt,aX as en,r as tn,s as nn,aY as rn,ac as on,ad as sn,aZ as an,a_ as cn,a$ as dn,b0 as un,b1 as ln,Y as fn,b2 as hn,b3 as mn,h as pn,b4 as gn,a as yn,ao as wn,b5 as _n,k as bn,b6 as kn,S as In,b7 as An,b8 as Tn,q as vn,b9 as En}from"./signing-DR1diqT_.js";import{_ as k}from"./index-C9kcmpvP.js";import{a as Qe,b as Ye,e as Sn,w as Cn}from"./wait-for-tx-receipt-CdM1R_-M.js";import{eth_estimateGas as Pn}from"./eth_estimateGas-BLq5fjmK.js";import{a as Xe}from"./transactionReceipt-DgYVdPLL.js";import{e as $n}from"./eth_getStorageAt-BdHAJUde.js";import{eth_getTransactionCount as On}from"./eth_getTransactionCount-uA-BuCYb.js";import{decimals as pe}from"./decimals-CDYEp2UZ.js";import{b as Dn,a as zn,o as Rn,c as Bn,z as Nn,d as jn}from"./zora-sepolia-BS_ncL_N.js";import{a as xn,s as Un}from"./send-batch-transaction-BvT25Mc6.js";class R 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 Ln(e){const{originChainId:t,originTokenAddress:n,destinationChainId:r,destinationTokenAddress:o,client:s,maxSteps:i}=e,a="buyAmountWei"in e?e.buyAmountWei:e.amount,c=T(s),d=new URL(`${v("bridge")}/v1/buy/quote`);d.searchParams.set("originChainId",t.toString()),d.searchParams.set("originTokenAddress",n),d.searchParams.set("destinationChainId",r.toString()),d.searchParams.set("destinationTokenAddress",o),d.searchParams.set("buyAmountWei",a.toString()),d.searchParams.set("amount",a.toString()),i&&d.searchParams.set("maxSteps",i.toString());const p=await c(d.toString());if(!p.ok){const u=await p.json();throw new R({code:u.code||"UNKNOWN_ERROR",correlationId:u.correlationId||void 0,message:u.message||p.statusText,statusCode:p.status})}const{data:f}=await p.json();return{blockNumber:f.blockNumber?BigInt(f.blockNumber):void 0,destinationAmount:BigInt(f.destinationAmount),estimatedExecutionTimeMs:f.estimatedExecutionTimeMs,intent:{amount:a,buyAmountWei:a,destinationChainId:r,destinationTokenAddress:o,originChainId:t,originTokenAddress:n},originAmount:BigInt(f.originAmount),steps:f.steps,timestamp:f.timestamp}}async function et(e){const{originChainId:t,originTokenAddress:n,destinationChainId:r,destinationTokenAddress:o,sender:s,receiver:i,client:a,amount:c,purchaseData:d,maxSteps:p,paymentLinkId:f,slippageToleranceBps:u}=e,l=T(a),h=new URL(`${v("bridge")}/v1/buy/prepare`),m=await l(h.toString(),{body:A({amount:c.toString(),buyAmountWei:c.toString(),destinationChainId:r.toString(),destinationTokenAddress:o,maxSteps:p,originChainId:t.toString(),originTokenAddress:n,paymentLinkId:f,purchaseData:d,receiver:i,sender:s,slippageToleranceBps:u}),headers:{"Content-Type":"application/json"},method:"POST"});if(!m.ok){const _=await m.json();throw new R({code:_.code||"UNKNOWN_ERROR",correlationId:_.correlationId||void 0,message:_.message||m.statusText,statusCode:m.status})}const{data:y}=await m.json();return{blockNumber:y.blockNumber?BigInt(y.blockNumber):void 0,destinationAmount:BigInt(y.destinationAmount),estimatedExecutionTimeMs:y.estimatedExecutionTimeMs,intent:{amount:c,destinationChainId:r,destinationTokenAddress:o,originChainId:t,originTokenAddress:n,receiver:i,sender:s},originAmount:BigInt(y.originAmount),steps:y.steps.map(_=>({..._,transactions:_.transactions.map(g=>({...g,chain:ee(g.chainId),client:a,value:g.value?BigInt(g.value):void 0}))})),timestamp:y.timestamp}}const Mn=Object.freeze(Object.defineProperty({__proto__:null,prepare:et,quote:Ln},Symbol.toStringTag,{value:"Module"}));async function qn(e){const{client:t}=e;return St(async()=>{const n=T(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 o=await n(r.toString());if(!o.ok){const i=await o.json();throw new R({code:i.code||"UNKNOWN_ERROR",correlationId:i.correlationId||void 0,message:i.message||o.statusText,statusCode:o.status})}const{data:s}=await o.json();return s},{cacheKey:`bridge-chains-${JSON.stringify(e)}`,cacheTime:1e3*60*60*1})}async function Fn(e){const{id:t,client:n}=e,r=T(n),o=new URL(`${v("bridge")}/v1/onramp/status`);o.searchParams.set("id",t);const s=await r(o.toString());if(!s.ok){const a=await s.json();throw new R({code:a.code||"UNKNOWN_ERROR",correlationId:a.correlationId||void 0,message:a.message||s.statusText,statusCode:s.status})}const{data:i}=await s.json();return i}async function Wn(e){const{client:t,onramp:n,chainId:r,tokenAddress:o,receiver:s,amount:i,purchaseData:a,sender:c,onrampTokenAddress:d,onrampChainId:p,currency:f,maxSteps:u,excludeChainIds:l,paymentLinkId:h,country:m}=e,y=T(t),_=`${v("bridge")}/v1/onramp/prepare`,g={chainId:Number(r),onramp:n,receiver:s,tokenAddress:o};i!==void 0&&(g.amount=i.toString()),a!==void 0&&(g.purchaseData=a),c!==void 0&&(g.sender=c),d!==void 0&&(g.onrampTokenAddress=d),p!==void 0&&(g.onrampChainId=Number(p)),f!==void 0&&(g.currency=f),u!==void 0&&(g.maxSteps=u),l!==void 0&&(g.excludeChainIds=Array.isArray(l)?l.join(","):l),h!==void 0&&(g.paymentLinkId=h),m!==void 0&&(g.country=m);const b=await y(_,{body:A(g),headers:{"Content-Type":"application/json"},method:"POST"});if(!b.ok){const P=await b.json();throw new R({code:P.code||"UNKNOWN_ERROR",correlationId:P.correlationId||void 0,message:P.message||b.statusText,statusCode:b.status})}const{data:w}=await b.json(),E=w.steps.map(P=>({...P,destinationAmount:BigInt(P.destinationAmount),originAmount:BigInt(P.originAmount),transactions:P.transactions.map(L=>({...L,chain:ee(L.chainId),client:t,value:L.value?BigInt(L.value):void 0}))})),N={...w.intent,amount:w.intent.amount?w.intent.amount:void 0};return{...w,destinationAmount:BigInt(w.destinationAmount),intent:N,steps:E}}const Vn=Object.freeze(Object.defineProperty({__proto__:null,prepare:Wn,status:Fn},Symbol.toStringTag,{value:"Module"}));async function Zn(e){const{originChainId:t,originTokenAddress:n,destinationChainId:r,destinationTokenAddress:o,amount:s,client:i,maxSteps:a}=e,c=T(i),d=new URL(`${v("bridge")}/v1/sell/quote`);d.searchParams.set("originChainId",t.toString()),d.searchParams.set("originTokenAddress",n),d.searchParams.set("destinationChainId",r.toString()),d.searchParams.set("destinationTokenAddress",o),d.searchParams.set("sellAmountWei",s.toString()),d.searchParams.set("amount",s.toString()),typeof a<"u"&&d.searchParams.set("maxSteps",a.toString());const p=await c(d.toString());if(!p.ok){const u=await p.json();throw new R({code:u.code||"UNKNOWN_ERROR",correlationId:u.correlationId||void 0,message:u.message||p.statusText,statusCode:p.status})}const{data:f}=await p.json();return{blockNumber:f.blockNumber?BigInt(f.blockNumber):void 0,destinationAmount:BigInt(f.destinationAmount),estimatedExecutionTimeMs:f.estimatedExecutionTimeMs,intent:{amount:s,destinationChainId:r,destinationTokenAddress:o,originChainId:t,originTokenAddress:n},originAmount:BigInt(f.originAmount),steps:f.steps,timestamp:f.timestamp}}async function tt(e){const{originChainId:t,originTokenAddress:n,destinationChainId:r,destinationTokenAddress:o,amount:s,sender:i,receiver:a,client:c,purchaseData:d,maxSteps:p,paymentLinkId:f,slippageToleranceBps:u}=e,l=T(c),h=new URL(`${v("bridge")}/v1/sell/prepare`),m=await l(h.toString(),{body:A({amount:s.toString(),destinationChainId:r.toString(),destinationTokenAddress:o,maxSteps:p,originChainId:t.toString(),originTokenAddress:n,paymentLinkId:f,purchaseData:d,receiver:a,sellAmountWei:s.toString(),sender:i,slippageToleranceBps:u}),headers:{"Content-Type":"application/json"},method:"POST"});if(!m.ok){const _=await m.json();throw new R({code:_.code||"UNKNOWN_ERROR",correlationId:_.correlationId||void 0,message:_.message||m.statusText,statusCode:m.status})}const{data:y}=await m.json();return{blockNumber:y.blockNumber?BigInt(y.blockNumber):void 0,destinationAmount:BigInt(y.destinationAmount),estimatedExecutionTimeMs:y.estimatedExecutionTimeMs,expiration:y.expiration,intent:{amount:s,destinationChainId:r,destinationTokenAddress:o,originChainId:t,originTokenAddress:n,purchaseData:d,receiver:a,sender:i},originAmount:BigInt(y.originAmount),steps:y.steps.map(_=>({..._,transactions:_.transactions.map(g=>({...g,chain:ee(g.chainId),client:c,value:g.value?BigInt(g.value):void 0}))})),timestamp:y.timestamp}}const Hn=Object.freeze(Object.defineProperty({__proto__:null,prepare:tt,quote:Zn},Symbol.toStringTag,{value:"Module"}));async function nt(e){const{transactionHash:t,client:n,transactionId:r}=e,o="chainId"in e?e.chainId:e.chain.id,s=T(n),i=new URL(`${v("bridge")}/v1/status`);i.searchParams.set("transactionHash",t),i.searchParams.set("chainId",o.toString()),r&&i.searchParams.set("transactionId",r);const a=await s(i.toString());if(!a.ok){const d=await a.json();throw new R({code:d.code||"UNKNOWN_ERROR",correlationId:d.correlationId||void 0,message:d.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 Kn(e){const{client:t,chainId:n,tokenAddress:r,symbol:o,name:s,limit:i,offset:a,includePrices:c,sortBy:d,query:p}=e,f=T(t),u=new URL(`${v("bridge")}/v1/tokens`);n!=null&&u.searchParams.set("chainId",n.toString()),r&&u.searchParams.set("tokenAddress",r),o&&u.searchParams.set("symbol",o),s&&u.searchParams.set("name",s),i!==void 0&&u.searchParams.set("limit",i.toString()),a!=null&&u.searchParams.set("offset",a.toString()),c!==void 0&&u.searchParams.set("includePrices",c.toString()),d!==void 0&&u.searchParams.set("sortBy",d),p!==void 0&&u.searchParams.set("query",p);const l=await f(u.toString());if(!l.ok){const m=await l.json();throw new R({code:m.code||"UNKNOWN_ERROR",correlationId:m.correlationId||void 0,message:m.message||l.statusText,statusCode:l.status})}const{data:h}=await l.json();return h}async function rt(e){const{chainId:t,tokenAddress:n,sender:r,receiver:o,client:s,amount:i,purchaseData:a,feePayer:c,paymentLinkId:d}=e,p=T(s),f=new URL(`${v("bridge")}/v1/transfer/prepare`),u=await p(f.toString(),{body:A({amount:i.toString(),chainId:t.toString(),feePayer:c,paymentLinkId:d,purchaseData:a,receiver:o,sender:r,tokenAddress:n,transferAmountWei:i.toString()}),headers:{"Content-Type":"application/json"},method:"POST"});if(!u.ok){const h=await u.json();throw new R({code:h.code||"UNKNOWN_ERROR",correlationId:h.correlationId||void 0,message:h.message||u.statusText,statusCode:u.status})}const{data:l}=await u.json();return{blockNumber:l.blockNumber?BigInt(l.blockNumber):void 0,destinationAmount:BigInt(l.destinationAmount),estimatedExecutionTimeMs:l.estimatedExecutionTimeMs,intent:{amount:i,chainId:t,feePayer:c,receiver:o,sender:r,tokenAddress:n},originAmount:BigInt(l.originAmount),steps:l.steps.map(h=>({...h,transactions:h.transactions.map(m=>({...m,chain:ee(m.chainId),client:s,value:m.value?BigInt(m.value):void 0}))})),timestamp:l.timestamp}}const Jn=Object.freeze(Object.defineProperty({__proto__:null,prepare:rt},Symbol.toStringTag,{value:"Module"}));function I(e,t,n){function r(a,c){var d;Object.defineProperty(a,"_zod",{value:a._zod??{},enumerable:!1}),(d=a._zod).traits??(d.traits=new Set),a._zod.traits.add(e),t(a,c);for(const p in i.prototype)p in a||Object.defineProperty(a,p,{value:i.prototype[p].bind(a)});a._zod.constr=i,a._zod.def=c}const o=(n==null?void 0:n.Parent)??Object;class s extends o{}Object.defineProperty(s,"name",{value:e});function i(a){var c;const d=n!=null&&n.Parent?new s:this;r(d,a),(c=d._zod).deferred??(c.deferred=[]);for(const p of d._zod.deferred)p();return d}return Object.defineProperty(i,"init",{value:r}),Object.defineProperty(i,Symbol.hasInstance,{value:a=>{var c,d;return n!=null&&n.Parent&&a instanceof n.Parent?!0:(d=(c=a==null?void 0:a._zod)==null?void 0:c.traits)==null?void 0:d.has(e)}}),Object.defineProperty(i,"name",{value:e}),i}class oe extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}const ot={};function H(e){return ot}function Gn(e){const t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,o])=>t.indexOf(+r)===-1).map(([r,o])=>o)}function Qn(e,t){return typeof t=="bigint"?t.toString():t}function Te(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function st(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function B(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 Yn(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function G(e){return JSON.stringify(e)}const it=Error.captureStackTrace?Error.captureStackTrace:(...e)=>{};function se(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const Xn=Te(()=>{var e;if(typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)!=null&&e.includes("Cloudflare")))return!1;try{const t=Function;return new t(""),!0}catch{return!1}});function er(e){if(se(e)===!1)return!1;const t=e.constructor;if(t===void 0)return!0;const n=t.prototype;return!(se(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}const tr=new Set(["string","number","symbol"]);function at(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function nr(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n!=null&&n.parent)&&(r._zod.parent=e),r}function D(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if((t==null?void 0:t.message)!==void 0){if((t==null?void 0: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 rr(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}function de(e,t=0){var n;for(let r=t;r<e.issues.length;r++)if(((n=e.issues[r])==null?void 0:n.continue)!==!0)return!0;return!1}function M(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function te(e){return typeof e=="string"?e:e==null?void 0:e.message}function K(e,t,n){var o,s,i,a,c,d;const r={...e,path:e.path??[]};if(!e.message){const p=te((i=(s=(o=e.inst)==null?void 0:o._zod.def)==null?void 0:s.error)==null?void 0:i.call(s,e))??te((a=t==null?void 0:t.error)==null?void 0:a.call(t,e))??te((c=n.customError)==null?void 0:c.call(n,e))??te((d=n.localeError)==null?void 0:d.call(n,e))??"Invalid input";r.message=p}return delete r.inst,delete r.continue,t!=null&&t.reportInput||delete r.input,r}function or(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}const ct=(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,Qn,2)},enumerable:!0})},sr=I("$ZodError",ct),ae=I("$ZodError",ct,{Parent:Error}),ir=e=>(t,n,r,o)=>{const s=r?Object.assign(r,{async:!1}):{async:!1},i=t._zod.run({value:n,issues:[]},s);if(i instanceof Promise)throw new oe;if(i.issues.length){const a=new((o==null?void 0:o.Err)??e)(i.issues.map(c=>K(c,s,H())));throw it(a,o==null?void 0:o.callee),a}return i.value},ar=ir(ae),cr=e=>async(t,n,r,o)=>{const s=r?Object.assign(r,{async:!0}):{async:!0};let i=t._zod.run({value:n,issues:[]},s);if(i instanceof Promise&&(i=await i),i.issues.length){const a=new((o==null?void 0:o.Err)??e)(i.issues.map(c=>K(c,s,H())));throw it(a,o==null?void 0:o.callee),a}return i.value},dr=cr(ae),ur=e=>(t,n,r)=>{const o=r?{...r,async:!1}:{async:!1},s=t._zod.run({value:n,issues:[]},o);if(s instanceof Promise)throw new oe;return s.issues.length?{success:!1,error:new(e??sr)(s.issues.map(i=>K(i,o,H())))}:{success:!0,data:s.value}},dt=ur(ae),lr=e=>async(t,n,r)=>{const o=r?Object.assign(r,{async:!0}):{async:!0};let s=t._zod.run({value:n,issues:[]},o);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new e(s.issues.map(i=>K(i,o,H())))}:{success:!0,data:s.value}},ut=lr(ae),fr=e=>{const t=e?`[\\s\\S]{${(e==null?void 0:e.minimum)??0},${(e==null?void 0:e.maximum)??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},hr=/^\d+n?$/,mr=/^-?\d+(?:\.\d+)?/i,pr=I("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])});class gr{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),o=Math.min(...r.map(i=>i.length-i.trimStart().length)),s=r.map(i=>i.slice(o)).map(i=>" ".repeat(this.indent*2)+i);for(const i of s)this.content.push(i)}compile(){const t=Function,n=this==null?void 0:this.args,o=[...((this==null?void 0:this.content)??[""]).map(s=>` ${s}`)];return new t(...n,o.join(`
|
|
4
4
|
`))}}const yr={major:4,minor:0,patch:0},C=I("$ZodType",(e,t)=>{var o;var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=yr;const r=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&r.unshift(e);for(const s of r)for(const i of s._zod.onattach)i(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),(o=e._zod.deferred)==null||o.push(()=>{e._zod.run=e._zod.parse});else{const s=(i,a,c)=>{let d=de(i),p;for(const f of a){if(f._zod.when){if(!f._zod.when(i))continue}else if(d)continue;const u=i.issues.length,l=f._zod.check(i);if(l instanceof Promise&&(c==null?void 0:c.async)===!1)throw new oe;if(p||l instanceof Promise)p=(p??Promise.resolve()).then(async()=>{await l,i.issues.length!==u&&(d||(d=de(i,u)))});else{if(i.issues.length===u)continue;d||(d=de(i,u))}}return p?p.then(()=>i):i};e._zod.run=(i,a)=>{const c=e._zod.parse(i,a);if(c instanceof Promise){if(a.async===!1)throw new oe;return c.then(d=>s(d,r,a))}return s(c,r,a)}}e["~standard"]={validate:s=>{var i;try{const a=dt(e,s);return a.success?{value:a.data}:{issues:(i=a.error)==null?void 0:i.issues}}catch{return ut(e,s).then(c=>{var d;return c.success?{value:c.data}:{issues:(d=c.error)==null?void 0:d.issues}})}},vendor:"zod",version:1}}),wr=I("$ZodString",(e,t)=>{var n;C.init(e,t),e._zod.pattern=[...((n=e==null?void 0:e._zod.bag)==null?void 0:n.patterns)??[]].pop()??fr(e._zod.bag),e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),_r=I("$ZodNumber",(e,t)=>{C.init(e,t),e._zod.pattern=e._zod.bag.pattern??mr,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}const o=n.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return n;const s=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...s?{received:s}:{}}),n}}),br=I("$ZodBigInt",(e,t)=>{C.init(e,t),e._zod.pattern=hr,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}}),kr=I("$ZodUnknown",(e,t)=>{C.init(e,t),e._zod.parse=n=>n});function $e(e,t,n){e.issues.length&&t.issues.push(...M(n,e.issues)),t.value[n]=e.value}const Ir=I("$ZodArray",(e,t)=>{C.init(e,t),e._zod.parse=(n,r)=>{const o=n.value;if(!Array.isArray(o))return n.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),n;n.value=Array(o.length);const s=[];for(let i=0;i<o.length;i++){const a=o[i],c=t.element._zod.run({value:a,issues:[]},r);c instanceof Promise?s.push(c.then(d=>$e(d,n,i))):$e(c,n,i)}return s.length?Promise.all(s).then(()=>n):n}});function ne(e,t,n){e.issues.length&&t.issues.push(...M(n,e.issues)),t.value[n]=e.value}function Oe(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(...M(n,e.issues)):e.value===void 0?n in r&&(t.value[n]=void 0):t.value[n]=e.value}const Ar=I("$ZodObject",(e,t)=>{C.init(e,t);const n=Te(()=>{const f=Object.keys(t.shape);for(const l of f)if(!(t.shape[l]instanceof C))throw new Error(`Invalid element at key "${l}": expected a Zod schema`);const u=rr(t.shape);return{shape:t.shape,keys:f,keySet:new Set(f),numKeys:f.length,optionalKeys:new Set(u)}});B(e._zod,"propValues",()=>{const f=t.shape,u={};for(const l in f){const h=f[l]._zod;if(h.values){u[l]??(u[l]=new Set);for(const m of h.values)u[l].add(m)}}return u});const r=f=>{const u=new gr(["shape","payload","ctx"]),l=n.value,h=g=>{const b=G(g);return`shape[${b}]._zod.run({ value: input[${b}], issues: [] }, ctx)`};u.write("const input = payload.value;");const m=Object.create(null);let y=0;for(const g of l.keys)m[g]=`key_${y++}`;u.write("const newResult = {}");for(const g of l.keys)if(l.optionalKeys.has(g)){const b=m[g];u.write(`const ${b} = ${h(g)};`);const w=G(g);u.write(`
|
|
5
5
|
if (${b}.issues.length) {
|
|
@@ -24,4 +24,4 @@ import{e as v,c as T,d as ee,w as St,L as Ct,h as Pt,a as Y,f as $t}from"./utils
|
|
|
24
24
|
if (${b}.issues.length) payload.issues = payload.issues.concat(${b}.issues.map(iss => ({
|
|
25
25
|
...iss,
|
|
26
26
|
path: iss.path ? [${G(g)}, ...iss.path] : [${G(g)}]
|
|
27
|
-
})));`),u.write(`newResult[${G(g)}] = ${b}.value`)}u.write("payload.value = newResult;"),u.write("return payload;");const _=u.compile();return(g,b)=>_(f,g,b)};let o;const s=se,i=!ot.jitless,c=i&&Xn.value,d=t.catchall;let p;e._zod.parse=(f,u)=>{p??(p=n.value);const l=f.value;if(!s(l))return f.issues.push({expected:"object",code:"invalid_type",input:l,inst:e}),f;const h=[];if(i&&c&&(u==null?void 0:u.async)===!1&&u.jitless!==!0)o||(o=r(t.shape)),f=o(f,u);else{f.value={};const b=p.shape;for(const w of p.keys){const E=b[w],N=E._zod.run({value:l[w],issues:[]},u),P=E._zod.optin==="optional"&&E._zod.optout==="optional";N instanceof Promise?h.push(N.then(L=>P?Oe(L,f,w,l):ne(L,f,w))):P?Oe(N,f,w,l):ne(N,f,w)}}if(!d)return h.length?Promise.all(h).then(()=>f):f;const m=[],y=p.keySet,_=d._zod,g=_.def.type;for(const b of Object.keys(l)){if(y.has(b))continue;if(g==="never"){m.push(b);continue}const w=_.run({value:l[b],issues:[]},u);w instanceof Promise?h.push(w.then(E=>ne(E,f,b))):ne(w,f,b)}return m.length&&f.issues.push({code:"unrecognized_keys",keys:m,input:l,inst:e}),h.length?Promise.all(h).then(()=>f):f}});function De(e,t,n,r){for(const o of e)if(o.issues.length===0)return t.value=o.value,t;return t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(o=>o.issues.map(s=>K(s,r,H())))}),t}const Tr=I("$ZodUnion",(e,t)=>{C.init(e,t),B(e._zod,"optin",()=>t.options.some(n=>n._zod.optin==="optional")?"optional":void 0),B(e._zod,"optout",()=>t.options.some(n=>n._zod.optout==="optional")?"optional":void 0),B(e._zod,"values",()=>{if(t.options.every(n=>n._zod.values))return new Set(t.options.flatMap(n=>Array.from(n._zod.values)))}),B(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=>st(r.source)).join("|")})$`)}}),e._zod.parse=(n,r)=>{let o=!1;const s=[];for(const i of t.options){const a=i._zod.run({value:n.value,issues:[]},r);if(a instanceof Promise)s.push(a),o=!0;else{if(a.issues.length===0)return a;s.push(a)}}return o?Promise.all(s).then(i=>De(i,n,e,r)):De(s,n,e,r)}}),vr=I("$ZodDiscriminatedUnion",(e,t)=>{Tr.init(e,t);const n=e._zod.parse;B(e._zod,"propValues",()=>{const o={};for(const s of t.options){const i=s._zod.propValues;if(!i||Object.keys(i).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(s)}"`);for(const[a,c]of Object.entries(i)){o[a]||(o[a]=new Set);for(const d of c)o[a].add(d)}}return o});const r=Te(()=>{const o=t.options,s=new Map;for(const i of o){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(s.has(c))throw new Error(`Duplicate discriminator value "${String(c)}"`);s.set(c,i)}}return s});e._zod.parse=(o,s)=>{const i=o.value;if(!se(i))return o.issues.push({code:"invalid_type",expected:"object",input:i,inst:e}),o;const a=r.value.get(i==null?void 0:i[t.discriminator]);return a?a._zod.run(o,s):t.unionFallback?n(o,s):(o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",input:i,path:[t.discriminator],inst:e}),o)}}),Er=I("$ZodRecord",(e,t)=>{C.init(e,t),e._zod.parse=(n,r)=>{const o=n.value;if(!er(o))return n.issues.push({expected:"record",code:"invalid_type",input:o,inst:e}),n;const s=[];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 d=t.valueType._zod.run({value:o[c],issues:[]},r);d instanceof Promise?s.push(d.then(p=>{p.issues.length&&n.issues.push(...M(c,p.issues)),n.value[c]=p.value})):(d.issues.length&&n.issues.push(...M(c,d.issues)),n.value[c]=d.value)}let a;for(const c in o)i.has(c)||(a=a??[],a.push(c));a&&a.length>0&&n.issues.push({code:"unrecognized_keys",input:o,inst:e,keys:a})}else{n.value={};for(const i of Reflect.ownKeys(o)){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(d=>K(d,r,H())),input:i,path:[i],inst:e}),n.value[a.value]=a.value;continue}const c=t.valueType._zod.run({value:o[i],issues:[]},r);c instanceof Promise?s.push(c.then(d=>{d.issues.length&&n.issues.push(...M(i,d.issues)),n.value[a.value]=d.value})):(c.issues.length&&n.issues.push(...M(i,c.issues)),n.value[a.value]=c.value)}}return s.length?Promise.all(s).then(()=>n):n}}),Sr=I("$ZodEnum",(e,t)=>{C.init(e,t);const n=Gn(t.entries);e._zod.values=new Set(n),e._zod.pattern=new RegExp(`^(${n.filter(r=>tr.has(typeof r)).map(r=>typeof r=="string"?at(r):r.toString()).join("|")})$`),e._zod.parse=(r,o)=>{const s=r.value;return e._zod.values.has(s)||r.issues.push({code:"invalid_value",values:n,input:s,inst:e}),r}}),Cr=I("$ZodLiteral",(e,t)=>{C.init(e,t),e._zod.values=new Set(t.values),e._zod.pattern=new RegExp(`^(${t.values.map(n=>typeof n=="string"?at(n):n?n.toString():String(n)).join("|")})$`),e._zod.parse=(n,r)=>{const o=n.value;return e._zod.values.has(o)||n.issues.push({code:"invalid_value",values:t.values,input:o,inst:e}),n}}),Pr=I("$ZodOptional",(e,t)=>{C.init(e,t),e._zod.optin="optional",e._zod.optout="optional",B(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),B(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${st(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)}),$r=I("$ZodCustom",(e,t)=>{pr.init(e,t),C.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=n=>{const r=n.value,o=t.fn(r);if(o instanceof Promise)return o.then(s=>ze(s,n,r,e));ze(o,n,r,e)}});function ze(e,t,n,r){if(!e){const o={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(o.params=r._zod.def.params),t.issues.push(or(o))}}function Or(e,t){return new e({type:"string",...D(t)})}function Dr(e,t){return new e({type:"number",checks:[],...D(t)})}function zr(e,t){return new e({type:"number",coerce:!0,checks:[],...D(t)})}function Rr(e,t){return new e({type:"bigint",coerce:!0,...D(t)})}function Br(e){return new e({type:"unknown"})}function Nr(e,t,n){return new e({type:"custom",check:"custom",fn:t,...D(n)})}const O=I("ZodMiniType",(e,t)=>{if(!e._zod)throw new Error("Uninitialized schema in ZodMiniType.");C.init(e,t),e.def=t,e.parse=(n,r)=>ar(e,n,r,{callee:e.parse}),e.safeParse=(n,r)=>dt(e,n,r),e.parseAsync=async(n,r)=>dr(e,n,r,{callee:e.parseAsync}),e.safeParseAsync=async(n,r)=>ut(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)=>nr(e,n,r),e.brand=()=>e,e.register=(n,r)=>(n.add(e,r),e)}),jr=I("ZodMiniString",(e,t)=>{wr.init(e,t),O.init(e,t)});function S(e){return Or(jr,e)}const lt=I("ZodMiniNumber",(e,t)=>{_r.init(e,t),O.init(e,t)});function xr(e){return Dr(lt,e)}const Ur=I("ZodMiniBigInt",(e,t)=>{br.init(e,t),O.init(e,t)}),Lr=I("ZodMiniUnknown",(e,t)=>{kr.init(e,t),O.init(e,t)});function ft(){return Br(Lr)}const Mr=I("ZodMiniArray",(e,t)=>{Ir.init(e,t),O.init(e,t)});function qr(e,t){return new Mr({type:"array",element:e,...D(t)})}const Fr=I("ZodMiniObject",(e,t)=>{Ar.init(e,t),O.init(e,t),B(e,"shape",()=>t.shape)});function z(e,t){const n={type:"object",get shape(){return Yn(this,"shape",{...e}),this.shape},...D(t)};return new Fr(n)}const Wr=I("ZodMiniDiscriminatedUnion",(e,t)=>{vr.init(e,t),O.init(e,t)});function ve(e,t,n){return new Wr({type:"union",options:t,discriminator:e,...D(n)})}const Vr=I("ZodMiniRecord",(e,t)=>{Er.init(e,t),O.init(e,t)});function Zr(e,t,n){return new Vr({type:"record",keyType:e,valueType:t,...D(n)})}const Hr=I("ZodMiniEnum",(e,t)=>{Sr.init(e,t),O.init(e,t)});function ge(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new Hr({type:"enum",entries:n,...D(t)})}const Kr=I("ZodMiniLiteral",(e,t)=>{Cr.init(e,t),O.init(e,t)});function x(e,t){return new Kr({type:"literal",values:Array.isArray(e)?e:[e],...D(t)})}const Jr=I("ZodMiniOptional",(e,t)=>{Pr.init(e,t),O.init(e,t)});function W(e){return new Jr({type:"optional",innerType:e})}const Gr=I("ZodMiniCustom",(e,t)=>{$r.init(e,t),O.init(e,t)});function ht(e,t={}){return Nr(Gr,e,t)}function Q(e){return zr(lt,e)}function ye(e){return Rr(Ur,e)}const mt=S().check(ht(ie,{message:"Invalid hex string"})),V=S().check(ht(xe,{message:"Invalid address"})),we=z({address:V,chainId:Q(),decimals:Q(),iconUri:W(S()),name:S(),priceUsd:Q(),symbol:S()}),Qr=ve("version",[z({data:z({}),type:x("pay.onchain-transaction"),version:x(1)}),z({data:z({action:ge(["TRANSFER","BUY","SELL"]),clientId:S(),destinationAmount:ye(),destinationToken:we,developerFeeBps:Q(),developerFeeRecipient:V,originAmount:ye(),originToken:we,paymentId:S(),paymentLinkId:W(S()),purchaseData:W(Zr(S(),ft())),receiver:V,sender:V,status:ge(["PENDING","FAILED","COMPLETED"]),transactions:qr(z({chainId:Q(),transactionHash:mt})),type:S()}),type:x("pay.onchain-transaction"),version:x(2)})]),Yr=ve("version",[z({data:z({}),type:x("pay.onramp-transaction"),version:x(1)}),z({data:z({amount:ye(),currency:S(),currencyAmount:xr(),id:S(),onramp:S(),paymentLinkId:W(S()),purchaseData:ft(),receiver:V,sender:W(V),status:ge(["PENDING","COMPLETED","FAILED"]),token:we,transactionHash:W(mt)}),type:x("pay.onramp-transaction"),version:x(2)})]),Xr=ve("type",[Qr,Yr]);async function pt(e,t,n,r=300,o){const s=t["x-payload-signature"]||t["x-pay-signature"],i=t["x-timestamp"]||t["x-pay-timestamp"];if(!s||!i)throw new Error("Missing required webhook headers: signature or timestamp");const a=Math.floor(Date.now()/1e3),c=Number.parseInt(i,10),d=Math.abs(a-c);if(d>r)throw new Error(`Webhook timestamp is too old. Difference: ${d}s, tolerance: ${r}s`);const p=new TextEncoder,f=await crypto.subtle.importKey("raw",p.encode(n),{hash:"SHA-256",name:"HMAC"},!1,["sign"]),u=await crypto.subtle.sign("HMAC",f,p.encode(`${i}.${e}`));if(Array.from(new Uint8Array(u)).map(y=>y.toString(16).padStart(2,"0")).join("")!==s)throw new Error("Invalid webhook signature");let h;try{h=JSON.parse(e)}catch{throw new Error("Invalid webhook payload: not valid JSON")}const m=Xr.parse(h);if(m.version===1)throw new Error("Invalid webhook payload: version 1 is no longer supported, please upgrade to webhook version 2.");if(o){if(o.receiverAddress&&m.data.receiver.toLowerCase()!==o.receiverAddress.toLowerCase())throw new Error(`Verification Failed: receiverAddress mismatch, Expected: ${o.receiverAddress}, Received: ${m.data.receiver}`);if(o.destinationTokenAddress){if("destinationToken"in m.data){if(m.data.destinationToken.address.toLowerCase()!==o.destinationTokenAddress.toLowerCase())throw new Error(`Verification Failed: destinationTokenAddress mismatch, Expected: ${o.destinationTokenAddress}, Received: ${m.data.destinationToken.address}`)}else if("onramp"in m.data&&m.data.token.address.toLowerCase()!==o.destinationTokenAddress.toLowerCase())throw new Error(`Verification Failed: destinationTokenAddress mismatch, Expected: ${o.destinationTokenAddress}, Received: ${m.data.token.address}`)}if(o.destinationChainId){if("destinationToken"in m.data){if(m.data.destinationToken.chainId!==o.destinationChainId)throw new Error(`Verification Failed: destinationChainId mismatch, Expected: ${o.destinationChainId}, Received: ${m.data.destinationToken.chainId}`)}else if("onramp"in m.data&&m.data.token.chainId!==o.destinationChainId)throw new Error(`Verification Failed: destinationChainId mismatch, Expected: ${o.destinationChainId}, Received: ${m.data.token.chainId}`)}if(o.minDestinationAmount){if("destinationAmount"in m.data){if(m.data.destinationAmount<o.minDestinationAmount)throw new Error(`Verification Failed: minDestinationAmount, Expected minimum amount to be ${o.minDestinationAmount}, Received: ${m.data.destinationAmount}`)}else if("onramp"in m.data&&m.data.amount<o.minDestinationAmount)throw new Error(`Verification Failed: minDestinationAmount, Expected minimum amount to be ${o.minDestinationAmount}, Received: ${m.data.amount}`)}}return m}const eo=Object.freeze(Object.defineProperty({__proto__:null,parse:pt},Symbol.toStringTag,{value:"Module"})),to=Object.freeze(Object.defineProperty({__proto__:null,Buy:Mn,Onramp:Vn,Sell:Hn,Transfer:Jn,Webhook:eo,chains:qn,parse:pt,status:nt,tokens:Kn},Symbol.toStringTag,{value:"Module"}));function gt(e,t){const n=Ot(ie(e,{strict:!1})?Ue(e):e);return t==="bytes"?n:Le(n)}const ue=new Ct(4096);function no(e){if(ue.has(e))return ue.get(e);const t=gt(Me(e)).slice(2,34);return ue.set(e,t),t}function ro(e){const{clientId:t,secretKey:n,...r}=e;let o=t;if(n)if(Pt(n)){if(!t)throw new Error("clientId must be provided when using a JWT secretKey")}else o=t??no(n);if(!o)throw new Error("clientId or secretKey must be provided");return{...r,clientId:o,secretKey:n}}const oo={bodySerializer:e=>JSON.stringify(e,(t,n)=>typeof n=="bigint"?n.toString():n)},so=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},io=e=>{switch(e){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},ao=e=>{switch(e){case"form":return",";case"pipeDelimited":return"|";case"spaceDelimited":return"%20";default:return","}},co=e=>{switch(e){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},yt=({allowReserved:e,explode:t,name:n,style:r,value:o})=>{if(!t){const a=(e?o:o.map(c=>encodeURIComponent(c))).join(ao(r));switch(r){case"label":return`.${a}`;case"matrix":return`;${n}=${a}`;case"simple":return a;default:return`${n}=${a}`}}const s=io(r),i=o.map(a=>r==="label"||r==="simple"?e?a:encodeURIComponent(a):ce({allowReserved:e,name:n,value:a})).join(s);return r==="label"||r==="matrix"?s+i:i},ce=({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)}`},wt=({allowReserved:e,explode:t,name:n,style:r,value:o,valueOnly:s})=>{if(o instanceof Date)return s?o.toISOString():`${n}=${o.toISOString()}`;if(r!=="deepObject"&&!t){let c=[];Object.entries(o).forEach(([p,f])=>{c=[...c,p,e?f:encodeURIComponent(f)]});const d=c.join(",");switch(r){case"form":return`${n}=${d}`;case"label":return`.${d}`;case"matrix":return`;${n}=${d}`;default:return d}}const i=co(r),a=Object.entries(o).map(([c,d])=>ce({allowReserved:e,name:r==="deepObject"?`${n}[${c}]`:c,value:d})).join(i);return r==="label"||r==="matrix"?i+a:a},uo=/\{[^{}]+\}/g,lo=({path:e,url:t})=>{let n=t;const r=t.match(uo);if(r)for(const o of r){let s=!1,i=o.substring(1,o.length-1),a="simple";i.endsWith("*")&&(s=!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(o,yt({explode:s,name:i,style:a,value:c}));continue}if(typeof c=="object"){n=n.replace(o,wt({explode:s,name:i,style:a,value:c,valueOnly:!0}));continue}if(a==="matrix"){n=n.replace(o,`;${ce({name:i,value:c})}`);continue}const d=encodeURIComponent(a==="label"?`.${c}`:c);n=n.replace(o,d)}return n},_t=({allowReserved:e,array:t,object:n}={})=>o=>{const s=[];if(o&&typeof o=="object")for(const i in o){const a=o[i];if(a!=null)if(Array.isArray(a)){const c=yt({allowReserved:e,explode:!0,name:i,style:"form",value:a,...t});c&&s.push(c)}else if(typeof a=="object"){const c=wt({allowReserved:e,explode:!0,name:i,style:"deepObject",value:a,...n});c&&s.push(c)}else{const c=ce({allowReserved:e,name:i,value:a});c&&s.push(c)}}return s.join("&")},fo=e=>{var n;if(!e)return"stream";const t=(n=e.split(";")[0])==null?void 0:n.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(r=>t.startsWith(r)))return"blob";if(t.startsWith("text/"))return"text"}},ho=async({security:e,...t})=>{for(const n of e){const r=await so(n,t.auth);if(!r)continue;const o=n.name??"Authorization";switch(n.in){case"query":t.query||(t.query={}),t.query[o]=r;break;case"cookie":t.headers.append("Cookie",`${o}=${r}`);break;case"header":default:t.headers.set(o,r);break}return}},Re=e=>mo({baseUrl:e.baseUrl,path:e.path,query:e.query,querySerializer:typeof e.querySerializer=="function"?e.querySerializer:_t(e.querySerializer),url:e.url}),mo=({baseUrl:e,path:t,query:n,querySerializer:r,url:o})=>{const s=o.startsWith("/")?o:`/${o}`;let i=(e??"")+s;t&&(i=lo({path:t,url:i}));let a=n?r(n):"";return a.startsWith("?")&&(a=a.substring(1)),a&&(i+=`?${a}`),i},Be=(e,t)=>{var r;const n={...e,...t};return(r=n.baseUrl)!=null&&r.endsWith("/")&&(n.baseUrl=n.baseUrl.substring(0,n.baseUrl.length-1)),n.headers=bt(e.headers,t.headers),n},bt=(...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[o,s]of r)if(s===null)t.delete(o);else if(Array.isArray(s))for(const i of s)t.append(o,i);else s!==void 0&&t.set(o,typeof s=="object"?JSON.stringify(s):s)}return t};class le{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 po=()=>({error:new le,request:new le,response:new le}),go=_t({allowReserved:!1,array:{explode:!0,style:"form"},object:{explode:!0,style:"deepObject"}}),yo={"Content-Type":"application/json"},kt=(e={})=>({...oo,headers:yo,parseAs:"auto",querySerializer:go,...e}),wo=(e={})=>{let t=Be(kt(),e);const n=()=>({...t}),r=i=>(t=Be(t,i),n()),o=po(),s=async i=>{const a={...t,...i,fetch:i.fetch??t.fetch??globalThis.fetch,headers:bt(t.headers,i.headers)};a.security&&await ho({...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=Re(a),d={redirect:"follow",...a};let p=new Request(c,d);for(const y of o.request._fns)y&&(p=await y(p,a));const f=a.fetch;let u=await f(p);for(const y of o.response._fns)y&&(u=await y(u,p,a));const l={request:p,response:u};if(u.ok){if(u.status===204||u.headers.get("Content-Length")==="0")return a.responseStyle==="data"?{}:{data:{},...l};const y=(a.parseAs==="auto"?fo(u.headers.get("Content-Type")):a.parseAs)??"json";let _;switch(y){case"arrayBuffer":case"blob":case"formData":case"json":case"text":_=await u[y]();break;case"stream":return a.responseStyle==="data"?u.body:{data:u.body,...l}}return y==="json"&&(a.responseValidator&&await a.responseValidator(_),a.responseTransformer&&(_=await a.responseTransformer(_))),a.responseStyle==="data"?_:{data:_,...l}}let h=await u.text();try{h=JSON.parse(h)}catch{}let m=h;for(const y of o.error._fns)y&&(m=await y(h,u,p,a));if(m=m||{},a.throwOnError)throw m;return a.responseStyle==="data"?void 0:{error:m,...l}};return{buildUrl:Re,connect:i=>s({...i,method:"CONNECT"}),delete:i=>s({...i,method:"DELETE"}),get:i=>s({...i,method:"GET"}),getConfig:n,head:i=>s({...i,method:"HEAD"}),interceptors:o,options:i=>s({...i,method:"OPTIONS"}),patch:i=>s({...i,method:"PATCH"}),post:i=>s({...i,method:"POST"}),put:i=>s({...i,method:"PUT"}),request:s,setConfig:r,trace:i=>s({...i,method:"TRACE"})}},J=wo(kt({baseUrl:"https://engine.thirdweb.com"})),_o=e=>(e.client??J).post({security:[{name:"x-secret-key",type:"apiKey"}],url:"/v1/write/transaction",...e,headers:{"Content-Type":"application/json",...e.headers}}),bo=e=>(e.client??J).post({security:[{name:"x-secret-key",type:"apiKey"}],url:"/v1/sign/message",...e,headers:{"Content-Type":"application/json",...e.headers}}),ko=e=>(e.client??J).post({security:[{name:"x-secret-key",type:"apiKey"}],url:"/v1/sign/typed-data",...e,headers:{"Content-Type":"application/json",...e.headers}}),Io=e=>((e==null?void 0:e.client)??J).get({security:[{name:"x-secret-key",type:"apiKey"}],url:"/v1/accounts",...e}),Ao=e=>((e==null?void 0:e.client)??J).post({security:[{name:"x-secret-key",type:"apiKey"}],url:"/v1/accounts",...e,headers:{"Content-Type":"application/json",...e==null?void 0:e.headers}}),It=e=>((e==null?void 0:e.client)??J).post({security:[{name:"x-secret-key",type:"apiKey"}],url:"/v1/transactions/search",...e,headers:{"Content-Type":"application/json",...e==null?void 0:e.headers}});function Ne(e){return"result"in e}async function To(e){var s;const{client:t,label:n}=e,r=await Ao({baseUrl:v("engineCloud"),body:{label:n},bodySerializer:Z,fetch:T(t)});if(r.error)throw new Error(`Error creating server wallet with label ${n}: ${Z(r.error)}`);const o=(s=r.data)==null?void 0:s.result;if(!o)throw new Error(`No server wallet created with label ${n}`);return o}async function At(e){var i,a,c;const{client:t,transactionId:n}=e,r=await It({baseUrl:v("engineCloud"),body:{filters:[{field:"id",operation:"OR",values:[n]}]},bodySerializer:A,fetch:T(t)});if(r.error)throw new Error(`Error searching for transaction ${n}: ${A(r.error)}`);const o=(c=(a=(i=r.data)==null?void 0:i.result)==null?void 0:a.transactions)==null?void 0:c[0];if(!o)throw new Error(`Transaction ${n} not found`);return{...o.executionResult,cancelledAt:o.cancelledAt,chain:Y(Number(o.chainId)),confirmedAt:o.confirmedAt,createdAt:o.createdAt,from:o.from??void 0,id:o.id}}async function vo(e){var o;const{client:t}=e,n=await Io({baseUrl:v("engineCloud"),bodySerializer:Z,fetch:T(t),query:{limit:e.limit,page:e.page}});if(n.error)throw new Error(`Error listing server wallets: ${Z(n.error)}`);const r=(o=n.data)==null?void 0:o.result;if(!r)throw new Error("No server wallets found");return r}async function Eo(e){var a;const{client:t,filters:n,pageSize:r=100,page:o=1}=e,s=await It({baseUrl:v("engineCloud"),body:{filters:n,limit:r,page:o},bodySerializer:A,fetch:T(t)});if(s.error)throw new Error(`Error searching for transaction with filters ${A(n)}: ${A(s.error)}`);const i=(a=s.data)==null?void 0:a.result;if(!i)throw new Error(`No transactions found with filters ${A(n)}`);return i}async function _e(e){const t=Date.now(),n=e.timeoutInSeconds?e.timeoutInSeconds*1e3:5*60*1e3;for(;Date.now()-t<n;){const r=await At(e);switch(r.status){case"FAILED":throw new Error(`Transaction failed: ${Z(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==null?void 0:i.errorName)||"unknown error"} ${i!=null&&i.errorArgs?Z(i.errorArgs):""} - ${r.transactionHash?r.transactionHash:""}`)}return{chain:r.chain,client:e.client,transactionHash:r.transactionHash}}default:await new Promise(s=>setTimeout(s,1e3))}}throw new Error(`Transaction timed out after ${n/1e3} seconds`)}function So(e){const{client:t,vaultAccessToken:n,address:r,chain:o,executionOptions:s}=e,i=n?{"x-vault-access-token":n}:{},a=f=>{if(!s)return{chainId:f,from:r,type:"auto"};switch(s.type){case"auto":return{chainId:f,from:r,type:"auto"};case"ERC4337":return{...s,chainId:f,type:"ERC4337"};case"EOA":return{chainId:f,from:r,type:"EOA"};case"EIP7702":return{...s,chainId:f,type:"EIP7702"}}},c=f=>{if(!f)return{from:r,type:"EOA"};if(!s)return{chainId:f,from:r,type:"auto"};switch(s.type){case"ERC4337":return{chainId:f,...s,type:"ERC4337"};case"auto":return{chainId:f,from:r,type:"auto"};case"EIP7702":case"EOA":return{chainId:f,from:r,type:"EOA"}}},d=async f=>{var _,g,b;if(f.length===0)throw new Error("No transactions to enqueue");const u=f[0];if(!u)throw new Error("No transactions to enqueue");const l=u.chainId;for(let w=1;w<f.length;w++)if(((_=f[w])==null?void 0:_.chainId)!==l)throw new Error(`All transactions in batch must be on the same chain. Expected ${l}, got ${(g=f[w])==null?void 0:g.chainId} at index ${w}`);const h={executionOptions:a(l),params:f.map(w=>{var E;return{data:w.data,to:w.to,gasLimit:w.gas?Number(w.gas):void 0,value:(E=w.value)==null?void 0:E.toString()}})},m=await _o({baseUrl:v("engineCloud"),body:h,bodySerializer:A,fetch:T(t),headers:i});if(m.error)throw new Error(`Error sending transaction: ${A(m.error)}`);const y=(b=m.data)==null?void 0:b.result;if(!y)throw new Error("No data returned from engine");return y.transactions.map(w=>w.id)};return{address:(s==null?void 0:s.type)==="ERC4337"&&s.smartAccountAddress?s.smartAccountAddress:r,enqueueBatchTransaction:async f=>{const u=[];for(const m of f.transactions){const[y,_,g]=await Promise.all([m.to?j(m.to):null,re(m),m.value?j(m.value):null]);u.push({chainId:m.chain.id,data:_,to:y??void 0,value:g??void 0})}const h=(await d(u))[0];if(!h)throw new Error("No transactionId returned from engine");return{transactionId:h}},enqueueTransaction:async f=>{let u;if(f.simulate)u=await Fe({transaction:f.transaction,from:r});else{const[m,y,_]=await Promise.all([f.transaction.to?j(f.transaction.to):null,re(f.transaction),f.transaction.value?j(f.transaction.value):null]);u={chainId:f.transaction.chain.id,data:y,to:m??void 0,value:_??void 0}}const h=(await d([u]))[0];if(!h)throw new Error("No transactionId returned from engine");return{transactionId:h}},sendBatchTransaction:async f=>{const l=(await d(f))[0];if(!l)throw new Error("No transactionId returned from engine");return _e({client:t,transactionId:l})},sendTransaction:async f=>{const l=(await d([f]))[0];if(!l)throw new Error("No transactionId returned from engine");return _e({client:t,transactionId:l})},signMessage:async f=>{var b;const{message:u,chainId:l}=f;let h,m=!1;typeof u=="string"?h=u:(h=qe(u.raw),m=!0);const y=l||(o==null?void 0:o.id);if(!y)throw new Error("Chain ID is required for signing messages");const _=await bo({baseUrl:v("engineCloud"),body:{params:[{format:m?"hex":"text",message:h}],signingOptions:c(y)},bodySerializer:A,fetch:T(t),headers:i});if(_.error)throw new Error(`Error signing message: ${A(_.error)}`);const g=(b=_.data)==null?void 0:b.result[0];if(g&&Ne(g))return g.result.signature;throw new Error(`Failed to sign message: ${A(g==null?void 0:g.error)||"Unknown error"}`)},signTypedData:async f=>{var m;const u=o==null?void 0:o.id;if(!u)throw new Error("Chain ID is required for signing messages");const l=await ko({baseUrl:v("engineCloud"),body:{params:[f],signingOptions:c(u)},bodySerializer:A,fetch:T(t),headers:i});if(l.error)throw new Error(`Error signing message: ${A(l.error)}`);const h=(m=l.data)==null?void 0:m.result[0];if(h&&Ne(h))return h.result.signature;throw new Error(`Failed to sign message: ${A(h==null?void 0:h.error)||"Unknown error"}`)}}}const Co=Object.freeze(Object.defineProperty({__proto__:null,createServerWallet:To,getServerWallets:vo,getTransactionStatus:At,searchTransactions:Eo,serverWallet:So,waitForTransactionHash:_e},Symbol.toStringTag,{value:"Module"}));async function Ee(e){var h;const[{getV1EventsByContractAddress:t},{getThirdwebDomains:n},{getClientFetch:r},{assertInsightEnabled:o},{stringify:s}]=await Promise.all([k(()=>import("./thirdweb-DZ2vK6IO.js"),[]),k(()=>import("./utils-B2dQKDW4.js").then(m=>m.q),__vite__mapDeps([0,1,2])),k(()=>import("./utils-B2dQKDW4.js").then(m=>m.r),__vite__mapDeps([0,1,2])),k(()=>import("./common-C1bFpXXr.js"),__vite__mapDeps([3,0,1,2])),k(()=>import("./signing-D7VaTtN_.js").then(m=>m.cS),__vite__mapDeps([4,0,1,2]))]),{client:i,chains:a,contractAddress:c,event:d,queryOptions:p,decodeLogs:f}=e;await o(a);const u={chain:a.map(m=>m.id),decode:f,limit:100};d&&(u.filter_topic_0=d.topics[0],u.filter_topic_1=d.topics[1],u.filter_topic_2=d.topics[2],u.filter_topic_3=d.topics[3]);const l=await t({baseUrl:`https://${n().insight}`,fetch:r(i),path:{contractAddress:c},query:{...u,...p}});if(l.error)throw new Error(`${l.response.status} ${l.response.statusText} - ${l.error?s(l.error):"Unknown error"}`);return((h=l.data)==null?void 0:h.data)??[]}async function Po(e){var h;const[{getV1Nfts:t},{getThirdwebDomains:n},{getClientFetch:r},{assertInsightEnabled:o},{stringify:s}]=await Promise.all([k(()=>import("./thirdweb-DZ2vK6IO.js"),[]),k(()=>import("./utils-B2dQKDW4.js").then(m=>m.q),__vite__mapDeps([0,1,2])),k(()=>import("./utils-B2dQKDW4.js").then(m=>m.r),__vite__mapDeps([0,1,2])),k(()=>import("./common-C1bFpXXr.js"),__vite__mapDeps([3,0,1,2])),k(()=>import("./index-vC3WND5c.js"),__vite__mapDeps([5,6,4,0,1,2,7,8,9,10,11]))]),{client:i,chains:a,ownerAddress:c,contractAddresses:d,queryOptions:p}=e;await o(a);const f={chain:a.map(m=>m.id),limit:50,owner_address:[c],contract_address:d||void 0},u=await t({baseUrl:`https://${n().insight}`,fetch:r(i),query:{...f,...p}});if(u.error)throw new Error(`${u.response.status} ${u.response.statusText} - ${u.error?s(u.error):"Unknown error"}`);return(await Se(((h=u.data)==null?void 0:h.data)??[],i,c)).map(m=>({...m,quantityOwned:m.quantityOwned??1n}))}async function $o(e){var l;const[{getV1NftsByContractAddress:t},{getThirdwebDomains:n},{getClientFetch:r},{assertInsightEnabled:o},{stringify:s}]=await Promise.all([k(()=>import("./thirdweb-DZ2vK6IO.js"),[]),k(()=>import("./utils-B2dQKDW4.js").then(h=>h.q),__vite__mapDeps([0,1,2])),k(()=>import("./utils-B2dQKDW4.js").then(h=>h.r),__vite__mapDeps([0,1,2])),k(()=>import("./common-C1bFpXXr.js"),__vite__mapDeps([3,0,1,2])),k(()=>import("./signing-D7VaTtN_.js").then(h=>h.cS),__vite__mapDeps([4,0,1,2]))]),{client:i,chains:a,contractAddress:c,includeOwners:d=!0,queryOptions:p}=e,f={chain:a.map(h=>h.id),include_owners:d===!0?"true":"false",limit:50};await o(a);const u=await t({baseUrl:`https://${n().insight}`,fetch:r(i),path:{contract_address:c},query:{...f,...p}});if(u.error)throw new Error(`${u.response.status} ${u.response.statusText} - ${u.error?s(u.error):"Unknown error"}`);return Se(((l=u.data)==null?void 0:l.data)??[],i)}async function Oo(e){var m;const[{getV1NftsByContractAddressByTokenId:t},{getThirdwebDomains:n},{getClientFetch:r},{assertInsightEnabled:o},{stringify:s}]=await Promise.all([k(()=>import("./thirdweb-DZ2vK6IO.js"),[]),k(()=>import("./utils-B2dQKDW4.js").then(y=>y.q),__vite__mapDeps([0,1,2])),k(()=>import("./utils-B2dQKDW4.js").then(y=>y.r),__vite__mapDeps([0,1,2])),k(()=>import("./common-C1bFpXXr.js"),__vite__mapDeps([3,0,1,2])),k(()=>import("./signing-D7VaTtN_.js").then(y=>y.cS),__vite__mapDeps([4,0,1,2]))]),{client:i,chain:a,contractAddress:c,tokenId:d,includeOwners:p=!0,queryOptions:f}=e;await o([a]);const u={chain_id:[a.id],include_owners:p===!0?"true":"false"},l=await t({baseUrl:`https://${n().insight}`,fetch:r(i),path:{contract_address:c,token_id:d.toString()},query:{...u,...f}});if(l.error)throw new Error(`${l.response.status} ${l.response.statusText} - ${l.error?s(l.error):"Unknown error"}`);const h=await Se(((m=l.data)==null?void 0:m.data)??[],i);return h==null?void 0:h[0]}async function Se(e,t,n){const[{parseNFT:r},{totalSupply:o}]=await Promise.all([k(()=>import("./parseNft-CKnRi_6q.js"),__vite__mapDeps([12,1,2,0,4])),k(()=>import("./totalSupply-Dtpa-Rc2.js"),__vite__mapDeps([13,4,0,1,2,14]))]);return await Promise.all(e.map(async s=>{var w;let i;const{contract:a,extra_metadata:c,collection:d,metadata_url:p,chain_id:f,token_id:u,status:l,balance:h,token_type:m,...y}=s;let _=y,g=n?[U(n)]:void 0;if("owner_addresses"in y){const{owner_addresses:E,...N}=y;_=N,g=g??(E==null?void 0:E.map(P=>U(P)))}const b=Tt({attributes:((w=s.extra_metadata)==null?void 0:w.attributes)??void 0,image:s.image_url,uri:s.metadata_url??"",..._});if((a==null?void 0:a.type)==="erc1155"){const E=await o({contract:X({address:a.address,chain:Y(a.chain_id),client:t}),id:BigInt(u)}).catch(()=>0n);i=r(b,{chainId:(a==null?void 0:a.chain_id)??0,owner:g==null?void 0:g[0],supply:E,tokenAddress:(a==null?void 0:a.address)??"",tokenId:BigInt(u),tokenUri:be(p)??"",type:"ERC1155"})}else i=r(b,{chainId:(a==null?void 0:a.chain_id)??0,owner:g==null?void 0:g[0],tokenAddress:(a==null?void 0:a.address)??"",tokenId:BigInt(u),tokenUri:be(p)??"",type:"ERC721"});return{...i,...(a==null?void 0:a.type)==="erc1155"?{quantityOwned:h?BigInt(h):void 0}:{}}}))}function Tt(e){if(typeof e!="object"||e===null)return e;for(const t in e)typeof e[t]=="string"?e[t]=be(e[t]):Tt(e[t]);return e}function be(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(s=>s==="ipfs");if(r===-1)return e;const o=n.slice(r+1).join("/");return o?`ipfs://${o}`:e}}catch{return e}return e}async function Do(e){var l;const[{getV1Tokens:t},{getThirdwebDomains:n},{getClientFetch:r},{assertInsightEnabled:o},{stringify:s}]=await Promise.all([k(()=>import("./thirdweb-DZ2vK6IO.js"),[]),k(()=>import("./utils-B2dQKDW4.js").then(h=>h.q),__vite__mapDeps([0,1,2])),k(()=>import("./utils-B2dQKDW4.js").then(h=>h.r),__vite__mapDeps([0,1,2])),k(()=>import("./common-C1bFpXXr.js"),__vite__mapDeps([3,0,1,2])),k(()=>import("./signing-D7VaTtN_.js").then(h=>h.cS),__vite__mapDeps([4,0,1,2]))]),{client:i,chains:a,ownerAddress:c,tokenAddresses:d,queryOptions:p}=e;await o(a);const f={chain_id:a.length>0?a.map(h=>h.id):[1],include_native:"true",include_spam:"false",limit:50,metadata:"true",owner_address:[c],token_address:d||void 0,sort_by:"balance",sort_order:"desc"},u=await t({baseUrl:`https://${n().insight}`,fetch:r(i),query:{...f,...p}});if(u.error)throw new Error(`${u.response.status} ${u.response.statusText} - ${u.error?s(u.error):"Unknown error"}`);return zo(((l=u.data)==null?void 0:l.data)??[])}async function zo(e){const{toTokens:t}=await k(async()=>{const{toTokens:n}=await import("./signing-D7VaTtN_.js").then(r=>r.cT);return{toTokens:n}},__vite__mapDeps([4,0,1,2]));return e.map(n=>{const r=n.decimals??18,o=BigInt(n.balance);return{chainId:n.chain_id,decimals:r,displayValue:t(o,r),name:n.name??"",symbol:n.symbol??"",tokenAddress:n.token_address,value:o}})}async function Ro(e){const[{getV1WalletsByWalletAddressTransactions:t},{getThirdwebDomains:n},{getClientFetch:r},{assertInsightEnabled:o},{stringify:s}]=await Promise.all([k(()=>import("./thirdweb-DZ2vK6IO.js"),[]),k(()=>import("./utils-B2dQKDW4.js").then(l=>l.q),__vite__mapDeps([0,1,2])),k(()=>import("./utils-B2dQKDW4.js").then(l=>l.r),__vite__mapDeps([0,1,2])),k(()=>import("./common-C1bFpXXr.js"),__vite__mapDeps([3,0,1,2])),k(()=>import("./signing-D7VaTtN_.js").then(l=>l.cS),__vite__mapDeps([4,0,1,2]))]);await o(e.chains);const i=Math.floor((Date.now()-3*30*24*60*60*1e3)/1e3),{client:a,walletAddress:c,chains:d,queryOptions:p}=e,f={chain:d.map(l=>l.id),filter_block_timestamp_gte:i,limit:100},u=await t({baseUrl:`https://${n().insight}`,fetch:r(a),path:{wallet_address:c},query:{...f,...p}});if(u.error)throw new Error(`${u.response.status} ${u.response.statusText} - ${u.error?s(u.error):"Unknown error"}`);return u.data.data||[]}const Bo=Object.freeze(Object.defineProperty({__proto__:null,getContractEvents:Ee,getContractNFTs:$o,getNFT:Oo,getOwnedNFTs:Po,getOwnedTokens:Do,getTransactions:Ro},Symbol.toStringTag,{value:"Module"}));async function No(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 Dt(r)}async function ke(e,t={}){const n=t.topics??[];let r;if(t.blockHash){const o={blockHash:t.blockHash,topics:n};t.address&&(o.address=U(t.address)),r=await e({method:"eth_getLogs",params:[o]})}else{const o={topics:n};t.address&&(o.address=t.address),t.fromBlock&&(o.fromBlock=typeof t.fromBlock=="bigint"?F(t.fromBlock):t.fromBlock),t.toBlock&&(o.toBlock=typeof t.toBlock=="bigint"?F(t.toBlock):t.toBlock),r=await e({method:"eth_getLogs",params:[o]})}return r.map(o=>Xe(o))}async function jo(e,t){const n=await e({method:"eth_getTransactionByHash",params:[t.hash]});if(!n)throw new Error("Transaction not found.");return zt(n)}async function vt(e){var u;const{contract:t,events:n,blockRange:r,useIndexer:o=!0,...s}=e,i=Ie(t);if(s.blockHash&&(r||s.fromBlock||s.toBlock))throw new Error("Cannot specify blockHash and range simultaneously,");const a=await Qe(i);if(r){const{fromBlock:l,toBlock:h}=s;if(l!==void 0&&h!==void 0&&BigInt(h)-BigInt(l)!==BigInt(r))throw new Error("Incompatible blockRange with specified fromBlock and toBlock. Please only define fromBlock or toBlock when specifying blockRange.");l!==void 0?s.toBlock=BigInt(l)+BigInt(r)-1n:h!==void 0?s.fromBlock=BigInt(h)-BigInt(r)+1n:(s.toBlock=a,s.fromBlock=a-BigInt(r)+1n)}let c=n??[];if(!(n!=null&&n.length)&&t){if(o){const l=await Ee({chains:[t.chain],client:t.client,contractAddress:t.address,decodeLogs:!0,queryOptions:{filter_block_hash:s.blockHash,filter_block_number_gte:s.fromBlock,filter_block_number_lte:s.toBlock,limit:500}}).catch(()=>null);if(l)return Et(l)}(u=t.abi)!=null&&u.length?c=t.abi.filter(Ce).map(l=>he({signature:l})):c=(await We(t)).filter(Ce).map(h=>he({signature:h}))}const d=n&&n.length>0?n.map(l=>({...s,address:U(t.address),topics:l.topics})):[{...s,address:U(t.address)}];let p=[];if(o)try{p=await Promise.all(d.map(l=>xo({contract:t,params:l})))}catch(l){console.warn("Error fetching from insight, falling back to rpc",l),p=await Promise.all(d.map(h=>ke(i,h)))}else p=await Promise.all(d.map(l=>ke(i,l)));const f=p.flat().sort((l,h)=>Number((l.blockNumber??0n)-(h.blockNumber??0n)));return Ve({events:c,logs:f})}async function xo(e){var i,a,c,d;const{params:t,contract:n}=e,r=typeof t.fromBlock=="bigint"?Number(t.fromBlock):void 0,o=typeof t.toBlock=="bigint"?Number(t.toBlock):void 0,s=await Ee({chains:[n.chain],client:n.client,contractAddress:n.address,queryOptions:{filter_block_hash:t.blockHash,filter_block_number_gte:r,filter_block_number_lte:o,filter_topic_0:(i=t.topics)==null?void 0:i[0],filter_topic_1:(a=t.topics)==null?void 0:a[1],filter_topic_2:(c=t.topics)==null?void 0:c[2],filter_topic_3:(d=t.topics)==null?void 0:d[3],limit:500}});return Et(s)}function Et(e){return e.map(n=>({address:n.address,blockHash:n.block_hash,blockNumber:F(Number(n.block_number)),blockTimestamp:n.block_timestamp,chainId:n.chain_id,data:n.data,logIndex:F(n.log_index),topics:n.topics,transactionHash:n.transaction_hash,transactionIndex:F(n.transaction_index),...n.decoded?{args:{...n.decoded.indexed_params,...n.decoded.non_indexed_params},eventName:n.decoded.name}:{}})).map(n=>Xe(n)).sort((n,r)=>Number((n.blockNumber??0n)-(r.blockNumber??0n)))}async function Uo(e,t){const n=t.retries,r=t.delay;let o=null;for(let s=0;s<n;s++)try{return await e()}catch(i){o=i,await new Promise(a=>setTimeout(a,r))}throw o}function Lo(e){return Ye({...e.contract,latestBlockNumber:e.latestBlockNumber,onNewBlockNumber:async t=>{const n=await Uo(async()=>vt({...e,fromBlock:t,toBlock:t,useIndexer:!1}),{delay:500,retries:3});n.length&&e.onEvents(n)}})}const Mo=()=>{const e=$t().pay;return e.startsWith("localhost")?`http://${e}`:`https://${e}`},qo=()=>`${Mo()}/buy-with-crypto/history/v1`;async function Fo(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=`${qo()}?${n}`,o=await T(e.client)(r);if(!o.ok){const i=await o.text().catch(()=>null);throw new Error(`HTTP error! status: ${o.status} - ${o.statusText}: ${i||"unknown error"}`)}return(await o.json()).result}catch(t){throw new Error(`Fetch failed: ${t}`)}}const Wo=[Dn.id,zn.id,Rn.id,Bn.id,Nn.id,jn.id,34443,919,42220,44787,204,5611];async function Vo(e){if(e.id===1337||e.id===31337)return!1;if(Wo.includes(e.id))return!0;try{const{getChainMetadata:t}=await k(async()=>{const{getChainMetadata:r}=await import("./utils-B2dQKDW4.js").then(o=>o.u);return{getChainMetadata:r}},__vite__mapDeps([0,1,2]));return(await t(e)).stackType==="optimism_bedrock"}catch{return!1}}async function Zo(e){var c;const{transaction:t}=e,n=e.from??((c=e.account)==null?void 0:c.address)??void 0,r=await j(t.gas)||await Ze({from:n,transaction:t}),o=await Rt(t.client,t.chain),s=o.maxFeePerGas||o.gasPrice;if(s===void 0)throw new Error(`Unable to determine gas price for chain ${t.chain.id}`);let i;if(await Vo(t.chain)){const{estimateL1Fee:d}=await k(async()=>{const{estimateL1Fee:p}=await import("./estimate-l1-fee-0EMQlb1T.js");return{estimateL1Fee:p}},__vite__mapDeps([15,4,0,1,2]));i=await d({transaction:t})}else i=0n;const a=r*s+i;return{ether:He(a),wei:a}}async function Ho(e){try{const t=await(async()=>{if(e.toAmount){const d=X({address:e.toTokenAddress,chain:Y(e.toChainId),client:e.client}),p=d.address.toLowerCase()===Ae?18:await pe({contract:d}),f=me(e.toAmount,p);return et({amount:f,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 d=X({address:e.fromTokenAddress,chain:Y(e.fromChainId),client:e.client}),p=await pe({contract:d}),f=me(e.fromAmount,p);return tt({amount:f,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(d=>d.action==="approval");if(r.length>1)throw new Error("This quote is incompatible with getBuyWithCryptoQuote. Please use Bridge.Buy.prepare instead.");const o=r[0],s=n.transactions.filter(d=>d.action!=="approval");if(s.length>1)throw new Error("This quote is incompatible with getBuyWithCryptoQuote. Please use Bridge.Buy.prepare instead.");const i=s[0];if(!i)throw new Error("This quote is incompatible with getBuyWithCryptoQuote. Please use Bridge.Buy.prepare instead.");let a;if(o){const d=Ke(["function approve(address spender, uint256 amount)"]),[p,f]=Je(d,o.data);a={amountWei:f.toString(),chainId:n.originToken.chainId,spenderAddress:p,tokenAddress:n.originToken.address}}return{approvalData:a,client:e.client,paymentTokens:[{amount:$(t.originAmount,n.originToken.decimals).toString(),amountUSDCents:Number($(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($(t.originAmount,n.originToken.decimals))*(n.originToken.prices.USD||0)*100,gasCostUSDCents:0,slippageBPS:0,toAmountMinUSDCents:Number($(t.destinationAmount,n.destinationToken.decimals))*(n.destinationToken.prices.USD||0)*100,toAmountUSDCents:Number($(t.destinationAmount,n.destinationToken.decimals))*(n.destinationToken.prices.USD||0)*100},fromAddress:t.intent.sender,fromAmount:$(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:$(t.destinationAmount,n.destinationToken.decimals).toString(),toAmountMin:$(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 Ko(e){var t,n,r,o;try{if(!e.transactionHash)throw new Error("Transaction hash is required");const s=await nt({chainId:e.chainId,client:e.client,transactionHash:e.transactionHash});switch(s.status){case"COMPLETED":{const i=(t=s.transactions)==null?void 0:t.find(c=>c.chainId===e.chainId),a=(n=s.transactions)==null?void 0:n.find(c=>c.chainId!==e.chainId);return fe({destinationAmount:s.destinationAmount,destinationChainId:s.destinationChainId,destinationToken:s.destinationToken,destinationTokenAddress:s.destinationTokenAddress,destinationTransaction:a,originAmount:s.originAmount,originChainId:s.originChainId,originToken:s.originToken,originTokenAddress:s.originTokenAddress,originTransaction:i,paymentId:s.paymentId,purchaseData:s.purchaseData,receiver:s.receiver,sender:s.sender,status:s.status})}case"PENDING":return fe({destinationChainId:s.destinationChainId,destinationToken:s.destinationToken,destinationTokenAddress:s.destinationTokenAddress,originAmount:s.originAmount,originChainId:s.originChainId,originToken:s.originToken,originTokenAddress:s.originTokenAddress,paymentId:s.paymentId,purchaseData:s.purchaseData,receiver:s.receiver,sender:s.sender,status:s.status});case"FAILED":{const i=(r=s.transactions)==null?void 0:r.find(c=>c.chainId===e.chainId),a=(o=s.transactions)==null?void 0:o.find(c=>c.chainId!==e.chainId);return fe({destinationChainId:0,destinationToken:void 0,destinationTokenAddress:"",destinationTransaction:a,originAmount:BigInt(0),originChainId:0,originToken:void 0,originTokenAddress:"",originTransaction:i,paymentId:"",purchaseData:s.purchaseData,receiver:"",sender:"",status:s.status})}default:return{status:"NOT_FOUND"}}}catch(s){throw console.error("Fetch error:",s),new Error(`Fetch failed: ${s}`)}}function fe(e){const{originTransaction:t,destinationTransaction:n,status:r,purchaseData:o,originAmount:s,destinationAmount:i,originTokenAddress:a,destinationTokenAddress:c,originChainId:d,destinationChainId:p,sender:f,receiver:u,originToken:l,destinationToken:h}=e;return{bridge:"STARPORT",destination:{amount:h?q(i??BigInt(0),h.decimals).toString():"",amountUSDCents:0,amountWei:(i==null?void 0:i.toString())??"",completedAt:new Date().toISOString(),explorerLink:"",token:{chainId:p,decimals:(h==null?void 0:h.decimals)??18,name:(h==null?void 0:h.name)??"",priceUSDCents:0,symbol:(h==null?void 0:h.symbol)??"",tokenAddress:c},transactionHash:(n==null?void 0:n.transactionHash)??""},fromAddress:f,purchaseData:o,quote:{createdAt:new Date().toISOString(),estimated:{durationSeconds:0,feesUSDCents:0,fromAmountUSDCents:0,gasCostUSDCents:0,slippageBPS:0,toAmountMinUSDCents:0,toAmountUSDCents:0},fromAmount:l?q(s,l.decimals).toString():"",fromAmountWei:s.toString(),fromToken:{chainId:d,decimals:(l==null?void 0:l.decimals)??18,name:(l==null?void 0:l.name)??"",priceUSDCents:0,symbol:(l==null?void 0:l.symbol)??"",tokenAddress:a},toAmount:h&&i?q(i,h.decimals).toString():"",toAmountMin:h?q(i??BigInt(0),h.decimals).toString():"",toAmountMinWei:i?i.toString():"",toAmountWei:i?i.toString():"",toToken:{chainId:p,decimals:(h==null?void 0:h.decimals)??18,name:(h==null?void 0:h.name)??"",priceUSDCents:0,symbol:(h==null?void 0:h.symbol)??"",tokenAddress:c}},source:{amount:l?q(s,l.decimals).toString():"",amountUSDCents:0,amountWei:s.toString(),completedAt:new Date().toISOString(),explorerLink:"",token:{chainId:d,decimals:(l==null?void 0:l.decimals)??18,name:(l==null?void 0:l.name)??"",priceUSDCents:0,symbol:(l==null?void 0:l.symbol)??"",tokenAddress:a},transactionHash:(t==null?void 0:t.transactionHash)??""},status:r,subStatus:r==="COMPLETED"?"SUCCESS":"NONE",swapType:(t==null?void 0:t.chainId)===(n==null?void 0:n.chainId)?"SAME_CHAIN":"CROSS_CHAIN",toAddress:u}}async function Jo(e){try{const t=X({address:e.tokenAddress,chain:Y(e.chainId),client:e.client}),n=t.address.toLowerCase()===Ae?18:await pe({contract:t}),r=me(e.amount,n),o=await rt({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}),s=o.steps[0];if(!s)throw new Error("This quote is incompatible with getBuyWithCryptoTransfer. Please use Bridge.Transfer.prepare instead.");const i=s.transactions.filter(u=>u.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 u=Ke(["function approve(address spender, uint256 amount)"]),[l,h]=Je(u,a.data);c={amountWei:h.toString(),chainId:s.originToken.chainId,spenderAddress:l,tokenAddress:s.originToken.address}}const d=s.transactions.filter(u=>u.action!=="approval");if(d.length>1)throw new Error("This quote is incompatible with getBuyWithCryptoTransfer. Please use Bridge.Transfer.prepare instead.");const p=d[0];if(!p)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:$(o.originAmount,s.originToken.decimals).toString(),amountUSDCents:Number($(o.originAmount,s.originToken.decimals))*(s.originToken.prices.USD||0)*100,amountWei:o.originAmount.toString(),token:{chainId:s.originToken.chainId,decimals:s.originToken.decimals,name:s.originToken.name,priceUSDCents:(s.originToken.prices.USD||0)*100,symbol:s.originToken.symbol,tokenAddress:s.originToken.address}},processingFee:{amount:e.feePayer==="sender"?$(o.originAmount-o.destinationAmount,s.originToken.decimals).toString():"0",amountUSDCents:e.feePayer==="sender"?Number($(o.originAmount-o.destinationAmount,s.originToken.decimals))*(s.originToken.prices.USD||0)*100:0,amountWei:e.feePayer==="sender"?(o.originAmount-o.destinationAmount).toString():"0",token:{chainId:s.originToken.chainId,decimals:s.originToken.decimals,name:s.originToken.name,priceUSDCents:(s.originToken.prices.USD||0)*100,symbol:s.originToken.symbol,tokenAddress:s.originToken.address}},toAddress:e.toAddress,transactionRequest:{...p,extraGas:50000n}}}catch(t){throw console.error("Error getting buy with crypto transfer",t),t}}async function Go(e){var c;const[t,n,r,o]=await Promise.all([re(e.transaction),j(e.transaction.to),j(e.transaction.accessList),j(e.transaction.value)]),s=e.from??((c=e.account)==null?void 0:c.address)??void 0,i=Bt({accessList:r,data:t,from:s?U(s):void 0,to:n?U(n):void 0,value:o}),a=Ie(e.transaction);try{const d=await Ge(a,i);if(!e.transaction.__preparedMethod)return d;const p=await e.transaction.__preparedMethod(),f=Nt(p[2],d);return Array.isArray(f)&&f.length===1?f[0]:f}catch(d){throw await jt({contract:e.transaction.__contract,error:d,fromAddress:s})}}function Qo(e){return async t=>{var o;if(typeof e=="string"&&e.startsWith("function "))return xt(e);const r=((o=t.abi)!=null&&o.length?t.abi:await We(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 je(e,t=[]){return Yo(e)&&t.every(n=>n in e)}function Xo(e){return je(e,["__contract"])&&je(e.__contract,["address","chain"])&&typeof e.__contract.address=="string"}async function es({address:e,signature:t,client:n,chain:r,accountFactory:o,message:s,domain:i,primaryType:a,types:c}){const d=Ut({domain:i,message:s,primaryType:a,types:c});if(!ie(t))return!1;try{if(Lt({payload:d,signature:Mt(t)}).toLowerCase()===e.toLowerCase())return!0}catch{}return qt({accountFactory:o,address:e,chain:r,client:n,hash:d,signature:t})}async function ts(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 hs=Object.freeze(Object.defineProperty({__proto__:null,ADDRESS_ZERO:Pe,Bridge:to,Engine:Co,Insight:Bo,NATIVE_TOKEN_ADDRESS:Ae,ZERO_ADDRESS:Pe,boolToBytes:kn,boolToHex:hn,bytesToBigInt:an,bytesToBool:cn,bytesToNumber:dn,bytesToString:un,concatHex:fn,createThirdwebClient:ro,defineChain:ee,deploySmartAccount:En,encode:re,estimateGas:Ze,estimateGasCost:Zo,eth_blockNumber:Qe,eth_call:Ge,eth_estimateGas:Pn,eth_gasPrice:Ft,eth_getBalance:Wt,eth_getBlockByHash:No,eth_getBlockByNumber:Vt,eth_getCode:Zt,eth_getLogs:ke,eth_getStorageAt:$n,eth_getTransactionByHash:jo,eth_getTransactionCount:On,eth_getTransactionReceipt:Sn,eth_maxPriorityFeePerGas:Ht,eth_sendRawTransaction:Kt,fromBytes:ln,fromGwei:rn,fromHex:mn,getAddress:U,getBuyWithCryptoHistory:Fo,getBuyWithCryptoQuote:Ho,getBuyWithCryptoStatus:Ko,getBuyWithCryptoTransfer:Jo,getContract:X,getContractEvents:vt,getGasPrice:Gt,getRpcClient:Ie,getUser:Jt,hexToBigInt:pn,hexToBool:gn,hexToBytes:In,hexToNumber:yn,hexToString:wn,hexToUint8Array:Ue,isAddress:xe,isBaseTransactionOptions:Xo,isHex:ie,keccak256:vn,numberToBytes:An,numberToHex:F,padHex:_n,parseEventLogs:Ve,prepareContractCall:Xt,prepareEvent:he,prepareTransaction:en,readContract:tn,resolveMethod:Qo,sendAndConfirmTransaction:xn,sendBatchTransaction:Un,sendTransaction:Qt,serializeTransaction:nn,sha256:gt,signAuthorization:ts,signTransaction:Yt,simulateTransaction:Go,stringToBytes:Me,stringToHex:bn,toBytes:Tn,toEther:He,toHex:qe,toSerializableTransaction:Fe,toTokens:q,toUnits:on,toWei:sn,uint8ArrayToHex:Le,verifyTypedData:es,waitForReceipt:Cn,watchBlockNumber:Ye,watchContractEvents:Lo},Symbol.toStringTag,{value:"Module"}));export{Oo as g,hs as t};
|
|
27
|
+
})));`),u.write(`newResult[${G(g)}] = ${b}.value`)}u.write("payload.value = newResult;"),u.write("return payload;");const _=u.compile();return(g,b)=>_(f,g,b)};let o;const s=se,i=!ot.jitless,c=i&&Xn.value,d=t.catchall;let p;e._zod.parse=(f,u)=>{p??(p=n.value);const l=f.value;if(!s(l))return f.issues.push({expected:"object",code:"invalid_type",input:l,inst:e}),f;const h=[];if(i&&c&&(u==null?void 0:u.async)===!1&&u.jitless!==!0)o||(o=r(t.shape)),f=o(f,u);else{f.value={};const b=p.shape;for(const w of p.keys){const E=b[w],N=E._zod.run({value:l[w],issues:[]},u),P=E._zod.optin==="optional"&&E._zod.optout==="optional";N instanceof Promise?h.push(N.then(L=>P?Oe(L,f,w,l):ne(L,f,w))):P?Oe(N,f,w,l):ne(N,f,w)}}if(!d)return h.length?Promise.all(h).then(()=>f):f;const m=[],y=p.keySet,_=d._zod,g=_.def.type;for(const b of Object.keys(l)){if(y.has(b))continue;if(g==="never"){m.push(b);continue}const w=_.run({value:l[b],issues:[]},u);w instanceof Promise?h.push(w.then(E=>ne(E,f,b))):ne(w,f,b)}return m.length&&f.issues.push({code:"unrecognized_keys",keys:m,input:l,inst:e}),h.length?Promise.all(h).then(()=>f):f}});function De(e,t,n,r){for(const o of e)if(o.issues.length===0)return t.value=o.value,t;return t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(o=>o.issues.map(s=>K(s,r,H())))}),t}const Tr=I("$ZodUnion",(e,t)=>{C.init(e,t),B(e._zod,"optin",()=>t.options.some(n=>n._zod.optin==="optional")?"optional":void 0),B(e._zod,"optout",()=>t.options.some(n=>n._zod.optout==="optional")?"optional":void 0),B(e._zod,"values",()=>{if(t.options.every(n=>n._zod.values))return new Set(t.options.flatMap(n=>Array.from(n._zod.values)))}),B(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=>st(r.source)).join("|")})$`)}}),e._zod.parse=(n,r)=>{let o=!1;const s=[];for(const i of t.options){const a=i._zod.run({value:n.value,issues:[]},r);if(a instanceof Promise)s.push(a),o=!0;else{if(a.issues.length===0)return a;s.push(a)}}return o?Promise.all(s).then(i=>De(i,n,e,r)):De(s,n,e,r)}}),vr=I("$ZodDiscriminatedUnion",(e,t)=>{Tr.init(e,t);const n=e._zod.parse;B(e._zod,"propValues",()=>{const o={};for(const s of t.options){const i=s._zod.propValues;if(!i||Object.keys(i).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(s)}"`);for(const[a,c]of Object.entries(i)){o[a]||(o[a]=new Set);for(const d of c)o[a].add(d)}}return o});const r=Te(()=>{const o=t.options,s=new Map;for(const i of o){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(s.has(c))throw new Error(`Duplicate discriminator value "${String(c)}"`);s.set(c,i)}}return s});e._zod.parse=(o,s)=>{const i=o.value;if(!se(i))return o.issues.push({code:"invalid_type",expected:"object",input:i,inst:e}),o;const a=r.value.get(i==null?void 0:i[t.discriminator]);return a?a._zod.run(o,s):t.unionFallback?n(o,s):(o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",input:i,path:[t.discriminator],inst:e}),o)}}),Er=I("$ZodRecord",(e,t)=>{C.init(e,t),e._zod.parse=(n,r)=>{const o=n.value;if(!er(o))return n.issues.push({expected:"record",code:"invalid_type",input:o,inst:e}),n;const s=[];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 d=t.valueType._zod.run({value:o[c],issues:[]},r);d instanceof Promise?s.push(d.then(p=>{p.issues.length&&n.issues.push(...M(c,p.issues)),n.value[c]=p.value})):(d.issues.length&&n.issues.push(...M(c,d.issues)),n.value[c]=d.value)}let a;for(const c in o)i.has(c)||(a=a??[],a.push(c));a&&a.length>0&&n.issues.push({code:"unrecognized_keys",input:o,inst:e,keys:a})}else{n.value={};for(const i of Reflect.ownKeys(o)){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(d=>K(d,r,H())),input:i,path:[i],inst:e}),n.value[a.value]=a.value;continue}const c=t.valueType._zod.run({value:o[i],issues:[]},r);c instanceof Promise?s.push(c.then(d=>{d.issues.length&&n.issues.push(...M(i,d.issues)),n.value[a.value]=d.value})):(c.issues.length&&n.issues.push(...M(i,c.issues)),n.value[a.value]=c.value)}}return s.length?Promise.all(s).then(()=>n):n}}),Sr=I("$ZodEnum",(e,t)=>{C.init(e,t);const n=Gn(t.entries);e._zod.values=new Set(n),e._zod.pattern=new RegExp(`^(${n.filter(r=>tr.has(typeof r)).map(r=>typeof r=="string"?at(r):r.toString()).join("|")})$`),e._zod.parse=(r,o)=>{const s=r.value;return e._zod.values.has(s)||r.issues.push({code:"invalid_value",values:n,input:s,inst:e}),r}}),Cr=I("$ZodLiteral",(e,t)=>{C.init(e,t),e._zod.values=new Set(t.values),e._zod.pattern=new RegExp(`^(${t.values.map(n=>typeof n=="string"?at(n):n?n.toString():String(n)).join("|")})$`),e._zod.parse=(n,r)=>{const o=n.value;return e._zod.values.has(o)||n.issues.push({code:"invalid_value",values:t.values,input:o,inst:e}),n}}),Pr=I("$ZodOptional",(e,t)=>{C.init(e,t),e._zod.optin="optional",e._zod.optout="optional",B(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),B(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${st(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)}),$r=I("$ZodCustom",(e,t)=>{pr.init(e,t),C.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=n=>{const r=n.value,o=t.fn(r);if(o instanceof Promise)return o.then(s=>ze(s,n,r,e));ze(o,n,r,e)}});function ze(e,t,n,r){if(!e){const o={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(o.params=r._zod.def.params),t.issues.push(or(o))}}function Or(e,t){return new e({type:"string",...D(t)})}function Dr(e,t){return new e({type:"number",checks:[],...D(t)})}function zr(e,t){return new e({type:"number",coerce:!0,checks:[],...D(t)})}function Rr(e,t){return new e({type:"bigint",coerce:!0,...D(t)})}function Br(e){return new e({type:"unknown"})}function Nr(e,t,n){return new e({type:"custom",check:"custom",fn:t,...D(n)})}const O=I("ZodMiniType",(e,t)=>{if(!e._zod)throw new Error("Uninitialized schema in ZodMiniType.");C.init(e,t),e.def=t,e.parse=(n,r)=>ar(e,n,r,{callee:e.parse}),e.safeParse=(n,r)=>dt(e,n,r),e.parseAsync=async(n,r)=>dr(e,n,r,{callee:e.parseAsync}),e.safeParseAsync=async(n,r)=>ut(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)=>nr(e,n,r),e.brand=()=>e,e.register=(n,r)=>(n.add(e,r),e)}),jr=I("ZodMiniString",(e,t)=>{wr.init(e,t),O.init(e,t)});function S(e){return Or(jr,e)}const lt=I("ZodMiniNumber",(e,t)=>{_r.init(e,t),O.init(e,t)});function xr(e){return Dr(lt,e)}const Ur=I("ZodMiniBigInt",(e,t)=>{br.init(e,t),O.init(e,t)}),Lr=I("ZodMiniUnknown",(e,t)=>{kr.init(e,t),O.init(e,t)});function ft(){return Br(Lr)}const Mr=I("ZodMiniArray",(e,t)=>{Ir.init(e,t),O.init(e,t)});function qr(e,t){return new Mr({type:"array",element:e,...D(t)})}const Fr=I("ZodMiniObject",(e,t)=>{Ar.init(e,t),O.init(e,t),B(e,"shape",()=>t.shape)});function z(e,t){const n={type:"object",get shape(){return Yn(this,"shape",{...e}),this.shape},...D(t)};return new Fr(n)}const Wr=I("ZodMiniDiscriminatedUnion",(e,t)=>{vr.init(e,t),O.init(e,t)});function ve(e,t,n){return new Wr({type:"union",options:t,discriminator:e,...D(n)})}const Vr=I("ZodMiniRecord",(e,t)=>{Er.init(e,t),O.init(e,t)});function Zr(e,t,n){return new Vr({type:"record",keyType:e,valueType:t,...D(n)})}const Hr=I("ZodMiniEnum",(e,t)=>{Sr.init(e,t),O.init(e,t)});function ge(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new Hr({type:"enum",entries:n,...D(t)})}const Kr=I("ZodMiniLiteral",(e,t)=>{Cr.init(e,t),O.init(e,t)});function x(e,t){return new Kr({type:"literal",values:Array.isArray(e)?e:[e],...D(t)})}const Jr=I("ZodMiniOptional",(e,t)=>{Pr.init(e,t),O.init(e,t)});function W(e){return new Jr({type:"optional",innerType:e})}const Gr=I("ZodMiniCustom",(e,t)=>{$r.init(e,t),O.init(e,t)});function ht(e,t={}){return Nr(Gr,e,t)}function Q(e){return zr(lt,e)}function ye(e){return Rr(Ur,e)}const mt=S().check(ht(ie,{message:"Invalid hex string"})),V=S().check(ht(xe,{message:"Invalid address"})),we=z({address:V,chainId:Q(),decimals:Q(),iconUri:W(S()),name:S(),priceUsd:Q(),symbol:S()}),Qr=ve("version",[z({data:z({}),type:x("pay.onchain-transaction"),version:x(1)}),z({data:z({action:ge(["TRANSFER","BUY","SELL"]),clientId:S(),destinationAmount:ye(),destinationToken:we,developerFeeBps:Q(),developerFeeRecipient:V,originAmount:ye(),originToken:we,paymentId:S(),paymentLinkId:W(S()),purchaseData:W(Zr(S(),ft())),receiver:V,sender:V,status:ge(["PENDING","FAILED","COMPLETED"]),transactions:qr(z({chainId:Q(),transactionHash:mt})),type:S()}),type:x("pay.onchain-transaction"),version:x(2)})]),Yr=ve("version",[z({data:z({}),type:x("pay.onramp-transaction"),version:x(1)}),z({data:z({amount:ye(),currency:S(),currencyAmount:xr(),id:S(),onramp:S(),paymentLinkId:W(S()),purchaseData:ft(),receiver:V,sender:W(V),status:ge(["PENDING","COMPLETED","FAILED"]),token:we,transactionHash:W(mt)}),type:x("pay.onramp-transaction"),version:x(2)})]),Xr=ve("type",[Qr,Yr]);async function pt(e,t,n,r=300,o){const s=t["x-payload-signature"]||t["x-pay-signature"],i=t["x-timestamp"]||t["x-pay-timestamp"];if(!s||!i)throw new Error("Missing required webhook headers: signature or timestamp");const a=Math.floor(Date.now()/1e3),c=Number.parseInt(i,10),d=Math.abs(a-c);if(d>r)throw new Error(`Webhook timestamp is too old. Difference: ${d}s, tolerance: ${r}s`);const p=new TextEncoder,f=await crypto.subtle.importKey("raw",p.encode(n),{hash:"SHA-256",name:"HMAC"},!1,["sign"]),u=await crypto.subtle.sign("HMAC",f,p.encode(`${i}.${e}`));if(Array.from(new Uint8Array(u)).map(y=>y.toString(16).padStart(2,"0")).join("")!==s)throw new Error("Invalid webhook signature");let h;try{h=JSON.parse(e)}catch{throw new Error("Invalid webhook payload: not valid JSON")}const m=Xr.parse(h);if(m.version===1)throw new Error("Invalid webhook payload: version 1 is no longer supported, please upgrade to webhook version 2.");if(o){if(o.receiverAddress&&m.data.receiver.toLowerCase()!==o.receiverAddress.toLowerCase())throw new Error(`Verification Failed: receiverAddress mismatch, Expected: ${o.receiverAddress}, Received: ${m.data.receiver}`);if(o.destinationTokenAddress){if("destinationToken"in m.data){if(m.data.destinationToken.address.toLowerCase()!==o.destinationTokenAddress.toLowerCase())throw new Error(`Verification Failed: destinationTokenAddress mismatch, Expected: ${o.destinationTokenAddress}, Received: ${m.data.destinationToken.address}`)}else if("onramp"in m.data&&m.data.token.address.toLowerCase()!==o.destinationTokenAddress.toLowerCase())throw new Error(`Verification Failed: destinationTokenAddress mismatch, Expected: ${o.destinationTokenAddress}, Received: ${m.data.token.address}`)}if(o.destinationChainId){if("destinationToken"in m.data){if(m.data.destinationToken.chainId!==o.destinationChainId)throw new Error(`Verification Failed: destinationChainId mismatch, Expected: ${o.destinationChainId}, Received: ${m.data.destinationToken.chainId}`)}else if("onramp"in m.data&&m.data.token.chainId!==o.destinationChainId)throw new Error(`Verification Failed: destinationChainId mismatch, Expected: ${o.destinationChainId}, Received: ${m.data.token.chainId}`)}if(o.minDestinationAmount){if("destinationAmount"in m.data){if(m.data.destinationAmount<o.minDestinationAmount)throw new Error(`Verification Failed: minDestinationAmount, Expected minimum amount to be ${o.minDestinationAmount}, Received: ${m.data.destinationAmount}`)}else if("onramp"in m.data&&m.data.amount<o.minDestinationAmount)throw new Error(`Verification Failed: minDestinationAmount, Expected minimum amount to be ${o.minDestinationAmount}, Received: ${m.data.amount}`)}}return m}const eo=Object.freeze(Object.defineProperty({__proto__:null,parse:pt},Symbol.toStringTag,{value:"Module"})),to=Object.freeze(Object.defineProperty({__proto__:null,Buy:Mn,Onramp:Vn,Sell:Hn,Transfer:Jn,Webhook:eo,chains:qn,parse:pt,status:nt,tokens:Kn},Symbol.toStringTag,{value:"Module"}));function gt(e,t){const n=Ot(ie(e,{strict:!1})?Ue(e):e);return t==="bytes"?n:Le(n)}const ue=new Ct(4096);function no(e){if(ue.has(e))return ue.get(e);const t=gt(Me(e)).slice(2,34);return ue.set(e,t),t}function ro(e){const{clientId:t,secretKey:n,...r}=e;let o=t;if(n)if(Pt(n)){if(!t)throw new Error("clientId must be provided when using a JWT secretKey")}else o=t??no(n);if(!o)throw new Error("clientId or secretKey must be provided");return{...r,clientId:o,secretKey:n}}const oo={bodySerializer:e=>JSON.stringify(e,(t,n)=>typeof n=="bigint"?n.toString():n)},so=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},io=e=>{switch(e){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},ao=e=>{switch(e){case"form":return",";case"pipeDelimited":return"|";case"spaceDelimited":return"%20";default:return","}},co=e=>{switch(e){case"label":return".";case"matrix":return";";case"simple":return",";default:return"&"}},yt=({allowReserved:e,explode:t,name:n,style:r,value:o})=>{if(!t){const a=(e?o:o.map(c=>encodeURIComponent(c))).join(ao(r));switch(r){case"label":return`.${a}`;case"matrix":return`;${n}=${a}`;case"simple":return a;default:return`${n}=${a}`}}const s=io(r),i=o.map(a=>r==="label"||r==="simple"?e?a:encodeURIComponent(a):ce({allowReserved:e,name:n,value:a})).join(s);return r==="label"||r==="matrix"?s+i:i},ce=({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)}`},wt=({allowReserved:e,explode:t,name:n,style:r,value:o,valueOnly:s})=>{if(o instanceof Date)return s?o.toISOString():`${n}=${o.toISOString()}`;if(r!=="deepObject"&&!t){let c=[];Object.entries(o).forEach(([p,f])=>{c=[...c,p,e?f:encodeURIComponent(f)]});const d=c.join(",");switch(r){case"form":return`${n}=${d}`;case"label":return`.${d}`;case"matrix":return`;${n}=${d}`;default:return d}}const i=co(r),a=Object.entries(o).map(([c,d])=>ce({allowReserved:e,name:r==="deepObject"?`${n}[${c}]`:c,value:d})).join(i);return r==="label"||r==="matrix"?i+a:a},uo=/\{[^{}]+\}/g,lo=({path:e,url:t})=>{let n=t;const r=t.match(uo);if(r)for(const o of r){let s=!1,i=o.substring(1,o.length-1),a="simple";i.endsWith("*")&&(s=!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(o,yt({explode:s,name:i,style:a,value:c}));continue}if(typeof c=="object"){n=n.replace(o,wt({explode:s,name:i,style:a,value:c,valueOnly:!0}));continue}if(a==="matrix"){n=n.replace(o,`;${ce({name:i,value:c})}`);continue}const d=encodeURIComponent(a==="label"?`.${c}`:c);n=n.replace(o,d)}return n},_t=({allowReserved:e,array:t,object:n}={})=>o=>{const s=[];if(o&&typeof o=="object")for(const i in o){const a=o[i];if(a!=null)if(Array.isArray(a)){const c=yt({allowReserved:e,explode:!0,name:i,style:"form",value:a,...t});c&&s.push(c)}else if(typeof a=="object"){const c=wt({allowReserved:e,explode:!0,name:i,style:"deepObject",value:a,...n});c&&s.push(c)}else{const c=ce({allowReserved:e,name:i,value:a});c&&s.push(c)}}return s.join("&")},fo=e=>{var n;if(!e)return"stream";const t=(n=e.split(";")[0])==null?void 0:n.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(r=>t.startsWith(r)))return"blob";if(t.startsWith("text/"))return"text"}},ho=async({security:e,...t})=>{for(const n of e){const r=await so(n,t.auth);if(!r)continue;const o=n.name??"Authorization";switch(n.in){case"query":t.query||(t.query={}),t.query[o]=r;break;case"cookie":t.headers.append("Cookie",`${o}=${r}`);break;case"header":default:t.headers.set(o,r);break}return}},Re=e=>mo({baseUrl:e.baseUrl,path:e.path,query:e.query,querySerializer:typeof e.querySerializer=="function"?e.querySerializer:_t(e.querySerializer),url:e.url}),mo=({baseUrl:e,path:t,query:n,querySerializer:r,url:o})=>{const s=o.startsWith("/")?o:`/${o}`;let i=(e??"")+s;t&&(i=lo({path:t,url:i}));let a=n?r(n):"";return a.startsWith("?")&&(a=a.substring(1)),a&&(i+=`?${a}`),i},Be=(e,t)=>{var r;const n={...e,...t};return(r=n.baseUrl)!=null&&r.endsWith("/")&&(n.baseUrl=n.baseUrl.substring(0,n.baseUrl.length-1)),n.headers=bt(e.headers,t.headers),n},bt=(...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[o,s]of r)if(s===null)t.delete(o);else if(Array.isArray(s))for(const i of s)t.append(o,i);else s!==void 0&&t.set(o,typeof s=="object"?JSON.stringify(s):s)}return t};class le{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 po=()=>({error:new le,request:new le,response:new le}),go=_t({allowReserved:!1,array:{explode:!0,style:"form"},object:{explode:!0,style:"deepObject"}}),yo={"Content-Type":"application/json"},kt=(e={})=>({...oo,headers:yo,parseAs:"auto",querySerializer:go,...e}),wo=(e={})=>{let t=Be(kt(),e);const n=()=>({...t}),r=i=>(t=Be(t,i),n()),o=po(),s=async i=>{const a={...t,...i,fetch:i.fetch??t.fetch??globalThis.fetch,headers:bt(t.headers,i.headers)};a.security&&await ho({...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=Re(a),d={redirect:"follow",...a};let p=new Request(c,d);for(const y of o.request._fns)y&&(p=await y(p,a));const f=a.fetch;let u=await f(p);for(const y of o.response._fns)y&&(u=await y(u,p,a));const l={request:p,response:u};if(u.ok){if(u.status===204||u.headers.get("Content-Length")==="0")return a.responseStyle==="data"?{}:{data:{},...l};const y=(a.parseAs==="auto"?fo(u.headers.get("Content-Type")):a.parseAs)??"json";let _;switch(y){case"arrayBuffer":case"blob":case"formData":case"json":case"text":_=await u[y]();break;case"stream":return a.responseStyle==="data"?u.body:{data:u.body,...l}}return y==="json"&&(a.responseValidator&&await a.responseValidator(_),a.responseTransformer&&(_=await a.responseTransformer(_))),a.responseStyle==="data"?_:{data:_,...l}}let h=await u.text();try{h=JSON.parse(h)}catch{}let m=h;for(const y of o.error._fns)y&&(m=await y(h,u,p,a));if(m=m||{},a.throwOnError)throw m;return a.responseStyle==="data"?void 0:{error:m,...l}};return{buildUrl:Re,connect:i=>s({...i,method:"CONNECT"}),delete:i=>s({...i,method:"DELETE"}),get:i=>s({...i,method:"GET"}),getConfig:n,head:i=>s({...i,method:"HEAD"}),interceptors:o,options:i=>s({...i,method:"OPTIONS"}),patch:i=>s({...i,method:"PATCH"}),post:i=>s({...i,method:"POST"}),put:i=>s({...i,method:"PUT"}),request:s,setConfig:r,trace:i=>s({...i,method:"TRACE"})}},J=wo(kt({baseUrl:"https://engine.thirdweb.com"})),_o=e=>(e.client??J).post({security:[{name:"x-secret-key",type:"apiKey"}],url:"/v1/write/transaction",...e,headers:{"Content-Type":"application/json",...e.headers}}),bo=e=>(e.client??J).post({security:[{name:"x-secret-key",type:"apiKey"}],url:"/v1/sign/message",...e,headers:{"Content-Type":"application/json",...e.headers}}),ko=e=>(e.client??J).post({security:[{name:"x-secret-key",type:"apiKey"}],url:"/v1/sign/typed-data",...e,headers:{"Content-Type":"application/json",...e.headers}}),Io=e=>((e==null?void 0:e.client)??J).get({security:[{name:"x-secret-key",type:"apiKey"}],url:"/v1/accounts",...e}),Ao=e=>((e==null?void 0:e.client)??J).post({security:[{name:"x-secret-key",type:"apiKey"}],url:"/v1/accounts",...e,headers:{"Content-Type":"application/json",...e==null?void 0:e.headers}}),It=e=>((e==null?void 0:e.client)??J).post({security:[{name:"x-secret-key",type:"apiKey"}],url:"/v1/transactions/search",...e,headers:{"Content-Type":"application/json",...e==null?void 0:e.headers}});function Ne(e){return"result"in e}async function To(e){var s;const{client:t,label:n}=e,r=await Ao({baseUrl:v("engineCloud"),body:{label:n},bodySerializer:Z,fetch:T(t)});if(r.error)throw new Error(`Error creating server wallet with label ${n}: ${Z(r.error)}`);const o=(s=r.data)==null?void 0:s.result;if(!o)throw new Error(`No server wallet created with label ${n}`);return o}async function At(e){var i,a,c;const{client:t,transactionId:n}=e,r=await It({baseUrl:v("engineCloud"),body:{filters:[{field:"id",operation:"OR",values:[n]}]},bodySerializer:A,fetch:T(t)});if(r.error)throw new Error(`Error searching for transaction ${n}: ${A(r.error)}`);const o=(c=(a=(i=r.data)==null?void 0:i.result)==null?void 0:a.transactions)==null?void 0:c[0];if(!o)throw new Error(`Transaction ${n} not found`);return{...o.executionResult,cancelledAt:o.cancelledAt,chain:Y(Number(o.chainId)),confirmedAt:o.confirmedAt,createdAt:o.createdAt,from:o.from??void 0,id:o.id}}async function vo(e){var o;const{client:t}=e,n=await Io({baseUrl:v("engineCloud"),bodySerializer:Z,fetch:T(t),query:{limit:e.limit,page:e.page}});if(n.error)throw new Error(`Error listing server wallets: ${Z(n.error)}`);const r=(o=n.data)==null?void 0:o.result;if(!r)throw new Error("No server wallets found");return r}async function Eo(e){var a;const{client:t,filters:n,pageSize:r=100,page:o=1}=e,s=await It({baseUrl:v("engineCloud"),body:{filters:n,limit:r,page:o},bodySerializer:A,fetch:T(t)});if(s.error)throw new Error(`Error searching for transaction with filters ${A(n)}: ${A(s.error)}`);const i=(a=s.data)==null?void 0:a.result;if(!i)throw new Error(`No transactions found with filters ${A(n)}`);return i}async function _e(e){const t=Date.now(),n=e.timeoutInSeconds?e.timeoutInSeconds*1e3:5*60*1e3;for(;Date.now()-t<n;){const r=await At(e);switch(r.status){case"FAILED":throw new Error(`Transaction failed: ${Z(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==null?void 0:i.errorName)||"unknown error"} ${i!=null&&i.errorArgs?Z(i.errorArgs):""} - ${r.transactionHash?r.transactionHash:""}`)}return{chain:r.chain,client:e.client,transactionHash:r.transactionHash}}default:await new Promise(s=>setTimeout(s,1e3))}}throw new Error(`Transaction timed out after ${n/1e3} seconds`)}function So(e){const{client:t,vaultAccessToken:n,address:r,chain:o,executionOptions:s}=e,i=n?{"x-vault-access-token":n}:{},a=f=>{if(!s)return{chainId:f,from:r,type:"auto"};switch(s.type){case"auto":return{chainId:f,from:r,type:"auto"};case"ERC4337":return{...s,chainId:f,type:"ERC4337"};case"EOA":return{chainId:f,from:r,type:"EOA"};case"EIP7702":return{...s,chainId:f,type:"EIP7702"}}},c=f=>{if(!f)return{from:r,type:"EOA"};if(!s)return{chainId:f,from:r,type:"auto"};switch(s.type){case"ERC4337":return{chainId:f,...s,type:"ERC4337"};case"auto":return{chainId:f,from:r,type:"auto"};case"EIP7702":case"EOA":return{chainId:f,from:r,type:"EOA"}}},d=async f=>{var _,g,b;if(f.length===0)throw new Error("No transactions to enqueue");const u=f[0];if(!u)throw new Error("No transactions to enqueue");const l=u.chainId;for(let w=1;w<f.length;w++)if(((_=f[w])==null?void 0:_.chainId)!==l)throw new Error(`All transactions in batch must be on the same chain. Expected ${l}, got ${(g=f[w])==null?void 0:g.chainId} at index ${w}`);const h={executionOptions:a(l),params:f.map(w=>{var E;return{data:w.data,to:w.to,gasLimit:w.gas?Number(w.gas):void 0,value:(E=w.value)==null?void 0:E.toString()}})},m=await _o({baseUrl:v("engineCloud"),body:h,bodySerializer:A,fetch:T(t),headers:i});if(m.error)throw new Error(`Error sending transaction: ${A(m.error)}`);const y=(b=m.data)==null?void 0:b.result;if(!y)throw new Error("No data returned from engine");return y.transactions.map(w=>w.id)};return{address:(s==null?void 0:s.type)==="ERC4337"&&s.smartAccountAddress?s.smartAccountAddress:r,enqueueBatchTransaction:async f=>{const u=[];for(const m of f.transactions){const[y,_,g]=await Promise.all([m.to?j(m.to):null,re(m),m.value?j(m.value):null]);u.push({chainId:m.chain.id,data:_,to:y??void 0,value:g??void 0})}const h=(await d(u))[0];if(!h)throw new Error("No transactionId returned from engine");return{transactionId:h}},enqueueTransaction:async f=>{let u;if(f.simulate)u=await Fe({transaction:f.transaction,from:r});else{const[m,y,_]=await Promise.all([f.transaction.to?j(f.transaction.to):null,re(f.transaction),f.transaction.value?j(f.transaction.value):null]);u={chainId:f.transaction.chain.id,data:y,to:m??void 0,value:_??void 0}}const h=(await d([u]))[0];if(!h)throw new Error("No transactionId returned from engine");return{transactionId:h}},sendBatchTransaction:async f=>{const l=(await d(f))[0];if(!l)throw new Error("No transactionId returned from engine");return _e({client:t,transactionId:l})},sendTransaction:async f=>{const l=(await d([f]))[0];if(!l)throw new Error("No transactionId returned from engine");return _e({client:t,transactionId:l})},signMessage:async f=>{var b;const{message:u,chainId:l}=f;let h,m=!1;typeof u=="string"?h=u:(h=qe(u.raw),m=!0);const y=l||(o==null?void 0:o.id);if(!y)throw new Error("Chain ID is required for signing messages");const _=await bo({baseUrl:v("engineCloud"),body:{params:[{format:m?"hex":"text",message:h}],signingOptions:c(y)},bodySerializer:A,fetch:T(t),headers:i});if(_.error)throw new Error(`Error signing message: ${A(_.error)}`);const g=(b=_.data)==null?void 0:b.result[0];if(g&&Ne(g))return g.result.signature;throw new Error(`Failed to sign message: ${A(g==null?void 0:g.error)||"Unknown error"}`)},signTypedData:async f=>{var m;const u=o==null?void 0:o.id;if(!u)throw new Error("Chain ID is required for signing messages");const l=await ko({baseUrl:v("engineCloud"),body:{params:[f],signingOptions:c(u)},bodySerializer:A,fetch:T(t),headers:i});if(l.error)throw new Error(`Error signing message: ${A(l.error)}`);const h=(m=l.data)==null?void 0:m.result[0];if(h&&Ne(h))return h.result.signature;throw new Error(`Failed to sign message: ${A(h==null?void 0:h.error)||"Unknown error"}`)}}}const Co=Object.freeze(Object.defineProperty({__proto__:null,createServerWallet:To,getServerWallets:vo,getTransactionStatus:At,searchTransactions:Eo,serverWallet:So,waitForTransactionHash:_e},Symbol.toStringTag,{value:"Module"}));async function Ee(e){var h;const[{getV1EventsByContractAddress:t},{getThirdwebDomains:n},{getClientFetch:r},{assertInsightEnabled:o},{stringify:s}]=await Promise.all([k(()=>import("./thirdweb-DZ2vK6IO.js"),[]),k(()=>import("./utils-CUIXWH1v.js").then(m=>m.q),__vite__mapDeps([0,1,2])),k(()=>import("./utils-CUIXWH1v.js").then(m=>m.r),__vite__mapDeps([0,1,2])),k(()=>import("./common-DttAkYAP.js"),__vite__mapDeps([3,0,1,2])),k(()=>import("./signing-DR1diqT_.js").then(m=>m.cS),__vite__mapDeps([4,0,1,2]))]),{client:i,chains:a,contractAddress:c,event:d,queryOptions:p,decodeLogs:f}=e;await o(a);const u={chain:a.map(m=>m.id),decode:f,limit:100};d&&(u.filter_topic_0=d.topics[0],u.filter_topic_1=d.topics[1],u.filter_topic_2=d.topics[2],u.filter_topic_3=d.topics[3]);const l=await t({baseUrl:`https://${n().insight}`,fetch:r(i),path:{contractAddress:c},query:{...u,...p}});if(l.error)throw new Error(`${l.response.status} ${l.response.statusText} - ${l.error?s(l.error):"Unknown error"}`);return((h=l.data)==null?void 0:h.data)??[]}async function Po(e){var h;const[{getV1Nfts:t},{getThirdwebDomains:n},{getClientFetch:r},{assertInsightEnabled:o},{stringify:s}]=await Promise.all([k(()=>import("./thirdweb-DZ2vK6IO.js"),[]),k(()=>import("./utils-CUIXWH1v.js").then(m=>m.q),__vite__mapDeps([0,1,2])),k(()=>import("./utils-CUIXWH1v.js").then(m=>m.r),__vite__mapDeps([0,1,2])),k(()=>import("./common-DttAkYAP.js"),__vite__mapDeps([3,0,1,2])),k(()=>import("./index-zeKYF1_9.js"),__vite__mapDeps([5,6,4,0,1,2,7,8,9,10,11]))]),{client:i,chains:a,ownerAddress:c,contractAddresses:d,queryOptions:p}=e;await o(a);const f={chain:a.map(m=>m.id),limit:50,owner_address:[c],contract_address:d||void 0},u=await t({baseUrl:`https://${n().insight}`,fetch:r(i),query:{...f,...p}});if(u.error)throw new Error(`${u.response.status} ${u.response.statusText} - ${u.error?s(u.error):"Unknown error"}`);return(await Se(((h=u.data)==null?void 0:h.data)??[],i,c)).map(m=>({...m,quantityOwned:m.quantityOwned??1n}))}async function $o(e){var l;const[{getV1NftsByContractAddress:t},{getThirdwebDomains:n},{getClientFetch:r},{assertInsightEnabled:o},{stringify:s}]=await Promise.all([k(()=>import("./thirdweb-DZ2vK6IO.js"),[]),k(()=>import("./utils-CUIXWH1v.js").then(h=>h.q),__vite__mapDeps([0,1,2])),k(()=>import("./utils-CUIXWH1v.js").then(h=>h.r),__vite__mapDeps([0,1,2])),k(()=>import("./common-DttAkYAP.js"),__vite__mapDeps([3,0,1,2])),k(()=>import("./signing-DR1diqT_.js").then(h=>h.cS),__vite__mapDeps([4,0,1,2]))]),{client:i,chains:a,contractAddress:c,includeOwners:d=!0,queryOptions:p}=e,f={chain:a.map(h=>h.id),include_owners:d===!0?"true":"false",limit:50};await o(a);const u=await t({baseUrl:`https://${n().insight}`,fetch:r(i),path:{contract_address:c},query:{...f,...p}});if(u.error)throw new Error(`${u.response.status} ${u.response.statusText} - ${u.error?s(u.error):"Unknown error"}`);return Se(((l=u.data)==null?void 0:l.data)??[],i)}async function Oo(e){var m;const[{getV1NftsByContractAddressByTokenId:t},{getThirdwebDomains:n},{getClientFetch:r},{assertInsightEnabled:o},{stringify:s}]=await Promise.all([k(()=>import("./thirdweb-DZ2vK6IO.js"),[]),k(()=>import("./utils-CUIXWH1v.js").then(y=>y.q),__vite__mapDeps([0,1,2])),k(()=>import("./utils-CUIXWH1v.js").then(y=>y.r),__vite__mapDeps([0,1,2])),k(()=>import("./common-DttAkYAP.js"),__vite__mapDeps([3,0,1,2])),k(()=>import("./signing-DR1diqT_.js").then(y=>y.cS),__vite__mapDeps([4,0,1,2]))]),{client:i,chain:a,contractAddress:c,tokenId:d,includeOwners:p=!0,queryOptions:f}=e;await o([a]);const u={chain_id:[a.id],include_owners:p===!0?"true":"false"},l=await t({baseUrl:`https://${n().insight}`,fetch:r(i),path:{contract_address:c,token_id:d.toString()},query:{...u,...f}});if(l.error)throw new Error(`${l.response.status} ${l.response.statusText} - ${l.error?s(l.error):"Unknown error"}`);const h=await Se(((m=l.data)==null?void 0:m.data)??[],i);return h==null?void 0:h[0]}async function Se(e,t,n){const[{parseNFT:r},{totalSupply:o}]=await Promise.all([k(()=>import("./parseNft-bgONNYbj.js"),__vite__mapDeps([12,1,2,0,4])),k(()=>import("./totalSupply-CVGbD7FC.js"),__vite__mapDeps([13,4,0,1,2,14]))]);return await Promise.all(e.map(async s=>{var w;let i;const{contract:a,extra_metadata:c,collection:d,metadata_url:p,chain_id:f,token_id:u,status:l,balance:h,token_type:m,...y}=s;let _=y,g=n?[U(n)]:void 0;if("owner_addresses"in y){const{owner_addresses:E,...N}=y;_=N,g=g??(E==null?void 0:E.map(P=>U(P)))}const b=Tt({attributes:((w=s.extra_metadata)==null?void 0:w.attributes)??void 0,image:s.image_url,uri:s.metadata_url??"",..._});if((a==null?void 0:a.type)==="erc1155"){const E=await o({contract:X({address:a.address,chain:Y(a.chain_id),client:t}),id:BigInt(u)}).catch(()=>0n);i=r(b,{chainId:(a==null?void 0:a.chain_id)??0,owner:g==null?void 0:g[0],supply:E,tokenAddress:(a==null?void 0:a.address)??"",tokenId:BigInt(u),tokenUri:be(p)??"",type:"ERC1155"})}else i=r(b,{chainId:(a==null?void 0:a.chain_id)??0,owner:g==null?void 0:g[0],tokenAddress:(a==null?void 0:a.address)??"",tokenId:BigInt(u),tokenUri:be(p)??"",type:"ERC721"});return{...i,...(a==null?void 0:a.type)==="erc1155"?{quantityOwned:h?BigInt(h):void 0}:{}}}))}function Tt(e){if(typeof e!="object"||e===null)return e;for(const t in e)typeof e[t]=="string"?e[t]=be(e[t]):Tt(e[t]);return e}function be(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(s=>s==="ipfs");if(r===-1)return e;const o=n.slice(r+1).join("/");return o?`ipfs://${o}`:e}}catch{return e}return e}async function Do(e){var l;const[{getV1Tokens:t},{getThirdwebDomains:n},{getClientFetch:r},{assertInsightEnabled:o},{stringify:s}]=await Promise.all([k(()=>import("./thirdweb-DZ2vK6IO.js"),[]),k(()=>import("./utils-CUIXWH1v.js").then(h=>h.q),__vite__mapDeps([0,1,2])),k(()=>import("./utils-CUIXWH1v.js").then(h=>h.r),__vite__mapDeps([0,1,2])),k(()=>import("./common-DttAkYAP.js"),__vite__mapDeps([3,0,1,2])),k(()=>import("./signing-DR1diqT_.js").then(h=>h.cS),__vite__mapDeps([4,0,1,2]))]),{client:i,chains:a,ownerAddress:c,tokenAddresses:d,queryOptions:p}=e;await o(a);const f={chain_id:a.length>0?a.map(h=>h.id):[1],include_native:"true",include_spam:"false",limit:50,metadata:"true",owner_address:[c],token_address:d||void 0,sort_by:"balance",sort_order:"desc"},u=await t({baseUrl:`https://${n().insight}`,fetch:r(i),query:{...f,...p}});if(u.error)throw new Error(`${u.response.status} ${u.response.statusText} - ${u.error?s(u.error):"Unknown error"}`);return zo(((l=u.data)==null?void 0:l.data)??[])}async function zo(e){const{toTokens:t}=await k(async()=>{const{toTokens:n}=await import("./signing-DR1diqT_.js").then(r=>r.cT);return{toTokens:n}},__vite__mapDeps([4,0,1,2]));return e.map(n=>{const r=n.decimals??18,o=BigInt(n.balance);return{chainId:n.chain_id,decimals:r,displayValue:t(o,r),name:n.name??"",symbol:n.symbol??"",tokenAddress:n.token_address,value:o}})}async function Ro(e){const[{getV1WalletsByWalletAddressTransactions:t},{getThirdwebDomains:n},{getClientFetch:r},{assertInsightEnabled:o},{stringify:s}]=await Promise.all([k(()=>import("./thirdweb-DZ2vK6IO.js"),[]),k(()=>import("./utils-CUIXWH1v.js").then(l=>l.q),__vite__mapDeps([0,1,2])),k(()=>import("./utils-CUIXWH1v.js").then(l=>l.r),__vite__mapDeps([0,1,2])),k(()=>import("./common-DttAkYAP.js"),__vite__mapDeps([3,0,1,2])),k(()=>import("./signing-DR1diqT_.js").then(l=>l.cS),__vite__mapDeps([4,0,1,2]))]);await o(e.chains);const i=Math.floor((Date.now()-3*30*24*60*60*1e3)/1e3),{client:a,walletAddress:c,chains:d,queryOptions:p}=e,f={chain:d.map(l=>l.id),filter_block_timestamp_gte:i,limit:100},u=await t({baseUrl:`https://${n().insight}`,fetch:r(a),path:{wallet_address:c},query:{...f,...p}});if(u.error)throw new Error(`${u.response.status} ${u.response.statusText} - ${u.error?s(u.error):"Unknown error"}`);return u.data.data||[]}const Bo=Object.freeze(Object.defineProperty({__proto__:null,getContractEvents:Ee,getContractNFTs:$o,getNFT:Oo,getOwnedNFTs:Po,getOwnedTokens:Do,getTransactions:Ro},Symbol.toStringTag,{value:"Module"}));async function No(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 Dt(r)}async function ke(e,t={}){const n=t.topics??[];let r;if(t.blockHash){const o={blockHash:t.blockHash,topics:n};t.address&&(o.address=U(t.address)),r=await e({method:"eth_getLogs",params:[o]})}else{const o={topics:n};t.address&&(o.address=t.address),t.fromBlock&&(o.fromBlock=typeof t.fromBlock=="bigint"?F(t.fromBlock):t.fromBlock),t.toBlock&&(o.toBlock=typeof t.toBlock=="bigint"?F(t.toBlock):t.toBlock),r=await e({method:"eth_getLogs",params:[o]})}return r.map(o=>Xe(o))}async function jo(e,t){const n=await e({method:"eth_getTransactionByHash",params:[t.hash]});if(!n)throw new Error("Transaction not found.");return zt(n)}async function vt(e){var u;const{contract:t,events:n,blockRange:r,useIndexer:o=!0,...s}=e,i=Ie(t);if(s.blockHash&&(r||s.fromBlock||s.toBlock))throw new Error("Cannot specify blockHash and range simultaneously,");const a=await Qe(i);if(r){const{fromBlock:l,toBlock:h}=s;if(l!==void 0&&h!==void 0&&BigInt(h)-BigInt(l)!==BigInt(r))throw new Error("Incompatible blockRange with specified fromBlock and toBlock. Please only define fromBlock or toBlock when specifying blockRange.");l!==void 0?s.toBlock=BigInt(l)+BigInt(r)-1n:h!==void 0?s.fromBlock=BigInt(h)-BigInt(r)+1n:(s.toBlock=a,s.fromBlock=a-BigInt(r)+1n)}let c=n??[];if(!(n!=null&&n.length)&&t){if(o){const l=await Ee({chains:[t.chain],client:t.client,contractAddress:t.address,decodeLogs:!0,queryOptions:{filter_block_hash:s.blockHash,filter_block_number_gte:s.fromBlock,filter_block_number_lte:s.toBlock,limit:500}}).catch(()=>null);if(l)return Et(l)}(u=t.abi)!=null&&u.length?c=t.abi.filter(Ce).map(l=>he({signature:l})):c=(await We(t)).filter(Ce).map(h=>he({signature:h}))}const d=n&&n.length>0?n.map(l=>({...s,address:U(t.address),topics:l.topics})):[{...s,address:U(t.address)}];let p=[];if(o)try{p=await Promise.all(d.map(l=>xo({contract:t,params:l})))}catch(l){console.warn("Error fetching from insight, falling back to rpc",l),p=await Promise.all(d.map(h=>ke(i,h)))}else p=await Promise.all(d.map(l=>ke(i,l)));const f=p.flat().sort((l,h)=>Number((l.blockNumber??0n)-(h.blockNumber??0n)));return Ve({events:c,logs:f})}async function xo(e){var i,a,c,d;const{params:t,contract:n}=e,r=typeof t.fromBlock=="bigint"?Number(t.fromBlock):void 0,o=typeof t.toBlock=="bigint"?Number(t.toBlock):void 0,s=await Ee({chains:[n.chain],client:n.client,contractAddress:n.address,queryOptions:{filter_block_hash:t.blockHash,filter_block_number_gte:r,filter_block_number_lte:o,filter_topic_0:(i=t.topics)==null?void 0:i[0],filter_topic_1:(a=t.topics)==null?void 0:a[1],filter_topic_2:(c=t.topics)==null?void 0:c[2],filter_topic_3:(d=t.topics)==null?void 0:d[3],limit:500}});return Et(s)}function Et(e){return e.map(n=>({address:n.address,blockHash:n.block_hash,blockNumber:F(Number(n.block_number)),blockTimestamp:n.block_timestamp,chainId:n.chain_id,data:n.data,logIndex:F(n.log_index),topics:n.topics,transactionHash:n.transaction_hash,transactionIndex:F(n.transaction_index),...n.decoded?{args:{...n.decoded.indexed_params,...n.decoded.non_indexed_params},eventName:n.decoded.name}:{}})).map(n=>Xe(n)).sort((n,r)=>Number((n.blockNumber??0n)-(r.blockNumber??0n)))}async function Uo(e,t){const n=t.retries,r=t.delay;let o=null;for(let s=0;s<n;s++)try{return await e()}catch(i){o=i,await new Promise(a=>setTimeout(a,r))}throw o}function Lo(e){return Ye({...e.contract,latestBlockNumber:e.latestBlockNumber,onNewBlockNumber:async t=>{const n=await Uo(async()=>vt({...e,fromBlock:t,toBlock:t,useIndexer:!1}),{delay:500,retries:3});n.length&&e.onEvents(n)}})}const Mo=()=>{const e=$t().pay;return e.startsWith("localhost")?`http://${e}`:`https://${e}`},qo=()=>`${Mo()}/buy-with-crypto/history/v1`;async function Fo(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=`${qo()}?${n}`,o=await T(e.client)(r);if(!o.ok){const i=await o.text().catch(()=>null);throw new Error(`HTTP error! status: ${o.status} - ${o.statusText}: ${i||"unknown error"}`)}return(await o.json()).result}catch(t){throw new Error(`Fetch failed: ${t}`)}}const Wo=[Dn.id,zn.id,Rn.id,Bn.id,Nn.id,jn.id,34443,919,42220,44787,204,5611];async function Vo(e){if(e.id===1337||e.id===31337)return!1;if(Wo.includes(e.id))return!0;try{const{getChainMetadata:t}=await k(async()=>{const{getChainMetadata:r}=await import("./utils-CUIXWH1v.js").then(o=>o.u);return{getChainMetadata:r}},__vite__mapDeps([0,1,2]));return(await t(e)).stackType==="optimism_bedrock"}catch{return!1}}async function Zo(e){var c;const{transaction:t}=e,n=e.from??((c=e.account)==null?void 0:c.address)??void 0,r=await j(t.gas)||await Ze({from:n,transaction:t}),o=await Rt(t.client,t.chain),s=o.maxFeePerGas||o.gasPrice;if(s===void 0)throw new Error(`Unable to determine gas price for chain ${t.chain.id}`);let i;if(await Vo(t.chain)){const{estimateL1Fee:d}=await k(async()=>{const{estimateL1Fee:p}=await import("./estimate-l1-fee-BXqjzhsB.js");return{estimateL1Fee:p}},__vite__mapDeps([15,4,0,1,2]));i=await d({transaction:t})}else i=0n;const a=r*s+i;return{ether:He(a),wei:a}}async function Ho(e){try{const t=await(async()=>{if(e.toAmount){const d=X({address:e.toTokenAddress,chain:Y(e.toChainId),client:e.client}),p=d.address.toLowerCase()===Ae?18:await pe({contract:d}),f=me(e.toAmount,p);return et({amount:f,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 d=X({address:e.fromTokenAddress,chain:Y(e.fromChainId),client:e.client}),p=await pe({contract:d}),f=me(e.fromAmount,p);return tt({amount:f,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(d=>d.action==="approval");if(r.length>1)throw new Error("This quote is incompatible with getBuyWithCryptoQuote. Please use Bridge.Buy.prepare instead.");const o=r[0],s=n.transactions.filter(d=>d.action!=="approval");if(s.length>1)throw new Error("This quote is incompatible with getBuyWithCryptoQuote. Please use Bridge.Buy.prepare instead.");const i=s[0];if(!i)throw new Error("This quote is incompatible with getBuyWithCryptoQuote. Please use Bridge.Buy.prepare instead.");let a;if(o){const d=Ke(["function approve(address spender, uint256 amount)"]),[p,f]=Je(d,o.data);a={amountWei:f.toString(),chainId:n.originToken.chainId,spenderAddress:p,tokenAddress:n.originToken.address}}return{approvalData:a,client:e.client,paymentTokens:[{amount:$(t.originAmount,n.originToken.decimals).toString(),amountUSDCents:Number($(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($(t.originAmount,n.originToken.decimals))*(n.originToken.prices.USD||0)*100,gasCostUSDCents:0,slippageBPS:0,toAmountMinUSDCents:Number($(t.destinationAmount,n.destinationToken.decimals))*(n.destinationToken.prices.USD||0)*100,toAmountUSDCents:Number($(t.destinationAmount,n.destinationToken.decimals))*(n.destinationToken.prices.USD||0)*100},fromAddress:t.intent.sender,fromAmount:$(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:$(t.destinationAmount,n.destinationToken.decimals).toString(),toAmountMin:$(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 Ko(e){var t,n,r,o;try{if(!e.transactionHash)throw new Error("Transaction hash is required");const s=await nt({chainId:e.chainId,client:e.client,transactionHash:e.transactionHash});switch(s.status){case"COMPLETED":{const i=(t=s.transactions)==null?void 0:t.find(c=>c.chainId===e.chainId),a=(n=s.transactions)==null?void 0:n.find(c=>c.chainId!==e.chainId);return fe({destinationAmount:s.destinationAmount,destinationChainId:s.destinationChainId,destinationToken:s.destinationToken,destinationTokenAddress:s.destinationTokenAddress,destinationTransaction:a,originAmount:s.originAmount,originChainId:s.originChainId,originToken:s.originToken,originTokenAddress:s.originTokenAddress,originTransaction:i,paymentId:s.paymentId,purchaseData:s.purchaseData,receiver:s.receiver,sender:s.sender,status:s.status})}case"PENDING":return fe({destinationChainId:s.destinationChainId,destinationToken:s.destinationToken,destinationTokenAddress:s.destinationTokenAddress,originAmount:s.originAmount,originChainId:s.originChainId,originToken:s.originToken,originTokenAddress:s.originTokenAddress,paymentId:s.paymentId,purchaseData:s.purchaseData,receiver:s.receiver,sender:s.sender,status:s.status});case"FAILED":{const i=(r=s.transactions)==null?void 0:r.find(c=>c.chainId===e.chainId),a=(o=s.transactions)==null?void 0:o.find(c=>c.chainId!==e.chainId);return fe({destinationChainId:0,destinationToken:void 0,destinationTokenAddress:"",destinationTransaction:a,originAmount:BigInt(0),originChainId:0,originToken:void 0,originTokenAddress:"",originTransaction:i,paymentId:"",purchaseData:s.purchaseData,receiver:"",sender:"",status:s.status})}default:return{status:"NOT_FOUND"}}}catch(s){throw console.error("Fetch error:",s),new Error(`Fetch failed: ${s}`)}}function fe(e){const{originTransaction:t,destinationTransaction:n,status:r,purchaseData:o,originAmount:s,destinationAmount:i,originTokenAddress:a,destinationTokenAddress:c,originChainId:d,destinationChainId:p,sender:f,receiver:u,originToken:l,destinationToken:h}=e;return{bridge:"STARPORT",destination:{amount:h?q(i??BigInt(0),h.decimals).toString():"",amountUSDCents:0,amountWei:(i==null?void 0:i.toString())??"",completedAt:new Date().toISOString(),explorerLink:"",token:{chainId:p,decimals:(h==null?void 0:h.decimals)??18,name:(h==null?void 0:h.name)??"",priceUSDCents:0,symbol:(h==null?void 0:h.symbol)??"",tokenAddress:c},transactionHash:(n==null?void 0:n.transactionHash)??""},fromAddress:f,purchaseData:o,quote:{createdAt:new Date().toISOString(),estimated:{durationSeconds:0,feesUSDCents:0,fromAmountUSDCents:0,gasCostUSDCents:0,slippageBPS:0,toAmountMinUSDCents:0,toAmountUSDCents:0},fromAmount:l?q(s,l.decimals).toString():"",fromAmountWei:s.toString(),fromToken:{chainId:d,decimals:(l==null?void 0:l.decimals)??18,name:(l==null?void 0:l.name)??"",priceUSDCents:0,symbol:(l==null?void 0:l.symbol)??"",tokenAddress:a},toAmount:h&&i?q(i,h.decimals).toString():"",toAmountMin:h?q(i??BigInt(0),h.decimals).toString():"",toAmountMinWei:i?i.toString():"",toAmountWei:i?i.toString():"",toToken:{chainId:p,decimals:(h==null?void 0:h.decimals)??18,name:(h==null?void 0:h.name)??"",priceUSDCents:0,symbol:(h==null?void 0:h.symbol)??"",tokenAddress:c}},source:{amount:l?q(s,l.decimals).toString():"",amountUSDCents:0,amountWei:s.toString(),completedAt:new Date().toISOString(),explorerLink:"",token:{chainId:d,decimals:(l==null?void 0:l.decimals)??18,name:(l==null?void 0:l.name)??"",priceUSDCents:0,symbol:(l==null?void 0:l.symbol)??"",tokenAddress:a},transactionHash:(t==null?void 0:t.transactionHash)??""},status:r,subStatus:r==="COMPLETED"?"SUCCESS":"NONE",swapType:(t==null?void 0:t.chainId)===(n==null?void 0:n.chainId)?"SAME_CHAIN":"CROSS_CHAIN",toAddress:u}}async function Jo(e){try{const t=X({address:e.tokenAddress,chain:Y(e.chainId),client:e.client}),n=t.address.toLowerCase()===Ae?18:await pe({contract:t}),r=me(e.amount,n),o=await rt({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}),s=o.steps[0];if(!s)throw new Error("This quote is incompatible with getBuyWithCryptoTransfer. Please use Bridge.Transfer.prepare instead.");const i=s.transactions.filter(u=>u.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 u=Ke(["function approve(address spender, uint256 amount)"]),[l,h]=Je(u,a.data);c={amountWei:h.toString(),chainId:s.originToken.chainId,spenderAddress:l,tokenAddress:s.originToken.address}}const d=s.transactions.filter(u=>u.action!=="approval");if(d.length>1)throw new Error("This quote is incompatible with getBuyWithCryptoTransfer. Please use Bridge.Transfer.prepare instead.");const p=d[0];if(!p)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:$(o.originAmount,s.originToken.decimals).toString(),amountUSDCents:Number($(o.originAmount,s.originToken.decimals))*(s.originToken.prices.USD||0)*100,amountWei:o.originAmount.toString(),token:{chainId:s.originToken.chainId,decimals:s.originToken.decimals,name:s.originToken.name,priceUSDCents:(s.originToken.prices.USD||0)*100,symbol:s.originToken.symbol,tokenAddress:s.originToken.address}},processingFee:{amount:e.feePayer==="sender"?$(o.originAmount-o.destinationAmount,s.originToken.decimals).toString():"0",amountUSDCents:e.feePayer==="sender"?Number($(o.originAmount-o.destinationAmount,s.originToken.decimals))*(s.originToken.prices.USD||0)*100:0,amountWei:e.feePayer==="sender"?(o.originAmount-o.destinationAmount).toString():"0",token:{chainId:s.originToken.chainId,decimals:s.originToken.decimals,name:s.originToken.name,priceUSDCents:(s.originToken.prices.USD||0)*100,symbol:s.originToken.symbol,tokenAddress:s.originToken.address}},toAddress:e.toAddress,transactionRequest:{...p,extraGas:50000n}}}catch(t){throw console.error("Error getting buy with crypto transfer",t),t}}async function Go(e){var c;const[t,n,r,o]=await Promise.all([re(e.transaction),j(e.transaction.to),j(e.transaction.accessList),j(e.transaction.value)]),s=e.from??((c=e.account)==null?void 0:c.address)??void 0,i=Bt({accessList:r,data:t,from:s?U(s):void 0,to:n?U(n):void 0,value:o}),a=Ie(e.transaction);try{const d=await Ge(a,i);if(!e.transaction.__preparedMethod)return d;const p=await e.transaction.__preparedMethod(),f=Nt(p[2],d);return Array.isArray(f)&&f.length===1?f[0]:f}catch(d){throw await jt({contract:e.transaction.__contract,error:d,fromAddress:s})}}function Qo(e){return async t=>{var o;if(typeof e=="string"&&e.startsWith("function "))return xt(e);const r=((o=t.abi)!=null&&o.length?t.abi:await We(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 je(e,t=[]){return Yo(e)&&t.every(n=>n in e)}function Xo(e){return je(e,["__contract"])&&je(e.__contract,["address","chain"])&&typeof e.__contract.address=="string"}async function es({address:e,signature:t,client:n,chain:r,accountFactory:o,message:s,domain:i,primaryType:a,types:c}){const d=Ut({domain:i,message:s,primaryType:a,types:c});if(!ie(t))return!1;try{if(Lt({payload:d,signature:Mt(t)}).toLowerCase()===e.toLowerCase())return!0}catch{}return qt({accountFactory:o,address:e,chain:r,client:n,hash:d,signature:t})}async function ts(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 hs=Object.freeze(Object.defineProperty({__proto__:null,ADDRESS_ZERO:Pe,Bridge:to,Engine:Co,Insight:Bo,NATIVE_TOKEN_ADDRESS:Ae,ZERO_ADDRESS:Pe,boolToBytes:kn,boolToHex:hn,bytesToBigInt:an,bytesToBool:cn,bytesToNumber:dn,bytesToString:un,concatHex:fn,createThirdwebClient:ro,defineChain:ee,deploySmartAccount:En,encode:re,estimateGas:Ze,estimateGasCost:Zo,eth_blockNumber:Qe,eth_call:Ge,eth_estimateGas:Pn,eth_gasPrice:Ft,eth_getBalance:Wt,eth_getBlockByHash:No,eth_getBlockByNumber:Vt,eth_getCode:Zt,eth_getLogs:ke,eth_getStorageAt:$n,eth_getTransactionByHash:jo,eth_getTransactionCount:On,eth_getTransactionReceipt:Sn,eth_maxPriorityFeePerGas:Ht,eth_sendRawTransaction:Kt,fromBytes:ln,fromGwei:rn,fromHex:mn,getAddress:U,getBuyWithCryptoHistory:Fo,getBuyWithCryptoQuote:Ho,getBuyWithCryptoStatus:Ko,getBuyWithCryptoTransfer:Jo,getContract:X,getContractEvents:vt,getGasPrice:Gt,getRpcClient:Ie,getUser:Jt,hexToBigInt:pn,hexToBool:gn,hexToBytes:In,hexToNumber:yn,hexToString:wn,hexToUint8Array:Ue,isAddress:xe,isBaseTransactionOptions:Xo,isHex:ie,keccak256:vn,numberToBytes:An,numberToHex:F,padHex:_n,parseEventLogs:Ve,prepareContractCall:Xt,prepareEvent:he,prepareTransaction:en,readContract:tn,resolveMethod:Qo,sendAndConfirmTransaction:xn,sendBatchTransaction:Un,sendTransaction:Qt,serializeTransaction:nn,sha256:gt,signAuthorization:ts,signTransaction:Yt,simulateTransaction:Go,stringToBytes:Me,stringToHex:bn,toBytes:Tn,toEther:He,toHex:qe,toSerializableTransaction:Fe,toTokens:q,toUnits:on,toWei:sn,uint8ArrayToHex:Le,verifyTypedData:es,waitForReceipt:Cn,watchBlockNumber:Ye,watchContractEvents:Lo},Symbol.toStringTag,{value:"Module"}));export{Oo as g,hs as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as n,d as a,r as c}from"./signing-
|
|
1
|
+
import{e as n,d as a,r as c}from"./signing-DR1diqT_.js";import{d}from"./detectExtension-C1-4KxEP.js";import"./utils-CUIXWH1v.js";import"./index-C9kcmpvP.js";const 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 n(o,[t.id])}function S(t){return e+p(t).slice(2)}function y(t){return a(r,t)[0]}async function T(t){return c({contract:t.contract,method:[e,o,r],params:[t.id]})}export{e as FN_SELECTOR,y as decodeTotalSupplyResult,S as encodeTotalSupply,p as encodeTotalSupplyParams,l as isTotalSupplySupported,T as totalSupply};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as n,w as a,x as c}from"./ThirdwebWalletManager-
|
|
1
|
+
import{r as n,w as a,x as c}from"./ThirdwebWalletManager-_8PV4raS.js";import{d as p}from"./detectExtension-DaHwTBEl.js";import"./index-C9kcmpvP.js";import"./store-CraP4F4Y.js";import"./webauthn.min-CGpVStYZ.js";import"./index.es-D0_25Oh-.js";const e="0xbd85b039",o=[{name:"id",type:"uint256"}],r=[{type:"uint256"}];function y(t){return p({availableSelectors:t,method:[e,o,r]})}function i(t){return a(o,[t.id])}function T(t){return e+i(t).slice(2)}function f(t){return c(r,t)[0]}async function P(t){return n({contract:t.contract,method:[e,o,r],params:[t.id]})}export{e as FN_SELECTOR,f as decodeTotalSupplyResult,T as encodeTotalSupply,i as encodeTotalSupplyParams,y as isTotalSupplySupported,P as totalSupply};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{y as d,z as r,A as e}from"./signing-
|
|
1
|
+
import{y as d,z as r,A as e}from"./signing-DR1diqT_.js";function n(s,{args:u,eventName:l}={}){return{...s,blockHash:s.blockHash?s.blockHash:null,blockNumber:s.blockNumber?BigInt(s.blockNumber):null,logIndex:s.logIndex?Number(s.logIndex):null,transactionHash:s.transactionHash?s.transactionHash:null,transactionIndex:s.transactionIndex?Number(s.transactionIndex):null,...l?{args:u,eventName:l}:{}}}const a={"0x0":"reverted","0x1":"success"};function o(s,u){const l={...s,blockNumber:s.blockNumber?BigInt(s.blockNumber):null,contractAddress:s.contractAddress?s.contractAddress:null,cumulativeGasUsed:s.cumulativeGasUsed?BigInt(s.cumulativeGasUsed):null,effectiveGasPrice:s.effectiveGasPrice?BigInt(s.effectiveGasPrice):null,gasUsed:s.gasUsed?BigInt(s.gasUsed):null,logs:s.logs?s.logs.map(b=>n(b)):null,to:s.to?s.to:null,transactionIndex:s.transactionIndex?e(s.transactionIndex):null,status:s.status?a[s.status]:null,type:s.type?r[s.type]||s.type:null};return s.blobGasPrice&&(l.blobGasPrice=BigInt(s.blobGasPrice)),s.blobGasUsed&&(l.blobGasUsed=BigInt(s.blobGasUsed)),l}const f=d("transactionReceipt",o);export{n as a,f as d,o as f,a as r};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{n as m,l as f,m as p}from"./index-
|
|
1
|
+
import{n as m,l as f,m as p}from"./index-CyiA1q8T.js";import{c as a}from"./index-Dn7k_DQ8.js";import"./index-Dmgfza45.js";import"./index-C9kcmpvP.js";import"./NetworkUtil-Ci2WRYQ5.js";import"./hmac-Bk4Z90TB.js";import"./index.es-D0_25Oh-.js";import"./index.es-BnBQYKMl.js";import"./index-CMJ_znKB.js";import"./if-defined-DDCgUiYp.js";import"./index-CGZLkuWn.js";import"./index-DsUVe2Dc.js";import"./index-CnyP_n54.js";const d=m`
|
|
2
2
|
:host > wui-flex:first-child {
|
|
3
3
|
height: 500px;
|
|
4
4
|
overflow-y: auto;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as z}from"./index-
|
|
1
|
+
import{b as z}from"./index-C9kcmpvP.js";const w="rpc.thirdweb.com",L="social.thirdweb.com",A="embedded-wallet.thirdweb.com",R="pay.thirdweb.com",C="storage.thirdweb.com",x="bundler.thirdweb.com",$="c.thirdweb.com",v="insight.thirdweb.com",N="engine.thirdweb.com",O="bridge.thirdweb.com";let T={analytics:$,bridge:O,bundler:x,engineCloud:N,inAppWallet:A,insight:v,pay:R,rpc:w,social:L,storage:C};const H=e=>{T={analytics:e.analytics??$,bridge:e.bridge??O,bundler:e.bundler??x,engineCloud:e.engineCloud??N,inAppWallet:e.inAppWallet??A,insight:e.insight??v,pay:e.pay??R,rpc:e.rpc??w,social:e.social??L,storage:e.storage??C}},l=()=>T,V=e=>{const t=T[e];return t.startsWith("localhost")?`http://${t}`:`https://${t}`};let M=null;const X=e=>{M=e},P=()=>M,Se=Object.freeze(Object.defineProperty({__proto__:null,DEFAULT_RPC_URL:w,getServiceKey:P,getThirdwebBaseUrl:V,getThirdwebDomains:l,setServiceKey:X,setThirdwebDomains:H},Symbol.toStringTag,{value:"Module"})),G="5.119.0";class Q extends Map{constructor(t){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=t}get(t){const n=super.get(t);return super.has(t)&&n!==void 0&&(this.delete(t),super.set(t,n)),n}set(t,n){if(super.set(t,n),this.maxSize&&this.size>this.maxSize){const r=this.keys().next().value;r&&this.delete(r)}return this}}const U=[["iOS",/iP(hone|od|ad)/],["Android OS",/Android/],["BlackBerry OS",/BlackBerry|BB10/],["Windows Mobile",/IEMobile/],["Amazon OS",/Kindle/],["Windows 3.11",/Win16/],["Windows 95",/(Windows 95)|(Win95)|(Windows_95)/],["Windows 98",/(Windows 98)|(Win98)/],["Windows 2000",/(Windows NT 5.0)|(Windows 2000)/],["Windows XP",/(Windows NT 5.1)|(Windows XP)/],["Windows Server 2003",/(Windows NT 5.2)/],["Windows Vista",/(Windows NT 6.0)/],["Windows 7",/(Windows NT 6.1)/],["Windows 8",/(Windows NT 6.2)/],["Windows 8.1",/(Windows NT 6.3)/],["Windows 10",/(Windows NT 10.0)/],["Windows ME",/Windows ME/],["Windows CE",/Windows CE|WinCE|Microsoft Pocket Internet Explorer/],["Open BSD",/OpenBSD/],["Sun OS",/SunOS/],["Chrome OS",/CrOS/],["Linux",/(Linux)|(X11)/],["Mac OS",/(Mac_PowerPC)|(Macintosh)/],["QNX",/QNX/],["BeOS",/BeOS/],["OS/2",/OS\/2/]];function Y(){return typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?"mobile":typeof navigator<"u"?"browser":"node"}function q(e){for(let t=0,n=U.length;t<n;t++){const[r,s]=U[t];if(s.exec(e))return r}return null}function E(e){return e.split(".").length===3}var J={};const Z=typeof z<"u"&&J&&!1,ee=6e4;function te(e,t){async function n(r,s){const{requestTimeoutMs:o=ee,useAuthToken:c,...y}=s||{};let i=y.headers?new Headers(y.headers):typeof r=="object"?r.headers:void 0;const f=typeof r=="string"?r:r.url;if(_(f)){i||(i=new Headers);const p=c&&e.secretKey&&E(e.secretKey)?e.secretKey:void 0,W=e.secretKey&&!E(e.secretKey)?e.secretKey:void 0,h=e.clientId;p&&ie(f)?(i.set("authorization",`Bearer ${p}`),e.teamId&&i.set("x-team-id",e.teamId),h&&i.set("x-client-id",h)):p&&!re(f)&&!se(f)?(i.set("authorization",`Bearer ${p}`),e.teamId&&i.set("x-team-id",e.teamId)):(W&&i.set("x-secret-key",W),h&&i.set("x-client-id",h)),t&&(i.set("x-ecosystem-id",t.id),t.partnerId&&i.set("x-ecosystem-partner-id",t.partnerId));for(const[j,K]of k())i.set(j,K);const S=P();S&&i.set("x-service-api-key",S)}let u,g;return o&&(u=new AbortController,g=setTimeout(()=>{u==null||u.abort("timeout")},o)),fetch(r,{...y,headers:i,signal:u==null?void 0:u.signal}).finally(()=>{g&&clearTimeout(g)})}return n}const ne=[".thirdweb.com",".ipfscdn.io",".thirdweb.dev",".thirdweb-dev.com",".thirdwebstorage-dev.com"],d=new Q(4096);function _(e){if(d.has(e))return d.get(e);try{const{hostname:t}=new URL(e);try{}catch{}const n=ne.some(r=>t.endsWith(r));return d.set(e,n),n}catch{return d.set(e,!1),!1}}function re(e){try{const{hostname:t}=new URL(e);return t.startsWith("pay.")}catch{return!1}}function se(e){try{const{hostname:t}=new URL(e);return t.startsWith("in-app-wallet.")||t.startsWith("embedded-wallet.")}catch{return!1}}function ie(e){try{const{hostname:t}=new URL(e);return t.endsWith(".bundler.thirdweb.com")||t.endsWith(".bundler.thirdweb-dev.com")}catch{return!1}}const oe="unified-sdk";let m;function k(){if(m)return m;let e=null;typeof navigator<"u"&&(e=q(navigator.userAgent));let t;return typeof globalThis<"u"&&"Application"in globalThis&&(t=globalThis.Application.applicationId),m=Object.entries({"x-sdk-name":oe,"x-sdk-os":e?ce(e):"unknown","x-sdk-platform":Y(),"x-sdk-version":G,...t?{"x-bundle-id":t}:{}}),m}function ce(e){const t=e.toLowerCase();if(t.startsWith("win"))return"win";switch(e){case"Mac OS":return"mac";case"iOS":return"ios";case"Android OS":return"android";default:return t.replace(/\s/gi,"_")}}const Ue=Object.freeze(Object.defineProperty({__proto__:null,IS_THIRDWEB_URL_CACHE:d,getClientFetch:te,getPlatformHeaders:k,isThirdwebUrl:_},Symbol.toStringTag,{value:"Module"})),ue=new Map,ae=new Map;function le(e){const t=(s,o)=>({clear:()=>o.delete(s),get:()=>o.get(s),set:c=>o.set(s,c)}),n=t(e,ue),r=t(e,ae);return{clear:()=>{n.clear(),r.clear()},promise:n,response:r}}async function B(e,{cacheKey:t,cacheTime:n=Number.POSITIVE_INFINITY}){const r=le(t),s=r.response.get();if(s&&n>0&&Date.now()-s.created.getTime()<n)return s.data;let o=r.promise.get();o||(o=e(),r.promise.set(o));try{const c=await o;return r.response.set({created:new Date,data:c}),c}finally{r.promise.clear()}}const a=new Map;function de(e){const t=l().rpc;if(typeof e=="number")return{id:e,rpc:`https://${e}.${t}`};if(we(e))return D(e);if(me(e))return F(e);let n=e.rpc;n||(n=`https://${e.id}.${t}`);const r={...e,rpc:n};return a.set(e.id,r),r}function fe(e){for(const t of e)a.set(t.id,t)}function pe(e){if(a.has(e))return a.get(e);const t=l().rpc;return{id:e,rpc:`https://${e}.${t}`}}function he(e){return a.get(e)}function me(e){return"rpc"in e&&Array.isArray(e.rpc)&&"slug"in e}function F(e){var n;const t=l().rpc;return{blockExplorers:(n=e==null?void 0:e.explorers)==null?void 0:n.map(r=>({apiUrl:r.url,name:r.name,url:r.url})),faucets:e.faucets?[...e.faucets]:void 0,icon:e.icon,id:e.chainId,name:e.name,nativeCurrency:{decimals:e.nativeCurrency.decimals,name:e.nativeCurrency.name,symbol:e.nativeCurrency.symbol},rpc:e.rpc[0]??`https://${e.chainId}.${t}`,testnet:e.testnet?!0:void 0}}function we(e){return"rpcUrls"in e&&!("rpc"in e)}function D(e){const t=l().rpc;return{blockExplorers:e!=null&&e.blockExplorers?Object.values(e==null?void 0:e.blockExplorers).map(n=>({apiUrl:n.apiUrl,name:n.name,url:n.url})):[],id:e.id,name:e.name,nativeCurrency:{decimals:e.nativeCurrency.decimals,name:e.nativeCurrency.name,symbol:e.nativeCurrency.symbol},rpc:e.rpcUrls.default.http[0]??`https://${e.id}.${t}`,testnet:e.testnet?!0:void 0}}function be(e){const t=l().rpc;if(typeof e.chain=="number")return`https://${e.chain}.${t}/${e.client.clientId}`;const{rpc:n}=e.chain;if(_(n)){const r=new URL(e.chain.rpc.replace(w,t));return(r.pathname==="/"||r.pathname.startsWith("/$"))&&(r.pathname=`/${e.client.clientId}`),r.toString()}return n}async function ye(e){var t;return(t=e.nativeCurrency)!=null&&t.symbol?e.nativeCurrency.symbol:b(e).then(n=>n.nativeCurrency.symbol).catch(()=>"ETH")}async function ge(e){var t;return(t=e.nativeCurrency)!=null&&t.decimals?e.nativeCurrency.decimals:b(e).then(n=>n.nativeCurrency.decimals).catch(()=>18)}async function Te(e){var t;return(t=e.nativeCurrency)!=null&&t.name?e.nativeCurrency.name:b(e).then(n=>n.nativeCurrency.name).catch(()=>"ETH")}function b(e){const t=e.id;return B(async()=>{try{const n=await fetch(`https://api.thirdweb.com/v1/chains/${t}`);if(!n.ok)throw new Error(`Failed to fetch chain data for chainId ${t}. ${n.status} ${n.statusText}`);const r=await n.json();if(r.error)throw new Error(`Failed to fetch chain data for chainId ${t}`);if(!r.data)throw new Error(`Failed to fetch chain data for chainId ${t}`);const s=r.data;return I(e,s)}catch{return I(e)}},{cacheKey:`chain:${t}`,cacheTime:5*60*1e3})}async function _e(){return B(async()=>{const e=await fetch("https://api.thirdweb.com/v1/chains/services?service=insight");if(!e.ok)throw new Error(`Failed to fetch services. ${e.status} ${e.statusText}`);const t=await e.json();return Object.keys(t.data).map(n=>Number(n))},{cacheKey:"chain:insight-enabled",cacheTime:24*60*60*1e3})}function I(e,t){var r;const n=e.nativeCurrency?{...t==null?void 0:t.nativeCurrency,...e.nativeCurrency}:t==null?void 0:t.nativeCurrency;return{...t,chain:(t==null?void 0:t.chain)||e.name||"",chainId:e.id||(t==null?void 0:t.chainId)||-1,explorers:((r=e.blockExplorers)==null?void 0:r.map(s=>({name:s.name,standard:"EIP3091",url:s.url})))||(t==null?void 0:t.explorers),icon:e.icon||(t==null?void 0:t.icon),name:e.name||(t==null?void 0:t.name)||"",nativeCurrency:{decimals:(n==null?void 0:n.decimals)||18,name:(n==null?void 0:n.name)||"",symbol:(n==null?void 0:n.symbol)||""},rpc:e.rpc?[e.rpc]:(t==null?void 0:t.rpc)||[""],shortName:(t==null?void 0:t.shortName)||e.name||"",slug:(t==null?void 0:t.slug)||e.name||"",stackType:(t==null?void 0:t.stackType)||"",testnet:e.testnet||(t==null?void 0:t.testnet)||!1}}const Ee=Object.freeze(Object.defineProperty({__proto__:null,CUSTOM_CHAIN_MAP:a,cacheChains:fe,convertLegacyChain:F,convertViemChain:D,defineChain:de,getCachedChain:pe,getCachedChainIfExists:he,getChainDecimals:ge,getChainMetadata:b,getChainNativeCurrencyName:Te,getChainSymbol:ye,getInsightEnabledChainIds:_e,getRpcUrlForChain:be},Symbol.toStringTag,{value:"Module"}));export{Q as L,pe as a,be as b,te as c,de as d,V as e,l as f,_e as g,E as h,_ as i,b as j,q as k,he as l,ye as m,ge as n,Te as o,fe as p,Se as q,Ue as r,Ee as u,B as w};
|