@dcl/blog-site 0.2.3-23948667956.commit-cfe47f9 → 0.2.3-24088316758.commit-34384cf
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/{QueryClientProvider-mZKMZTwe.js → QueryClientProvider-DFnrqjxK.js} +1 -1
- package/assets/{SignInRedirect-CXUOqOjy.js → SignInRedirect-YsS_y43O.js} +5 -5
- package/assets/{X-3yocgepi.js → X-DQRyaTAP.js} +1 -1
- package/assets/{__federation_expose_App-CMGDAIUH.js → __federation_expose_App-BWDr6ljs.js} +1 -1
- package/assets/{__federation_fn_import-C51lglKS.js → __federation_fn_import-DsoKw508.js} +1 -1
- package/assets/__federation_shared_@dcl/{hooks-Dm9PRmKy.js → hooks-P78bsY9M.js} +3 -3
- package/assets/__federation_shared_@emotion/react-CtCvVI4H.js +1 -0
- package/assets/__federation_shared_@emotion/{styled-aZ9bk9Xh.js → styled-CtXq_gFe.js} +1 -1
- package/assets/{__federation_shared_decentraland-ui2-KxrbFOTA.js → __federation_shared_decentraland-ui2-DRl5ehN-.js} +6 -6
- package/assets/{__federation_shared_react-redux-Ckcz2edF.js → __federation_shared_react-redux-DRaqgPHP.js} +1 -1
- package/assets/{__federation_shared_react-router-dom-jUWpDOjR.js → __federation_shared_react-router-dom-ClUJIur8.js} +1 -1
- package/assets/{__federation_shared_viem-Cdp7wK0V.js → __federation_shared_viem-OkDZ_da3.js} +1 -1
- package/assets/{__federation_shared_wagmi-CHWRoybR.js → __federation_shared_wagmi-DxQyjTpB.js} +1 -1
- package/assets/{add-DHMb_tRw.js → add-BJhrLyz2.js} +1 -1
- package/assets/{all-wallets-Bo3QRxXL.js → all-wallets-BKl1d9ay.js} +1 -1
- package/assets/{app-store-BHwDXU8D.js → app-store-Cz4wx5Ml.js} +1 -1
- package/assets/{apple-BFX-plRw.js → apple-ZB0nqM0P.js} +1 -1
- package/assets/{arrow-bottom-Djx9NXV2.js → arrow-bottom-DPabveW2.js} +1 -1
- package/assets/{arrow-bottom-circle-DcJnW2eo.js → arrow-bottom-circle-qQ6xlCaO.js} +1 -1
- package/assets/{arrow-left-BS_dJGSP.js → arrow-left-D_0jfro8.js} +1 -1
- package/assets/{arrow-right-B-mwy0Iu.js → arrow-right-Bxr-_0TM.js} +1 -1
- package/assets/{arrow-top-Di1bbZG1.js → arrow-top-CcZJfPaY.js} +1 -1
- package/assets/{auto-track-pkMvCaah.js → auto-track-CXTejErn.js} +1 -1
- package/assets/{bank-B9SMq-ix.js → bank-qzSNVmpL.js} +1 -1
- package/assets/{basic-DijYF-IW.js → basic-CriAqicR.js} +1 -1
- package/assets/{biconomy-CCw3vtwR.js → biconomy-7PcFs3b0.js} +1 -1
- package/assets/{browser-CdKdszu-.js → browser-B01ZPlHW.js} +1 -1
- package/assets/{card-CQu4Eu8c.js → card-C8yazSyG.js} +1 -1
- package/assets/{ccip-AgQ5AD9v.js → ccip-D0tvzkwi.js} +1 -1
- package/assets/{checkmark-D2vezo75.js → checkmark-DEpAI8yr.js} +1 -1
- package/assets/{checkmark-bold-DriAapzP.js → checkmark-bold-CmJidmVJ.js} +1 -1
- package/assets/{chevron-bottom-CcFEOVdH.js → chevron-bottom-DWsbL4vJ.js} +1 -1
- package/assets/{chevron-left-BXS-ybhL.js → chevron-left-DLMg9i5k.js} +1 -1
- package/assets/{chevron-right-TvO5COya.js → chevron-right-BR2L5tDn.js} +1 -1
- package/assets/{chevron-top-D84SgxMg.js → chevron-top-BWtZfQ2F.js} +1 -1
- package/assets/{chrome-store-rpsfVQln.js → chrome-store-BGE1p2Hx.js} +1 -1
- package/assets/{clock-BMJ2gt7b.js → clock-B12ZBUD7.js} +1 -1
- package/assets/{close-kAWkeKAP.js → close-B54jTe2O.js} +1 -1
- package/assets/{coinPlaceholder-Dz8MKewa.js → coinPlaceholder-B5PhQfVg.js} +1 -1
- package/assets/{compass-BednEqu-.js → compass-CEs6S01I.js} +1 -1
- package/assets/{controller-D0Gc4Hsp.js → controller-n5F8mc3X.js} +2 -2
- package/assets/{copy-D7rBk-hZ.js → copy-DwrKUUfz.js} +1 -1
- package/assets/{core-Bn8Mr-tS.js → core-DPOUi4Tl.js} +3 -3
- package/assets/{createBundlerClient-DhRCLsYO.js → createBundlerClient-YqcE2yqs.js} +1 -1
- package/assets/{createClient-C9QPJaZu.js → createClient-BxHhKlNq.js} +1 -1
- package/assets/{cursor-C8UG2IDe.js → cursor-CGBFNPoh.js} +1 -1
- package/assets/{cursor-transparent-CyP0H3C5.js → cursor-transparent-D3nfFufs.js} +1 -1
- package/assets/{decimals-DedKFk8m.js → decimals-BMO-32AD.js} +1 -1
- package/assets/{decimals-B7Pm5rZk.js → decimals-D0IunObY.js} +1 -1
- package/assets/{desktop-LBcRpcZE.js → desktop-Bjkc6WkG.js} +1 -1
- package/assets/{detectExtension-C2uVeK-n.js → detectExtension-BEr9WLqO.js} +1 -1
- package/assets/{disconnect-DEBEe-yK.js → disconnect-D9dYAsxs.js} +1 -1
- package/assets/{discord-BlVFKMf0.js → discord-DZuYBrqS.js} +1 -1
- package/assets/{emotion-react.browser.esm-BzYQLDSp.js → emotion-react.browser.esm-Ce2LppU1.js} +1 -1
- package/assets/{emotion-use-insertion-effect-with-fallbacks.browser.esm-TsHx33zg.js → emotion-use-insertion-effect-with-fallbacks.browser.esm-ByQDcQjl.js} +1 -1
- package/assets/{encode-DvvW4ZKt.js → encode-cHgp5mHv.js} +2 -2
- package/assets/{engine-CD7SeAap.js → engine-BVbFCTQK.js} +1 -1
- package/assets/{estimate-gas-CeHGaIbG.js → estimate-gas-DBgT8NWo.js} +3 -3
- package/assets/{estimate-l1-fee-ClMO5l7U.js → estimate-l1-fee-C2ptcVct.js} +1 -1
- package/assets/{eth_getStorageAt-BHgF2qz5.js → eth_getStorageAt-B9Y_JVAm.js} +1 -1
- package/assets/{etherscan-C_pqcV9R.js → etherscan-oUtlOsmK.js} +1 -1
- package/assets/{exclamation-triangle-R9Xq3IaG.js → exclamation-triangle-BdB5oh3a.js} +1 -1
- package/assets/{extension-DkA_7Cbg.js → extension-CjK6xfgN.js} +1 -1
- package/assets/{external-link-BPOw_fuW.js → external-link-dD0-Gy7Y.js} +1 -1
- package/assets/{extractIPFS-B4LGER25.js → extractIPFS-BN8-L65J.js} +1 -1
- package/assets/{facebook-CMZk_t1A.js → facebook-CInWYo4e.js} +1 -1
- package/assets/{farcaster-CveILPqa.js → farcaster-Dk7xCnWZ.js} +1 -1
- package/assets/{fee-data-BKBGP5kG.js → fee-data-DBS1-uI-.js} +1 -1
- package/assets/{fetchTokenMetadata-BLDHgO8L.js → fetchTokenMetadata-sBUH3xE3.js} +2 -2
- package/assets/{filters-BspTrZpX.js → filters-CQJE56FO.js} +1 -1
- package/assets/{get-ecosystem-wallet-info-D3PrM5FE.js → get-ecosystem-wallet-info-DkhEjWQL.js} +1 -1
- package/assets/{getBalance-D7nzATjL.js → getBalance-NroDyfvQ.js} +1 -1
- package/assets/{getInstalledModules-Ck_Gj8FO.js → getInstalledModules-DFAdG78-.js} +1 -1
- package/assets/{getNFT-BcCS23O_.js → getNFT-CM6jDDoS.js} +1 -1
- package/assets/{getNFT-DXdMP0Q5.js → getNFT-CZphITDU.js} +2 -2
- package/assets/{github-DoFHEMIF.js → github-D7bNXBE_.js} +1 -1
- package/assets/{google-NTQi9GVe.js → google-C7wxpdtc.js} +1 -1
- package/assets/{help-circle-DV0uNPdn.js → help-circle-jHfnx5-M.js} +1 -1
- package/assets/{id-UAVc1FOO.js → id-B0bg6br2.js} +1 -1
- package/assets/{image-BeHBzCPG.js → image-CFkOYVVZ.js} +1 -1
- package/assets/{in-app-wallet-calls-CvFtsXP9.js → in-app-wallet-calls-CUJMAfNk.js} +1 -1
- package/assets/{index-CjuQOkbh.js → index-B6POK61z.js} +1 -1
- package/assets/{index-BozJS3za.js → index-BgKyyaW6.js} +1 -1
- package/assets/index-BjzJcZq6.js +1 -1
- package/assets/{index-DajuSfcu.js → index-BqaO8h_q.js} +2 -2
- package/assets/{index-B65z14KI.js → index-C2t4sTPE.js} +1 -1
- package/assets/{index-CgMDPZul.js → index-C9ZtSkAF.js} +1 -1
- package/assets/{index-B2OCb4Ez.js → index-CDUZj6Gh.js} +1 -1
- package/assets/{index-D6ZAha0r.js → index-CK_y9rJC.js} +3 -3
- package/assets/{index-C2hdqzGT.js → index-CgabfD28.js} +2 -2
- package/assets/index-Dot3cU3_.js +1 -0
- package/assets/{index-DeklogZX.js → index-DuUs6XE9.js} +1 -1
- package/assets/index-Dy0yjznp.js +1 -1
- package/assets/{index-DmAaXUNv.js → index-DyFSxszr.js} +1 -1
- package/assets/{index-D1lXZVQu.js → index-HwVh-q7L.js} +1 -1
- package/assets/{index-HvoTJwGm.js → index-p2T8GhRA.js} +1 -1
- package/assets/{index.es-CAXGMBEH.js → index.es-C4uogg3R.js} +1 -1
- package/assets/{index.es-C8Kfv-K1.js → index.es-DiIxomE4.js} +3 -3
- package/assets/{info-CzcA85TO.js → info-a5qnZWSp.js} +1 -1
- package/assets/{info-circle-D3Mr3R9u.js → info-circle-CtpHiT1K.js} +1 -1
- package/assets/jsx-runtime-DncYoG30.js +1 -1
- package/assets/{lightbulb-B2FZtM_8.js → lightbulb-Cedc0rYJ.js} +1 -1
- package/assets/{localBatchGatewayRequest-BIEAG3VG.js → localBatchGatewayRequest-xHNW-Ehl.js} +1 -1
- package/assets/{mail-CkhGbows.js → mail-D96xVokz.js} +1 -1
- package/assets/{mobile-1H3FtqAS.js → mobile-DsDxm8mI.js} +1 -1
- package/assets/{more-CZiQi624.js → more-BedDVxwf.js} +1 -1
- package/assets/{network-placeholder-DA2bm2rC.js → network-placeholder-CpA4BghL.js} +1 -1
- package/assets/{nftPlaceholder-C9t5Ydxp.js → nftPlaceholder-E0nNrT1f.js} +1 -1
- package/assets/{off-D8z0OQ3M.js → off-C8YtcDJA.js} +1 -1
- package/assets/{openzeppelin-ZKz6sLW9.js → openzeppelin-CQer_fI1.js} +1 -1
- package/assets/{ownerOf-D1aXOt9Q.js → ownerOf-GjaKoeq1.js} +1 -1
- package/assets/{parseNft-LjEwmOst.js → parseNft-CxF6cVbB.js} +2 -2
- package/assets/{play-store-_X5LrPwx.js → play-store-wzv988wO.js} +1 -1
- package/assets/{plus-JriDhMxt.js → plus-BOnP2W3B.js} +1 -1
- package/assets/{preload-helper-BorDCKdG.js → preload-helper-2M-6abck.js} +1 -1
- package/assets/{qr-code-DaB080BF.js → qr-code-5Zy3Jwmz.js} +1 -1
- package/assets/{qr-overlay-CGnFhcTk.js → qr-overlay-qPTQSVWY.js} +1 -1
- package/assets/{recycle-horizontal-CGeFmMrT.js → recycle-horizontal-BiLXE1ph.js} +1 -1
- package/assets/{refresh-Dgvxxw5C.js → refresh-DrIaQxXR.js} +1 -1
- package/assets/remoteEntry.js +1 -1
- package/assets/{reown-logo-CBX48aN9.js → reown-logo-C50d_2u-.js} +1 -1
- package/assets/{resolveImplementation-Cb2bL1tx.js → resolveImplementation-Bp817C6y.js} +1 -1
- package/assets/{search-DamXBOxM.js → search-CtoMI8IW.js} +1 -1
- package/assets/{secp256k1-UEF-yOzn.js → secp256k1-lKd37s6b.js} +1 -1
- package/assets/{send-BLpUSx_G.js → send-DjyS4WAU.js} +1 -1
- package/assets/{send-batch-transaction-DnH876GL.js → send-batch-transaction-DBV6UBBv.js} +1 -1
- package/assets/{send-eip712-transaction-D_FU-Avh.js → send-eip712-transaction-CI65hvCl.js} +2 -2
- package/assets/{send-gasless-transaction-MP1Q_mLW.js → send-gasless-transaction-C7lHksJD.js} +2 -2
- package/assets/{serializeTransaction-mtsVBaO6.js → serializeTransaction-6LlbmJwH.js} +1 -1
- package/assets/{session-proposal-CM3P7DaL.js → session-proposal-BJ6dUV4k.js} +1 -1
- package/assets/{session-request-Dqw67u3p.js → session-request-Cen_JpY8.js} +2 -2
- package/assets/{signing-BFeVjjPi.js → signing-BsPRCC1P.js} +3 -3
- package/assets/{swapHorizontal-Br-MZ1tO.js → swapHorizontal-DUMDblJm.js} +1 -1
- package/assets/{swapHorizontalBold-CkUNbZ1G.js → swapHorizontalBold-Du4gzczl.js} +1 -1
- package/assets/{swapHorizontalMedium-D3qEQNb5.js → swapHorizontalMedium-BkSTzo9o.js} +1 -1
- package/assets/{swapHorizontalRoundedBold-CzzBPCtt.js → swapHorizontalRoundedBold-CQD5i-I5.js} +1 -1
- package/assets/{swapVertical-Mrn3zm_W.js → swapVertical-CjSXuBHb.js} +1 -1
- package/assets/{telegram-ZTLC9FiA.js → telegram-uAGG8XwG.js} +1 -1
- package/assets/{thirdweb-D5ezTmuN.js → thirdweb-DOoFBA7F.js} +3 -3
- package/assets/{three-dots-DYl4uQjm.js → three-dots-BWtFKrpY.js} +1 -1
- package/assets/{totalSupply-B5jHW8gx.js → totalSupply-CjCaaPZD.js} +1 -1
- package/assets/{twitch-DPLkA98Q.js → twitch-VH9Dk-Bx.js} +1 -1
- package/assets/{twitterIcon-BEY_UAyG.js → twitterIcon-Bfs32uTm.js} +1 -1
- package/assets/{uid-D00jCazq.js → uid-XfAtrElX.js} +3 -3
- package/assets/{verify-DuPdiufm.js → verify-4fUj-WRm.js} +1 -1
- package/assets/{verify-filled-CdqEW5AP.js → verify-filled-sllS8Nrv.js} +1 -1
- package/assets/{w3m-modal-BLzhBUlF.js → w3m-modal-Blb5XI95.js} +1 -1
- package/assets/{wait-for-tx-receipt-B-o5aPQ8.js → wait-for-tx-receipt-BR33kfvc.js} +1 -1
- package/assets/{wallet-CZw1g3L8.js → wallet-DuQpuU5E.js} +1 -1
- package/assets/{wallet-placeholder-OAkoJuru.js → wallet-placeholder-CERukyIC.js} +1 -1
- package/assets/{walletconnect-BJ3w7-IU.js → walletconnect-CsB9GzlO.js} +1 -1
- package/assets/{wallets-Q5RcRyG6.js → wallets-vcnqEomN.js} +5 -5
- package/assets/{warning-circle-DpDeOZKv.js → warning-circle-C8yGFMlX.js} +1 -1
- package/assets/{web-connector-CB7tpRui.js → web-connector-Jj-2yhMg.js} +3 -3
- package/assets/{webSocket-dQW3n9NM.js → webSocket-BfTFTYzP.js} +1 -1
- package/assets/{x-liJqLZUi.js → x-BXVsZnMK.js} +1 -1
- package/index.html +17 -17
- package/package.json +3 -3
- package/assets/__federation_shared_@emotion/react-AmEOkpjC.js +0 -1
- package/assets/index-Tsk25L8E.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{l as H,m as V,n as A,B as I,o as ue,h as Ie,q as Z,i as U,S as Ca,v as ke,g as Pe,w as Qn,x as q,I as ku,y as Fe,z as Na,A as Cu,C as Tt,p as Un,D as Fo,E as Nu,f as Ru,F as Nn,e as ts,H as Mu,G as Ou,t as zu,a as _o,b as Fu,j as _u,J as Lu,K as Uu,k as Dt,L as ju}from"./utils-C7urdXtO.js";import{M as rb,N as sb,O as ob,P as ab,Q as ib,R as cb,T as ub,U as db,V as fb}from"./utils-C7urdXtO.js";import{i as Q,I as de,k as J,c as Ra,g as Ce,p as qu,L as er,a as Du}from"./publicKeyToAddress-CxEKPAKT.js";import{_ as zs}from"./preload-helper-BorDCKdG.js";import{s as Gu,a as tr,H as Hu,b as Vu}from"./sha256-DYtpy1Qz.js";import{c as pb,d as hb,e as mb,f as yb,g as bb,h as gb,i as wb,j as xb,k as vb,l as Eb,n as Pb,o as Ib,p as Ab,q as Tb,r as $b,t as Bb,u as Sb,v as kb,w as Cb,x as Nb,y as Rb,z as Mb,A as Ob,B as zb,C as Fb,D as _b,E as Lb,F as Ub,G as jb,I as qb,J as Db,K as Gb,L as Hb,M as Vb,N as Wb,O as Zb,P as Yb,Q as Kb,R as Jb,m as Xb,S as Qb,T as e6,U as t6,V as n6,W as r6,X as s6,Y as o6,Z as a6,_ as i6,$ as c6,a0 as u6,a1 as d6,a2 as f6,a3 as l6,a4 as p6,a5 as h6,a6 as m6,a7 as y6,a8 as b6,a9 as g6,aa as w6,ab as x6,ac as v6,ad as E6,ae as P6,af as I6,ag as A6,ah as T6,ai as $6,aj as B6,ak as S6,al as k6,am as C6,an as N6,ao as R6,ap as M6,aq as O6,ar as z6,as as F6,at as _6,au as L6,av as U6,aw as j6,ax as q6,ay as D6,az as G6,aA as H6,aB as V6,aC as W6,aD as Z6,aE as Y6,aF as K6,aG as J6,aH as X6,aI as Q6}from"./sha256-DYtpy1Qz.js";import{E as t5}from"./estimate-gas-CeHGaIbG.js";function nr(e,t){return({exclude:n,format:r})=>({exclude:n,format:(s,o)=>{const a=t(s,o);if(n)for(const i of n)delete a[i];return{...a,...r(s,o)}},type:e})}const Ma={"0x0":"legacy","0x1":"eip2930","0x2":"eip1559","0x3":"eip4844","0x4":"eip7702"};function Fs(e,t){const n={...e,blockHash:e.blockHash?e.blockHash:null,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,chainId:e.chainId?H(e.chainId):void 0,gas:e.gas?BigInt(e.gas):void 0,gasPrice:e.gasPrice?BigInt(e.gasPrice):void 0,maxFeePerBlobGas:e.maxFeePerBlobGas?BigInt(e.maxFeePerBlobGas):void 0,maxFeePerGas:e.maxFeePerGas?BigInt(e.maxFeePerGas):void 0,maxPriorityFeePerGas:e.maxPriorityFeePerGas?BigInt(e.maxPriorityFeePerGas):void 0,nonce:e.nonce?H(e.nonce):void 0,to:e.to?e.to:null,transactionIndex:e.transactionIndex?Number(e.transactionIndex):null,type:e.type?Ma[e.type]:void 0,typeHex:e.type?e.type:void 0,value:e.value?BigInt(e.value):void 0,v:e.v?BigInt(e.v):void 0};return e.authorizationList&&(n.authorizationList=Wu(e.authorizationList)),n.yParity=(()=>{if(e.yParity)return Number(e.yParity);if(typeof n.v=="bigint"){if(n.v===0n||n.v===27n)return 0;if(n.v===1n||n.v===28n)return 1;if(n.v>=35n)return n.v%2n===0n?1:0}})(),n.type==="legacy"&&(delete n.accessList,delete n.maxFeePerBlobGas,delete n.maxFeePerGas,delete n.maxPriorityFeePerGas,delete n.yParity),n.type==="eip2930"&&(delete n.maxFeePerBlobGas,delete n.maxFeePerGas,delete n.maxPriorityFeePerGas),n.type==="eip1559"&&delete n.maxFeePerBlobGas,n}const Wm=nr("transaction",Fs);function Wu(e){return e.map(t=>({address:t.address,chainId:Number(t.chainId),nonce:Number(t.nonce),r:t.r,s:t.s,yParity:Number(t.yParity)}))}function _s(e,t){const n=(e.transactions??[]).map(r=>typeof r=="string"?r:Fs(r));return{...e,baseFeePerGas:e.baseFeePerGas?BigInt(e.baseFeePerGas):null,blobGasUsed:e.blobGasUsed?BigInt(e.blobGasUsed):void 0,difficulty:e.difficulty?BigInt(e.difficulty):void 0,excessBlobGas:e.excessBlobGas?BigInt(e.excessBlobGas):void 0,gasLimit:e.gasLimit?BigInt(e.gasLimit):void 0,gasUsed:e.gasUsed?BigInt(e.gasUsed):void 0,hash:e.hash?e.hash:null,logsBloom:e.logsBloom?e.logsBloom:null,nonce:e.nonce?e.nonce:null,number:e.number?BigInt(e.number):null,size:e.size?BigInt(e.size):void 0,timestamp:e.timestamp?BigInt(e.timestamp):void 0,transactions:n,totalDifficulty:e.totalDifficulty?BigInt(e.totalDifficulty):null}}const Zm=nr("block",_s);function Le(e,{args:t,eventName:n}={}){return{...e,blockHash:e.blockHash?e.blockHash:null,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,logIndex:e.logIndex?Number(e.logIndex):null,transactionHash:e.transactionHash?e.transactionHash:null,transactionIndex:e.transactionIndex?Number(e.transactionIndex):null,...n?{args:t,eventName:n}:{}}}const Oa={"0x0":"reverted","0x1":"success"};function Ls(e,t){const n={...e,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,contractAddress:e.contractAddress?e.contractAddress:null,cumulativeGasUsed:e.cumulativeGasUsed?BigInt(e.cumulativeGasUsed):null,effectiveGasPrice:e.effectiveGasPrice?BigInt(e.effectiveGasPrice):null,gasUsed:e.gasUsed?BigInt(e.gasUsed):null,logs:e.logs?e.logs.map(r=>Le(r)):null,to:e.to?e.to:null,transactionIndex:e.transactionIndex?H(e.transactionIndex):null,status:e.status?Oa[e.status]:null,type:e.type?Ma[e.type]||e.type:null};return e.blobGasPrice&&(n.blobGasPrice=BigInt(e.blobGasPrice)),e.blobGasUsed&&(n.blobGasUsed=BigInt(e.blobGasUsed)),n}const Ym=nr("transactionReceipt",Ls),Zu={legacy:"0x0",eip2930:"0x1",eip1559:"0x2",eip4844:"0x3",eip7702:"0x4"};function je(e,t){const n={};return typeof e.authorizationList<"u"&&(n.authorizationList=Yu(e.authorizationList)),typeof e.accessList<"u"&&(n.accessList=e.accessList),typeof e.blobVersionedHashes<"u"&&(n.blobVersionedHashes=e.blobVersionedHashes),typeof e.blobs<"u"&&(typeof e.blobs[0]!="string"?n.blobs=e.blobs.map(r=>V(r)):n.blobs=e.blobs),typeof e.data<"u"&&(n.data=e.data),e.account&&(n.from=e.account.address),typeof e.from<"u"&&(n.from=e.from),typeof e.gas<"u"&&(n.gas=A(e.gas)),typeof e.gasPrice<"u"&&(n.gasPrice=A(e.gasPrice)),typeof e.maxFeePerBlobGas<"u"&&(n.maxFeePerBlobGas=A(e.maxFeePerBlobGas)),typeof e.maxFeePerGas<"u"&&(n.maxFeePerGas=A(e.maxFeePerGas)),typeof e.maxPriorityFeePerGas<"u"&&(n.maxPriorityFeePerGas=A(e.maxPriorityFeePerGas)),typeof e.nonce<"u"&&(n.nonce=A(e.nonce)),typeof e.to<"u"&&(n.to=e.to),typeof e.type<"u"&&(n.type=Zu[e.type]),typeof e.value<"u"&&(n.value=A(e.value)),n}const Km=nr("transactionRequest",je);function Yu(e){return e.map(t=>({address:t.address,r:t.r?A(BigInt(t.r)):t.r,s:t.s?A(BigInt(t.s)):t.s,chainId:A(t.chainId),nonce:A(t.nonce),...typeof t.yParity<"u"?{yParity:A(t.yParity)}:{},...typeof t.v<"u"&&typeof t.yParity>"u"?{v:A(t.v)}:{}}))}function fe(e){return typeof e[0]=="string"?ye(e):Ku(e)}function Ku(e){let t=0;for(const s of e)t+=s.length;const n=new Uint8Array(t);let r=0;for(const s of e)n.set(s,r),r+=s.length;return n}function ye(e){return`0x${e.reduce((t,n)=>t+n.replace("0x",""),"")}`}let Lo=class extends I{constructor({offset:t}){super(`Offset \`${t}\` cannot be negative.`,{name:"NegativeOffsetError"})}},za=class extends I{constructor({length:t,position:n}){super(`Position \`${n}\` is out of bounds (\`0 < position < ${t}\`).`,{name:"PositionOutOfBoundsError"})}},Ju=class extends I{constructor({count:t,limit:n}){super(`Recursive read limit of \`${n}\` exceeded (recursive read count: \`${t}\`).`,{name:"RecursiveReadLimitExceededError"})}};const Xu={bytes:new Uint8Array,dataView:new DataView(new ArrayBuffer(0)),position:0,positionReadCount:new Map,recursiveReadCount:0,recursiveReadLimit:Number.POSITIVE_INFINITY,assertReadLimit(){if(this.recursiveReadCount>=this.recursiveReadLimit)throw new Ju({count:this.recursiveReadCount+1,limit:this.recursiveReadLimit})},assertPosition(e){if(e<0||e>this.bytes.length-1)throw new za({length:this.bytes.length,position:e})},decrementPosition(e){if(e<0)throw new Lo({offset:e});const t=this.position-e;this.assertPosition(t),this.position=t},getReadCount(e){return this.positionReadCount.get(e||this.position)||0},incrementPosition(e){if(e<0)throw new Lo({offset:e});const t=this.position+e;this.assertPosition(t),this.position=t},inspectByte(e){const t=e??this.position;return this.assertPosition(t),this.bytes[t]},inspectBytes(e,t){const n=t??this.position;return this.assertPosition(n+e-1),this.bytes.subarray(n,n+e)},inspectUint8(e){const t=e??this.position;return this.assertPosition(t),this.bytes[t]},inspectUint16(e){const t=e??this.position;return this.assertPosition(t+1),this.dataView.getUint16(t)},inspectUint24(e){const t=e??this.position;return this.assertPosition(t+2),(this.dataView.getUint16(t)<<8)+this.dataView.getUint8(t+2)},inspectUint32(e){const t=e??this.position;return this.assertPosition(t+3),this.dataView.getUint32(t)},pushByte(e){this.assertPosition(this.position),this.bytes[this.position]=e,this.position++},pushBytes(e){this.assertPosition(this.position+e.length-1),this.bytes.set(e,this.position),this.position+=e.length},pushUint8(e){this.assertPosition(this.position),this.bytes[this.position]=e,this.position++},pushUint16(e){this.assertPosition(this.position+1),this.dataView.setUint16(this.position,e),this.position+=2},pushUint24(e){this.assertPosition(this.position+2),this.dataView.setUint16(this.position,e>>8),this.dataView.setUint8(this.position+2,e&255),this.position+=3},pushUint32(e){this.assertPosition(this.position+3),this.dataView.setUint32(this.position,e),this.position+=4},readByte(){this.assertReadLimit(),this._touch();const e=this.inspectByte();return this.position++,e},readBytes(e,t){this.assertReadLimit(),this._touch();const n=this.inspectBytes(e);return this.position+=t??e,n},readUint8(){this.assertReadLimit(),this._touch();const e=this.inspectUint8();return this.position+=1,e},readUint16(){this.assertReadLimit(),this._touch();const e=this.inspectUint16();return this.position+=2,e},readUint24(){this.assertReadLimit(),this._touch();const e=this.inspectUint24();return this.position+=3,e},readUint32(){this.assertReadLimit(),this._touch();const e=this.inspectUint32();return this.position+=4,e},get remaining(){return this.bytes.length-this.position},setPosition(e){const t=this.position;return this.assertPosition(e),this.position=e,()=>this.position=t},_touch(){if(this.recursiveReadLimit===Number.POSITIVE_INFINITY)return;const e=this.getReadCount();this.positionReadCount.set(this.position,e+1),e>0&&this.recursiveReadCount++}};function $t(e,{recursiveReadLimit:t=8192}={}){const n=Object.create(Xu);return n.bytes=e,n.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength),n.positionReadCount=new Map,n.recursiveReadLimit=t,n}function Ne(e,t="hex"){const n=Fa(e),r=$t(new Uint8Array(n.length));return n.encode(r),t==="hex"?V(r.bytes):r.bytes}function ey(e,t="bytes"){return Ne(e,t)}function ty(e,t="hex"){return Ne(e,t)}function Fa(e){return Array.isArray(e)?Qu(e.map(t=>Fa(t))):e0(e)}function Qu(e){const t=e.reduce((s,o)=>s+o.length,0),n=_a(t);return{length:t<=55?1+t:1+n+t,encode(s){t<=55?s.pushByte(192+t):(s.pushByte(247+n),n===1?s.pushUint8(t):n===2?s.pushUint16(t):n===3?s.pushUint24(t):s.pushUint32(t));for(const{encode:o}of e)o(s)}}}function e0(e){const t=typeof e=="string"?ue(e):e,n=_a(t.length);return{length:t.length===1&&t[0]<128?1:t.length<=55?1+t.length:1+n+t.length,encode(s){t.length===1&&t[0]<128?s.pushBytes(t):t.length<=55?(s.pushByte(128+t.length),s.pushBytes(t)):(s.pushByte(183+n),n===1?s.pushUint8(t.length):n===2?s.pushUint16(t.length):n===3?s.pushUint24(t.length):s.pushUint32(t.length),s.pushBytes(t))}}}function _a(e){if(e<2**8)return 1;if(e<2**16)return 2;if(e<2**24)return 3;if(e<2**32)return 4;throw new I("Length is too large.")}const La={gwei:9,wei:18},Ua={ether:-9,wei:9},ny={ether:-18,gwei:-9};function ja(e,t){let n=e.toString();const r=n.startsWith("-");r&&(n=n.slice(1)),n=n.padStart(t,"0");let[s,o]=[n.slice(0,n.length-t),n.slice(n.length-t)];return o=o.replace(/(0+)$/,""),`${r?"-":""}${s||"0"}${o?`.${o}`:""}`}function Us(e,t="wei"){return ja(e,La[t])}function ce(e,t="wei"){return ja(e,Ua[t])}function mn(e){const t=Object.entries(e).map(([r,s])=>s===void 0||s===!1?null:[r,s]).filter(Boolean),n=t.reduce((r,[s])=>Math.max(r,s.length),0);return t.map(([r,s])=>` ${`${r}:`.padEnd(n+1)} ${s}`).join(`
|
|
1
|
+
import{l as H,m as V,n as A,B as I,o as ue,h as Ie,q as Z,i as U,S as Ca,v as ke,g as Pe,w as Qn,x as q,I as ku,y as Fe,z as Na,A as Cu,C as Tt,p as Un,D as Fo,E as Nu,f as Ru,F as Nn,e as ts,H as Mu,G as Ou,t as zu,a as _o,b as Fu,j as _u,J as Lu,K as Uu,k as Dt,L as ju}from"./utils-C7urdXtO.js";import{M as rb,N as sb,O as ob,P as ab,Q as ib,R as cb,T as ub,U as db,V as fb}from"./utils-C7urdXtO.js";import{i as Q,I as de,k as J,c as Ra,g as Ce,p as qu,L as er,a as Du}from"./publicKeyToAddress-CxEKPAKT.js";import{_ as zs}from"./preload-helper-2M-6abck.js";import{s as Gu,a as tr,H as Hu,b as Vu}from"./sha256-DYtpy1Qz.js";import{c as pb,d as hb,e as mb,f as yb,g as bb,h as gb,i as wb,j as xb,k as vb,l as Eb,n as Pb,o as Ib,p as Ab,q as Tb,r as $b,t as Bb,u as Sb,v as kb,w as Cb,x as Nb,y as Rb,z as Mb,A as Ob,B as zb,C as Fb,D as _b,E as Lb,F as Ub,G as jb,I as qb,J as Db,K as Gb,L as Hb,M as Vb,N as Wb,O as Zb,P as Yb,Q as Kb,R as Jb,m as Xb,S as Qb,T as e6,U as t6,V as n6,W as r6,X as s6,Y as o6,Z as a6,_ as i6,$ as c6,a0 as u6,a1 as d6,a2 as f6,a3 as l6,a4 as p6,a5 as h6,a6 as m6,a7 as y6,a8 as b6,a9 as g6,aa as w6,ab as x6,ac as v6,ad as E6,ae as P6,af as I6,ag as A6,ah as T6,ai as $6,aj as B6,ak as S6,al as k6,am as C6,an as N6,ao as R6,ap as M6,aq as O6,ar as z6,as as F6,at as _6,au as L6,av as U6,aw as j6,ax as q6,ay as D6,az as G6,aA as H6,aB as V6,aC as W6,aD as Z6,aE as Y6,aF as K6,aG as J6,aH as X6,aI as Q6}from"./sha256-DYtpy1Qz.js";import{E as t5}from"./estimate-gas-DBgT8NWo.js";function nr(e,t){return({exclude:n,format:r})=>({exclude:n,format:(s,o)=>{const a=t(s,o);if(n)for(const i of n)delete a[i];return{...a,...r(s,o)}},type:e})}const Ma={"0x0":"legacy","0x1":"eip2930","0x2":"eip1559","0x3":"eip4844","0x4":"eip7702"};function Fs(e,t){const n={...e,blockHash:e.blockHash?e.blockHash:null,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,chainId:e.chainId?H(e.chainId):void 0,gas:e.gas?BigInt(e.gas):void 0,gasPrice:e.gasPrice?BigInt(e.gasPrice):void 0,maxFeePerBlobGas:e.maxFeePerBlobGas?BigInt(e.maxFeePerBlobGas):void 0,maxFeePerGas:e.maxFeePerGas?BigInt(e.maxFeePerGas):void 0,maxPriorityFeePerGas:e.maxPriorityFeePerGas?BigInt(e.maxPriorityFeePerGas):void 0,nonce:e.nonce?H(e.nonce):void 0,to:e.to?e.to:null,transactionIndex:e.transactionIndex?Number(e.transactionIndex):null,type:e.type?Ma[e.type]:void 0,typeHex:e.type?e.type:void 0,value:e.value?BigInt(e.value):void 0,v:e.v?BigInt(e.v):void 0};return e.authorizationList&&(n.authorizationList=Wu(e.authorizationList)),n.yParity=(()=>{if(e.yParity)return Number(e.yParity);if(typeof n.v=="bigint"){if(n.v===0n||n.v===27n)return 0;if(n.v===1n||n.v===28n)return 1;if(n.v>=35n)return n.v%2n===0n?1:0}})(),n.type==="legacy"&&(delete n.accessList,delete n.maxFeePerBlobGas,delete n.maxFeePerGas,delete n.maxPriorityFeePerGas,delete n.yParity),n.type==="eip2930"&&(delete n.maxFeePerBlobGas,delete n.maxFeePerGas,delete n.maxPriorityFeePerGas),n.type==="eip1559"&&delete n.maxFeePerBlobGas,n}const Wm=nr("transaction",Fs);function Wu(e){return e.map(t=>({address:t.address,chainId:Number(t.chainId),nonce:Number(t.nonce),r:t.r,s:t.s,yParity:Number(t.yParity)}))}function _s(e,t){const n=(e.transactions??[]).map(r=>typeof r=="string"?r:Fs(r));return{...e,baseFeePerGas:e.baseFeePerGas?BigInt(e.baseFeePerGas):null,blobGasUsed:e.blobGasUsed?BigInt(e.blobGasUsed):void 0,difficulty:e.difficulty?BigInt(e.difficulty):void 0,excessBlobGas:e.excessBlobGas?BigInt(e.excessBlobGas):void 0,gasLimit:e.gasLimit?BigInt(e.gasLimit):void 0,gasUsed:e.gasUsed?BigInt(e.gasUsed):void 0,hash:e.hash?e.hash:null,logsBloom:e.logsBloom?e.logsBloom:null,nonce:e.nonce?e.nonce:null,number:e.number?BigInt(e.number):null,size:e.size?BigInt(e.size):void 0,timestamp:e.timestamp?BigInt(e.timestamp):void 0,transactions:n,totalDifficulty:e.totalDifficulty?BigInt(e.totalDifficulty):null}}const Zm=nr("block",_s);function Le(e,{args:t,eventName:n}={}){return{...e,blockHash:e.blockHash?e.blockHash:null,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,logIndex:e.logIndex?Number(e.logIndex):null,transactionHash:e.transactionHash?e.transactionHash:null,transactionIndex:e.transactionIndex?Number(e.transactionIndex):null,...n?{args:t,eventName:n}:{}}}const Oa={"0x0":"reverted","0x1":"success"};function Ls(e,t){const n={...e,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,contractAddress:e.contractAddress?e.contractAddress:null,cumulativeGasUsed:e.cumulativeGasUsed?BigInt(e.cumulativeGasUsed):null,effectiveGasPrice:e.effectiveGasPrice?BigInt(e.effectiveGasPrice):null,gasUsed:e.gasUsed?BigInt(e.gasUsed):null,logs:e.logs?e.logs.map(r=>Le(r)):null,to:e.to?e.to:null,transactionIndex:e.transactionIndex?H(e.transactionIndex):null,status:e.status?Oa[e.status]:null,type:e.type?Ma[e.type]||e.type:null};return e.blobGasPrice&&(n.blobGasPrice=BigInt(e.blobGasPrice)),e.blobGasUsed&&(n.blobGasUsed=BigInt(e.blobGasUsed)),n}const Ym=nr("transactionReceipt",Ls),Zu={legacy:"0x0",eip2930:"0x1",eip1559:"0x2",eip4844:"0x3",eip7702:"0x4"};function je(e,t){const n={};return typeof e.authorizationList<"u"&&(n.authorizationList=Yu(e.authorizationList)),typeof e.accessList<"u"&&(n.accessList=e.accessList),typeof e.blobVersionedHashes<"u"&&(n.blobVersionedHashes=e.blobVersionedHashes),typeof e.blobs<"u"&&(typeof e.blobs[0]!="string"?n.blobs=e.blobs.map(r=>V(r)):n.blobs=e.blobs),typeof e.data<"u"&&(n.data=e.data),e.account&&(n.from=e.account.address),typeof e.from<"u"&&(n.from=e.from),typeof e.gas<"u"&&(n.gas=A(e.gas)),typeof e.gasPrice<"u"&&(n.gasPrice=A(e.gasPrice)),typeof e.maxFeePerBlobGas<"u"&&(n.maxFeePerBlobGas=A(e.maxFeePerBlobGas)),typeof e.maxFeePerGas<"u"&&(n.maxFeePerGas=A(e.maxFeePerGas)),typeof e.maxPriorityFeePerGas<"u"&&(n.maxPriorityFeePerGas=A(e.maxPriorityFeePerGas)),typeof e.nonce<"u"&&(n.nonce=A(e.nonce)),typeof e.to<"u"&&(n.to=e.to),typeof e.type<"u"&&(n.type=Zu[e.type]),typeof e.value<"u"&&(n.value=A(e.value)),n}const Km=nr("transactionRequest",je);function Yu(e){return e.map(t=>({address:t.address,r:t.r?A(BigInt(t.r)):t.r,s:t.s?A(BigInt(t.s)):t.s,chainId:A(t.chainId),nonce:A(t.nonce),...typeof t.yParity<"u"?{yParity:A(t.yParity)}:{},...typeof t.v<"u"&&typeof t.yParity>"u"?{v:A(t.v)}:{}}))}function fe(e){return typeof e[0]=="string"?ye(e):Ku(e)}function Ku(e){let t=0;for(const s of e)t+=s.length;const n=new Uint8Array(t);let r=0;for(const s of e)n.set(s,r),r+=s.length;return n}function ye(e){return`0x${e.reduce((t,n)=>t+n.replace("0x",""),"")}`}let Lo=class extends I{constructor({offset:t}){super(`Offset \`${t}\` cannot be negative.`,{name:"NegativeOffsetError"})}},za=class extends I{constructor({length:t,position:n}){super(`Position \`${n}\` is out of bounds (\`0 < position < ${t}\`).`,{name:"PositionOutOfBoundsError"})}},Ju=class extends I{constructor({count:t,limit:n}){super(`Recursive read limit of \`${n}\` exceeded (recursive read count: \`${t}\`).`,{name:"RecursiveReadLimitExceededError"})}};const Xu={bytes:new Uint8Array,dataView:new DataView(new ArrayBuffer(0)),position:0,positionReadCount:new Map,recursiveReadCount:0,recursiveReadLimit:Number.POSITIVE_INFINITY,assertReadLimit(){if(this.recursiveReadCount>=this.recursiveReadLimit)throw new Ju({count:this.recursiveReadCount+1,limit:this.recursiveReadLimit})},assertPosition(e){if(e<0||e>this.bytes.length-1)throw new za({length:this.bytes.length,position:e})},decrementPosition(e){if(e<0)throw new Lo({offset:e});const t=this.position-e;this.assertPosition(t),this.position=t},getReadCount(e){return this.positionReadCount.get(e||this.position)||0},incrementPosition(e){if(e<0)throw new Lo({offset:e});const t=this.position+e;this.assertPosition(t),this.position=t},inspectByte(e){const t=e??this.position;return this.assertPosition(t),this.bytes[t]},inspectBytes(e,t){const n=t??this.position;return this.assertPosition(n+e-1),this.bytes.subarray(n,n+e)},inspectUint8(e){const t=e??this.position;return this.assertPosition(t),this.bytes[t]},inspectUint16(e){const t=e??this.position;return this.assertPosition(t+1),this.dataView.getUint16(t)},inspectUint24(e){const t=e??this.position;return this.assertPosition(t+2),(this.dataView.getUint16(t)<<8)+this.dataView.getUint8(t+2)},inspectUint32(e){const t=e??this.position;return this.assertPosition(t+3),this.dataView.getUint32(t)},pushByte(e){this.assertPosition(this.position),this.bytes[this.position]=e,this.position++},pushBytes(e){this.assertPosition(this.position+e.length-1),this.bytes.set(e,this.position),this.position+=e.length},pushUint8(e){this.assertPosition(this.position),this.bytes[this.position]=e,this.position++},pushUint16(e){this.assertPosition(this.position+1),this.dataView.setUint16(this.position,e),this.position+=2},pushUint24(e){this.assertPosition(this.position+2),this.dataView.setUint16(this.position,e>>8),this.dataView.setUint8(this.position+2,e&255),this.position+=3},pushUint32(e){this.assertPosition(this.position+3),this.dataView.setUint32(this.position,e),this.position+=4},readByte(){this.assertReadLimit(),this._touch();const e=this.inspectByte();return this.position++,e},readBytes(e,t){this.assertReadLimit(),this._touch();const n=this.inspectBytes(e);return this.position+=t??e,n},readUint8(){this.assertReadLimit(),this._touch();const e=this.inspectUint8();return this.position+=1,e},readUint16(){this.assertReadLimit(),this._touch();const e=this.inspectUint16();return this.position+=2,e},readUint24(){this.assertReadLimit(),this._touch();const e=this.inspectUint24();return this.position+=3,e},readUint32(){this.assertReadLimit(),this._touch();const e=this.inspectUint32();return this.position+=4,e},get remaining(){return this.bytes.length-this.position},setPosition(e){const t=this.position;return this.assertPosition(e),this.position=e,()=>this.position=t},_touch(){if(this.recursiveReadLimit===Number.POSITIVE_INFINITY)return;const e=this.getReadCount();this.positionReadCount.set(this.position,e+1),e>0&&this.recursiveReadCount++}};function $t(e,{recursiveReadLimit:t=8192}={}){const n=Object.create(Xu);return n.bytes=e,n.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength),n.positionReadCount=new Map,n.recursiveReadLimit=t,n}function Ne(e,t="hex"){const n=Fa(e),r=$t(new Uint8Array(n.length));return n.encode(r),t==="hex"?V(r.bytes):r.bytes}function ey(e,t="bytes"){return Ne(e,t)}function ty(e,t="hex"){return Ne(e,t)}function Fa(e){return Array.isArray(e)?Qu(e.map(t=>Fa(t))):e0(e)}function Qu(e){const t=e.reduce((s,o)=>s+o.length,0),n=_a(t);return{length:t<=55?1+t:1+n+t,encode(s){t<=55?s.pushByte(192+t):(s.pushByte(247+n),n===1?s.pushUint8(t):n===2?s.pushUint16(t):n===3?s.pushUint24(t):s.pushUint32(t));for(const{encode:o}of e)o(s)}}}function e0(e){const t=typeof e=="string"?ue(e):e,n=_a(t.length);return{length:t.length===1&&t[0]<128?1:t.length<=55?1+t.length:1+n+t.length,encode(s){t.length===1&&t[0]<128?s.pushBytes(t):t.length<=55?(s.pushByte(128+t.length),s.pushBytes(t)):(s.pushByte(183+n),n===1?s.pushUint8(t.length):n===2?s.pushUint16(t.length):n===3?s.pushUint24(t.length):s.pushUint32(t.length),s.pushBytes(t))}}}function _a(e){if(e<2**8)return 1;if(e<2**16)return 2;if(e<2**24)return 3;if(e<2**32)return 4;throw new I("Length is too large.")}const La={gwei:9,wei:18},Ua={ether:-9,wei:9},ny={ether:-18,gwei:-9};function ja(e,t){let n=e.toString();const r=n.startsWith("-");r&&(n=n.slice(1)),n=n.padStart(t,"0");let[s,o]=[n.slice(0,n.length-t),n.slice(n.length-t)];return o=o.replace(/(0+)$/,""),`${r?"-":""}${s||"0"}${o?`.${o}`:""}`}function Us(e,t="wei"){return ja(e,La[t])}function ce(e,t="wei"){return ja(e,Ua[t])}function mn(e){const t=Object.entries(e).map(([r,s])=>s===void 0||s===!1?null:[r,s]).filter(Boolean),n=t.reduce((r,[s])=>Math.max(r,s.length),0);return t.map(([r,s])=>` ${`${r}:`.padEnd(n+1)} ${s}`).join(`
|
|
2
2
|
`)}class t0 extends I{constructor(){super(["Cannot specify both a `gasPrice` and a `maxFeePerGas`/`maxPriorityFeePerGas`.","Use `maxFeePerGas`/`maxPriorityFeePerGas` for EIP-1559 compatible networks, and `gasPrice` for others."].join(`
|
|
3
3
|
`),{name:"FeeConflictError"})}}class qa extends I{constructor({v:t}){super(`Invalid \`v\` value "${t}". Expected 27 or 28.`,{name:"InvalidLegacyVError"})}}class n0 extends I{constructor({transaction:t}){super("Cannot infer a transaction type from provided transaction.",{metaMessages:["Provided Transaction:","{",mn(t),"}","","To infer the type, either provide:","- a `type` to the Transaction, or","- an EIP-1559 Transaction with `maxFeePerGas`, or","- an EIP-2930 Transaction with `gasPrice` & `accessList`, or","- an EIP-4844 Transaction with `blobs`, `blobVersionedHashes`, `sidecars`, or","- an EIP-7702 Transaction with `authorizationList`, or","- a Legacy Transaction with `gasPrice`"],name:"InvalidSerializableTransactionError"})}}class r0 extends I{constructor({serializedType:t}){super(`Serialized transaction type "${t}" is invalid.`,{name:"InvalidSerializedTransactionType"}),Object.defineProperty(this,"serializedType",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.serializedType=t}}class yn extends I{constructor({attributes:t,serializedTransaction:n,type:r}){const s=Object.entries(t).map(([o,a])=>typeof a>"u"?o:void 0).filter(Boolean);super(`Invalid serialized transaction of type "${r}" was provided.`,{metaMessages:[`Serialized Transaction: "${n}"`,s.length>0?`Missing Attributes: ${s.join(", ")}`:""].filter(Boolean),name:"InvalidSerializedTransactionError"}),Object.defineProperty(this,"serializedTransaction",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.serializedTransaction=n,this.type=r}}class s0 extends I{constructor({storageKey:t}){super(`Size for storage key "${t}" is invalid. Expected 32 bytes. Got ${Math.floor((t.length-2)/2)} bytes.`,{name:"InvalidStorageKeySizeError"})}}class o0 extends I{constructor(t,{account:n,docsPath:r,chain:s,data:o,gas:a,gasPrice:i,maxFeePerGas:c,maxPriorityFeePerGas:u,nonce:d,to:l,value:f}){const p=mn({chain:s&&`${s?.name} (id: ${s?.id})`,from:n?.address,to:l,value:typeof f<"u"&&`${Us(f)} ${s?.nativeCurrency?.symbol||"ETH"}`,data:o,gas:a,gasPrice:typeof i<"u"&&`${ce(i)} gwei`,maxFeePerGas:typeof c<"u"&&`${ce(c)} gwei`,maxPriorityFeePerGas:typeof u<"u"&&`${ce(u)} gwei`,nonce:d});super(t.shortMessage,{cause:t,docsPath:r,metaMessages:[...t.metaMessages?[...t.metaMessages," "]:[],"Request Arguments:",p].filter(Boolean),name:"TransactionExecutionError"}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.cause=t}}class Da extends I{constructor({blockHash:t,blockNumber:n,blockTag:r,hash:s,index:o}){let a="Transaction";r&&o!==void 0&&(a=`Transaction at block time "${r}" at index "${o}"`),t&&o!==void 0&&(a=`Transaction at block hash "${t}" at index "${o}"`),n&&o!==void 0&&(a=`Transaction at block number "${n}" at index "${o}"`),s&&(a=`Transaction with hash "${s}"`),super(`${a} could not be found.`,{name:"TransactionNotFoundError"})}}class Ga extends I{constructor({hash:t}){super(`Transaction receipt with hash "${t}" could not be found. The Transaction may not be processed on a block yet.`,{name:"TransactionReceiptNotFoundError"})}}class Ha extends I{constructor({receipt:t}){super(`Transaction with hash "${t.transactionHash}" reverted.`,{metaMessages:['The receipt marked the transaction as "reverted". This could mean that the function on the contract you are trying to call threw an error.'," ","You can attempt to extract the revert reason by:","- calling the `simulateContract` or `simulateCalls` Action with the `abi` and `functionName` of the contract","- using the `call` Action with raw `data`"],name:"TransactionReceiptRevertedError"}),Object.defineProperty(this,"receipt",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.receipt=t}}class a0 extends I{constructor({hash:t}){super(`Timed out while waiting for transaction with hash "${t}" to be confirmed.`,{name:"WaitForTransactionReceiptTimeoutError"})}}function i0(e){if(!e||e.length===0)return[];const t=[];for(const n of e){const{chainId:r,nonce:s,...o}=n,a=n.address;t.push([r?Ie(r):"0x",a,s?Ie(s):"0x",...gn({},o)])}return t}function js(e){const{kzg:t}=e,n=e.to??(typeof e.blobs[0]=="string"?"hex":"bytes"),r=typeof e.blobs[0]=="string"?e.blobs.map(o=>ue(o)):e.blobs,s=[];for(const o of r)s.push(Uint8Array.from(t.blobToKzgCommitment(o)));return n==="bytes"?s:s.map(o=>V(o))}function qs(e){const{kzg:t}=e,n=e.to??(typeof e.blobs[0]=="string"?"hex":"bytes"),r=typeof e.blobs[0]=="string"?e.blobs.map(a=>ue(a)):e.blobs,s=typeof e.commitments[0]=="string"?e.commitments.map(a=>ue(a)):e.commitments,o=[];for(let a=0;a<r.length;a++){const i=r[a],c=s[a];o.push(Uint8Array.from(t.computeBlobKzgProof(i,c)))}return n==="bytes"?o:o.map(a=>V(a))}function Va(e){const{commitment:t,version:n=1}=e,r=e.to??(typeof t=="string"?"hex":"bytes"),s=Gu(t,"bytes");return s.set([n],0),r==="bytes"?s:V(s)}function Wa(e){const{commitments:t,version:n}=e,r=e.to??(typeof t[0]=="string"?"hex":"bytes"),s=[];for(const o of t)s.push(Va({commitment:o,to:r,version:n}));return s}const Uo=6,Za=32,Ds=4096,Ya=Za*Ds,jo=Ya*Uo-1-1*Ds*Uo,Ka=1;class c0 extends I{constructor({maxSize:t,size:n}){super("Blob size is too large.",{metaMessages:[`Max: ${t} bytes`,`Given: ${n} bytes`],name:"BlobSizeTooLargeError"})}}class Ja extends I{constructor(){super("Blob data must not be empty.",{name:"EmptyBlobError"})}}class u0 extends I{constructor({hash:t,size:n}){super(`Versioned hash "${t}" size is invalid.`,{metaMessages:["Expected: 32",`Received: ${n}`],name:"InvalidVersionedHashSizeError"})}}class d0 extends I{constructor({hash:t,version:n}){super(`Versioned hash "${t}" version is invalid.`,{metaMessages:[`Expected: ${Ka}`,`Received: ${n}`],name:"InvalidVersionedHashVersionError"})}}function f0(e){const t=e.to??(typeof e.data=="string"?"hex":"bytes"),n=typeof e.data=="string"?ue(e.data):e.data,r=Z(n);if(!r)throw new Ja;if(r>jo)throw new c0({maxSize:jo,size:r});const s=[];let o=!0,a=0;for(;o;){const i=$t(new Uint8Array(Ya));let c=0;for(;c<Ds;){const u=n.slice(a,a+(Za-1));if(i.pushByte(0),i.pushBytes(u),u.length<31){i.pushByte(128),o=!1;break}c++,a+=31}s.push(i)}return t==="bytes"?s.map(i=>i.bytes):s.map(i=>V(i.bytes))}function Gs(e){const{data:t,kzg:n,to:r}=e,s=e.blobs??f0({data:t,to:r}),o=e.commitments??js({blobs:s,kzg:n,to:r}),a=e.proofs??qs({blobs:s,commitments:o,kzg:n,to:r}),i=[];for(let c=0;c<s.length;c++)i.push({blob:s[c],commitment:o[c],proof:a[c]});return i}class ns extends I{constructor({blockNumber:t,chain:n,contract:r}){super(`Chain "${n.name}" does not support contract "${r.name}".`,{metaMessages:["This could be due to any of the following:",...t&&r.blockCreated&&r.blockCreated>t?[`- The contract "${r.name}" was not deployed until block ${r.blockCreated} (current block ${t}).`]:[`- The chain does not have the contract "${r.name}" configured.`]],name:"ChainDoesNotSupportContract"})}}class l0 extends I{constructor({chain:t,currentChainId:n}){super(`The current chain of the wallet (id: ${n}) does not match the target chain for the transaction (id: ${t.id} – ${t.name}).`,{metaMessages:[`Current Chain ID: ${n}`,`Expected Chain ID: ${t.id} – ${t.name}`],name:"ChainMismatchError"})}}class p0 extends I{constructor(){super(["No chain was provided to the request.","Please provide a chain with the `chain` argument on the Action, or by supplying a `chain` to WalletClient."].join(`
|
|
4
4
|
`),{name:"ChainNotFoundError"})}}class Xa extends I{constructor(){super("No chain was provided to the Client.",{name:"ClientChainNotConfiguredError"})}}class rr extends I{constructor({chainId:t}){super(typeof t=="number"?`Chain ID "${t}" is invalid.`:"Chain ID is invalid.",{name:"InvalidChainIdError"})}}class Je extends I{constructor({cause:t,message:n}={}){const r=n?.replace("execution reverted: ","")?.replace("execution reverted","");super(`Execution reverted ${r?`with reason: ${r}`:"for an unknown reason"}.`,{cause:t,name:"ExecutionRevertedError"})}}Object.defineProperty(Je,"code",{enumerable:!0,configurable:!0,writable:!0,value:3});Object.defineProperty(Je,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/execution reverted/});class st extends I{constructor({cause:t,maxFeePerGas:n}={}){super(`The fee cap (\`maxFeePerGas\`${n?` = ${ce(n)} gwei`:""}) cannot be higher than the maximum allowed value (2^256-1).`,{cause:t,name:"FeeCapTooHighError"})}}Object.defineProperty(st,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max fee per gas higher than 2\^256-1|fee cap higher than 2\^256-1/});class rs extends I{constructor({cause:t,maxFeePerGas:n}={}){super(`The fee cap (\`maxFeePerGas\`${n?` = ${ce(n)}`:""} gwei) cannot be lower than the block base fee.`,{cause:t,name:"FeeCapTooLowError"})}}Object.defineProperty(rs,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max fee per gas less than block base fee|fee cap less than block base fee|transaction is outdated/});class ss extends I{constructor({cause:t,nonce:n}={}){super(`Nonce provided for the transaction ${n?`(${n}) `:""}is higher than the next one expected.`,{cause:t,name:"NonceTooHighError"})}}Object.defineProperty(ss,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/nonce too high/});class os extends I{constructor({cause:t,nonce:n}={}){super([`Nonce provided for the transaction ${n?`(${n}) `:""}is lower than the current nonce of the account.`,"Try increasing the nonce or find the latest nonce with `getTransactionCount`."].join(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_ as f,a as v,c as _,b as p}from"./tslib.es6-DbvBTznf.js";import{l as N,g as k,u as j,r as y,c as P,C as z,d as C,e as b,i as F,m as L,b as S,f as R,P as B,h as Q,j as W,k as G,n as T,o as U}from"./index-
|
|
1
|
+
import{_ as f,a as v,c as _,b as p}from"./tslib.es6-DbvBTznf.js";import{l as N,g as k,u as j,r as y,c as P,C as z,d as C,e as b,i as F,m as L,b as S,f as R,P as B,h as Q,j as W,k as G,n as T,o as U}from"./index-CgabfD28.js";import{i as V}from"./is-plan-event-enabled-DeNtQvA5.js";function D(i){return i.toLowerCase().replace(".","").replace(/\s+/g,"-")}function E(i,t){return t===void 0&&(t=!1),t?btoa(i).replace(/=/g,""):void 0}function H(i){return("Integration"in i?i.Integration:i).prototype.name}function J(i,t,n){var e,a;try{var r=((a=(e=window?.performance)===null||e===void 0?void 0:e.getEntriesByName(i,"resource"))!==null&&a!==void 0?a:[])[0];r&&t.stats.gauge("legacy_destination_time",Math.round(r.duration),_([n],r.duration<100?["cached"]:[],!0))}catch{}}function K(i,t,n){var e;if("Integration"in i){var a={user:function(){return n.user()},addIntegration:function(){}};i(a),e=i.Integration}else e=i;var r=new e(t);return r.analytics=n,r}function X(i,t,n,e){return f(this,void 0,void 0,function(){var a,r,o,u,s,l;return v(this,function(d){switch(d.label){case 0:a=D(t),r=E(a,e),o=k(),u="".concat(o,"/integrations/").concat(r??a,"/").concat(n,"/").concat(r??a,".dynamic.js.gz"),d.label=1;case 1:return d.trys.push([1,3,,4]),[4,N(u)];case 2:return d.sent(),J(u,i,t),[3,4];case 3:throw s=d.sent(),i.stats.gauge("legacy_destination_time",-1,["plugin:".concat(t),"failed"]),s;case 4:return l=window["".concat(a,"Deps")],[4,Promise.all(l.map(function(g){return N(o+g+".gz")}))];case 5:return d.sent(),window["".concat(a,"Loader")](),[2,window["".concat(a,"Integration")]]}})})}function Y(i,t,n){return f(this,void 0,void 0,function(){var e,a,r,o;return v(this,function(u){return e=k(),a=D(i),r=E(i,n),o="".concat(e,"/integrations/").concat(r??a,"/").concat(t,"/").concat(r??a,".dynamic.js.gz"),[2,j(o)]})})}function Z(i){var t,n,e,a;return(a=(n=(t=i?.versionSettings)===null||t===void 0?void 0:t.override)!==null&&n!==void 0?n:(e=i?.versionSettings)===null||e===void 0?void 0:e.version)!==null&&a!==void 0?a:"latest"}var $=function(i,t){var n,e=t.type,a=t.bundlingStatus,r=t.versionSettings,o=a!=="unbundled"&&(e==="browser"||((n=r?.componentTypes)===null||n===void 0?void 0:n.includes("browser")));return!i.startsWith("Segment")&&i!=="Iterable"&&o},q=function(i,t){var n=t.All===!1&&t[i]===void 0;return t[i]===!1||n};function x(i,t){return f(this,void 0,void 0,function(){var n,e=this;return v(this,function(a){switch(a.label){case 0:return n=[],P()?[2,t]:[4,W(function(){return t.length>0&&U()},function(){return f(e,void 0,void 0,function(){var r,o,u;return v(this,function(s){switch(s.label){case 0:return r=t.pop(),r?[4,G(r,i)]:[2];case 1:return o=s.sent(),u=o instanceof T,u||n.push(r),[2]}})})})];case 1:return a.sent(),n.map(function(r){return t.pushWithBackoff(r)}),[2,t]}})})}var tt=function(){function i(t,n,e,a,r,o){a===void 0&&(a={});var u=this;this.options={},this.type="destination",this.middleware=[],this.initializePromise=R(),this.flushing=!1,this.name=t,this.version=n,this.settings=p({},a),this.disableAutoISOConversion=r.disableAutoISOConversion||!1,this.integrationSource=o,this.settings.type&&this.settings.type==="browser"&&delete this.settings.type,this.initializePromise.promise.then(function(s){return u._initialized=s},function(){}),this.options=r,this.buffer=r.disableClientPersistence?new B(4,[]):new Q(4,"".concat(e,":dest-").concat(t)),this.scheduleFlush()}return i.prototype.isLoaded=function(){return!!this._ready},i.prototype.ready=function(){var t=this;return this.initializePromise.promise.then(function(){var n;return(n=t.onReady)!==null&&n!==void 0?n:Promise.resolve()})},i.prototype.load=function(t,n){var e;return f(this,void 0,void 0,function(){var a,r,o,u=this;return v(this,function(s){switch(s.label){case 0:if(this._ready||this.onReady!==void 0)return[2];s.label=1;case 1:return s.trys.push([1,5,,6]),(e=this.integrationSource)!==null&&e!==void 0?(r=e,[3,4]):[3,2];case 2:return[4,X(t,this.name,this.version,this.options.obfuscate)];case 3:r=s.sent(),s.label=4;case 4:return a=r,this.integration=K(a,this.settings,n),[3,6];case 5:throw o=s.sent(),y(t,{integrationName:this.name,methodName:"load",type:"classic",didError:!0}),o;case 6:this.onReady=new Promise(function(l){var d=function(){u._ready=!0,l(!0)};u.integration.once("ready",d)}),this.integration.on("initialize",function(){u.initializePromise.resolve(!0)});try{y(t,{integrationName:this.name,methodName:"initialize",type:"classic"}),this.integration.initialize()}catch(l){throw y(t,{integrationName:this.name,methodName:"initialize",type:"classic",didError:!0}),this.initializePromise.resolve(!1),l}return[2]}})})},i.prototype.unload=function(t,n){return Y(this.name,this.version,this.options.obfuscate)},i.prototype.addMiddleware=function(){for(var t,n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];this.middleware=(t=this.middleware).concat.apply(t,n)},i.prototype.shouldBuffer=function(t){return t.event.type!=="page"&&(P()||this._ready!==!0||this._initialized!==!0)},i.prototype.send=function(t,n,e){var a,r;return f(this,void 0,void 0,function(){var o,u,s,l,d,g;return v(this,function(h){switch(h.label){case 0:return this.shouldBuffer(t)?(this.buffer.push(t),this.scheduleFlush(),[2,t]):(o=(r=(a=this.options)===null||a===void 0?void 0:a.plan)===null||r===void 0?void 0:r.track,u=t.event.event,o&&u&&this.name!=="Segment.io"&&(s=o[u],V(o,s)?t.updateEvent("integrations",p(p({},t.event.integrations),s?.integrations)):(t.updateEvent("integrations",p(p({},t.event.integrations),{All:!1,"Segment.io":!0})),t.cancel(new z({retry:!1,reason:"Event ".concat(u," disabled for integration ").concat(this.name," in tracking plan"),type:"Dropped by plan"}))),s?.enabled&&s?.integrations[this.name]===!1&&t.cancel(new z({retry:!1,reason:"Event ".concat(u," disabled for integration ").concat(this.name," in tracking plan"),type:"Dropped by plan"}))),[4,C(this.name,t.event,this.middleware)]);case 1:if(l=h.sent(),l===null)return[2,t];d=new n(l,{traverse:!this.disableAutoISOConversion}),y(t,{integrationName:this.name,methodName:e,type:"classic"}),h.label=2;case 2:return h.trys.push([2,5,,6]),this.integration?[4,this.integration.invoke.call(this.integration,e,d)]:[3,4];case 3:h.sent(),h.label=4;case 4:return[3,6];case 5:throw g=h.sent(),y(t,{integrationName:this.name,methodName:e,type:"classic",didError:!0}),g;case 6:return[2,t]}})})},i.prototype.track=function(t){return f(this,void 0,void 0,function(){return v(this,function(n){return[2,this.send(t,b.Track,"track")]})})},i.prototype.page=function(t){var n;return f(this,void 0,void 0,function(){return v(this,function(e){switch(e.label){case 0:return!((n=this.integration)===null||n===void 0)&&n._assumesPageview&&!this._initialized&&this.integration.initialize(),[4,this.initializePromise.promise];case 1:return e.sent(),[2,this.send(t,b.Page,"page")]}})})},i.prototype.identify=function(t){return f(this,void 0,void 0,function(){return v(this,function(n){return[2,this.send(t,b.Identify,"identify")]})})},i.prototype.alias=function(t){return f(this,void 0,void 0,function(){return v(this,function(n){return[2,this.send(t,b.Alias,"alias")]})})},i.prototype.group=function(t){return f(this,void 0,void 0,function(){return v(this,function(n){return[2,this.send(t,b.Group,"group")]})})},i.prototype.scheduleFlush=function(){var t=this;this.flushing||setTimeout(function(){return f(t,void 0,void 0,function(){var n;return v(this,function(e){switch(e.label){case 0:return P()||this._ready!==!0||this._initialized!==!0?(this.scheduleFlush(),[2]):(this.flushing=!0,n=this,[4,x(this,this.buffer)]);case 1:return n.buffer=e.sent(),this.flushing=!1,this.buffer.todo>0&&this.scheduleFlush(),[2]}})})},Math.random()*5e3)},i}();function rt(i,t,n,e,a,r){var o,u;if(n===void 0&&(n={}),e===void 0&&(e={}),F())return[];t.plan&&(e=e??{},e.plan=t.plan);var s=(u=(o=t.middlewareSettings)===null||o===void 0?void 0:o.routingRules)!==null&&u!==void 0?u:[],l=t.integrations,d=e.integrations,g=L(t,e??{}),h=r?.reduce(function(c,w){var m;return p(p({},c),(m={},m[H(w)]=w,m))},{}),O=new Set(_(_([],Object.keys(l).filter(function(c){return $(c,l[c])}),!0),Object.keys(h||{}).filter(function(c){return S(l[c])||S(d?.[c])}),!0));return Array.from(O).filter(function(c){return!q(c,n)}).map(function(c){var w=l[c],m=Z(w),I=new tt(c,m,i,g[c],e,h?.[c]),A=s.filter(function(M){return M.destinationName===c});return A.length>0&&a&&I.addMiddleware(a),I})}export{tt as LegacyDestination,rt as ajsDestinations};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{K as at,q as L,t as kt,Y as F,P as Ht,F as M,V as R,u as J,v as $t,w as Tt}from"./wallets-Q5RcRyG6.js";import{O as Mt,k as Bt,f as Lt,o as g,a as At}from"./index.es-D3pP9hN4.js";import{f as P}from"./index.es-D5YKsq2-.js";import{N as Jt}from"./events-B5inrCVE.js";const ot="error",zt="wss://relay.walletconnect.org",Gt="wc",Vt="universal_provider",x=`${Gt}@2:${Vt}:`,Et="https://rpc.walletconnect.org/v1/",St="generic",Kt=`${Et}bundler`,_="call_status",Wt=86400,v={DEFAULT_CHAIN_CHANGED:"default_chain_changed"};function et(i){return i==null||typeof i!="object"&&typeof i!="function"}function qt(i){return Object.getOwnPropertySymbols(i).filter(t=>Object.prototype.propertyIsEnumerable.call(i,t))}function Nt(i){return i==null?i===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(i)}const Yt="[object RegExp]",Dt="[object String]",_t="[object Number]",Ft="[object Boolean]",Rt="[object Arguments]",Qt="[object Symbol]",Xt="[object Date]",Zt="[object Map]",te="[object Set]",ee="[object Array]",ie="[object ArrayBuffer]",se="[object Object]",re="[object DataView]",ne="[object Uint8Array]",ae="[object Uint8ClampedArray]",oe="[object Uint16Array]",ce="[object Uint32Array]",he="[object Int8Array]",pe="[object Int16Array]",ue="[object Int32Array]",le="[object Float32Array]",de="[object Float64Array]";function it(i){return ArrayBuffer.isView(i)&&!(i instanceof DataView)}function fe(i,t){return D(i,void 0,i,new Map,t)}function D(i,t,e,s=new Map,n=void 0){const a=n?.(i,t,e,s);if(a!=null)return a;if(et(i))return i;if(s.has(i))return s.get(i);if(Array.isArray(i)){const r=new Array(i.length);s.set(i,r);for(let o=0;o<i.length;o++)r[o]=D(i[o],o,e,s,n);return Object.hasOwn(i,"index")&&(r.index=i.index),Object.hasOwn(i,"input")&&(r.input=i.input),r}if(i instanceof Date)return new Date(i.getTime());if(i instanceof RegExp){const r=new RegExp(i.source,i.flags);return r.lastIndex=i.lastIndex,r}if(i instanceof Map){const r=new Map;s.set(i,r);for(const[o,c]of i)r.set(o,D(c,o,e,s,n));return r}if(i instanceof Set){const r=new Set;s.set(i,r);for(const o of i)r.add(D(o,void 0,e,s,n));return r}if(typeof Buffer<"u"&&Buffer.isBuffer(i))return i.subarray();if(it(i)){const r=new(Object.getPrototypeOf(i)).constructor(i.length);s.set(i,r);for(let o=0;o<i.length;o++)r[o]=D(i[o],o,e,s,n);return r}if(i instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&i instanceof SharedArrayBuffer)return i.slice(0);if(i instanceof DataView){const r=new DataView(i.buffer.slice(0),i.byteOffset,i.byteLength);return s.set(i,r),y(r,i,e,s,n),r}if(typeof File<"u"&&i instanceof File){const r=new File([i],i.name,{type:i.type});return s.set(i,r),y(r,i,e,s,n),r}if(i instanceof Blob){const r=new Blob([i],{type:i.type});return s.set(i,r),y(r,i,e,s,n),r}if(i instanceof Error){const r=new i.constructor;return s.set(i,r),r.message=i.message,r.name=i.name,r.stack=i.stack,r.cause=i.cause,y(r,i,e,s,n),r}if(typeof i=="object"&&me(i)){const r=Object.create(Object.getPrototypeOf(i));return s.set(i,r),y(r,i,e,s,n),r}return i}function y(i,t,e=i,s,n){const a=[...Object.keys(t),...qt(t)];for(let r=0;r<a.length;r++){const o=a[r],c=Object.getOwnPropertyDescriptor(i,o);(c==null||c.writable)&&(i[o]=D(t[o],o,e,s,n))}}function me(i){switch(Nt(i)){case Rt:case ee:case ie:case re:case Ft:case Xt:case le:case de:case he:case pe:case ue:case Zt:case _t:case se:case Yt:case te:case Dt:case Qt:case ne:case ae:case oe:case ce:return!0;default:return!1}}function ve(i,t){return fe(i,(e,s,n,a)=>{if(typeof i=="object")switch(Object.prototype.toString.call(i)){case _t:case Dt:case Ft:{const r=new i.constructor(i?.valueOf());return y(r,i),r}case Rt:{const r={};return y(r,i),r.length=i.length,r[Symbol.iterator]=i[Symbol.iterator],r}default:return}})}function ct(i){return ve(i)}function ht(i){return i!==null&&typeof i=="object"&&Nt(i)==="[object Arguments]"}function pt(i){return typeof i=="object"&&i!==null}function ge(){}function Pe(i){return it(i)}function we(i){if(typeof i!="object"||i==null)return!1;if(Object.getPrototypeOf(i)===null)return!0;if(Object.prototype.toString.call(i)!=="[object Object]"){const e=i[Symbol.toStringTag];return e==null||!Object.getOwnPropertyDescriptor(i,Symbol.toStringTag)?.writable?!1:i.toString()===`[object ${e}]`}let t=i;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(i)===t}function be(i){if(et(i))return i;if(Array.isArray(i)||it(i)||i instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&i instanceof SharedArrayBuffer)return i.slice(0);const t=Object.getPrototypeOf(i),e=t.constructor;if(i instanceof Date||i instanceof Map||i instanceof Set)return new e(i);if(i instanceof RegExp){const s=new e(i);return s.lastIndex=i.lastIndex,s}if(i instanceof DataView)return new e(i.buffer.slice(0));if(i instanceof Error){const s=new e(i.message);return s.stack=i.stack,s.name=i.name,s.cause=i.cause,s}if(typeof File<"u"&&i instanceof File)return new e([i],i.name,{type:i.type,lastModified:i.lastModified});if(typeof i=="object"){const s=Object.create(t);return Object.assign(s,i)}return i}function ye(i,...t){const e=t.slice(0,-1),s=t[t.length-1];let n=i;for(let a=0;a<e.length;a++){const r=e[a];n=X(n,r,s,new Map)}return n}function X(i,t,e,s){if(et(i)&&(i=Object(i)),t==null||typeof t!="object")return i;if(s.has(t))return be(s.get(t));if(s.set(t,i),Array.isArray(t)){t=t.slice();for(let a=0;a<t.length;a++)t[a]=t[a]??void 0}const n=[...Object.keys(t),...qt(t)];for(let a=0;a<n.length;a++){const r=n[a];let o=t[r],c=i[r];if(ht(o)&&(o={...o}),ht(c)&&(c={...c}),typeof Buffer<"u"&&Buffer.isBuffer(o)&&(o=ct(o)),Array.isArray(o))if(typeof c=="object"&&c!=null){const l=[],p=Reflect.ownKeys(c);for(let w=0;w<p.length;w++){const d=p[w];l[d]=c[d]}c=l}else c=[];const u=e(c,o,r,i,t,s);u!=null?i[r]=u:Array.isArray(o)||pt(c)&&pt(o)?i[r]=X(c,o,e,s):c==null&&we(o)?i[r]=X({},o,e,s):c==null&&Pe(o)?i[r]=ct(o):(c===void 0||o!==void 0)&&(i[r]=o)}return i}function Ce(i,...t){return ye(i,...t,ge)}var Ie=Object.defineProperty,Oe=Object.defineProperties,je=Object.getOwnPropertyDescriptors,ut=Object.getOwnPropertySymbols,He=Object.prototype.hasOwnProperty,$e=Object.prototype.propertyIsEnumerable,lt=(i,t,e)=>t in i?Ie(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,U=(i,t)=>{for(var e in t||(t={}))He.call(t,e)&<(i,e,t[e]);if(ut)for(var e of ut(t))$e.call(t,e)&<(i,e,t[e]);return i},Ae=(i,t)=>Oe(i,je(t));function f(i,t,e){var s;const n=M(i);return((s=t.rpcMap)==null?void 0:s[n.reference])||`${Et}?chainId=${n.namespace}:${n.reference}&projectId=${e}`}function C(i){return i.includes(":")?i.split(":")[1]:i}function xt(i){return i.map(t=>`${t.split(":")[0]}:${t.split(":")[1]}`)}function Ee(i,t){const e=Object.keys(t.namespaces).filter(n=>n.includes(i));if(!e.length)return[];const s=[];return e.forEach(n=>{const a=t.namespaces[n].accounts;s.push(...a)}),s}function dt(i){return Object.fromEntries(Object.entries(i).filter(([t,e])=>{var s,n;return((s=e?.chains)==null?void 0:s.length)&&((n=e?.chains)==null?void 0:n.length)>0}))}function k(i={},t={}){const e=dt(ft(i)),s=dt(ft(t));return Ce(e,s)}function ft(i){var t,e,s,n,a;const r={};if(!R(i))return r;for(const[o,c]of Object.entries(i)){const u=Ht(o)?[o]:c.chains,l=c.methods||[],p=c.events||[],w=c.rpcMap||{},d=F(o);r[d]=Ae(U(U({},r[d]),c),{chains:J(u,(t=r[d])==null?void 0:t.chains),methods:J(l,(e=r[d])==null?void 0:e.methods),events:J(p,(s=r[d])==null?void 0:s.events)}),(R(w)||R(((n=r[d])==null?void 0:n.rpcMap)||{}))&&(r[d].rpcMap=U(U({},w),(a=r[d])==null?void 0:a.rpcMap))}return r}function mt(i){return i.includes(":")?i.split(":")[2]:i}function vt(i){const t={};for(const[e,s]of Object.entries(i)){const n=s.methods||[],a=s.events||[],r=s.accounts||[],o=Ht(e)?[e]:s.chains?s.chains:xt(s.accounts);t[e]={chains:o,methods:n,events:a,accounts:r}}return t}function z(i){return typeof i=="number"?i:i.includes("0x")?parseInt(i,16):(i=i.includes(":")?i.split(":")[1]:i,isNaN(Number(i))?i:Number(i))}function Se(i){try{const t=JSON.parse(i);return typeof t=="object"&&t!==null&&!Array.isArray(t)}catch{return!1}}const Ut={},h=i=>Ut[i],G=(i,t)=>{Ut[i]=t};var qe=Object.defineProperty,gt=Object.getOwnPropertySymbols,Ne=Object.prototype.hasOwnProperty,De=Object.prototype.propertyIsEnumerable,Pt=(i,t,e)=>t in i?qe(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,wt=(i,t)=>{for(var e in t||(t={}))Ne.call(t,e)&&Pt(i,e,t[e]);if(gt)for(var e of gt(t))De.call(t,e)&&Pt(i,e,t[e]);return i};const bt="eip155",_e=["atomic","flow-control","paymasterService","sessionKeys","auxiliaryFunds"],Fe=i=>i&&i.startsWith("0x")?BigInt(i).toString(10):i,V=i=>i&&i.startsWith("0x")?i:`0x${BigInt(i).toString(16)}`,yt=i=>Object.keys(i).filter(t=>_e.includes(t)).reduce((t,e)=>(t[e]=Re(i[e]),t),{}),Re=i=>typeof i=="string"&&Se(i)?JSON.parse(i):i,xe=(i,t,e)=>{const{sessionProperties:s={},scopedProperties:n={}}=i,a={};if(!R(n)&&!R(s))return;const r=yt(s);for(const o of e){const c=Fe(o);if(!c)continue;a[V(c)]=r;const u=n?.[`${bt}:${c}`];if(u){const l=u?.[`${bt}:${c}:${t}`];a[V(c)]=wt(wt({},a[V(c)]),yt(l||u))}}for(const[o,c]of Object.entries(a))Object.keys(c).length===0&&delete a[o];return Object.keys(a).length>0?a:void 0};var Ue=Object.defineProperty,ke=(i,t,e)=>t in i?Ue(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,Te=(i,t,e)=>ke(i,t+"",e);let K;class st{constructor(t){Te(this,"storage"),this.storage=t}async getItem(t){return await this.storage.getItem(t)}async setItem(t,e){return await this.storage.setItem(t,e)}async removeItem(t){return await this.storage.removeItem(t)}static getStorage(t){return K||(K=new st(t)),K}}var Me=Object.defineProperty,Be=Object.defineProperties,Le=Object.getOwnPropertyDescriptors,Ct=Object.getOwnPropertySymbols,Je=Object.prototype.hasOwnProperty,ze=Object.prototype.propertyIsEnumerable,It=(i,t,e)=>t in i?Me(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,Ge=(i,t)=>{for(var e in t||(t={}))Je.call(t,e)&&It(i,e,t[e]);if(Ct)for(var e of Ct(t))ze.call(t,e)&&It(i,e,t[e]);return i},Ve=(i,t)=>Be(i,Le(t));async function Ke(i,t){const e=M(i.result.capabilities.caip345.caip2),s=i.result.capabilities.caip345.transactionHashes,n=await Promise.allSettled(s.map(p=>We(e.reference,p,t))),a=n.filter(p=>p.status==="fulfilled").map(p=>p.value).filter(p=>p);n.filter(p=>p.status==="rejected").forEach(p=>console.warn("Failed to fetch transaction receipt:",p.reason));const r=!a.length||a.some(p=>!p),o=a.every(p=>p?.status==="0x1"),c=a.every(p=>p?.status==="0x0"),u=a.some(p=>p?.status==="0x0");let l;return r?l=100:o?l=200:c?l=500:u&&(l=600),{id:i.result.id,version:i.request.version,atomic:i.request.atomicRequired,chainId:i.request.chainId,capabilities:i.result.capabilities,receipts:a,status:l}}async function We(i,t,e){return await e(parseInt(i)).request(At("eth_getTransactionReceipt",[t]))}async function Ye({sendCalls:i,storage:t}){const e=await t.getItem(_);await t.setItem(_,Ve(Ge({},e),{[i.result.id]:{request:i.request,result:i.result,expiry:Tt(Wt)}}))}async function Qe({resultId:i,storage:t}){const e=await t.getItem(_);if(e){delete e[i],await t.setItem(_,e);for(const s in e)$t(e[s].expiry)&&delete e[s];await t.setItem(_,e)}}async function Xe({resultId:i,storage:t}){const e=await t.getItem(_),s=e?.[i];if(s&&!$t(s.expiry))return s;await Qe({resultId:i,storage:t})}var Ze=Object.defineProperty,ti=(i,t,e)=>t in i?Ze(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,I=(i,t,e)=>ti(i,typeof t!="symbol"?t+"":t,e);class ei{constructor(t){I(this,"name","polkadot"),I(this,"client"),I(this,"httpProviders"),I(this,"events"),I(this,"namespace"),I(this,"chainId"),this.namespace=t.namespace,this.events=h("events"),this.client=h("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){this.httpProviders[t]||this.setHttpProvider(t,e),this.chainId=t,this.events.emit(v.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`)}getAccounts(){const t=this.namespace.accounts;return t?t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2])||[]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{var s;const n=C(e);t[n]=this.createHttpProvider(n,(s=this.namespace.rpcMap)==null?void 0:s[e])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const s=this.createHttpProvider(t,e);s&&(this.httpProviders[t]=s)}createHttpProvider(t,e){const s=e||f(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new g(new P(s,h("disableProviderPing")))}}var ii=Object.defineProperty,si=Object.defineProperties,ri=Object.getOwnPropertyDescriptors,Ot=Object.getOwnPropertySymbols,ni=Object.prototype.hasOwnProperty,ai=Object.prototype.propertyIsEnumerable,Z=(i,t,e)=>t in i?ii(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,W=(i,t)=>{for(var e in t||(t={}))ni.call(t,e)&&Z(i,e,t[e]);if(Ot)for(var e of Ot(t))ai.call(t,e)&&Z(i,e,t[e]);return i},Y=(i,t)=>si(i,ri(t)),b=(i,t,e)=>Z(i,typeof t!="symbol"?t+"":t,e);class oi{constructor(t){b(this,"name","eip155"),b(this,"client"),b(this,"chainId"),b(this,"namespace"),b(this,"httpProviders"),b(this,"events"),b(this,"storage"),this.namespace=t.namespace,this.events=h("events"),this.client=h("client"),this.httpProviders=this.createHttpProviders(),this.chainId=parseInt(this.getDefaultChain()),this.storage=st.getStorage(this.client.core.storage)}async request(t){switch(t.request.method){case"eth_requestAccounts":return this.getAccounts();case"eth_accounts":return this.getAccounts();case"wallet_switchEthereumChain":return await this.handleSwitchChain(t);case"eth_chainId":return parseInt(this.getDefaultChain());case"wallet_getCapabilities":return await this.getCapabilities(t);case"wallet_getCallsStatus":return await this.getCallStatus(t);case"wallet_sendCalls":return await this.sendCalls(t)}return this.namespace.methods.includes(t.request.method)?await this.client.request(t):this.getHttpProvider().request(t.request)}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}setDefaultChain(t,e){this.httpProviders[t]||this.setHttpProvider(parseInt(t),e),this.chainId=parseInt(t),this.events.emit(v.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId.toString();if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}createHttpProvider(t,e){const s=e||f(`${this.name}:${t}`,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new g(new P(s,h("disableProviderPing")))}setHttpProvider(t,e){const s=this.createHttpProvider(t,e);s&&(this.httpProviders[t]=s)}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{var s;const n=parseInt(C(e));t[n]=this.createHttpProvider(n,(s=this.namespace.rpcMap)==null?void 0:s[e])}),t}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}getHttpProvider(t){const e=t||this.chainId;return this.httpProviders[e]||(this.httpProviders=Y(W({},this.httpProviders),{[e]:this.createHttpProvider(e)}),this.httpProviders[e])}async handleSwitchChain(t){var e,s;let n=t.request.params?(e=t.request.params[0])==null?void 0:e.chainId:"0x0";n=n.startsWith("0x")?n:`0x${n}`;const a=parseInt(n,16);if(this.isChainApproved(a))this.setDefaultChain(`${a}`);else if(this.namespace.methods.includes("wallet_switchEthereumChain"))await this.client.request({topic:t.topic,request:{method:t.request.method,params:[{chainId:n}]},chainId:(s=this.namespace.chains)==null?void 0:s[0]}),this.setDefaultChain(`${a}`);else throw new Error(`Failed to switch to chain 'eip155:${a}'. The chain is not approved or the wallet does not support 'wallet_switchEthereumChain' method.`);return null}isChainApproved(t){return this.namespace.chains.includes(`${this.name}:${t}`)}async getCapabilities(t){var e,s,n,a,r;const o=(s=(e=t.request)==null?void 0:e.params)==null?void 0:s[0],c=((a=(n=t.request)==null?void 0:n.params)==null?void 0:a[1])||[];if(!o)throw new Error("Missing address parameter in `wallet_getCapabilities` request");const u=this.client.session.get(t.topic),l=((r=u?.sessionProperties)==null?void 0:r.capabilities)||{},p=`${o}${c.join(",")}`,w=l?.[p];if(w)return w;let d;try{d=xe(u,o,c)}catch(B){console.warn("Failed to extract capabilities from session",B)}if(d)return d;const nt=await this.client.request(t);try{await this.client.session.update(t.topic,{sessionProperties:Y(W({},u.sessionProperties||{}),{capabilities:Y(W({},l||{}),{[p]:nt})})})}catch(B){console.warn("Failed to update session with capabilities",B)}return nt}async getCallStatus(t){var e,s,n;const a=this.client.session.get(t.topic),r=(e=a.sessionProperties)==null?void 0:e.bundler_name;if(r){const u=this.getBundlerUrl(t.chainId,r);try{return await this.getUserOperationReceipt(u,t)}catch(l){console.warn("Failed to fetch call status from bundler",l,u)}}const o=(s=a.sessionProperties)==null?void 0:s.bundler_url;if(o)try{return await this.getUserOperationReceipt(o,t)}catch(u){console.warn("Failed to fetch call status from custom bundler",u,o)}const c=await Xe({resultId:(n=t.request.params)==null?void 0:n[0],storage:this.storage});if(c)try{return await Ke(c,this.getHttpProvider.bind(this))}catch(u){console.warn("Failed to fetch call status from stored send calls",u,c)}if(this.namespace.methods.includes(t.request.method))return await this.client.request(t);throw new Error("Fetching call status not approved by the wallet.")}async getUserOperationReceipt(t,e){var s;const n=new URL(t),a=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(At("eth_getUserOperationReceipt",[(s=e.request.params)==null?void 0:s[0]]))});if(!a.ok)throw new Error(`Failed to fetch user operation receipt - ${a.status}`);return await a.json()}getBundlerUrl(t,e){return`${Kt}?projectId=${this.client.core.projectId}&chainId=${t}&bundler=${e}`}async sendCalls(t){var e,s,n;const a=await this.client.request(t),r=(e=t.request.params)==null?void 0:e[0],o=a?.id,c=a?.capabilities||{},u=(s=c?.caip345)==null?void 0:s.caip2,l=(n=c?.caip345)==null?void 0:n.transactionHashes;return!o||!u||!(l!=null&&l.length)||await Ye({sendCalls:{request:r,result:a},storage:this.storage}),a}}var ci=Object.defineProperty,hi=(i,t,e)=>t in i?ci(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,O=(i,t,e)=>hi(i,typeof t!="symbol"?t+"":t,e);class pi{constructor(t){O(this,"name","solana"),O(this,"client"),O(this,"httpProviders"),O(this,"events"),O(this,"namespace"),O(this,"chainId"),this.namespace=t.namespace,this.events=h("events"),this.client=h("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){this.httpProviders[t]||this.setHttpProvider(t,e),this.chainId=t,this.events.emit(v.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{var s;const n=C(e);t[n]=this.createHttpProvider(n,(s=this.namespace.rpcMap)==null?void 0:s[e])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const s=this.createHttpProvider(t,e);s&&(this.httpProviders[t]=s)}createHttpProvider(t,e){const s=e||f(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new g(new P(s,h("disableProviderPing")))}}var ui=Object.defineProperty,li=(i,t,e)=>t in i?ui(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,j=(i,t,e)=>li(i,typeof t!="symbol"?t+"":t,e);class di{constructor(t){j(this,"name","cosmos"),j(this,"client"),j(this,"httpProviders"),j(this,"events"),j(this,"namespace"),j(this,"chainId"),this.namespace=t.namespace,this.events=h("events"),this.client=h("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){this.httpProviders[t]||this.setHttpProvider(t,e),this.chainId=t,this.events.emit(v.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{var s;const n=C(e);t[n]=this.createHttpProvider(n,(s=this.namespace.rpcMap)==null?void 0:s[e])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const s=this.createHttpProvider(t,e);s&&(this.httpProviders[t]=s)}createHttpProvider(t,e){const s=e||f(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new g(new P(s,h("disableProviderPing")))}}var fi=Object.defineProperty,mi=(i,t,e)=>t in i?fi(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,H=(i,t,e)=>mi(i,typeof t!="symbol"?t+"":t,e);class vi{constructor(t){H(this,"name","algorand"),H(this,"client"),H(this,"httpProviders"),H(this,"events"),H(this,"namespace"),H(this,"chainId"),this.namespace=t.namespace,this.events=h("events"),this.client=h("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){if(!this.httpProviders[t]){const s=e||f(`${this.name}:${t}`,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);this.setHttpProvider(t,s)}this.chainId=t,this.events.emit(v.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{var s;t[e]=this.createHttpProvider(e,(s=this.namespace.rpcMap)==null?void 0:s[e])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const s=this.createHttpProvider(t,e);s&&(this.httpProviders[t]=s)}createHttpProvider(t,e){const s=e||f(t,this.namespace,this.client.core.projectId);return typeof s>"u"?void 0:new g(new P(s,h("disableProviderPing")))}}var gi=Object.defineProperty,Pi=(i,t,e)=>t in i?gi(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,$=(i,t,e)=>Pi(i,typeof t!="symbol"?t+"":t,e);class wi{constructor(t){$(this,"name","cip34"),$(this,"client"),$(this,"httpProviders"),$(this,"events"),$(this,"namespace"),$(this,"chainId"),this.namespace=t.namespace,this.events=h("events"),this.client=h("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){this.httpProviders[t]||this.setHttpProvider(t,e),this.chainId=t,this.events.emit(v.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{const s=this.getCardanoRPCUrl(e),n=C(e);t[n]=this.createHttpProvider(n,s)}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}getCardanoRPCUrl(t){const e=this.namespace.rpcMap;if(e)return e[t]}setHttpProvider(t,e){const s=this.createHttpProvider(t,e);s&&(this.httpProviders[t]=s)}createHttpProvider(t,e){const s=e||this.getCardanoRPCUrl(t);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new g(new P(s,h("disableProviderPing")))}}var bi=Object.defineProperty,yi=(i,t,e)=>t in i?bi(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,A=(i,t,e)=>yi(i,typeof t!="symbol"?t+"":t,e);class Ci{constructor(t){A(this,"name","elrond"),A(this,"client"),A(this,"httpProviders"),A(this,"events"),A(this,"namespace"),A(this,"chainId"),this.namespace=t.namespace,this.events=h("events"),this.client=h("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){this.httpProviders[t]||this.setHttpProvider(t,e),this.chainId=t,this.events.emit(v.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{var s;const n=C(e);t[n]=this.createHttpProvider(n,(s=this.namespace.rpcMap)==null?void 0:s[e])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const s=this.createHttpProvider(t,e);s&&(this.httpProviders[t]=s)}createHttpProvider(t,e){const s=e||f(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new g(new P(s,h("disableProviderPing")))}}var Ii=Object.defineProperty,Oi=(i,t,e)=>t in i?Ii(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,E=(i,t,e)=>Oi(i,typeof t!="symbol"?t+"":t,e);class ji{constructor(t){E(this,"name","multiversx"),E(this,"client"),E(this,"httpProviders"),E(this,"events"),E(this,"namespace"),E(this,"chainId"),this.namespace=t.namespace,this.events=h("events"),this.client=h("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){this.httpProviders[t]||this.setHttpProvider(t,e),this.chainId=t,this.events.emit(v.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{var s;const n=C(e);t[n]=this.createHttpProvider(n,(s=this.namespace.rpcMap)==null?void 0:s[e])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const s=this.createHttpProvider(t,e);s&&(this.httpProviders[t]=s)}createHttpProvider(t,e){const s=e||f(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new g(new P(s,h("disableProviderPing")))}}var Hi=Object.defineProperty,$i=(i,t,e)=>t in i?Hi(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,S=(i,t,e)=>$i(i,typeof t!="symbol"?t+"":t,e);class Ai{constructor(t){S(this,"name","near"),S(this,"client"),S(this,"httpProviders"),S(this,"events"),S(this,"namespace"),S(this,"chainId"),this.namespace=t.namespace,this.events=h("events"),this.client=h("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){if(this.chainId=t,!this.httpProviders[t]){const s=e||f(`${this.name}:${t}`,this.namespace);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);this.setHttpProvider(t,s)}this.events.emit(v.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const t=this.namespace.accounts;return t?t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2])||[]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{var s;t[e]=this.createHttpProvider(e,(s=this.namespace.rpcMap)==null?void 0:s[e])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const s=this.createHttpProvider(t,e);s&&(this.httpProviders[t]=s)}createHttpProvider(t,e){const s=e||f(t,this.namespace);return typeof s>"u"?void 0:new g(new P(s,h("disableProviderPing")))}}var Ei=Object.defineProperty,Si=(i,t,e)=>t in i?Ei(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,q=(i,t,e)=>Si(i,typeof t!="symbol"?t+"":t,e);class qi{constructor(t){q(this,"name","tezos"),q(this,"client"),q(this,"httpProviders"),q(this,"events"),q(this,"namespace"),q(this,"chainId"),this.namespace=t.namespace,this.events=h("events"),this.client=h("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){if(this.chainId=t,!this.httpProviders[t]){const s=e||f(`${this.name}:${t}`,this.namespace);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);this.setHttpProvider(t,s)}this.events.emit(v.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const t=this.namespace.accounts;return t?t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2])||[]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{t[e]=this.createHttpProvider(e)}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const s=this.createHttpProvider(t,e);s&&(this.httpProviders[t]=s)}createHttpProvider(t,e){const s=e||f(t,this.namespace);return typeof s>"u"?void 0:new g(new P(s))}}var Ni=Object.defineProperty,Di=(i,t,e)=>t in i?Ni(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,N=(i,t,e)=>Di(i,typeof t!="symbol"?t+"":t,e);class _i{constructor(t){N(this,"name",St),N(this,"client"),N(this,"httpProviders"),N(this,"events"),N(this,"namespace"),N(this,"chainId"),this.namespace=t.namespace,this.events=h("events"),this.client=h("client"),this.chainId=this.getDefaultChain(),this.name=this.getNamespaceName(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace.chains=[...new Set((this.namespace.chains||[]).concat(t.chains||[]))],this.namespace.accounts=[...new Set((this.namespace.accounts||[]).concat(t.accounts||[]))],this.namespace.methods=[...new Set((this.namespace.methods||[]).concat(t.methods||[]))],this.namespace.events=[...new Set((this.namespace.events||[]).concat(t.events||[]))],this.httpProviders=this.createHttpProviders()}requestAccounts(){return this.getAccounts()}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider(t.chainId).request(t.request)}setDefaultChain(t,e){this.httpProviders[t]||this.setHttpProvider(t,e),this.chainId=t,this.events.emit(v.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}getNamespaceName(){const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return M(t).namespace}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){var t,e;const s={};return(e=(t=this.namespace)==null?void 0:t.accounts)==null||e.forEach(n=>{const a=M(n);s[a.reference]=this.createHttpProvider(n)}),s}getHttpProvider(t){const e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const s=this.createHttpProvider(t,e);s&&(this.httpProviders[t]=s)}createHttpProvider(t,e){const s=e||f(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new g(new P(s,h("disableProviderPing")))}}var Fi=Object.defineProperty,Ri=Object.defineProperties,xi=Object.getOwnPropertyDescriptors,jt=Object.getOwnPropertySymbols,Ui=Object.prototype.hasOwnProperty,ki=Object.prototype.propertyIsEnumerable,tt=(i,t,e)=>t in i?Fi(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,T=(i,t)=>{for(var e in t||(t={}))Ui.call(t,e)&&tt(i,e,t[e]);if(jt)for(var e of jt(t))ki.call(t,e)&&tt(i,e,t[e]);return i},Q=(i,t)=>Ri(i,xi(t)),m=(i,t,e)=>tt(i,typeof t!="symbol"?t+"":t,e);class rt{constructor(t){m(this,"client"),m(this,"namespaces"),m(this,"optionalNamespaces"),m(this,"sessionProperties"),m(this,"scopedProperties"),m(this,"events",new Jt),m(this,"rpcProviders",{}),m(this,"session"),m(this,"providerOpts"),m(this,"logger"),m(this,"uri"),m(this,"disableProviderPing",!1),this.providerOpts=t,this.logger=typeof t?.logger<"u"&&typeof t?.logger!="string"?t.logger:Mt(Bt({level:t?.logger||ot})),this.disableProviderPing=t?.disableProviderPing||!1}static async init(t){const e=new rt(t);return await e.initialize(),e}async request(t,e,s){const[n,a]=this.validateChain(e);if(!this.session)throw new Error("Please call connect() before request()");return await this.getProvider(n).request({request:T({},t),chainId:`${n}:${a}`,topic:this.session.topic,expiry:s})}sendAsync(t,e,s,n){const a=new Date().getTime();this.request(t,s,n).then(r=>e(null,Lt(a,r))).catch(r=>e(r,void 0))}async enable(){if(!this.client)throw new Error("Sign Client not initialized");return this.session||await this.connect({namespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties,scopedProperties:this.scopedProperties}),await this.requestAccounts()}async disconnect(){var t;if(!this.session)throw new Error("Please call connect() before enable()");await this.client.disconnect({topic:(t=this.session)==null?void 0:t.topic,reason:at("USER_DISCONNECTED")}),await this.cleanup()}async connect(t){if(!this.client)throw new Error("Sign Client not initialized");if(this.setNamespaces(t),this.cleanupPendingPairings(),!t.skipPairing)return await this.pair(t.pairingTopic)}async authenticate(t,e){if(!this.client)throw new Error("Sign Client not initialized");this.setNamespaces(t),await this.cleanupPendingPairings();const{uri:s,response:n}=await this.client.authenticate(t,e);s&&(this.uri=s,this.events.emit("display_uri",s));const a=await n();if(this.session=a.session,this.session){const r=vt(this.session.namespaces);this.namespaces=k(this.namespaces,r),await this.persist("namespaces",this.namespaces),this.onConnect()}return a}on(t,e){this.events.on(t,e)}once(t,e){this.events.once(t,e)}removeListener(t,e){this.events.removeListener(t,e)}off(t,e){this.events.off(t,e)}get isWalletConnect(){return!0}async pair(t){const{uri:e,approval:s}=await this.client.connect({pairingTopic:t,requiredNamespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties,scopedProperties:this.scopedProperties});e&&(this.uri=e,this.events.emit("display_uri",e));const n=await s();this.session=n;const a=vt(n.namespaces);return this.namespaces=k(this.namespaces,a),await this.persist("namespaces",this.namespaces),await this.persist("optionalNamespaces",this.optionalNamespaces),this.onConnect(),this.session}setDefaultChain(t,e){try{if(!this.session)return;const[s,n]=this.validateChain(t);this.getProvider(s).setDefaultChain(n,e)}catch(s){if(!/Please call connect/.test(s.message))throw s}}async cleanupPendingPairings(t={}){try{this.logger.info("Cleaning up inactive pairings...");const e=this.client.pairing.getAll();if(!L(e))return;for(const s of e)t.deletePairings?this.client.core.expirer.set(s.topic,0):await this.client.core.relayer.subscriber.unsubscribe(s.topic);this.logger.info(`Inactive pairings cleared: ${e.length}`)}catch(e){this.logger.warn("Failed to cleanup pending pairings",e)}}abortPairingAttempt(){this.logger.warn("abortPairingAttempt is deprecated. This is now a no-op.")}async checkStorage(){this.namespaces=await this.getFromStore("namespaces")||{},this.optionalNamespaces=await this.getFromStore("optionalNamespaces")||{},this.session&&this.createProviders()}async initialize(){this.logger.trace("Initialized"),await this.createClient(),await this.checkStorage(),this.registerEventListeners()}async createClient(){var t,e;if(this.client=this.providerOpts.client||await kt.init({core:this.providerOpts.core,logger:this.providerOpts.logger||ot,relayUrl:this.providerOpts.relayUrl||zt,projectId:this.providerOpts.projectId,metadata:this.providerOpts.metadata,storageOptions:this.providerOpts.storageOptions,storage:this.providerOpts.storage,name:this.providerOpts.name,customStoragePrefix:this.providerOpts.customStoragePrefix,telemetryEnabled:this.providerOpts.telemetryEnabled}),this.providerOpts.session)try{this.session=this.client.session.get(this.providerOpts.session.topic)}catch(s){throw this.logger.error("Failed to get session",s),new Error(`The provided session: ${(e=(t=this.providerOpts)==null?void 0:t.session)==null?void 0:e.topic} doesn't exist in the Sign client`)}else{const s=this.client.session.getAll();this.session=s[0]}this.logger.trace("SignClient Initialized")}createProviders(){if(!this.client)throw new Error("Sign Client not initialized");if(!this.session)throw new Error("Session not initialized. Please call connect() before enable()");const t=[...new Set(Object.keys(this.session.namespaces).map(e=>F(e)))];G("client",this.client),G("events",this.events),G("disableProviderPing",this.disableProviderPing),t.forEach(e=>{if(!this.session)return;const s=Ee(e,this.session);if(s?.length===0)return;const n=xt(s),a=k(this.namespaces,this.optionalNamespaces),r=Q(T({},a[e]),{accounts:s,chains:n});switch(e){case"eip155":this.rpcProviders[e]=new oi({namespace:r});break;case"algorand":this.rpcProviders[e]=new vi({namespace:r});break;case"solana":this.rpcProviders[e]=new pi({namespace:r});break;case"cosmos":this.rpcProviders[e]=new di({namespace:r});break;case"polkadot":this.rpcProviders[e]=new ei({namespace:r});break;case"cip34":this.rpcProviders[e]=new wi({namespace:r});break;case"elrond":this.rpcProviders[e]=new Ci({namespace:r});break;case"multiversx":this.rpcProviders[e]=new ji({namespace:r});break;case"near":this.rpcProviders[e]=new Ai({namespace:r});break;case"tezos":this.rpcProviders[e]=new qi({namespace:r});break;default:this.rpcProviders[e]=new _i({namespace:r})}})}registerEventListeners(){if(typeof this.client>"u")throw new Error("Sign Client is not initialized");this.client.on("session_ping",t=>{var e;const{topic:s}=t;s===((e=this.session)==null?void 0:e.topic)&&this.events.emit("session_ping",t)}),this.client.on("session_event",t=>{var e;const{params:s,topic:n}=t;if(n!==((e=this.session)==null?void 0:e.topic))return;const{event:a}=s;if(a.name==="accountsChanged"){const r=a.data;r&&L(r)&&this.events.emit("accountsChanged",r.map(mt))}else if(a.name==="chainChanged"){const r=s.chainId,o=s.event.data,c=F(r),u=z(r)!==z(o)?`${c}:${z(o)}`:r;this.onChainChanged(u)}else this.events.emit(a.name,a.data);this.events.emit("session_event",t)}),this.client.on("session_update",({topic:t,params:e})=>{var s,n;if(t!==((s=this.session)==null?void 0:s.topic))return;const{namespaces:a}=e,r=(n=this.client)==null?void 0:n.session.get(t);this.session=Q(T({},r),{namespaces:a}),this.onSessionUpdate(),this.events.emit("session_update",{topic:t,params:e})}),this.client.on("session_delete",async t=>{var e;t.topic===((e=this.session)==null?void 0:e.topic)&&(await this.cleanup(),this.events.emit("session_delete",t),this.events.emit("disconnect",Q(T({},at("USER_DISCONNECTED")),{data:t.topic})))}),this.on(v.DEFAULT_CHAIN_CHANGED,t=>{this.onChainChanged(t,!0)})}getProvider(t){return this.rpcProviders[t]||this.rpcProviders[St]}onSessionUpdate(){Object.keys(this.rpcProviders).forEach(t=>{var e;this.getProvider(t).updateNamespace((e=this.session)==null?void 0:e.namespaces[t])})}setNamespaces(t){const{namespaces:e={},optionalNamespaces:s={},sessionProperties:n,scopedProperties:a}=t;this.optionalNamespaces=k(e,s),this.sessionProperties=n,this.scopedProperties=a}validateChain(t){const[e,s]=t?.split(":")||["",""];if(!this.namespaces||!Object.keys(this.namespaces).length)return[e,s];if(e&&!Object.keys(this.namespaces||{}).map(r=>F(r)).includes(e))throw new Error(`Namespace '${e}' is not configured. Please call connect() first with namespace config.`);if(e&&s)return[e,s];const n=F(Object.keys(this.namespaces)[0]),a=this.rpcProviders[n].getDefaultChain();return[n,a]}async requestAccounts(){const[t]=this.validateChain();return await this.getProvider(t).requestAccounts()}async onChainChanged(t,e=!1){if(!this.namespaces)return;const[s,n]=this.validateChain(t);if(!n)return;this.updateNamespaceChain(s,n);const a=this.getProvider(s).getDefaultChain();e?(this.events.emit("chainChanged",n),this.emitAccountsChangedOnChainChange({namespace:s,previousChainId:a,newChainId:t})):this.getProvider(s).setDefaultChain(n),await this.persist("namespaces",this.namespaces)}emitAccountsChangedOnChainChange({namespace:t,previousChainId:e,newChainId:s}){var n,a;try{if(e===s)return;const r=(a=(n=this.session)==null?void 0:n.namespaces[t])==null?void 0:a.accounts;if(!r)return;const o=r.filter(c=>c.includes(`${s}:`)).map(mt);if(!L(o))return;this.events.emit("accountsChanged",o)}catch(r){this.logger.warn("Failed to emit accountsChanged on chain change",r)}}updateNamespaceChain(t,e){if(!this.namespaces)return;const s=this.namespaces[t]?t:`${t}:${e}`,n={chains:[],methods:[],events:[],defaultChain:e};this.namespaces[s]?this.namespaces[s]&&(this.namespaces[s].defaultChain=e):this.namespaces[s]=n}onConnect(){this.createProviders(),this.events.emit("connect",{session:this.session})}async cleanup(){this.namespaces=void 0,this.optionalNamespaces=void 0,this.sessionProperties=void 0,await this.deleteFromStore("namespaces"),await this.deleteFromStore("optionalNamespaces"),await this.deleteFromStore("sessionProperties"),this.session=void 0,this.cleanupPendingPairings({deletePairings:!0}),await this.cleanupStorage()}async persist(t,e){var s;const n=((s=this.session)==null?void 0:s.topic)||"";await this.client.core.storage.setItem(`${x}/${t}${n}`,e)}async getFromStore(t){var e;const s=((e=this.session)==null?void 0:e.topic)||"";return await this.client.core.storage.getItem(`${x}/${t}${s}`)}async deleteFromStore(t){var e;const s=((e=this.session)==null?void 0:e.topic)||"";await this.client.core.storage.removeItem(`${x}/${t}${s}`)}async cleanupStorage(){var t;try{if(((t=this.client)==null?void 0:t.session.length)>0)return;const e=await this.client.core.storage.getKeys();for(const s of e)s.startsWith(x)&&await this.client.core.storage.removeItem(s)}catch(e){this.logger.warn("Failed to cleanup storage",e)}}}const Ji=rt;export{Ji as UniversalProvider,rt as default};
|
|
1
|
+
import{K as at,q as L,t as kt,Y as F,P as Ht,F as M,V as R,u as J,v as $t,w as Tt}from"./wallets-vcnqEomN.js";import{O as Mt,k as Bt,f as Lt,o as g,a as At}from"./index.es-D3pP9hN4.js";import{f as P}from"./index.es-D5YKsq2-.js";import{N as Jt}from"./events-B5inrCVE.js";const ot="error",zt="wss://relay.walletconnect.org",Gt="wc",Vt="universal_provider",x=`${Gt}@2:${Vt}:`,Et="https://rpc.walletconnect.org/v1/",St="generic",Kt=`${Et}bundler`,_="call_status",Wt=86400,v={DEFAULT_CHAIN_CHANGED:"default_chain_changed"};function et(i){return i==null||typeof i!="object"&&typeof i!="function"}function qt(i){return Object.getOwnPropertySymbols(i).filter(t=>Object.prototype.propertyIsEnumerable.call(i,t))}function Nt(i){return i==null?i===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(i)}const Yt="[object RegExp]",Dt="[object String]",_t="[object Number]",Ft="[object Boolean]",Rt="[object Arguments]",Qt="[object Symbol]",Xt="[object Date]",Zt="[object Map]",te="[object Set]",ee="[object Array]",ie="[object ArrayBuffer]",se="[object Object]",re="[object DataView]",ne="[object Uint8Array]",ae="[object Uint8ClampedArray]",oe="[object Uint16Array]",ce="[object Uint32Array]",he="[object Int8Array]",pe="[object Int16Array]",ue="[object Int32Array]",le="[object Float32Array]",de="[object Float64Array]";function it(i){return ArrayBuffer.isView(i)&&!(i instanceof DataView)}function fe(i,t){return D(i,void 0,i,new Map,t)}function D(i,t,e,s=new Map,n=void 0){const a=n?.(i,t,e,s);if(a!=null)return a;if(et(i))return i;if(s.has(i))return s.get(i);if(Array.isArray(i)){const r=new Array(i.length);s.set(i,r);for(let o=0;o<i.length;o++)r[o]=D(i[o],o,e,s,n);return Object.hasOwn(i,"index")&&(r.index=i.index),Object.hasOwn(i,"input")&&(r.input=i.input),r}if(i instanceof Date)return new Date(i.getTime());if(i instanceof RegExp){const r=new RegExp(i.source,i.flags);return r.lastIndex=i.lastIndex,r}if(i instanceof Map){const r=new Map;s.set(i,r);for(const[o,c]of i)r.set(o,D(c,o,e,s,n));return r}if(i instanceof Set){const r=new Set;s.set(i,r);for(const o of i)r.add(D(o,void 0,e,s,n));return r}if(typeof Buffer<"u"&&Buffer.isBuffer(i))return i.subarray();if(it(i)){const r=new(Object.getPrototypeOf(i)).constructor(i.length);s.set(i,r);for(let o=0;o<i.length;o++)r[o]=D(i[o],o,e,s,n);return r}if(i instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&i instanceof SharedArrayBuffer)return i.slice(0);if(i instanceof DataView){const r=new DataView(i.buffer.slice(0),i.byteOffset,i.byteLength);return s.set(i,r),y(r,i,e,s,n),r}if(typeof File<"u"&&i instanceof File){const r=new File([i],i.name,{type:i.type});return s.set(i,r),y(r,i,e,s,n),r}if(i instanceof Blob){const r=new Blob([i],{type:i.type});return s.set(i,r),y(r,i,e,s,n),r}if(i instanceof Error){const r=new i.constructor;return s.set(i,r),r.message=i.message,r.name=i.name,r.stack=i.stack,r.cause=i.cause,y(r,i,e,s,n),r}if(typeof i=="object"&&me(i)){const r=Object.create(Object.getPrototypeOf(i));return s.set(i,r),y(r,i,e,s,n),r}return i}function y(i,t,e=i,s,n){const a=[...Object.keys(t),...qt(t)];for(let r=0;r<a.length;r++){const o=a[r],c=Object.getOwnPropertyDescriptor(i,o);(c==null||c.writable)&&(i[o]=D(t[o],o,e,s,n))}}function me(i){switch(Nt(i)){case Rt:case ee:case ie:case re:case Ft:case Xt:case le:case de:case he:case pe:case ue:case Zt:case _t:case se:case Yt:case te:case Dt:case Qt:case ne:case ae:case oe:case ce:return!0;default:return!1}}function ve(i,t){return fe(i,(e,s,n,a)=>{if(typeof i=="object")switch(Object.prototype.toString.call(i)){case _t:case Dt:case Ft:{const r=new i.constructor(i?.valueOf());return y(r,i),r}case Rt:{const r={};return y(r,i),r.length=i.length,r[Symbol.iterator]=i[Symbol.iterator],r}default:return}})}function ct(i){return ve(i)}function ht(i){return i!==null&&typeof i=="object"&&Nt(i)==="[object Arguments]"}function pt(i){return typeof i=="object"&&i!==null}function ge(){}function Pe(i){return it(i)}function we(i){if(typeof i!="object"||i==null)return!1;if(Object.getPrototypeOf(i)===null)return!0;if(Object.prototype.toString.call(i)!=="[object Object]"){const e=i[Symbol.toStringTag];return e==null||!Object.getOwnPropertyDescriptor(i,Symbol.toStringTag)?.writable?!1:i.toString()===`[object ${e}]`}let t=i;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(i)===t}function be(i){if(et(i))return i;if(Array.isArray(i)||it(i)||i instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&i instanceof SharedArrayBuffer)return i.slice(0);const t=Object.getPrototypeOf(i),e=t.constructor;if(i instanceof Date||i instanceof Map||i instanceof Set)return new e(i);if(i instanceof RegExp){const s=new e(i);return s.lastIndex=i.lastIndex,s}if(i instanceof DataView)return new e(i.buffer.slice(0));if(i instanceof Error){const s=new e(i.message);return s.stack=i.stack,s.name=i.name,s.cause=i.cause,s}if(typeof File<"u"&&i instanceof File)return new e([i],i.name,{type:i.type,lastModified:i.lastModified});if(typeof i=="object"){const s=Object.create(t);return Object.assign(s,i)}return i}function ye(i,...t){const e=t.slice(0,-1),s=t[t.length-1];let n=i;for(let a=0;a<e.length;a++){const r=e[a];n=X(n,r,s,new Map)}return n}function X(i,t,e,s){if(et(i)&&(i=Object(i)),t==null||typeof t!="object")return i;if(s.has(t))return be(s.get(t));if(s.set(t,i),Array.isArray(t)){t=t.slice();for(let a=0;a<t.length;a++)t[a]=t[a]??void 0}const n=[...Object.keys(t),...qt(t)];for(let a=0;a<n.length;a++){const r=n[a];let o=t[r],c=i[r];if(ht(o)&&(o={...o}),ht(c)&&(c={...c}),typeof Buffer<"u"&&Buffer.isBuffer(o)&&(o=ct(o)),Array.isArray(o))if(typeof c=="object"&&c!=null){const l=[],p=Reflect.ownKeys(c);for(let w=0;w<p.length;w++){const d=p[w];l[d]=c[d]}c=l}else c=[];const u=e(c,o,r,i,t,s);u!=null?i[r]=u:Array.isArray(o)||pt(c)&&pt(o)?i[r]=X(c,o,e,s):c==null&&we(o)?i[r]=X({},o,e,s):c==null&&Pe(o)?i[r]=ct(o):(c===void 0||o!==void 0)&&(i[r]=o)}return i}function Ce(i,...t){return ye(i,...t,ge)}var Ie=Object.defineProperty,Oe=Object.defineProperties,je=Object.getOwnPropertyDescriptors,ut=Object.getOwnPropertySymbols,He=Object.prototype.hasOwnProperty,$e=Object.prototype.propertyIsEnumerable,lt=(i,t,e)=>t in i?Ie(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,U=(i,t)=>{for(var e in t||(t={}))He.call(t,e)&<(i,e,t[e]);if(ut)for(var e of ut(t))$e.call(t,e)&<(i,e,t[e]);return i},Ae=(i,t)=>Oe(i,je(t));function f(i,t,e){var s;const n=M(i);return((s=t.rpcMap)==null?void 0:s[n.reference])||`${Et}?chainId=${n.namespace}:${n.reference}&projectId=${e}`}function C(i){return i.includes(":")?i.split(":")[1]:i}function xt(i){return i.map(t=>`${t.split(":")[0]}:${t.split(":")[1]}`)}function Ee(i,t){const e=Object.keys(t.namespaces).filter(n=>n.includes(i));if(!e.length)return[];const s=[];return e.forEach(n=>{const a=t.namespaces[n].accounts;s.push(...a)}),s}function dt(i){return Object.fromEntries(Object.entries(i).filter(([t,e])=>{var s,n;return((s=e?.chains)==null?void 0:s.length)&&((n=e?.chains)==null?void 0:n.length)>0}))}function k(i={},t={}){const e=dt(ft(i)),s=dt(ft(t));return Ce(e,s)}function ft(i){var t,e,s,n,a;const r={};if(!R(i))return r;for(const[o,c]of Object.entries(i)){const u=Ht(o)?[o]:c.chains,l=c.methods||[],p=c.events||[],w=c.rpcMap||{},d=F(o);r[d]=Ae(U(U({},r[d]),c),{chains:J(u,(t=r[d])==null?void 0:t.chains),methods:J(l,(e=r[d])==null?void 0:e.methods),events:J(p,(s=r[d])==null?void 0:s.events)}),(R(w)||R(((n=r[d])==null?void 0:n.rpcMap)||{}))&&(r[d].rpcMap=U(U({},w),(a=r[d])==null?void 0:a.rpcMap))}return r}function mt(i){return i.includes(":")?i.split(":")[2]:i}function vt(i){const t={};for(const[e,s]of Object.entries(i)){const n=s.methods||[],a=s.events||[],r=s.accounts||[],o=Ht(e)?[e]:s.chains?s.chains:xt(s.accounts);t[e]={chains:o,methods:n,events:a,accounts:r}}return t}function z(i){return typeof i=="number"?i:i.includes("0x")?parseInt(i,16):(i=i.includes(":")?i.split(":")[1]:i,isNaN(Number(i))?i:Number(i))}function Se(i){try{const t=JSON.parse(i);return typeof t=="object"&&t!==null&&!Array.isArray(t)}catch{return!1}}const Ut={},h=i=>Ut[i],G=(i,t)=>{Ut[i]=t};var qe=Object.defineProperty,gt=Object.getOwnPropertySymbols,Ne=Object.prototype.hasOwnProperty,De=Object.prototype.propertyIsEnumerable,Pt=(i,t,e)=>t in i?qe(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,wt=(i,t)=>{for(var e in t||(t={}))Ne.call(t,e)&&Pt(i,e,t[e]);if(gt)for(var e of gt(t))De.call(t,e)&&Pt(i,e,t[e]);return i};const bt="eip155",_e=["atomic","flow-control","paymasterService","sessionKeys","auxiliaryFunds"],Fe=i=>i&&i.startsWith("0x")?BigInt(i).toString(10):i,V=i=>i&&i.startsWith("0x")?i:`0x${BigInt(i).toString(16)}`,yt=i=>Object.keys(i).filter(t=>_e.includes(t)).reduce((t,e)=>(t[e]=Re(i[e]),t),{}),Re=i=>typeof i=="string"&&Se(i)?JSON.parse(i):i,xe=(i,t,e)=>{const{sessionProperties:s={},scopedProperties:n={}}=i,a={};if(!R(n)&&!R(s))return;const r=yt(s);for(const o of e){const c=Fe(o);if(!c)continue;a[V(c)]=r;const u=n?.[`${bt}:${c}`];if(u){const l=u?.[`${bt}:${c}:${t}`];a[V(c)]=wt(wt({},a[V(c)]),yt(l||u))}}for(const[o,c]of Object.entries(a))Object.keys(c).length===0&&delete a[o];return Object.keys(a).length>0?a:void 0};var Ue=Object.defineProperty,ke=(i,t,e)=>t in i?Ue(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,Te=(i,t,e)=>ke(i,t+"",e);let K;class st{constructor(t){Te(this,"storage"),this.storage=t}async getItem(t){return await this.storage.getItem(t)}async setItem(t,e){return await this.storage.setItem(t,e)}async removeItem(t){return await this.storage.removeItem(t)}static getStorage(t){return K||(K=new st(t)),K}}var Me=Object.defineProperty,Be=Object.defineProperties,Le=Object.getOwnPropertyDescriptors,Ct=Object.getOwnPropertySymbols,Je=Object.prototype.hasOwnProperty,ze=Object.prototype.propertyIsEnumerable,It=(i,t,e)=>t in i?Me(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,Ge=(i,t)=>{for(var e in t||(t={}))Je.call(t,e)&&It(i,e,t[e]);if(Ct)for(var e of Ct(t))ze.call(t,e)&&It(i,e,t[e]);return i},Ve=(i,t)=>Be(i,Le(t));async function Ke(i,t){const e=M(i.result.capabilities.caip345.caip2),s=i.result.capabilities.caip345.transactionHashes,n=await Promise.allSettled(s.map(p=>We(e.reference,p,t))),a=n.filter(p=>p.status==="fulfilled").map(p=>p.value).filter(p=>p);n.filter(p=>p.status==="rejected").forEach(p=>console.warn("Failed to fetch transaction receipt:",p.reason));const r=!a.length||a.some(p=>!p),o=a.every(p=>p?.status==="0x1"),c=a.every(p=>p?.status==="0x0"),u=a.some(p=>p?.status==="0x0");let l;return r?l=100:o?l=200:c?l=500:u&&(l=600),{id:i.result.id,version:i.request.version,atomic:i.request.atomicRequired,chainId:i.request.chainId,capabilities:i.result.capabilities,receipts:a,status:l}}async function We(i,t,e){return await e(parseInt(i)).request(At("eth_getTransactionReceipt",[t]))}async function Ye({sendCalls:i,storage:t}){const e=await t.getItem(_);await t.setItem(_,Ve(Ge({},e),{[i.result.id]:{request:i.request,result:i.result,expiry:Tt(Wt)}}))}async function Qe({resultId:i,storage:t}){const e=await t.getItem(_);if(e){delete e[i],await t.setItem(_,e);for(const s in e)$t(e[s].expiry)&&delete e[s];await t.setItem(_,e)}}async function Xe({resultId:i,storage:t}){const e=await t.getItem(_),s=e?.[i];if(s&&!$t(s.expiry))return s;await Qe({resultId:i,storage:t})}var Ze=Object.defineProperty,ti=(i,t,e)=>t in i?Ze(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,I=(i,t,e)=>ti(i,typeof t!="symbol"?t+"":t,e);class ei{constructor(t){I(this,"name","polkadot"),I(this,"client"),I(this,"httpProviders"),I(this,"events"),I(this,"namespace"),I(this,"chainId"),this.namespace=t.namespace,this.events=h("events"),this.client=h("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){this.httpProviders[t]||this.setHttpProvider(t,e),this.chainId=t,this.events.emit(v.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`)}getAccounts(){const t=this.namespace.accounts;return t?t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2])||[]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{var s;const n=C(e);t[n]=this.createHttpProvider(n,(s=this.namespace.rpcMap)==null?void 0:s[e])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const s=this.createHttpProvider(t,e);s&&(this.httpProviders[t]=s)}createHttpProvider(t,e){const s=e||f(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new g(new P(s,h("disableProviderPing")))}}var ii=Object.defineProperty,si=Object.defineProperties,ri=Object.getOwnPropertyDescriptors,Ot=Object.getOwnPropertySymbols,ni=Object.prototype.hasOwnProperty,ai=Object.prototype.propertyIsEnumerable,Z=(i,t,e)=>t in i?ii(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,W=(i,t)=>{for(var e in t||(t={}))ni.call(t,e)&&Z(i,e,t[e]);if(Ot)for(var e of Ot(t))ai.call(t,e)&&Z(i,e,t[e]);return i},Y=(i,t)=>si(i,ri(t)),b=(i,t,e)=>Z(i,typeof t!="symbol"?t+"":t,e);class oi{constructor(t){b(this,"name","eip155"),b(this,"client"),b(this,"chainId"),b(this,"namespace"),b(this,"httpProviders"),b(this,"events"),b(this,"storage"),this.namespace=t.namespace,this.events=h("events"),this.client=h("client"),this.httpProviders=this.createHttpProviders(),this.chainId=parseInt(this.getDefaultChain()),this.storage=st.getStorage(this.client.core.storage)}async request(t){switch(t.request.method){case"eth_requestAccounts":return this.getAccounts();case"eth_accounts":return this.getAccounts();case"wallet_switchEthereumChain":return await this.handleSwitchChain(t);case"eth_chainId":return parseInt(this.getDefaultChain());case"wallet_getCapabilities":return await this.getCapabilities(t);case"wallet_getCallsStatus":return await this.getCallStatus(t);case"wallet_sendCalls":return await this.sendCalls(t)}return this.namespace.methods.includes(t.request.method)?await this.client.request(t):this.getHttpProvider().request(t.request)}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}setDefaultChain(t,e){this.httpProviders[t]||this.setHttpProvider(parseInt(t),e),this.chainId=parseInt(t),this.events.emit(v.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId.toString();if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}createHttpProvider(t,e){const s=e||f(`${this.name}:${t}`,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new g(new P(s,h("disableProviderPing")))}setHttpProvider(t,e){const s=this.createHttpProvider(t,e);s&&(this.httpProviders[t]=s)}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{var s;const n=parseInt(C(e));t[n]=this.createHttpProvider(n,(s=this.namespace.rpcMap)==null?void 0:s[e])}),t}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}getHttpProvider(t){const e=t||this.chainId;return this.httpProviders[e]||(this.httpProviders=Y(W({},this.httpProviders),{[e]:this.createHttpProvider(e)}),this.httpProviders[e])}async handleSwitchChain(t){var e,s;let n=t.request.params?(e=t.request.params[0])==null?void 0:e.chainId:"0x0";n=n.startsWith("0x")?n:`0x${n}`;const a=parseInt(n,16);if(this.isChainApproved(a))this.setDefaultChain(`${a}`);else if(this.namespace.methods.includes("wallet_switchEthereumChain"))await this.client.request({topic:t.topic,request:{method:t.request.method,params:[{chainId:n}]},chainId:(s=this.namespace.chains)==null?void 0:s[0]}),this.setDefaultChain(`${a}`);else throw new Error(`Failed to switch to chain 'eip155:${a}'. The chain is not approved or the wallet does not support 'wallet_switchEthereumChain' method.`);return null}isChainApproved(t){return this.namespace.chains.includes(`${this.name}:${t}`)}async getCapabilities(t){var e,s,n,a,r;const o=(s=(e=t.request)==null?void 0:e.params)==null?void 0:s[0],c=((a=(n=t.request)==null?void 0:n.params)==null?void 0:a[1])||[];if(!o)throw new Error("Missing address parameter in `wallet_getCapabilities` request");const u=this.client.session.get(t.topic),l=((r=u?.sessionProperties)==null?void 0:r.capabilities)||{},p=`${o}${c.join(",")}`,w=l?.[p];if(w)return w;let d;try{d=xe(u,o,c)}catch(B){console.warn("Failed to extract capabilities from session",B)}if(d)return d;const nt=await this.client.request(t);try{await this.client.session.update(t.topic,{sessionProperties:Y(W({},u.sessionProperties||{}),{capabilities:Y(W({},l||{}),{[p]:nt})})})}catch(B){console.warn("Failed to update session with capabilities",B)}return nt}async getCallStatus(t){var e,s,n;const a=this.client.session.get(t.topic),r=(e=a.sessionProperties)==null?void 0:e.bundler_name;if(r){const u=this.getBundlerUrl(t.chainId,r);try{return await this.getUserOperationReceipt(u,t)}catch(l){console.warn("Failed to fetch call status from bundler",l,u)}}const o=(s=a.sessionProperties)==null?void 0:s.bundler_url;if(o)try{return await this.getUserOperationReceipt(o,t)}catch(u){console.warn("Failed to fetch call status from custom bundler",u,o)}const c=await Xe({resultId:(n=t.request.params)==null?void 0:n[0],storage:this.storage});if(c)try{return await Ke(c,this.getHttpProvider.bind(this))}catch(u){console.warn("Failed to fetch call status from stored send calls",u,c)}if(this.namespace.methods.includes(t.request.method))return await this.client.request(t);throw new Error("Fetching call status not approved by the wallet.")}async getUserOperationReceipt(t,e){var s;const n=new URL(t),a=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(At("eth_getUserOperationReceipt",[(s=e.request.params)==null?void 0:s[0]]))});if(!a.ok)throw new Error(`Failed to fetch user operation receipt - ${a.status}`);return await a.json()}getBundlerUrl(t,e){return`${Kt}?projectId=${this.client.core.projectId}&chainId=${t}&bundler=${e}`}async sendCalls(t){var e,s,n;const a=await this.client.request(t),r=(e=t.request.params)==null?void 0:e[0],o=a?.id,c=a?.capabilities||{},u=(s=c?.caip345)==null?void 0:s.caip2,l=(n=c?.caip345)==null?void 0:n.transactionHashes;return!o||!u||!(l!=null&&l.length)||await Ye({sendCalls:{request:r,result:a},storage:this.storage}),a}}var ci=Object.defineProperty,hi=(i,t,e)=>t in i?ci(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,O=(i,t,e)=>hi(i,typeof t!="symbol"?t+"":t,e);class pi{constructor(t){O(this,"name","solana"),O(this,"client"),O(this,"httpProviders"),O(this,"events"),O(this,"namespace"),O(this,"chainId"),this.namespace=t.namespace,this.events=h("events"),this.client=h("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){this.httpProviders[t]||this.setHttpProvider(t,e),this.chainId=t,this.events.emit(v.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{var s;const n=C(e);t[n]=this.createHttpProvider(n,(s=this.namespace.rpcMap)==null?void 0:s[e])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const s=this.createHttpProvider(t,e);s&&(this.httpProviders[t]=s)}createHttpProvider(t,e){const s=e||f(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new g(new P(s,h("disableProviderPing")))}}var ui=Object.defineProperty,li=(i,t,e)=>t in i?ui(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,j=(i,t,e)=>li(i,typeof t!="symbol"?t+"":t,e);class di{constructor(t){j(this,"name","cosmos"),j(this,"client"),j(this,"httpProviders"),j(this,"events"),j(this,"namespace"),j(this,"chainId"),this.namespace=t.namespace,this.events=h("events"),this.client=h("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){this.httpProviders[t]||this.setHttpProvider(t,e),this.chainId=t,this.events.emit(v.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{var s;const n=C(e);t[n]=this.createHttpProvider(n,(s=this.namespace.rpcMap)==null?void 0:s[e])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const s=this.createHttpProvider(t,e);s&&(this.httpProviders[t]=s)}createHttpProvider(t,e){const s=e||f(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new g(new P(s,h("disableProviderPing")))}}var fi=Object.defineProperty,mi=(i,t,e)=>t in i?fi(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,H=(i,t,e)=>mi(i,typeof t!="symbol"?t+"":t,e);class vi{constructor(t){H(this,"name","algorand"),H(this,"client"),H(this,"httpProviders"),H(this,"events"),H(this,"namespace"),H(this,"chainId"),this.namespace=t.namespace,this.events=h("events"),this.client=h("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){if(!this.httpProviders[t]){const s=e||f(`${this.name}:${t}`,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);this.setHttpProvider(t,s)}this.chainId=t,this.events.emit(v.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{var s;t[e]=this.createHttpProvider(e,(s=this.namespace.rpcMap)==null?void 0:s[e])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const s=this.createHttpProvider(t,e);s&&(this.httpProviders[t]=s)}createHttpProvider(t,e){const s=e||f(t,this.namespace,this.client.core.projectId);return typeof s>"u"?void 0:new g(new P(s,h("disableProviderPing")))}}var gi=Object.defineProperty,Pi=(i,t,e)=>t in i?gi(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,$=(i,t,e)=>Pi(i,typeof t!="symbol"?t+"":t,e);class wi{constructor(t){$(this,"name","cip34"),$(this,"client"),$(this,"httpProviders"),$(this,"events"),$(this,"namespace"),$(this,"chainId"),this.namespace=t.namespace,this.events=h("events"),this.client=h("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){this.httpProviders[t]||this.setHttpProvider(t,e),this.chainId=t,this.events.emit(v.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{const s=this.getCardanoRPCUrl(e),n=C(e);t[n]=this.createHttpProvider(n,s)}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}getCardanoRPCUrl(t){const e=this.namespace.rpcMap;if(e)return e[t]}setHttpProvider(t,e){const s=this.createHttpProvider(t,e);s&&(this.httpProviders[t]=s)}createHttpProvider(t,e){const s=e||this.getCardanoRPCUrl(t);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new g(new P(s,h("disableProviderPing")))}}var bi=Object.defineProperty,yi=(i,t,e)=>t in i?bi(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,A=(i,t,e)=>yi(i,typeof t!="symbol"?t+"":t,e);class Ci{constructor(t){A(this,"name","elrond"),A(this,"client"),A(this,"httpProviders"),A(this,"events"),A(this,"namespace"),A(this,"chainId"),this.namespace=t.namespace,this.events=h("events"),this.client=h("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){this.httpProviders[t]||this.setHttpProvider(t,e),this.chainId=t,this.events.emit(v.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{var s;const n=C(e);t[n]=this.createHttpProvider(n,(s=this.namespace.rpcMap)==null?void 0:s[e])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const s=this.createHttpProvider(t,e);s&&(this.httpProviders[t]=s)}createHttpProvider(t,e){const s=e||f(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new g(new P(s,h("disableProviderPing")))}}var Ii=Object.defineProperty,Oi=(i,t,e)=>t in i?Ii(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,E=(i,t,e)=>Oi(i,typeof t!="symbol"?t+"":t,e);class ji{constructor(t){E(this,"name","multiversx"),E(this,"client"),E(this,"httpProviders"),E(this,"events"),E(this,"namespace"),E(this,"chainId"),this.namespace=t.namespace,this.events=h("events"),this.client=h("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){this.httpProviders[t]||this.setHttpProvider(t,e),this.chainId=t,this.events.emit(v.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{var s;const n=C(e);t[n]=this.createHttpProvider(n,(s=this.namespace.rpcMap)==null?void 0:s[e])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const s=this.createHttpProvider(t,e);s&&(this.httpProviders[t]=s)}createHttpProvider(t,e){const s=e||f(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new g(new P(s,h("disableProviderPing")))}}var Hi=Object.defineProperty,$i=(i,t,e)=>t in i?Hi(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,S=(i,t,e)=>$i(i,typeof t!="symbol"?t+"":t,e);class Ai{constructor(t){S(this,"name","near"),S(this,"client"),S(this,"httpProviders"),S(this,"events"),S(this,"namespace"),S(this,"chainId"),this.namespace=t.namespace,this.events=h("events"),this.client=h("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){if(this.chainId=t,!this.httpProviders[t]){const s=e||f(`${this.name}:${t}`,this.namespace);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);this.setHttpProvider(t,s)}this.events.emit(v.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const t=this.namespace.accounts;return t?t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2])||[]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{var s;t[e]=this.createHttpProvider(e,(s=this.namespace.rpcMap)==null?void 0:s[e])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const s=this.createHttpProvider(t,e);s&&(this.httpProviders[t]=s)}createHttpProvider(t,e){const s=e||f(t,this.namespace);return typeof s>"u"?void 0:new g(new P(s,h("disableProviderPing")))}}var Ei=Object.defineProperty,Si=(i,t,e)=>t in i?Ei(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,q=(i,t,e)=>Si(i,typeof t!="symbol"?t+"":t,e);class qi{constructor(t){q(this,"name","tezos"),q(this,"client"),q(this,"httpProviders"),q(this,"events"),q(this,"namespace"),q(this,"chainId"),this.namespace=t.namespace,this.events=h("events"),this.client=h("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){if(this.chainId=t,!this.httpProviders[t]){const s=e||f(`${this.name}:${t}`,this.namespace);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);this.setHttpProvider(t,s)}this.events.emit(v.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const t=this.namespace.accounts;return t?t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2])||[]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{t[e]=this.createHttpProvider(e)}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const s=this.createHttpProvider(t,e);s&&(this.httpProviders[t]=s)}createHttpProvider(t,e){const s=e||f(t,this.namespace);return typeof s>"u"?void 0:new g(new P(s))}}var Ni=Object.defineProperty,Di=(i,t,e)=>t in i?Ni(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,N=(i,t,e)=>Di(i,typeof t!="symbol"?t+"":t,e);class _i{constructor(t){N(this,"name",St),N(this,"client"),N(this,"httpProviders"),N(this,"events"),N(this,"namespace"),N(this,"chainId"),this.namespace=t.namespace,this.events=h("events"),this.client=h("client"),this.chainId=this.getDefaultChain(),this.name=this.getNamespaceName(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace.chains=[...new Set((this.namespace.chains||[]).concat(t.chains||[]))],this.namespace.accounts=[...new Set((this.namespace.accounts||[]).concat(t.accounts||[]))],this.namespace.methods=[...new Set((this.namespace.methods||[]).concat(t.methods||[]))],this.namespace.events=[...new Set((this.namespace.events||[]).concat(t.events||[]))],this.httpProviders=this.createHttpProviders()}requestAccounts(){return this.getAccounts()}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider(t.chainId).request(t.request)}setDefaultChain(t,e){this.httpProviders[t]||this.setHttpProvider(t,e),this.chainId=t,this.events.emit(v.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}getNamespaceName(){const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return M(t).namespace}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){var t,e;const s={};return(e=(t=this.namespace)==null?void 0:t.accounts)==null||e.forEach(n=>{const a=M(n);s[a.reference]=this.createHttpProvider(n)}),s}getHttpProvider(t){const e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const s=this.createHttpProvider(t,e);s&&(this.httpProviders[t]=s)}createHttpProvider(t,e){const s=e||f(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new g(new P(s,h("disableProviderPing")))}}var Fi=Object.defineProperty,Ri=Object.defineProperties,xi=Object.getOwnPropertyDescriptors,jt=Object.getOwnPropertySymbols,Ui=Object.prototype.hasOwnProperty,ki=Object.prototype.propertyIsEnumerable,tt=(i,t,e)=>t in i?Fi(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,T=(i,t)=>{for(var e in t||(t={}))Ui.call(t,e)&&tt(i,e,t[e]);if(jt)for(var e of jt(t))ki.call(t,e)&&tt(i,e,t[e]);return i},Q=(i,t)=>Ri(i,xi(t)),m=(i,t,e)=>tt(i,typeof t!="symbol"?t+"":t,e);class rt{constructor(t){m(this,"client"),m(this,"namespaces"),m(this,"optionalNamespaces"),m(this,"sessionProperties"),m(this,"scopedProperties"),m(this,"events",new Jt),m(this,"rpcProviders",{}),m(this,"session"),m(this,"providerOpts"),m(this,"logger"),m(this,"uri"),m(this,"disableProviderPing",!1),this.providerOpts=t,this.logger=typeof t?.logger<"u"&&typeof t?.logger!="string"?t.logger:Mt(Bt({level:t?.logger||ot})),this.disableProviderPing=t?.disableProviderPing||!1}static async init(t){const e=new rt(t);return await e.initialize(),e}async request(t,e,s){const[n,a]=this.validateChain(e);if(!this.session)throw new Error("Please call connect() before request()");return await this.getProvider(n).request({request:T({},t),chainId:`${n}:${a}`,topic:this.session.topic,expiry:s})}sendAsync(t,e,s,n){const a=new Date().getTime();this.request(t,s,n).then(r=>e(null,Lt(a,r))).catch(r=>e(r,void 0))}async enable(){if(!this.client)throw new Error("Sign Client not initialized");return this.session||await this.connect({namespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties,scopedProperties:this.scopedProperties}),await this.requestAccounts()}async disconnect(){var t;if(!this.session)throw new Error("Please call connect() before enable()");await this.client.disconnect({topic:(t=this.session)==null?void 0:t.topic,reason:at("USER_DISCONNECTED")}),await this.cleanup()}async connect(t){if(!this.client)throw new Error("Sign Client not initialized");if(this.setNamespaces(t),this.cleanupPendingPairings(),!t.skipPairing)return await this.pair(t.pairingTopic)}async authenticate(t,e){if(!this.client)throw new Error("Sign Client not initialized");this.setNamespaces(t),await this.cleanupPendingPairings();const{uri:s,response:n}=await this.client.authenticate(t,e);s&&(this.uri=s,this.events.emit("display_uri",s));const a=await n();if(this.session=a.session,this.session){const r=vt(this.session.namespaces);this.namespaces=k(this.namespaces,r),await this.persist("namespaces",this.namespaces),this.onConnect()}return a}on(t,e){this.events.on(t,e)}once(t,e){this.events.once(t,e)}removeListener(t,e){this.events.removeListener(t,e)}off(t,e){this.events.off(t,e)}get isWalletConnect(){return!0}async pair(t){const{uri:e,approval:s}=await this.client.connect({pairingTopic:t,requiredNamespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties,scopedProperties:this.scopedProperties});e&&(this.uri=e,this.events.emit("display_uri",e));const n=await s();this.session=n;const a=vt(n.namespaces);return this.namespaces=k(this.namespaces,a),await this.persist("namespaces",this.namespaces),await this.persist("optionalNamespaces",this.optionalNamespaces),this.onConnect(),this.session}setDefaultChain(t,e){try{if(!this.session)return;const[s,n]=this.validateChain(t);this.getProvider(s).setDefaultChain(n,e)}catch(s){if(!/Please call connect/.test(s.message))throw s}}async cleanupPendingPairings(t={}){try{this.logger.info("Cleaning up inactive pairings...");const e=this.client.pairing.getAll();if(!L(e))return;for(const s of e)t.deletePairings?this.client.core.expirer.set(s.topic,0):await this.client.core.relayer.subscriber.unsubscribe(s.topic);this.logger.info(`Inactive pairings cleared: ${e.length}`)}catch(e){this.logger.warn("Failed to cleanup pending pairings",e)}}abortPairingAttempt(){this.logger.warn("abortPairingAttempt is deprecated. This is now a no-op.")}async checkStorage(){this.namespaces=await this.getFromStore("namespaces")||{},this.optionalNamespaces=await this.getFromStore("optionalNamespaces")||{},this.session&&this.createProviders()}async initialize(){this.logger.trace("Initialized"),await this.createClient(),await this.checkStorage(),this.registerEventListeners()}async createClient(){var t,e;if(this.client=this.providerOpts.client||await kt.init({core:this.providerOpts.core,logger:this.providerOpts.logger||ot,relayUrl:this.providerOpts.relayUrl||zt,projectId:this.providerOpts.projectId,metadata:this.providerOpts.metadata,storageOptions:this.providerOpts.storageOptions,storage:this.providerOpts.storage,name:this.providerOpts.name,customStoragePrefix:this.providerOpts.customStoragePrefix,telemetryEnabled:this.providerOpts.telemetryEnabled}),this.providerOpts.session)try{this.session=this.client.session.get(this.providerOpts.session.topic)}catch(s){throw this.logger.error("Failed to get session",s),new Error(`The provided session: ${(e=(t=this.providerOpts)==null?void 0:t.session)==null?void 0:e.topic} doesn't exist in the Sign client`)}else{const s=this.client.session.getAll();this.session=s[0]}this.logger.trace("SignClient Initialized")}createProviders(){if(!this.client)throw new Error("Sign Client not initialized");if(!this.session)throw new Error("Session not initialized. Please call connect() before enable()");const t=[...new Set(Object.keys(this.session.namespaces).map(e=>F(e)))];G("client",this.client),G("events",this.events),G("disableProviderPing",this.disableProviderPing),t.forEach(e=>{if(!this.session)return;const s=Ee(e,this.session);if(s?.length===0)return;const n=xt(s),a=k(this.namespaces,this.optionalNamespaces),r=Q(T({},a[e]),{accounts:s,chains:n});switch(e){case"eip155":this.rpcProviders[e]=new oi({namespace:r});break;case"algorand":this.rpcProviders[e]=new vi({namespace:r});break;case"solana":this.rpcProviders[e]=new pi({namespace:r});break;case"cosmos":this.rpcProviders[e]=new di({namespace:r});break;case"polkadot":this.rpcProviders[e]=new ei({namespace:r});break;case"cip34":this.rpcProviders[e]=new wi({namespace:r});break;case"elrond":this.rpcProviders[e]=new Ci({namespace:r});break;case"multiversx":this.rpcProviders[e]=new ji({namespace:r});break;case"near":this.rpcProviders[e]=new Ai({namespace:r});break;case"tezos":this.rpcProviders[e]=new qi({namespace:r});break;default:this.rpcProviders[e]=new _i({namespace:r})}})}registerEventListeners(){if(typeof this.client>"u")throw new Error("Sign Client is not initialized");this.client.on("session_ping",t=>{var e;const{topic:s}=t;s===((e=this.session)==null?void 0:e.topic)&&this.events.emit("session_ping",t)}),this.client.on("session_event",t=>{var e;const{params:s,topic:n}=t;if(n!==((e=this.session)==null?void 0:e.topic))return;const{event:a}=s;if(a.name==="accountsChanged"){const r=a.data;r&&L(r)&&this.events.emit("accountsChanged",r.map(mt))}else if(a.name==="chainChanged"){const r=s.chainId,o=s.event.data,c=F(r),u=z(r)!==z(o)?`${c}:${z(o)}`:r;this.onChainChanged(u)}else this.events.emit(a.name,a.data);this.events.emit("session_event",t)}),this.client.on("session_update",({topic:t,params:e})=>{var s,n;if(t!==((s=this.session)==null?void 0:s.topic))return;const{namespaces:a}=e,r=(n=this.client)==null?void 0:n.session.get(t);this.session=Q(T({},r),{namespaces:a}),this.onSessionUpdate(),this.events.emit("session_update",{topic:t,params:e})}),this.client.on("session_delete",async t=>{var e;t.topic===((e=this.session)==null?void 0:e.topic)&&(await this.cleanup(),this.events.emit("session_delete",t),this.events.emit("disconnect",Q(T({},at("USER_DISCONNECTED")),{data:t.topic})))}),this.on(v.DEFAULT_CHAIN_CHANGED,t=>{this.onChainChanged(t,!0)})}getProvider(t){return this.rpcProviders[t]||this.rpcProviders[St]}onSessionUpdate(){Object.keys(this.rpcProviders).forEach(t=>{var e;this.getProvider(t).updateNamespace((e=this.session)==null?void 0:e.namespaces[t])})}setNamespaces(t){const{namespaces:e={},optionalNamespaces:s={},sessionProperties:n,scopedProperties:a}=t;this.optionalNamespaces=k(e,s),this.sessionProperties=n,this.scopedProperties=a}validateChain(t){const[e,s]=t?.split(":")||["",""];if(!this.namespaces||!Object.keys(this.namespaces).length)return[e,s];if(e&&!Object.keys(this.namespaces||{}).map(r=>F(r)).includes(e))throw new Error(`Namespace '${e}' is not configured. Please call connect() first with namespace config.`);if(e&&s)return[e,s];const n=F(Object.keys(this.namespaces)[0]),a=this.rpcProviders[n].getDefaultChain();return[n,a]}async requestAccounts(){const[t]=this.validateChain();return await this.getProvider(t).requestAccounts()}async onChainChanged(t,e=!1){if(!this.namespaces)return;const[s,n]=this.validateChain(t);if(!n)return;this.updateNamespaceChain(s,n);const a=this.getProvider(s).getDefaultChain();e?(this.events.emit("chainChanged",n),this.emitAccountsChangedOnChainChange({namespace:s,previousChainId:a,newChainId:t})):this.getProvider(s).setDefaultChain(n),await this.persist("namespaces",this.namespaces)}emitAccountsChangedOnChainChange({namespace:t,previousChainId:e,newChainId:s}){var n,a;try{if(e===s)return;const r=(a=(n=this.session)==null?void 0:n.namespaces[t])==null?void 0:a.accounts;if(!r)return;const o=r.filter(c=>c.includes(`${s}:`)).map(mt);if(!L(o))return;this.events.emit("accountsChanged",o)}catch(r){this.logger.warn("Failed to emit accountsChanged on chain change",r)}}updateNamespaceChain(t,e){if(!this.namespaces)return;const s=this.namespaces[t]?t:`${t}:${e}`,n={chains:[],methods:[],events:[],defaultChain:e};this.namespaces[s]?this.namespaces[s]&&(this.namespaces[s].defaultChain=e):this.namespaces[s]=n}onConnect(){this.createProviders(),this.events.emit("connect",{session:this.session})}async cleanup(){this.namespaces=void 0,this.optionalNamespaces=void 0,this.sessionProperties=void 0,await this.deleteFromStore("namespaces"),await this.deleteFromStore("optionalNamespaces"),await this.deleteFromStore("sessionProperties"),this.session=void 0,this.cleanupPendingPairings({deletePairings:!0}),await this.cleanupStorage()}async persist(t,e){var s;const n=((s=this.session)==null?void 0:s.topic)||"";await this.client.core.storage.setItem(`${x}/${t}${n}`,e)}async getFromStore(t){var e;const s=((e=this.session)==null?void 0:e.topic)||"";return await this.client.core.storage.getItem(`${x}/${t}${s}`)}async deleteFromStore(t){var e;const s=((e=this.session)==null?void 0:e.topic)||"";await this.client.core.storage.removeItem(`${x}/${t}${s}`)}async cleanupStorage(){var t;try{if(((t=this.client)==null?void 0:t.session.length)>0)return;const e=await this.client.core.storage.getKeys();for(const s of e)s.startsWith(x)&&await this.client.core.storage.removeItem(s)}catch(e){this.logger.warn("Failed to cleanup storage",e)}}}const Ji=rt;export{Ji as UniversalProvider,rt as default};
|