@wormhole-foundation/wormhole-connect 1.1.7-beta.0-development → 1.1.8-beta.1-development
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{algorand-Bg-MfjsH.js → algorand-vDDEz6KP.js} +2 -2
- package/dist/assets/{ccip-Bk3xy3UX.js → ccip-DQXRFvqz.js} +1 -1
- package/dist/assets/{cosmwasm-xANzAboS.js → cosmwasm-DP4CIVSM.js} +2 -2
- package/dist/assets/{evm-B20gvxWA.js → evm-BB3755Wr.js} +1 -1
- package/dist/assets/{evm-CZSGnl_A.js → evm-C48USybm.js} +4 -4
- package/dist/assets/{index-eLk_b8u9.js → index-BU0ECMia.js} +1 -1
- package/dist/assets/{index-DyD6kblh.js → index-BbJVBTsE.js} +1 -1
- package/dist/assets/{index-BYxgRLLh.js → index-BhEp9mlK.js} +1 -1
- package/dist/assets/{index-CI40JjNh.js → index-BjxXYs1y.js} +2 -2
- package/dist/assets/{index-D3WFv54i.js → index-Bvun80fl.js} +1 -1
- package/dist/assets/{index-jD6ZZ5Tu.js → index-Bz-32kSJ.js} +1 -1
- package/dist/assets/{index-CLcPjTbq.js → index-CVb8oZT5.js} +2 -2
- package/dist/assets/{index-BN1xR-e3.js → index-Cx-EaiKs.js} +1 -1
- package/dist/assets/index-DP2zLB5d.js +5 -0
- package/dist/assets/{index-Bmx9-Bo8.js → index-DjbIKpGg.js} +1 -1
- package/dist/assets/{index-CxijOPcm.js → index-re-SltAL.js} +1 -1
- package/dist/assets/{index.es-CXW154rj.js → index.es-B57TzKWR.js} +2 -2
- package/dist/assets/{solana-DOaiyZir.js → solana-Bc-ePjuF.js} +1 -1
- package/dist/assets/{sui-mXOoFb4M.js → sui-DVNpNCUB.js} +4 -4
- package/dist/assets/{unsignedTransaction-0WUum9tP.js → unsignedTransaction-CPy_oMd2.js} +1 -1
- package/dist/assets/unsignedTransaction-arVvzoJx.js +1 -0
- package/dist/main.js +68 -68
- package/dist/src/config/devnet/chains.d.ts.map +1 -1
- package/dist/src/config/devnet/tokens.d.ts.map +1 -1
- package/dist/src/config/mainnet/chains.d.ts.map +1 -1
- package/dist/src/config/mainnet/tokens.d.ts.map +1 -1
- package/dist/src/config/testnet/chains.d.ts.map +1 -1
- package/dist/src/config/testnet/tokens.d.ts.map +1 -1
- package/dist/src/config/types.d.ts +4 -3
- package/dist/src/config/types.d.ts.map +1 -1
- package/dist/src/icons/ChainIcons.d.ts +9 -0
- package/dist/src/icons/ChainIcons.d.ts.map +1 -0
- package/dist/src/icons/Chains/APT.d.ts +4 -0
- package/dist/src/icons/Chains/APT.d.ts.map +1 -0
- package/dist/src/icons/Chains/ARBITRUM.d.ts +4 -0
- package/dist/src/icons/Chains/ARBITRUM.d.ts.map +1 -0
- package/dist/src/icons/Chains/AVAX.d.ts +4 -0
- package/dist/src/icons/Chains/AVAX.d.ts.map +1 -0
- package/dist/src/icons/Chains/BASE.d.ts +4 -0
- package/dist/src/icons/Chains/BASE.d.ts.map +1 -0
- package/dist/src/icons/Chains/BLAST.d.ts +4 -0
- package/dist/src/icons/Chains/BLAST.d.ts.map +1 -0
- package/dist/src/icons/Chains/BSC.d.ts +4 -0
- package/dist/src/icons/Chains/BSC.d.ts.map +1 -0
- package/dist/src/icons/Chains/CELO.d.ts +4 -0
- package/dist/src/icons/Chains/CELO.d.ts.map +1 -0
- package/dist/src/icons/Chains/ETH.d.ts +4 -0
- package/dist/src/icons/Chains/ETH.d.ts.map +1 -0
- package/dist/src/icons/Chains/FTM.d.ts +4 -0
- package/dist/src/icons/Chains/FTM.d.ts.map +1 -0
- package/dist/src/icons/Chains/GLMR.d.ts +4 -0
- package/dist/src/icons/Chains/GLMR.d.ts.map +1 -0
- package/dist/src/icons/Chains/KAIA.d.ts +4 -0
- package/dist/src/icons/Chains/KAIA.d.ts.map +1 -0
- package/dist/src/icons/Chains/MANTLE.d.ts +4 -0
- package/dist/src/icons/Chains/MANTLE.d.ts.map +1 -0
- package/dist/src/icons/Chains/OPTIMISM.d.ts +4 -0
- package/dist/src/icons/Chains/OPTIMISM.d.ts.map +1 -0
- package/dist/src/icons/Chains/OSMO.d.ts +4 -0
- package/dist/src/icons/Chains/OSMO.d.ts.map +1 -0
- package/dist/src/icons/{Tokens/MATIC.d.ts → Chains/POLY.d.ts} +1 -1
- package/dist/src/icons/Chains/POLY.d.ts.map +1 -0
- package/dist/src/icons/Chains/SCROLL.d.ts +4 -0
- package/dist/src/icons/Chains/SCROLL.d.ts.map +1 -0
- package/dist/src/icons/Chains/SOL.d.ts +4 -0
- package/dist/src/icons/Chains/SOL.d.ts.map +1 -0
- package/dist/src/icons/Chains/SUI.d.ts +4 -0
- package/dist/src/icons/Chains/SUI.d.ts.map +1 -0
- package/dist/src/icons/Chains/XLAYER.d.ts +4 -0
- package/dist/src/icons/Chains/XLAYER.d.ts.map +1 -0
- package/dist/src/icons/{Tokens/noIcon.d.ts → Chains/empty.d.ts} +1 -1
- package/dist/src/icons/Chains/empty.d.ts.map +1 -0
- package/dist/src/icons/Error.d.ts +5 -0
- package/dist/src/icons/Error.d.ts.map +1 -0
- package/dist/src/icons/TokenIcons.d.ts +4 -4
- package/dist/src/icons/TokenIcons.d.ts.map +1 -1
- package/dist/src/icons/Tokens/POLY.d.ts +4 -0
- package/dist/src/icons/Tokens/POLY.d.ts.map +1 -0
- package/{lib/src/icons/Tokens/noIcon.d.ts → dist/src/icons/Tokens/empty.d.ts} +1 -1
- package/dist/src/icons/Tokens/empty.d.ts.map +1 -0
- package/dist/src/icons/Warning.d.ts +5 -0
- package/dist/src/icons/Warning.d.ts.map +1 -0
- package/dist/src/utils/sdkv2.d.ts.map +1 -1
- package/dist/src/views/v2/Bridge/AmountInput/index.d.ts.map +1 -1
- package/dist/src/views/v2/Bridge/AssetPicker/ChainList.d.ts.map +1 -1
- package/dist/src/views/v2/Bridge/AssetPicker/index.d.ts.map +1 -1
- package/dist/src/views/v2/Bridge/Routes/SingleRoute.d.ts.map +1 -1
- package/dist/src/views/v2/Bridge/SwapInputs/index.d.ts.map +1 -1
- package/dist/src/views/v2/Redeem/TransactionDetails/index.d.ts.map +1 -1
- package/dist/src/views/v2/TxHistory/Item/index.d.ts.map +1 -1
- package/lib/{algorand-DsJKeIr5.mjs → algorand-CnhJd_dq.mjs} +3 -3
- package/lib/{algorand-BixJkKlf.js → algorand-F3xFUrZu.js} +1 -1
- package/lib/{aptos-BfNT2MMg.js → aptos-CUGJTnxp.js} +2 -2
- package/lib/{aptos-prTLw0zg.mjs → aptos-DZsV2iRv.mjs} +1 -1
- package/lib/{aptos-DP1G2KNL.mjs → aptos-Dzo7tWbP.mjs} +3 -3
- package/lib/{aptos-DSDxN2Oh.js → aptos-JorFrRlO.js} +1 -1
- package/lib/{ccip-DqvPZUFd.mjs → ccip-CGdvCMfU.mjs} +1 -1
- package/lib/{ccip-CORtuKLa.js → ccip-WvYiDS-K.js} +1 -1
- package/lib/{cosmwasm-CARLnvsg.mjs → cosmwasm-DN0AHdEC.mjs} +6 -6
- package/lib/{cosmwasm-D_THf_Jx.js → cosmwasm-Dg8T1AeT.js} +2 -2
- package/lib/{events-ByywXw-I.js → events-D8Ws4SSV.js} +1 -1
- package/lib/{events-D26WqMv7.mjs → events-DdSBahX7.mjs} +1 -1
- package/lib/{evm-B4avmxZ0.js → evm-3fprRMRy.js} +1 -1
- package/lib/{evm-PZUgLFER.js → evm-D-BOv3OA.js} +4 -4
- package/lib/{evm-qAJdXmfg.mjs → evm-DnhPF5dt.mjs} +12 -12
- package/lib/{evm-BIZUXCC2.mjs → evm-H_bKmdGg.mjs} +7 -7
- package/lib/{index-Dcw9cmF1.js → index--DjYWDRB.js} +1 -1
- package/lib/{index-7QTP5abI.js → index-B-zhCYHk.js} +1 -1
- package/lib/{index-C3wsSYLo.mjs → index-B17OfY1l.mjs} +2 -2
- package/lib/{index-Uwpj8GZq.js → index-B1wNeKc9.js} +1 -1
- package/lib/{index-D2AdBTEw.mjs → index-BHklNnJk.mjs} +4 -4
- package/lib/{index-DCWQkYP9.mjs → index-BVOQlHAu.mjs} +2 -2
- package/lib/{index-CZyMJdwZ.mjs → index-BcmVWAO0.mjs} +1 -1
- package/lib/{index-Bk4O6F71.mjs → index-BdfG3lJW.mjs} +1 -1
- package/lib/index-BjJ4BDhi.js +5 -0
- package/lib/{index-Bo-4EpMy.mjs → index-BlV7bTcP.mjs} +11 -11
- package/lib/{index-CjqSmvJv.mjs → index-BpgHIKBe.mjs} +11785 -10206
- package/lib/{index-B12QivYB.mjs → index-BuynHxM5.mjs} +140 -149
- package/lib/{index-Dui1f--u.mjs → index-BvmOowYJ.mjs} +4 -4
- package/lib/{index-Ci2My7Wd.js → index-C7Ggs6qV.js} +1 -1
- package/lib/{index-CyivlCUm.mjs → index-C7iFAy5u.mjs} +1 -1
- package/lib/{index-CjwkPmul.mjs → index-CMboM3K3.mjs} +2 -2
- package/lib/{index-B_MZPnqY.mjs → index-CXSjmxbe.mjs} +2 -2
- package/lib/{index-DkGpLtjt.js → index-CYuWGvEH.js} +1 -1
- package/lib/{index-C9pDNiDb.mjs → index-C_rNtVK6.mjs} +2 -2
- package/lib/{index-CPTLMohs.js → index-CjVR2y_P.js} +1 -1
- package/lib/index-CnSAQLrV.mjs +3816 -0
- package/lib/{index-DHqcaM3p.js → index-CqEKPcR6.js} +1 -1
- package/lib/{index-ByoyzlD8.mjs → index-D2ZeoQJK.mjs} +2 -2
- package/lib/{index-aGiZ0Ii1.mjs → index-D3KQzv3w.mjs} +3 -3
- package/lib/{index-pRsBJecB.mjs → index-D3R38eof.mjs} +2 -2
- package/lib/{index-BlY7x8aT.js → index-D4UVCCA_.js} +1 -1
- package/lib/{index-CQJHdG55.mjs → index-D5V8xUx6.mjs} +2 -2
- package/lib/{index-De8biE2M.mjs → index-DCDfhwO6.mjs} +1 -1
- package/lib/{index-BrMNAxOe.js → index-DJNuweoE.js} +1 -1
- package/lib/{index-BMrLuIZN.js → index-DK3NwBVm.js} +1 -1
- package/lib/{index-BsusxMly.js → index-DLboWTYu.js} +1 -1
- package/lib/{index-DPqJrtJC.js → index-DWjlQfKm.js} +1 -1
- package/lib/{index-DVYpLXjZ.mjs → index-DayCZrK8.mjs} +2 -2
- package/lib/{index-CwU49oAB.mjs → index-DeqerBZA.mjs} +2 -2
- package/lib/{index-DW5lODgc.js → index-DgegRtGl.js} +1 -1
- package/lib/{index-9uqt3JNu.js → index-DpDevDxN.js} +1 -1
- package/lib/{index-CYf3zJ9U.js → index-Ds1qW639.js} +1 -1
- package/lib/{index-0HzcGIG7.js → index-DwrJnKct.js} +1 -1
- package/lib/{index-DLtY6fYS.js → index-YHxHDLCx.js} +1 -1
- package/lib/index-ZxjZ25k7.js +5 -0
- package/lib/{index-CTR28Kqb.js → index-_H1GTLUN.js} +1 -1
- package/lib/{index-BckHu5WB.mjs → index-a0jcclYd.mjs} +4 -4
- package/lib/{index-Cm4mzU66.js → index-dJYuE1XM.js} +1 -1
- package/lib/{index-By-bUyoB.mjs → index-fWs1RWi9.mjs} +2 -2
- package/lib/{index-C0BdeM6x.js → index-tgY8ENKu.js} +1 -1
- package/lib/{index-C7GdFYql.js → index-uRFn7LyP.js} +83 -83
- package/lib/{index.es-Cck7Q64X.mjs → index.es-DmO_K9V9.mjs} +5 -5
- package/lib/{index.es-AHohFAAx.js → index.es-ebfnW8JA.js} +2 -2
- package/lib/index.js +1 -1
- package/lib/index.mjs +2 -2
- package/lib/{keccak-BH-QLSRT.mjs → keccak-C4VHYT3-.mjs} +1 -1
- package/lib/{keccak-eY58RWPu.js → keccak-CspXZGIt.js} +1 -1
- package/lib/{pbkdf2-BfOdx-Dl.mjs → pbkdf2-B6Kn0zmY.mjs} +1 -1
- package/lib/{pbkdf2-CSYv20wX.js → pbkdf2-DtpaWNtQ.js} +1 -1
- package/lib/{signer-B8jRb0nz.js → signer-DBqxRPZ3.js} +1 -1
- package/lib/{signer-DS-_n4Nt.mjs → signer-DZsY9TLP.mjs} +1 -1
- package/lib/{solana--qAtGpyY.mjs → solana-BABTG8N7.mjs} +4 -4
- package/lib/solana-CR8CywCk.mjs +16 -0
- package/lib/solana-CUDRhtZZ.js +1 -0
- package/lib/{solana-BSRpQGAt.js → solana-DEDJJyBR.js} +1 -1
- package/lib/{solanaEmbed.esm-BQflKuI4.mjs → solanaEmbed.esm-BAbo7-i8.mjs} +3 -3
- package/lib/{solanaEmbed.esm-5JVQ2kx5.js → solanaEmbed.esm-BIOABkzi.js} +1 -1
- package/lib/src/config/devnet/chains.d.ts.map +1 -1
- package/lib/src/config/devnet/tokens.d.ts.map +1 -1
- package/lib/src/config/mainnet/chains.d.ts.map +1 -1
- package/lib/src/config/mainnet/tokens.d.ts.map +1 -1
- package/lib/src/config/testnet/chains.d.ts.map +1 -1
- package/lib/src/config/testnet/tokens.d.ts.map +1 -1
- package/lib/src/config/types.d.ts +4 -3
- package/lib/src/config/types.d.ts.map +1 -1
- package/lib/src/icons/ChainIcons.d.ts +9 -0
- package/lib/src/icons/ChainIcons.d.ts.map +1 -0
- package/lib/src/icons/Chains/APT.d.ts +4 -0
- package/lib/src/icons/Chains/APT.d.ts.map +1 -0
- package/lib/src/icons/Chains/ARBITRUM.d.ts +4 -0
- package/lib/src/icons/Chains/ARBITRUM.d.ts.map +1 -0
- package/lib/src/icons/Chains/AVAX.d.ts +4 -0
- package/lib/src/icons/Chains/AVAX.d.ts.map +1 -0
- package/lib/src/icons/Chains/BASE.d.ts +4 -0
- package/lib/src/icons/Chains/BASE.d.ts.map +1 -0
- package/lib/src/icons/Chains/BLAST.d.ts +4 -0
- package/lib/src/icons/Chains/BLAST.d.ts.map +1 -0
- package/lib/src/icons/Chains/BSC.d.ts +4 -0
- package/lib/src/icons/Chains/BSC.d.ts.map +1 -0
- package/lib/src/icons/Chains/CELO.d.ts +4 -0
- package/lib/src/icons/Chains/CELO.d.ts.map +1 -0
- package/lib/src/icons/Chains/ETH.d.ts +4 -0
- package/lib/src/icons/Chains/ETH.d.ts.map +1 -0
- package/lib/src/icons/Chains/FTM.d.ts +4 -0
- package/lib/src/icons/Chains/FTM.d.ts.map +1 -0
- package/lib/src/icons/Chains/GLMR.d.ts +4 -0
- package/lib/src/icons/Chains/GLMR.d.ts.map +1 -0
- package/lib/src/icons/Chains/KAIA.d.ts +4 -0
- package/lib/src/icons/Chains/KAIA.d.ts.map +1 -0
- package/lib/src/icons/Chains/MANTLE.d.ts +4 -0
- package/lib/src/icons/Chains/MANTLE.d.ts.map +1 -0
- package/lib/src/icons/Chains/OPTIMISM.d.ts +4 -0
- package/lib/src/icons/Chains/OPTIMISM.d.ts.map +1 -0
- package/lib/src/icons/Chains/OSMO.d.ts +4 -0
- package/lib/src/icons/Chains/OSMO.d.ts.map +1 -0
- package/lib/src/icons/{Tokens/MATIC.d.ts → Chains/POLY.d.ts} +1 -1
- package/lib/src/icons/Chains/POLY.d.ts.map +1 -0
- package/lib/src/icons/Chains/SCROLL.d.ts +4 -0
- package/lib/src/icons/Chains/SCROLL.d.ts.map +1 -0
- package/lib/src/icons/Chains/SOL.d.ts +4 -0
- package/lib/src/icons/Chains/SOL.d.ts.map +1 -0
- package/lib/src/icons/Chains/SUI.d.ts +4 -0
- package/lib/src/icons/Chains/SUI.d.ts.map +1 -0
- package/lib/src/icons/Chains/XLAYER.d.ts +4 -0
- package/lib/src/icons/Chains/XLAYER.d.ts.map +1 -0
- package/lib/src/icons/Chains/empty.d.ts +4 -0
- package/lib/src/icons/Chains/empty.d.ts.map +1 -0
- package/lib/src/icons/Error.d.ts +5 -0
- package/lib/src/icons/Error.d.ts.map +1 -0
- package/lib/src/icons/TokenIcons.d.ts +4 -4
- package/lib/src/icons/TokenIcons.d.ts.map +1 -1
- package/lib/src/icons/Tokens/POLY.d.ts +4 -0
- package/lib/src/icons/Tokens/POLY.d.ts.map +1 -0
- package/lib/src/icons/Tokens/empty.d.ts +4 -0
- package/lib/src/icons/Tokens/empty.d.ts.map +1 -0
- package/lib/src/icons/Warning.d.ts +5 -0
- package/lib/src/icons/Warning.d.ts.map +1 -0
- package/lib/src/utils/sdkv2.d.ts.map +1 -1
- package/lib/src/views/v2/Bridge/AmountInput/index.d.ts.map +1 -1
- package/lib/src/views/v2/Bridge/AssetPicker/ChainList.d.ts.map +1 -1
- package/lib/src/views/v2/Bridge/AssetPicker/index.d.ts.map +1 -1
- package/lib/src/views/v2/Bridge/Routes/SingleRoute.d.ts.map +1 -1
- package/lib/src/views/v2/Bridge/SwapInputs/index.d.ts.map +1 -1
- package/lib/src/views/v2/Redeem/TransactionDetails/index.d.ts.map +1 -1
- package/lib/src/views/v2/TxHistory/Item/index.d.ts.map +1 -1
- package/lib/{sui-CHdzm0pJ.js → sui-CD_LLkGE.js} +2 -2
- package/lib/{sui-CTaDMtDE.mjs → sui-CfiEBlu_.mjs} +74 -75
- package/lib/{sui-BrXrepC3.mjs → sui-DYCvDMMh.mjs} +1 -1
- package/lib/{sui-B9mPyuqg.js → sui-Da1ir949.js} +1 -1
- package/lib/unsignedTransaction-BD81leu1.mjs +16 -0
- package/lib/{unsignedTransaction-B6O-8vao.js → unsignedTransaction-BNppfIUA.js} +1 -1
- package/lib/unsignedTransaction-DzSLsK-p.js +1 -0
- package/lib/{unsignedTransaction-BLH74msy.mjs → unsignedTransaction-l29mWyX4.mjs} +4 -4
- package/package.json +17 -17
- package/dist/src/icons/Tokens/MATIC.d.ts.map +0 -1
- package/dist/src/icons/Tokens/noIcon.d.ts.map +0 -1
- package/dist/src/utils/repairVaa.d.ts +0 -4
- package/dist/src/utils/repairVaa.d.ts.map +0 -1
- package/lib/index-CqmsT5vZ.js +0 -5
- package/lib/solana-Dcts27AJ.js +0 -1
- package/lib/solana-qJnrP02J.mjs +0 -16
- package/lib/src/icons/Tokens/MATIC.d.ts.map +0 -1
- package/lib/src/icons/Tokens/noIcon.d.ts.map +0 -1
- package/lib/src/utils/repairVaa.d.ts +0 -4
- package/lib/src/utils/repairVaa.d.ts.map +0 -1
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
var Er=Object.defineProperty;var xr=(e,t,r)=>t in e?Er(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var F=(e,t,r)=>xr(e,typeof t!="symbol"?t+"":t,r);import{s as Ir,az as jr,d5 as Or,cf as Ar,cd as kr,ce as Bt,ae as _r,cg as Rt,c3 as Cr}from"../main.js";import{S as Nt,u as Pt}from"./sui-DVNpNCUB.js";import{S as $r}from"./unsignedTransaction-arVvzoJx.js";import"./pbkdf2-DaCbRHcv.js";class Mr extends TypeError{constructor(t,r){let n;const{message:i,explanation:s,...a}=t,{path:o}=t,u=o.length===0?i:`At path: ${o.join(".")} -- ${i}`;super(s??u),s!=null&&(this.cause=u),Object.assign(this,a),this.name=this.constructor.name,this.failures=()=>n??(n=[t,...r()])}}function Ur(e){return z(e)&&typeof e[Symbol.iterator]=="function"}function z(e){return typeof e=="object"&&e!=null}function V(e){return typeof e=="symbol"?e.toString():typeof e=="string"?JSON.stringify(e):`${e}`}function Br(e){const{done:t,value:r}=e.next();return t?void 0:r}function Rr(e,t,r,n){if(e===!0)return;e===!1?e={}:typeof e=="string"&&(e={message:e});const{path:i,branch:s}=t,{type:a}=r,{refinement:o,message:u=`Expected a value of type \`${a}\`${o?` with refinement \`${o}\``:""}, but received: \`${V(n)}\``}=e;return{value:n,type:a,refinement:o,key:i[i.length-1],path:i,branch:s,...e,message:u}}function*Dt(e,t,r,n){Ur(e)||(e=[e]);for(const i of e){const s=Rr(i,t,r,n);s&&(yield s)}}function*nt(e,t,r={}){const{path:n=[],branch:i=[e],coerce:s=!1,mask:a=!1}=r,o={path:n,branch:i};if(s&&(e=t.coercer(e,o),a&&t.type!=="type"&&z(t.schema)&&z(e)&&!Array.isArray(e)))for(const d in e)t.schema[d]===void 0&&delete e[d];let u="valid";for(const d of t.validator(e,o))d.explanation=r.message,u="not_valid",yield[d,void 0];for(let[d,l,g]of t.entries(e,o)){const m=nt(l,g,{path:d===void 0?n:[...n,d],branch:d===void 0?i:[...i,l],coerce:s,mask:a,message:r.message});for(const p of m)p[0]?(u=p[0].refinement!=null?"not_refined":"not_valid",yield[p[0],void 0]):s&&(l=p[1],d===void 0?e=l:e instanceof Map?e.set(d,l):e instanceof Set?e.add(l):z(e)&&(l!==void 0||d in e)&&(e[d]=l))}if(u!=="not_valid")for(const d of t.refiner(e,o))d.explanation=r.message,u="not_refined",yield[d,void 0];u==="valid"&&(yield[void 0,e])}class Z{constructor(t){const{type:r,schema:n,validator:i,refiner:s,coercer:a=u=>u,entries:o=function*(){}}=t;this.type=r,this.schema=n,this.entries=o,this.coercer=a,i?this.validator=(u,d)=>{const l=i(u,d);return Dt(l,d,this,u)}:this.validator=()=>[],s?this.refiner=(u,d)=>{const l=s(u,d);return Dt(l,d,this,u)}:this.refiner=()=>[]}assert(t,r){return qe(t,this,r)}create(t,r){return Lt(t,this,r)}is(t){return N(t,this)}mask(t,r){return Kt(t,this,r)}validate(t,r={}){return Ee(t,this,r)}}function qe(e,t,r){const n=Ee(e,t,{message:r});if(n[0])throw n[0]}function Lt(e,t,r){const n=Ee(e,t,{coerce:!0,message:r});if(n[0])throw n[0];return n[1]}function Kt(e,t,r){const n=Ee(e,t,{coerce:!0,mask:!0,message:r});if(n[0])throw n[0];return n[1]}function N(e,t){return!Ee(e,t)[0]}function Ee(e,t,r={}){const n=nt(e,t,r),i=Br(n);return i[0]?[new Mr(i[0],function*(){for(const a of n)a[0]&&(yield a[0])}),void 0]:[void 0,i[1]]}function we(...e){const t=e[0].type==="type",r=e.map(i=>i.schema),n=Object.assign({},...r);return t?Pr(n):h(n)}function P(e,t){return new Z({type:e,schema:null,validator:t})}function Ze(){return P("any",()=>!0)}function v(e){return new Z({type:"array",schema:e,*entries(t){if(e&&Array.isArray(t))for(const[r,n]of t.entries())yield[r,n,e]},coercer(t){return Array.isArray(t)?t.slice():t},validator(t){return Array.isArray(t)||`Expected an array value, but received: ${V(t)}`}})}function Nr(){return P("bigint",e=>typeof e=="bigint")}function U(){return P("boolean",e=>typeof e=="boolean")}function q(){return P("integer",e=>typeof e=="number"&&!isNaN(e)&&Number.isInteger(e)||`Expected an integer, but received: ${V(e)}`)}function b(e){const t=V(e),r=typeof e;return new Z({type:"literal",schema:r==="string"||r==="number"||r==="boolean"?e:null,validator(n){return n===e||`Expected the literal \`${t}\`, but received: ${V(n)}`}})}function Wt(){return P("never",()=>!1)}function O(e){return new Z({...e,validator:(t,r)=>t===null||e.validator(t,r),refiner:(t,r)=>t===null||e.refiner(t,r)})}function ue(){return P("number",e=>typeof e=="number"&&!isNaN(e)||`Expected a number, but received: ${V(e)}`)}function h(e){const t=e?Object.keys(e):[],r=Wt();return new Z({type:"object",schema:e||null,*entries(n){if(e&&z(n)){const i=new Set(Object.keys(n));for(const s of t)i.delete(s),yield[s,n[s],e[s]];for(const s of i)yield[s,n[s],r]}},validator(n){return z(n)||`Expected an object, but received: ${V(n)}`},coercer(n){return z(n)?{...n}:n}})}function w(e){return new Z({...e,validator:(t,r)=>t===void 0||e.validator(t,r),refiner:(t,r)=>t===void 0||e.refiner(t,r)})}function H(e,t){return new Z({type:"record",schema:null,*entries(r){if(z(r))for(const n in r){const i=r[n];yield[n,n,e],yield[n,i,t]}},validator(r){return z(r)||`Expected an object, but received: ${V(r)}`}})}function f(){return P("string",e=>typeof e=="string"||`Expected a string, but received: ${V(e)}`)}function Jt(e){const t=Wt();return new Z({type:"tuple",schema:null,*entries(r){if(Array.isArray(r)){const n=Math.max(e.length,r.length);for(let i=0;i<n;i++)yield[i,r[i],e[i]||t]}},validator(r){return Array.isArray(r)||`Expected an array, but received: ${V(r)}`}})}function Pr(e){const t=Object.keys(e);return new Z({type:"type",schema:e,*entries(r){if(z(r))for(const n of t)yield[n,r[n],e[n]]},validator(r){return z(r)||`Expected an object, but received: ${V(r)}`},coercer(r){return z(r)?{...r}:r}})}function k(e){const t=e.map(r=>r.type).join(" | ");return new Z({type:"union",schema:null,coercer(r){for(const n of e){const[i,s]=n.validate(r,{coerce:!0});if(!i)return s}return r},validator(r,n){const i=[];for(const s of e){const[...a]=nt(r,s,n),[o]=a;if(o[0])for(const[u]of a)u&&i.push(u);else return[]}return[`Expected the value to satisfy a union of \`${t}\`, but received: ${V(r)}`,...i]}})}function Ht(){return P("unknown",()=>!0)}const it=k([h({AddressOwner:f()}),h({ObjectOwner:f()}),h({Shared:h({initial_shared_version:O(f())})}),b("Immutable")]);P("SuiJsonValue",()=>!0);const Dr=k([h({u32:f()}),h({u64:f()}),h({f64:f()})]);h({attributes:H(f(),O(Dr)),featureFlags:H(f(),U()),maxSupportedProtocolVersion:f(),minSupportedProtocolVersion:f(),protocolVersion:f()});k([f(),b("package")]);const se=h({digest:f(),objectId:f(),version:k([ue(),f(),Nr()])});h({owner:it,reference:se});h({objectId:f(),sequenceNumber:f()});h({payment:v(se),owner:f(),price:f(),budget:f()});const zr=we(se,h({type:f(),owner:it,previousTransaction:f()})),Vr=H(f(),Ze()),Gr=H(f(),Ht()),Fr=h({type:f(),fields:Vr,hasPublicTransfer:U()}),Lr=h({disassembled:Gr}),Kr=k([we(Fr,h({dataType:b("moveObject")})),we(Lr,h({dataType:b("package")}))]),Wr=h({type:f(),hasPublicTransfer:U(),version:f(),bcsBytes:f()}),Jr=h({id:f(),moduleMap:H(f(),f())}),Hr=k([we(Wr,h({dataType:b("moveObject")})),we(Jr,h({dataType:b("package")}))]);BigInt(1e9);const Xt=h({code:f(),error:w(f()),object_id:w(f()),parent_object_id:w(f()),version:w(f()),digest:w(f())}),Xr=h({data:O(w(H(f(),f()))),error:O(w(Xt))}),qr=k([Xr,w(H(f(),f()))]),qt=h({objectId:f(),version:f(),digest:f(),type:O(w(f())),content:O(w(Kr)),bcs:O(w(Hr)),owner:O(w(it)),previousTransaction:O(w(f())),storageRebate:O(w(f())),display:O(w(qr))});h({showType:O(w(U())),showContent:O(w(U())),showBcs:O(w(U())),showOwner:O(w(U())),showPreviousTransaction:O(w(U())),showStorageRebate:O(w(U())),showDisplay:O(w(U()))});k([b("Exists"),b("notExists"),b("Deleted")]);v(zr);const Zr=h({data:O(w(qt)),error:O(w(Xt))});function Yr(e){return e.data}function Qr(e){if(e.error&&"object_id"in e.error&&"version"in e.error&&"digest"in e.error){const t=e.error;return{objectId:t.object_id,version:t.version,digest:t.digest}}}function zt(e){if("reference"in e)return e.reference;const t=Yr(e);return t?{objectId:t.objectId,version:t.version,digest:t.digest}:Qr(e)}h({objectId:f(),atCheckpoint:w(ue())});h({data:v(Zr),nextCursor:w(O(f())),hasNextPage:U()});k([h({details:qt,status:b("VersionFound")}),h({details:f(),status:b("ObjectNotExists")}),h({details:se,status:b("ObjectDeleted")}),h({details:Jt([f(),ue()]),status:b("VersionNotFound")}),h({details:h({asked_version:ue(),latest_version:ue(),object_id:f()}),status:b("VersionTooHigh")})]);const en=k([f(),h({Object:f()})]);v(en);const tn=h({address:f(),name:f()}),rn=k([b("Private"),b("Public"),b("Friend")]),st=h({abilities:v(f())}),nn=h({constraints:st,isPhantom:U()}),sn=h({TypeParameter:ue()}),Ge=Jt([h({module:f(),package:f(),function:f()}),f()]);h({rank3Days:v(Ge),rank7Days:v(Ge),rank30Days:v(Ge)});function Zt(e){if(!e)return!1;if(typeof e=="string"||N(e,sn)||Yt(e))return!0;if(typeof e!="object")return!1;const t=e;return!!(N(t.Reference,le)||N(t.MutableReference,le)||N(t.Vector,le))}const le=P("SuiMoveNormalizedType",Zt);function Yt(e){if(!e||typeof e!="object")return!1;const t=e;if(!t.Struct||typeof t.Struct!="object")return!1;const r=t.Struct;return!(typeof r.address!="string"||typeof r.module!="string"||typeof r.name!="string"||!Array.isArray(r.typeArguments)||!r.typeArguments.every(n=>Zt(n)))}P("SuiMoveNormalizedStructType",Yt);const an=h({visibility:rn,isEntry:U(),typeParameters:v(st),parameters:v(le),return:v(le)}),on=h({name:f(),type:le}),cn=h({abilities:st,typeParameters:v(nn),fields:v(on)}),un=h({fileFormatVersion:ue(),address:f(),name:f(),friends:v(tn),structs:H(f(),cn),exposedFunctions:H(f(),an)});H(f(),un);function Ye(e){return typeof e=="object"&&"MutableReference"in e?e.MutableReference:void 0}function Qt(e){return typeof e=="object"&&"Reference"in e?e.Reference:void 0}function at(e){if(typeof e=="object"&&"Struct"in e)return e;const t=Qt(e),r=Ye(e);if(typeof t=="object"&&"Struct"in t)return t;if(typeof r=="object"&&"Struct"in r)return r}function dn(e){if(e.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),r=0;r<t.length;r++)t[r]=255;for(var n=0;n<e.length;n++){var i=e.charAt(n),s=i.charCodeAt(0);if(t[s]!==255)throw new TypeError(i+" is ambiguous");t[s]=n}var a=e.length,o=e.charAt(0),u=Math.log(a)/Math.log(256),d=Math.log(256)/Math.log(a);function l(p){if(p instanceof Uint8Array||(ArrayBuffer.isView(p)?p=new Uint8Array(p.buffer,p.byteOffset,p.byteLength):Array.isArray(p)&&(p=Uint8Array.from(p))),!(p instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(p.length===0)return"";for(var y=0,S=0,E=0,A=p.length;E!==A&&p[E]===0;)E++,y++;for(var _=(A-E)*d+1>>>0,D=new Uint8Array(_);E!==A;){for(var X=p[E],ne=0,G=_-1;(X!==0||ne<S)&&G!==-1;G--,ne++)X+=256*D[G]>>>0,D[G]=X%a>>>0,X=X/a>>>0;if(X!==0)throw new Error("Non-zero carry");S=ne,E++}for(var Y=_-S;Y!==_&&D[Y]===0;)Y++;for(var Oe=o.repeat(y);Y<_;++Y)Oe+=e.charAt(D[Y]);return Oe}function g(p){if(typeof p!="string")throw new TypeError("Expected String");if(p.length===0)return new Uint8Array;for(var y=0,S=0,E=0;p[y]===o;)S++,y++;for(var A=(p.length-y)*u+1>>>0,_=new Uint8Array(A);p[y];){var D=t[p.charCodeAt(y)];if(D===255)return;for(var X=0,ne=A-1;(D!==0||X<E)&&ne!==-1;ne--,X++)D+=a*_[ne]>>>0,_[ne]=D%256>>>0,D=D/256>>>0;if(D!==0)throw new Error("Non-zero carry");E=X,y++}for(var G=A-E;G!==A&&_[G]===0;)G++;for(var Y=new Uint8Array(S+(A-G)),Oe=S;G!==A;)Y[Oe++]=_[G++];return Y}function m(p){var y=g(p);if(y)return y;throw new Error("Non-base"+a+" character")}return{encode:l,decodeUnsafe:g,decode:m}}var fn=dn;const ln=fn,hn="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";var gn=ln(hn);const er=Ir(gn),xe=e=>er.encode(e),ot=e=>er.decode(e);function ae(e){return Uint8Array.from(atob(e),t=>t.charCodeAt(0))}const Fe=8192;function Ie(e){if(e.length<Fe)return btoa(String.fromCharCode(...e));let t="";for(var r=0;r<e.length;r+=Fe){const n=e.slice(r,r+Fe);t+=String.fromCharCode(...n)}return btoa(t)}function Ve(e){var i;const t=e.startsWith("0x")?e.slice(2):e,n=((i=(t.length%2===0?t:`0${t}}`).match(/.{2}/g))==null?void 0:i.map(s=>parseInt(s,16)))??[];return Uint8Array.from(n)}function je(e){return e.reduce((t,r)=>t+r.toString(16).padStart(2,"0"),"")}function ct(e){let t=[],r=0;if(e===0)return[0];for(;e>0;)t[r]=e&127,(e>>=7)&&(t[r]|=128),r+=1;return t}function pn(e){let t=0,r=0,n=0;for(;;){let i=e[n];if(n+=1,t|=(i&127)<<r,!(i&128))break;r+=7}return{value:t,length:n}}class tr{constructor(t){this.bytePosition=0,this.dataView=new DataView(t.buffer)}shift(t){return this.bytePosition+=t,this}read8(){let t=this.dataView.getUint8(this.bytePosition);return this.shift(1),t}read16(){let t=this.dataView.getUint16(this.bytePosition,!0);return this.shift(2),t}read32(){let t=this.dataView.getUint32(this.bytePosition,!0);return this.shift(4),t}read64(){let t=this.read32(),n=this.read32().toString(16)+t.toString(16).padStart(8,"0");return BigInt("0x"+n).toString(10)}read128(){let t=BigInt(this.read64()),n=BigInt(this.read64()).toString(16)+t.toString(16).padStart(16,"0");return BigInt("0x"+n).toString(10)}read256(){let t=BigInt(this.read128()),n=BigInt(this.read128()).toString(16)+t.toString(16).padStart(32,"0");return BigInt("0x"+n).toString(10)}readBytes(t){let r=this.bytePosition+this.dataView.byteOffset,n=new Uint8Array(this.dataView.buffer,r,t);return this.shift(t),n}readULEB(){let t=this.bytePosition+this.dataView.byteOffset,r=new Uint8Array(this.dataView.buffer,t),{value:n,length:i}=pn(r);return this.shift(i),n}readVec(t){let r=this.readULEB(),n=[];for(let i=0;i<r;i++)n.push(t(this,i,r));return n}}function mn(e,t){switch(t){case"base58":return xe(e);case"base64":return Ie(e);case"hex":return je(e);default:throw new Error("Unsupported encoding, supported values are: base64, hex")}}function yn(e,t){switch(t){case"base58":return ot(e);case"base64":return ae(e);case"hex":return Ve(e);default:throw new Error("Unsupported encoding, supported values are: base64, hex")}}function rr(e,t=["<",">"]){const[r,n]=t,i=[];let s="",a=0;for(let o=0;o<e.length;o++){const u=e[o];if(u===r&&a++,u===n&&a--,a===0&&u===","){i.push(s.trim()),s="";continue}s+=u}return i.push(s.trim()),i}class nr{constructor({size:t=1024,maxSize:r,allocateSize:n=1024}={}){this.bytePosition=0,this.size=t,this.maxSize=r||t,this.allocateSize=n,this.dataView=new DataView(new ArrayBuffer(t))}ensureSizeOrGrow(t){const r=this.bytePosition+t;if(r>this.size){const n=Math.min(this.maxSize,this.size+this.allocateSize);if(r>n)throw new Error(`Attempting to serialize to BCS, but buffer does not have enough size. Allocated size: ${this.size}, Max size: ${this.maxSize}, Required size: ${r}`);this.size=n;const i=new ArrayBuffer(this.size);new Uint8Array(i).set(new Uint8Array(this.dataView.buffer)),this.dataView=new DataView(i)}}shift(t){return this.bytePosition+=t,this}write8(t){return this.ensureSizeOrGrow(1),this.dataView.setUint8(this.bytePosition,Number(t)),this.shift(1)}write16(t){return this.ensureSizeOrGrow(2),this.dataView.setUint16(this.bytePosition,Number(t),!0),this.shift(2)}write32(t){return this.ensureSizeOrGrow(4),this.dataView.setUint32(this.bytePosition,Number(t),!0),this.shift(4)}write64(t){return Le(BigInt(t),8).forEach(r=>this.write8(r)),this}write128(t){return Le(BigInt(t),16).forEach(r=>this.write8(r)),this}write256(t){return Le(BigInt(t),32).forEach(r=>this.write8(r)),this}writeULEB(t){return ct(t).forEach(r=>this.write8(r)),this}writeVec(t,r){return this.writeULEB(t.length),Array.from(t).forEach((n,i)=>r(this,n,i,t.length)),this}*[Symbol.iterator](){for(let t=0;t<this.bytePosition;t++)yield this.dataView.getUint8(t);return this.toBytes()}toBytes(){return new Uint8Array(this.dataView.buffer.slice(0,this.bytePosition))}toString(t){return mn(this.toBytes(),t)}}function Le(e,t){let r=new Uint8Array(t),n=0;for(;e>0;)r[n]=Number(e%BigInt(256)),e=e/BigInt(256),n+=1;return r}var ir=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},K=(e,t,r)=>(ir(e,t,"read from private field"),r?r.call(e):t.get(e)),Be=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},Re=(e,t,r,n)=>(ir(e,t,"write to private field"),t.set(e,r),r),fe,ge,Ce,ie;const sr=class{constructor(e){Be(this,fe,void 0),Be(this,ge,void 0),this.name=e.name,this.read=e.read,this.serializedSize=e.serializedSize??(()=>null),Re(this,fe,e.write),Re(this,ge,e.serialize??((t,r)=>{const n=new nr({size:this.serializedSize(t)??void 0,...r});return K(this,fe).call(this,t,n),n.toBytes()})),this.validate=e.validate??(()=>{})}write(e,t){this.validate(e),K(this,fe).call(this,e,t)}serialize(e,t){return this.validate(e),new wn(this,K(this,ge).call(this,e,t))}parse(e){const t=new tr(e);return this.read(t)}transform({name:e,input:t,output:r}){return new sr({name:e??this.name,read:n=>r(this.read(n)),write:(n,i)=>K(this,fe).call(this,t(n),i),serializedSize:n=>this.serializedSize(t(n)),serialize:(n,i)=>K(this,ge).call(this,t(n),i),validate:n=>this.validate(t(n))})}};let W=sr;fe=new WeakMap;ge=new WeakMap;const ar=Symbol.for("@mysten/serialized-bcs");function ut(e){return!!e&&typeof e=="object"&&e[ar]===!0}class wn{constructor(t,r){Be(this,Ce,void 0),Be(this,ie,void 0),Re(this,Ce,t),Re(this,ie,r)}get[ar](){return!0}toBytes(){return K(this,ie)}toHex(){return je(K(this,ie))}toBase64(){return Ie(K(this,ie))}toBase58(){return xe(K(this,ie))}parse(){return K(this,Ce).parse(K(this,ie))}}Ce=new WeakMap;ie=new WeakMap;function Ne({size:e,...t}){return new W({...t,serializedSize:()=>e})}function Ke({readMethod:e,writeMethod:t,...r}){return Ne({...r,read:n=>n[e](),write:(n,i)=>i[t](n),validate:n=>{var i;if(n<0||n>r.maxValue)throw new TypeError(`Invalid ${r.name} value: ${n}. Expected value in range 0-${r.maxValue}`);(i=r.validate)==null||i.call(r,n)}})}function We({readMethod:e,writeMethod:t,...r}){return Ne({...r,read:n=>n[e](),write:(n,i)=>i[t](BigInt(n)),validate:n=>{var s;const i=BigInt(n);if(i<0||i>r.maxValue)throw new TypeError(`Invalid ${r.name} value: ${i}. Expected value in range 0-${r.maxValue}`);(s=r.validate)==null||s.call(r,i)}})}function bn({serialize:e,...t}){const r=new W({...t,serialize:e,write:(n,i)=>{for(const s of r.serialize(n).toBytes())i.write8(s)}});return r}function Sn({toBytes:e,fromBytes:t,...r}){return new W({...r,read:n=>{const i=n.readULEB(),s=n.readBytes(i);return t(s)},write:(n,i)=>{const s=e(n);i.writeULEB(s.length);for(let a=0;a<s.length;a++)i.write8(s[a])},serialize:n=>{const i=e(n),s=ct(i.length),a=new Uint8Array(s.length+i.length);return a.set(s,0),a.set(i,s.length),a},validate:n=>{var i;if(typeof n!="string")throw new TypeError(`Invalid ${r.name} value: ${n}. Expected string`);(i=r.validate)==null||i.call(r,n)}})}function Tn(e){let t=null;function r(){return t||(t=e()),t}return new W({name:"lazy",read:n=>r().read(n),serializedSize:n=>r().serializedSize(n),write:(n,i)=>r().write(n,i),serialize:(n,i)=>r().serialize(n,i).toBytes()})}const c={u8(e){return Ke({name:"u8",readMethod:"read8",writeMethod:"write8",size:1,maxValue:2**8-1,...e})},u16(e){return Ke({name:"u16",readMethod:"read16",writeMethod:"write16",size:2,maxValue:2**16-1,...e})},u32(e){return Ke({name:"u32",readMethod:"read32",writeMethod:"write32",size:4,maxValue:2**32-1,...e})},u64(e){return We({name:"u64",readMethod:"read64",writeMethod:"write64",size:8,maxValue:2n**64n-1n,...e})},u128(e){return We({name:"u128",readMethod:"read128",writeMethod:"write128",size:16,maxValue:2n**128n-1n,...e})},u256(e){return We({name:"u256",readMethod:"read256",writeMethod:"write256",size:32,maxValue:2n**256n-1n,...e})},bool(e){return Ne({name:"bool",size:1,read:t=>t.read8()===1,write:(t,r)=>r.write8(t?1:0),...e,validate:t=>{var r;if((r=e==null?void 0:e.validate)==null||r.call(e,t),typeof t!="boolean")throw new TypeError(`Expected boolean, found ${typeof t}`)}})},uleb128(e){return bn({name:"uleb128",read:t=>t.readULEB(),serialize:t=>Uint8Array.from(ct(t)),...e})},bytes(e,t){return Ne({name:`bytes[${e}]`,size:e,read:r=>r.readBytes(e),write:(r,n)=>{for(let i=0;i<e;i++)n.write8(r[i]??0)},...t,validate:r=>{var n;if((n=t==null?void 0:t.validate)==null||n.call(t,r),!("length"in r))throw new TypeError(`Expected array, found ${typeof r}`);if(r.length!==e)throw new TypeError(`Expected array of length ${e}, found ${r.length}`)}})},string(e){return Sn({name:"string",toBytes:t=>new TextEncoder().encode(t),fromBytes:t=>new TextDecoder().decode(t),...e})},fixedArray(e,t,r){return new W({name:`${t.name}[${e}]`,read:n=>{const i=new Array(e);for(let s=0;s<e;s++)i[s]=t.read(n);return i},write:(n,i)=>{for(const s of n)t.write(s,i)},...r,validate:n=>{var i;if((i=r==null?void 0:r.validate)==null||i.call(r,n),!("length"in n))throw new TypeError(`Expected array, found ${typeof n}`);if(n.length!==e)throw new TypeError(`Expected array of length ${e}, found ${n.length}`)}})},option(e){return c.enum(`Option<${e.name}>`,{None:null,Some:e}).transform({input:t=>t==null?{None:!0}:{Some:t},output:t=>"Some"in t?t.Some:null})},vector(e,t){return new W({name:`vector<${e.name}>`,read:r=>{const n=r.readULEB(),i=new Array(n);for(let s=0;s<n;s++)i[s]=e.read(r);return i},write:(r,n)=>{n.writeULEB(r.length);for(const i of r)e.write(i,n)},...t,validate:r=>{var n;if((n=t==null?void 0:t.validate)==null||n.call(t,r),!("length"in r))throw new TypeError(`Expected array, found ${typeof r}`)}})},tuple(e,t){return new W({name:`(${e.map(r=>r.name).join(", ")})`,serializedSize:r=>{let n=0;for(let i=0;i<e.length;i++){const s=e[i].serializedSize(r[i]);if(s==null)return null;n+=s}return n},read:r=>{const n=[];for(const i of e)n.push(i.read(r));return n},write:(r,n)=>{for(let i=0;i<e.length;i++)e[i].write(r[i],n)},...t,validate:r=>{var n;if((n=t==null?void 0:t.validate)==null||n.call(t,r),!Array.isArray(r))throw new TypeError(`Expected array, found ${typeof r}`);if(r.length!==e.length)throw new TypeError(`Expected array of length ${e.length}, found ${r.length}`)}})},struct(e,t,r){const n=Object.entries(t);return new W({name:e,serializedSize:i=>{let s=0;for(const[a,o]of n){const u=o.serializedSize(i[a]);if(u==null)return null;s+=u}return s},read:i=>{const s={};for(const[a,o]of n)s[a]=o.read(i);return s},write:(i,s)=>{for(const[a,o]of n)o.write(i[a],s)},...r,validate:i=>{var s;if((s=r==null?void 0:r.validate)==null||s.call(r,i),typeof i!="object"||i==null)throw new TypeError(`Expected object, found ${typeof i}`)}})},enum(e,t,r){const n=Object.entries(t);return new W({name:e,read:i=>{const s=i.readULEB(),[a,o]=n[s];return{[a]:(o==null?void 0:o.read(i))??!0}},write:(i,s)=>{const[a,o]=Object.entries(i)[0];for(let u=0;u<n.length;u++){const[d,l]=n[u];if(d===a){s.writeULEB(u),l==null||l.write(o,s);return}}},...r,validate:i=>{var o;if((o=r==null?void 0:r.validate)==null||o.call(r,i),typeof i!="object"||i==null)throw new TypeError(`Expected object, found ${typeof i}`);const s=Object.keys(i);if(s.length!==1)throw new TypeError(`Expected object with one key, found ${s.length}`);const[a]=s;if(!Object.hasOwn(t,a))throw new TypeError(`Invalid enum variant ${a}`)}})},map(e,t){return c.vector(c.tuple([e,t])).transform({name:`Map<${e.name}, ${t.name}>`,input:r=>[...r.entries()],output:r=>{const n=new Map;for(const[i,s]of r)n.set(i,s);return n}})},generic(e,t){return(...r)=>t(...r).transform({name:`${t.name}<${r.map(n=>n.name).join(", ")}>`,input:n=>n,output:n=>n})},lazy(e){return Tn(e)}},vn=32,pe=class{constructor(e){if(this.types=new Map,this.counter=0,e instanceof pe){this.schema=e.schema,this.types=new Map(e.types);return}if(this.schema=e,this.registerAddressType(pe.ADDRESS,e.addressLength,e.addressEncoding),this.registerVectorType(e.vectorType),e.types&&e.types.structs)for(let t of Object.keys(e.types.structs))this.registerStructType(t,e.types.structs[t]);if(e.types&&e.types.enums)for(let t of Object.keys(e.types.enums))this.registerEnumType(t,e.types.enums[t]);if(e.types&&e.types.aliases)for(let t of Object.keys(e.types.aliases))this.registerAlias(t,e.types.aliases[t]);e.withPrimitives!==!1&&En(this)}tempKey(){return`bcs-struct-${++this.counter}`}ser(e,t,r){if(typeof e=="string"||Array.isArray(e)){const{name:n,params:i}=this.parseTypeName(e);return this.getTypeInterface(n).encode(this,t,r,i)}if(typeof e=="object"){const n=this.tempKey();return new pe(this).registerStructType(n,e).ser(n,t,r)}throw new Error(`Incorrect type passed into the '.ser()' function.
|
|
2
|
+
${JSON.stringify(e)}`)}de(e,t,r){if(typeof t=="string")if(r)t=yn(t,r);else throw new Error("To pass a string to `bcs.de`, specify encoding");if(typeof e=="string"||Array.isArray(e)){const{name:n,params:i}=this.parseTypeName(e);return this.getTypeInterface(n).decode(this,t,i)}if(typeof e=="object"){const n=new pe(this),i=this.tempKey();return n.registerStructType(i,e).de(i,t,r)}throw new Error(`Incorrect type passed into the '.de()' function.
|
|
3
|
+
${JSON.stringify(e)}`)}hasType(e){return this.types.has(e)}registerAlias(e,t){return this.types.set(e,t),this}registerType(e,t,r,n=()=>!0){const{name:i,params:s}=this.parseTypeName(e);return this.types.set(i,{encode(a,o,u,d){const l=s.reduce((g,m,p)=>Object.assign(g,{[m]:d[p]}),{});return this._encodeRaw.call(a,new nr(u),o,d,l)},decode(a,o,u){const d=s.reduce((l,g,m)=>Object.assign(l,{[g]:u[m]}),{});return this._decodeRaw.call(a,new tr(o),u,d)},_encodeRaw(a,o,u,d){if(n(o))return t.call(this,a,o,u,d);throw new Error(`Validation failed for type ${i}, data: ${o}`)},_decodeRaw(a,o,u){return r.call(this,a,o,u)}}),this}registerBcsType(e,t){return this.registerType(e,(r,n,i)=>{const s=i.map(a=>new W({name:String(a),write:(o,u)=>{const{name:d,params:l}=this.parseTypeName(a),g=this.getTypeInterface(d),m=l.reduce((p,y,S)=>Object.assign(p,{[y]:i[S]}),{});return g._encodeRaw.call(this,u,o,l,m)},read:()=>{throw new Error("Not implemented")}}));return t(...s).write(n,r),r},(r,n)=>{const i=n.map(s=>new W({name:String(s),write:(a,o)=>{throw new Error("Not implemented")},read:a=>{const{name:o,params:u}=this.parseTypeName(s),d=this.getTypeInterface(o),l=u.reduce((g,m,p)=>Object.assign(g,{[m]:n[p]}),{});return d._decodeRaw.call(this,a,u,l)}}));return t(...i).read(r)}),this}registerAddressType(e,t,r="hex"){switch(r){case"base64":return this.registerType(e,function(i,s){return ae(s).reduce((a,o)=>a.write8(o),i)},function(i){return Ie(i.readBytes(t))});case"hex":return this.registerType(e,function(i,s){return Ve(s).reduce((a,o)=>a.write8(o),i)},function(i){return je(i.readBytes(t))});default:throw new Error("Unsupported encoding! Use either hex or base64")}}registerVectorType(e){let{name:t,params:r}=this.parseTypeName(e);if(r.length>1)throw new Error("Vector can have only one type parameter; got "+t);return this.registerType(e,function(i,s,a,o){return i.writeVec(s,(u,d)=>{let l=a[0];if(!l)throw new Error(`Incorrect number of type parameters passed a to vector '${e}'`);let{name:g,params:m}=this.parseTypeName(l);if(this.hasType(g))return this.getTypeInterface(g)._encodeRaw.call(this,u,d,m,o);if(!(g in o))throw new Error(`Unable to find a matching type definition for ${g} in vector; make sure you passed a generic`);let{name:p,params:y}=this.parseTypeName(o[g]);return this.getTypeInterface(p)._encodeRaw.call(this,u,d,y,o)})},function(i,s,a){return i.readVec(o=>{let u=s[0];if(!u)throw new Error(`Incorrect number of type parameters passed to a vector '${e}'`);let{name:d,params:l}=this.parseTypeName(u);if(this.hasType(d))return this.getTypeInterface(d)._decodeRaw.call(this,o,l,a);if(!(d in a))throw new Error(`Unable to find a matching type definition for ${d} in vector; make sure you passed a generic`);let{name:g,params:m}=this.parseTypeName(a[d]);return this.getTypeInterface(g)._decodeRaw.call(this,o,m,a)})})}registerStructType(e,t){for(let a in t){let o=this.tempKey(),u=t[a];!Array.isArray(u)&&typeof u!="string"&&(t[a]=o,this.registerStructType(o,u))}let r=Object.freeze(t),n=Object.keys(r),{name:i,params:s}=this.parseTypeName(e);return this.registerType(e,function(o,u,d,l){if(!u||u.constructor!==Object)throw new Error(`Expected ${i} to be an Object, got: ${u}`);if(d.length!==s.length)throw new Error(`Incorrect number of generic parameters passed; expected: ${s.length}, got: ${d.length}`);for(let g of n){if(!(g in u))throw new Error(`Struct ${i} requires field ${g}:${r[g]}`);const{name:m,params:p}=this.parseTypeName(r[g]);if(!s.includes(m))this.getTypeInterface(m)._encodeRaw.call(this,o,u[g],p,l);else{const y=s.indexOf(m);let{name:S,params:E}=this.parseTypeName(d[y]);if(this.hasType(S)){this.getTypeInterface(S)._encodeRaw.call(this,o,u[g],E,l);continue}if(!(S in l))throw new Error(`Unable to find a matching type definition for ${S} in ${i}; make sure you passed a generic`);let{name:A,params:_}=this.parseTypeName(l[S]);this.getTypeInterface(A)._encodeRaw.call(this,o,u[g],_,l)}}return o},function(o,u,d){if(u.length!==s.length)throw new Error(`Incorrect number of generic parameters passed; expected: ${s.length}, got: ${u.length}`);let l={};for(let g of n){const{name:m,params:p}=this.parseTypeName(r[g]);if(!s.includes(m))l[g]=this.getTypeInterface(m)._decodeRaw.call(this,o,p,d);else{const y=s.indexOf(m);let{name:S,params:E}=this.parseTypeName(u[y]);if(this.hasType(S)){l[g]=this.getTypeInterface(S)._decodeRaw.call(this,o,E,d);continue}if(!(S in d))throw new Error(`Unable to find a matching type definition for ${S} in ${i}; make sure you passed a generic`);let{name:A,params:_}=this.parseTypeName(d[S]);l[g]=this.getTypeInterface(A)._decodeRaw.call(this,o,_,d)}}return l})}registerEnumType(e,t){for(let a in t){let o=this.tempKey(),u=t[a];u!==null&&!Array.isArray(u)&&typeof u!="string"&&(t[a]=o,this.registerStructType(o,u))}let r=Object.freeze(t),n=Object.keys(r),{name:i,params:s}=this.parseTypeName(e);return this.registerType(e,function(o,u,d,l){if(!u)throw new Error(`Unable to write enum "${i}", missing data.
|
|
4
|
+
Received: "${u}"`);if(typeof u!="object")throw new Error(`Incorrect data passed into enum "${i}", expected object with properties: "${n.join(" | ")}".
|
|
5
|
+
Received: "${JSON.stringify(u)}"`);let g=Object.keys(u)[0];if(g===void 0)throw new Error(`Empty object passed as invariant of the enum "${i}"`);let m=n.indexOf(g);if(m===-1)throw new Error(`Unknown invariant of the enum "${i}", allowed values: "${n.join(" | ")}"; received "${g}"`);let p=n[m],y=r[p];if(o.write8(m),y===null)return o;let S=s.indexOf(y),E=S===-1?y:d[S];{let{name:A,params:_}=this.parseTypeName(E);return this.getTypeInterface(A)._encodeRaw.call(this,o,u[g],_,l)}},function(o,u,d){let l=o.readULEB(),g=n[l],m=r[g];if(l===-1)throw new Error(`Decoding type mismatch, expected enum "${i}" invariant index, received "${l}"`);if(m===null)return{[g]:!0};let p=s.indexOf(m),y=p===-1?m:u[p];{let{name:S,params:E}=this.parseTypeName(y);return{[g]:this.getTypeInterface(S)._decodeRaw.call(this,o,E,d)}}})}getTypeInterface(e){let t=this.types.get(e);if(typeof t=="string"){let r=[];for(;typeof t=="string";){if(r.includes(t))throw new Error(`Recursive definition found: ${r.join(" -> ")} -> ${t}`);r.push(t),t=this.types.get(t)}}if(t===void 0)throw new Error(`Type ${e} is not registered`);return t}parseTypeName(e){if(Array.isArray(e)){let[o,...u]=e;return{name:o,params:u}}if(typeof e!="string")throw new Error(`Illegal type passed as a name of the type: ${e}`);let[t,r]=this.schema.genericSeparators||["<",">"],n=e.indexOf(t),i=Array.from(e).reverse().indexOf(r);if(n===-1&&i===-1)return{name:e,params:[]};if(n===-1||i===-1)throw new Error(`Unclosed generic in name '${e}'`);let s=e.slice(0,n),a=rr(e.slice(n+1,e.length-i-1),this.schema.genericSeparators);return{name:s,params:a}}};let j=pe;j.U8="u8";j.U16="u16";j.U32="u32";j.U64="u64";j.U128="u128";j.U256="u256";j.BOOL="bool";j.VECTOR="vector";j.ADDRESS="address";j.STRING="string";j.HEX="hex-string";j.BASE58="base58-string";j.BASE64="base64-string";function En(e){e.registerType(j.U8,function(t,r){return t.write8(r)},function(t){return t.read8()},t=>t<256),e.registerType(j.U16,function(t,r){return t.write16(r)},function(t){return t.read16()},t=>t<65536),e.registerType(j.U32,function(t,r){return t.write32(r)},function(t){return t.read32()},t=>t<=4294967296n),e.registerType(j.U64,function(t,r){return t.write64(r)},function(t){return t.read64()}),e.registerType(j.U128,function(t,r){return t.write128(r)},function(t){return t.read128()}),e.registerType(j.U256,function(t,r){return t.write256(r)},function(t){return t.read256()}),e.registerType(j.BOOL,function(t,r){return t.write8(r)},function(t){return t.read8().toString(10)==="1"}),e.registerType(j.STRING,function(t,r){return t.writeVec(Array.from(r),(n,i)=>n.write8(i.charCodeAt(0)))},function(t){return t.readVec(r=>r.read8()).map(r=>String.fromCharCode(Number(r))).join("")},t=>!0),e.registerType(j.HEX,function(t,r){return t.writeVec(Array.from(Ve(r)),(n,i)=>n.write8(i))},function(t){let r=t.readVec(n=>n.read8());return je(new Uint8Array(r))}),e.registerType(j.BASE58,function(t,r){return t.writeVec(Array.from(ot(r)),(n,i)=>n.write8(i))},function(t){let r=t.readVec(n=>n.read8());return xe(new Uint8Array(r))}),e.registerType(j.BASE64,function(t,r){return t.writeVec(Array.from(ae(r)),(n,i)=>n.write8(i))},function(t){let r=t.readVec(n=>n.read8());return Ie(new Uint8Array(r))})}function xn(){return{genericSeparators:["<",">"],vectorType:"vector",addressLength:vn,addressEncoding:"hex"}}const dt=32;function In(e){return jn(e)&&On(e)===dt}function M(e,t=!1){let r=e.toLowerCase();return!t&&r.startsWith("0x")&&(r=r.slice(2)),`0x${r.padStart(dt*2,"0")}`}function be(e,t=!1){return M(e,t)}function jn(e){return/^(0x|0X)?[a-fA-F0-9]+$/.test(e)&&e.length%2===0}function On(e){return/^(0x|0X)/.test(e)?(e.length-2)/2:e.length/2}BigInt(1e9);const ft="0x1",or="0x2";be("0x6");const An=`${or}::sui::SUI`;be("0x5");const kn="object",_n="ID",Cn="ascii",$n="String",Mn="string",Un="String",Bn="option",Rn="Option",Nn={address:or,module:kn,name:_n},Pn={address:ft,module:Cn,name:$n},Dn={address:ft,module:Mn,name:Un},zn={address:ft,module:Bn,name:Rn},Ae=(e,t)=>e.address===t.address&&e.module===t.module&&e.name===t.name;function Vn(e){var r;const t=(r=at(e))==null?void 0:r.Struct;return(t==null?void 0:t.address)==="0x2"&&(t==null?void 0:t.module)==="tx_context"&&(t==null?void 0:t.name)==="TxContext"}function Je(e,t){if(!(typeof t>"u")&&typeof t!==e)throw new Error(`Expect ${t} to be ${e}, received ${typeof t}`)}const Gn=["Address","Bool","U8","U16","U32","U64","U128","U256"];function Qe(e,t){if(typeof e=="string"&&Gn.includes(e)){if(e in["U8","U16","U32","U64","U128","U256"])Je("number",t);else if(e==="Bool")Je("boolean",t);else if(e==="Address"&&(Je("string",t),t&&!In(t)))throw new Error("Invalid Sui Address");return e.toLowerCase()}else if(typeof e=="string")throw new Error(`Unknown pure normalized type ${JSON.stringify(e,null,2)}`);if("Vector"in e){if((t===void 0||typeof t=="string")&&e.Vector==="U8")return"string";if(t!==void 0&&!Array.isArray(t))throw new Error(`Expect ${t} to be a array, received ${typeof t}`);const r=Qe(e.Vector,t?t[0]:void 0);return r===void 0?void 0:`vector<${r}>`}if("Struct"in e){if(Ae(e.Struct,Pn))return"string";if(Ae(e.Struct,Dn))return"utf8string";if(Ae(e.Struct,Nn))return"address";if(Ae(e.Struct,zn)){const r={Vector:e.Struct.typeArguments[0]};return Qe(r,t)}}}const Fn=/^vector<(.+)>$/,Ln=/^([^:]+)::([^:]+)::([^<]+)(<(.+)>)?/;class ee{static parseFromStr(t,r=!1){if(t==="address")return{address:null};if(t==="bool")return{bool:null};if(t==="u8")return{u8:null};if(t==="u16")return{u16:null};if(t==="u32")return{u32:null};if(t==="u64")return{u64:null};if(t==="u128")return{u128:null};if(t==="u256")return{u256:null};if(t==="signer")return{signer:null};const n=t.match(Fn);if(n)return{vector:ee.parseFromStr(n[1],r)};const i=t.match(Ln);if(i)return{struct:{address:r?M(i[1]):i[1],module:i[2],name:i[3],typeParams:i[5]===void 0?[]:ee.parseStructTypeArgs(i[5],r)}};throw new Error(`Encountered unexpected token when parsing type args for ${t}`)}static parseStructTypeArgs(t,r=!1){return rr(t).map(n=>ee.parseFromStr(n,r))}static tagToString(t){if("bool"in t)return"bool";if("u8"in t)return"u8";if("u16"in t)return"u16";if("u32"in t)return"u32";if("u64"in t)return"u64";if("u128"in t)return"u128";if("u256"in t)return"u256";if("address"in t)return"address";if("signer"in t)return"signer";if("vector"in t)return`vector<${ee.tagToString(t.vector)}>`;if("struct"in t){const r=t.struct,n=r.typeParams.map(ee.tagToString).join(", ");return`${r.address}::${r.module}::${r.name}${n?`<${n}>`:""}`}throw new Error("Invalid TypeTag")}}const I=new j({...xn(),types:{enums:{"Option<T>":{None:null,Some:"T"}}}});function cr(e){return c.u64({name:"unsafe_u64",...e}).transform({input:t=>t,output:t=>Number(t)})}function Kn(e){return c.enum("Option",{None:null,Some:e})}function lt(e){return e.transform({input:t=>({[t.kind]:t}),output:t=>{const r=Object.keys(t)[0];return{kind:r,...t[r]}}})}const J=c.bytes(dt).transform({input:e=>typeof e=="string"?Ve(M(e)):e,output:e=>M(je(e))}),ht=c.vector(c.u8()).transform({name:"ObjectDigest",input:e=>ot(e),output:e=>xe(new Uint8Array(e))}),Se=c.struct("SuiObjectRef",{objectId:J,version:c.u64(),digest:ht}),gt=c.struct("SharedObjectRef",{objectId:J,initialSharedVersion:c.u64(),mutable:c.bool()}),Pe=c.enum("ObjectArg",{ImmOrOwned:Se,Shared:gt,Receiving:Se}),pt=c.enum("CallArg",{Pure:c.vector(c.u8()),Object:Pe,ObjVec:c.vector(Pe)}),he=c.enum("TypeTag",{bool:null,u8:null,u64:null,u128:null,address:null,signer:null,vector:c.lazy(()=>he),struct:c.lazy(()=>Tt),u16:null,u32:null,u256:null}),L=lt(c.enum("Argument",{GasCoin:null,Input:c.struct("Input",{index:c.u16()}),Result:c.struct("Result",{index:c.u16()}),NestedResult:c.struct("NestedResult",{index:c.u16(),resultIndex:c.u16()})})),mt=c.struct("ProgrammableMoveCall",{package:J,module:c.string(),function:c.string(),type_arguments:c.vector(he),arguments:c.vector(L)}).transform({input:e=>{const[t,r,n]=e.target.split("::"),i=e.typeArguments.map(s=>ee.parseFromStr(s,!0));return{package:M(t),module:r,function:n,type_arguments:i,arguments:e.arguments}},output:e=>({target:[e.package,e.module,e.function].join("::"),arguments:e.arguments,typeArguments:e.type_arguments.map(ee.tagToString)})}),yt=lt(c.enum("Transaction",{MoveCall:mt,TransferObjects:c.struct("TransferObjects",{objects:c.vector(L),address:L}),SplitCoins:c.struct("SplitCoins",{coin:L,amounts:c.vector(L)}),MergeCoins:c.struct("MergeCoins",{destination:L,sources:c.vector(L)}),Publish:c.struct("Publish",{modules:c.vector(c.vector(c.u8())),dependencies:c.vector(J)}),MakeMoveVec:c.struct("MakeMoveVec",{type:Kn(he),objects:c.vector(L)}),Upgrade:c.struct("Upgrade",{modules:c.vector(c.vector(c.u8())),dependencies:c.vector(J),packageId:J,ticket:L})})),wt=c.struct("ProgrammableTransaction",{inputs:c.vector(pt),transactions:c.vector(yt)}),bt=c.enum("TransactionKind",{ProgrammableTransaction:wt,ChangeEpoch:null,Genesis:null,ConsensusCommitPrologue:null}),St=c.enum("TransactionExpiration",{None:null,Epoch:cr()}),Tt=c.struct("StructTag",{address:J,module:c.string(),name:c.string(),typeParams:c.vector(he)}),vt=c.struct("GasData",{payment:c.vector(Se),owner:J,price:c.u64(),budget:c.u64()}),Et=c.struct("TransactionDataV1",{kind:bt,sender:J,gasData:vt,expiration:St}),xt=c.enum("TransactionData",{V1:Et}),Wn=c.enum("IntentScope",{TransactionData:null,TransactionEffects:null,CheckpointSummary:null,PersonalMessage:null}),Jn=c.enum("IntentVersion",{V0:null}),Hn=c.enum("AppId",{Sui:null}),Xn=c.struct("Intent",{scope:Wn,version:Jn,appId:Hn}),qn=c.generic(["T"],e=>c.struct("IntentMessage<T>",{intent:Xn,value:e})),It=c.enum("CompressedSignature",{ED25519:c.fixedArray(64,c.u8()),Secp256k1:c.fixedArray(64,c.u8()),Secp256r1:c.fixedArray(64,c.u8()),ZkLogin:c.vector(c.u8())}),jt=c.enum("PublicKey",{ED25519:c.fixedArray(32,c.u8()),Secp256k1:c.fixedArray(33,c.u8()),Secp256r1:c.fixedArray(33,c.u8()),ZkLogin:c.vector(c.u8())}),Ot=c.struct("MultiSigPkMap",{pubKey:jt,weight:c.u8()}),At=c.struct("MultiSigPublicKey",{pk_map:c.vector(Ot),threshold:c.u16()}),ur=c.struct("MultiSig",{sigs:c.vector(It),bitmap:c.u16(),multisig_pk:At}),Zn=c.vector(c.u8()).transform({input:e=>typeof e=="string"?ae(e):e,output:e=>Ie(new Uint8Array(e))}),dr=c.struct("SenderSignedTransaction",{intentMessage:qn(xt),txSignatures:c.vector(Zn)}),fr=c.vector(dr,{name:"SenderSignedData"}),C={...c,U8:c.u8(),U16:c.u16(),U32:c.u32(),U64:c.u64(),U128:c.u128(),U256:c.u256(),ULEB128:c.uleb128(),Bool:c.bool(),String:c.string(),Address:J,Argument:L,CallArg:pt,CompressedSignature:It,GasData:vt,MultiSig:ur,MultiSigPkMap:Ot,MultiSigPublicKey:At,ObjectArg:Pe,ObjectDigest:ht,ProgrammableMoveCall:mt,ProgrammableTransaction:wt,PublicKey:jt,SenderSignedData:fr,SenderSignedTransaction:dr,SharedObjectRef:gt,StructTag:Tt,SuiObjectRef:Se,Transaction:yt,TransactionData:xt,TransactionDataV1:Et,TransactionExpiration:St,TransactionKind:bt,TypeTag:he,ser:I.ser.bind(I),de:I.de.bind(I),getTypeInterface:I.getTypeInterface.bind(I),hasType:I.hasType.bind(I),parseTypeName:I.parseTypeName.bind(I),registerAddressType:I.registerAddressType.bind(I),registerAlias:I.registerAlias.bind(I),registerBcsType:I.registerBcsType.bind(I),registerEnumType:I.registerEnumType.bind(I),registerStructType:I.registerStructType.bind(I),registerType:I.registerType.bind(I),types:I.types};I.registerBcsType("utf8string",()=>c.string({name:"utf8string"}));I.registerBcsType("unsafe_u64",()=>cr());I.registerBcsType("enumKind",e=>lt(e));[J,L,pt,It,vt,ur,Ot,At,Pe,ht,mt,wt,jt,fr,gt,Tt,Se,yt,xt,Et,St,bt,he].forEach(e=>{I.registerBcsType(e.name,()=>e)});const Yn=k([h({ImmOrOwned:se}),h({Shared:h({objectId:f(),initialSharedVersion:k([q(),f()]),mutable:U()})}),h({Receiving:se})]),De=h({Pure:v(q())}),et=h({Object:Yn}),ze=k([De,et]);function Qn(e,t){return{Pure:Array.from(e instanceof Uint8Array?e:ut(e)?e.toBytes():C.ser(t,e,{maxSize:1/0}).toBytes())}}const R={Pure:Qn,ObjectRef({objectId:e,digest:t,version:r}){return{Object:{ImmOrOwned:{digest:t,version:r,objectId:M(e)}}}},SharedObjectRef({objectId:e,mutable:t,initialSharedVersion:r}){return{Object:{Shared:{mutable:t,initialSharedVersion:r,objectId:M(e)}}}},ReceivingRef({objectId:e,digest:t,version:r}){return{Object:{Receiving:{digest:t,version:r,objectId:M(e)}}}}};function Vt(e){return typeof e=="string"?M(e):"ImmOrOwned"in e.Object?M(e.Object.ImmOrOwned.objectId):"Receiving"in e.Object?M(e.Object.Receiving.objectId):M(e.Object.Shared.objectId)}function ei(e){return typeof e=="object"&&"Object"in e&&"Shared"in e.Object?e.Object.Shared:void 0}function ti(e){var t;return((t=ei(e))==null?void 0:t.mutable)??!1}function B(e,t){return Lt(e,t)}const ri=e=>k([h({None:k([b(!0),b(null)])}),h({Some:e})]),Te=k([h({kind:b("Input"),index:q(),value:w(Ze()),type:w(b("object"))}),h({kind:b("Input"),index:q(),value:w(Ze()),type:b("pure")})]),ni=[Te,h({kind:b("GasCoin")}),h({kind:b("Result"),index:q()}),h({kind:b("NestedResult"),index:q(),resultIndex:q()})],re=k([...ni]),lr=h({kind:b("MoveCall"),target:P("target",f().validator),typeArguments:v(f()),arguments:v(re)}),hr=h({kind:b("TransferObjects"),objects:v(re),address:re}),gr=h({kind:b("SplitCoins"),coin:re,amounts:v(re)}),pr=h({kind:b("MergeCoins"),destination:re,sources:v(re)}),mr=h({kind:b("MakeMoveVec"),type:w(ri(H(f(),Ht()))),objects:v(re)}),yr=h({kind:b("Publish"),modules:v(v(q())),dependencies:v(f())}),wr=h({kind:b("Upgrade"),modules:v(v(q())),dependencies:v(f()),packageId:f(),ticket:re}),ii=[lr,hr,gr,pr,yr,wr,mr],si=k([...ii]),ce={MoveCall(e){return B({kind:"MoveCall",target:e.target,arguments:e.arguments??[],typeArguments:e.typeArguments??[]},lr)},TransferObjects(e,t){return t.kind==="Input"&&t.type==="pure"&&typeof t.value!="object"&&(t.value=R.Pure(C.Address.serialize(t.value))),B({kind:"TransferObjects",objects:e,address:t},hr)},SplitCoins(e,t){return t.forEach(r=>{r.kind==="Input"&&r.type==="pure"&&typeof r.value!="object"&&(r.value=R.Pure(C.U64.serialize(r.value)))}),B({kind:"SplitCoins",coin:e,amounts:t},gr)},MergeCoins(e,t){return B({kind:"MergeCoins",destination:e,sources:t},pr)},Publish({modules:e,dependencies:t}){return B({kind:"Publish",modules:e.map(r=>typeof r=="string"?Array.from(ae(r)):r),dependencies:t.map(r=>be(r))},yr)},Upgrade({modules:e,dependencies:t,packageId:r,ticket:n}){return B({kind:"Upgrade",modules:e.map(i=>typeof i=="string"?Array.from(ae(i)):i),dependencies:t.map(i=>be(i)),packageId:r,ticket:n},wr)},MakeMoveVec({type:e,objects:t}){return B({kind:"MakeMoveVec",type:e?{Some:ee.parseFromStr(e)}:{None:null},objects:t},mr)}};function ai(e){function t(r,n){return e(r,n)}return t.u8=r=>e(C.U8.serialize(r)),t.u16=r=>e(C.U16.serialize(r)),t.u32=r=>e(C.U32.serialize(r)),t.u64=r=>e(C.U64.serialize(r)),t.u128=r=>e(C.U128.serialize(r)),t.u256=r=>e(C.U256.serialize(r)),t.bool=r=>e(C.Bool.serialize(r)),t.string=r=>e(C.String.serialize(r)),t.address=r=>e(C.Address.serialize(r)),t.id=t.address,t}function oi(e,t){const r=Array.from(`${e}::`).map(i=>i.charCodeAt(0)),n=new Uint8Array(r.length+t.length);return n.set(r),n.set(t,r.length),jr(n,{dkLen:32})}const ci=w(O(k([h({Epoch:q()}),h({None:k([b(!0),b(null)])})]))),Gt=P("StringEncodedBigint",e=>{if(!["string","number","bigint"].includes(typeof e))return!1;try{return BigInt(e),!0}catch{return!1}}),ui=h({budget:w(Gt),price:w(Gt),payment:w(v(se)),owner:w(f())}),ke=h({version:b(1),sender:w(f()),expiration:ci,gasConfig:ui,inputs:v(Te),transactions:v(si)});function Ft(e){return M(e).replace("0x","")}class te{constructor(t){this.version=1,this.sender=t==null?void 0:t.sender,this.expiration=t==null?void 0:t.expiration,this.gasConfig=(t==null?void 0:t.gasConfig)??{},this.inputs=(t==null?void 0:t.inputs)??[],this.transactions=(t==null?void 0:t.transactions)??[]}static fromKindBytes(t){const r=C.TransactionKind.parse(t),n="ProgrammableTransaction"in r?r.ProgrammableTransaction:null;if(!n)throw new Error("Unable to deserialize from bytes.");const i=B({version:1,gasConfig:{},inputs:n.inputs.map((s,a)=>B({kind:"Input",value:s,index:a,type:N(s,De)?"pure":"object"},Te)),transactions:n.transactions},ke);return te.restore(i)}static fromBytes(t){var a;const r=C.TransactionData.parse(t),n=r==null?void 0:r.V1,i="ProgrammableTransaction"in n.kind?(a=n==null?void 0:n.kind)==null?void 0:a.ProgrammableTransaction:null;if(!n||!i)throw new Error("Unable to deserialize from bytes.");const s=B({version:1,sender:n.sender,expiration:n.expiration,gasConfig:n.gasData,inputs:i.inputs.map((o,u)=>B({kind:"Input",value:o,index:u,type:N(o,De)?"pure":"object"},Te)),transactions:i.transactions},ke);return te.restore(s)}static restore(t){qe(t,ke);const r=new te;return Object.assign(r,t),r}static getDigestFromBytes(t){const r=oi("TransactionData",t);return xe(r)}build({maxSizeBytes:t=1/0,overrides:r,onlyTransactionKind:n}={}){const i=this.inputs.map(l=>(qe(l.value,ze),l.value)),s={ProgrammableTransaction:{inputs:i,transactions:this.transactions}};if(n)return C.TransactionKind.serialize(s,{maxSize:t}).toBytes();const a=(r==null?void 0:r.expiration)??this.expiration,o=(r==null?void 0:r.sender)??this.sender,u={...this.gasConfig,...r==null?void 0:r.gasConfig};if(!o)throw new Error("Missing transaction sender");if(!u.budget)throw new Error("Missing gas budget");if(!u.payment)throw new Error("Missing gas payment");if(!u.price)throw new Error("Missing gas price");const d={sender:Ft(o),expiration:a||{None:!0},gasData:{payment:u.payment,owner:Ft(this.gasConfig.owner??o),price:BigInt(u.price),budget:BigInt(u.budget)},kind:{ProgrammableTransaction:{inputs:i,transactions:this.transactions}}};return C.TransactionData.serialize({V1:d},{maxSize:t}).toBytes()}getDigest(){const t=this.build({onlyTransactionKind:!1});return te.getDigestFromBytes(t)}snapshot(){return B(this,ke)}}var kt=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},x=(e,t,r)=>(kt(e,t,"read from private field"),r?r.call(e):t.get(e)),Q=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},_e=(e,t,r,n)=>(kt(e,t,"write to private field"),t.set(e,r),r),$=(e,t,r)=>(kt(e,t,"access private method"),r),T,me,$e,ye,Me,oe,de,_t,br,Ct,Sr,$t,Tr,Mt,vr,Ue,tt;const di={maxPureArgumentSize:16*1024,maxTxGas:5e10,maxGasObjects:256,maxTxSizeBytes:128*1024};function fi(e){const t={kind:"Result",index:e},r=[],n=i=>r[i]??(r[i]={kind:"NestedResult",index:e,resultIndex:i});return new Proxy(t,{set(){throw new Error("The transaction result is a proxy, and does not support setting properties directly")},get(i,s){if(s in i)return Reflect.get(i,s);if(s===Symbol.iterator)return function*(){let o=0;for(;;)yield n(o),o++};if(typeof s=="symbol")return;const a=parseInt(s,10);if(!(Number.isNaN(a)||a<0))return n(a)}})}function li(e){const t=at(e);return t?t.Struct.address==="0x2"&&t.Struct.module==="transfer"&&t.Struct.name==="Receiving":!1}function ve(e){if(!e.client)throw new Error("No provider passed to Transaction#build, but transaction data was not sufficient to build offline.");return e.client}const hi=Symbol.for("@mysten/transaction"),He={maxTxGas:"max_tx_gas",maxGasObjects:"max_gas_payment_objects",maxTxSizeBytes:"max_tx_size_bytes",maxPureArgumentSize:"max_pure_argument_size"},gi=1000n,pi=50,mi=(e,t)=>Array.from({length:Math.ceil(e.length/t)},(r,n)=>e.slice(n*t,n*t+t)),rt=class{constructor(e){Q(this,me),Q(this,ye),Q(this,oe),Q(this,_t),Q(this,Ct),Q(this,$t),Q(this,Mt),Q(this,Ue),Q(this,T,void 0),_e(this,T,new te(e?e.blockData:void 0))}static fromKind(e){const t=new rt;return _e(t,T,te.fromKindBytes(typeof e=="string"?ae(e):e)),t}static from(e){const t=new rt;return typeof e!="string"||!e.startsWith("{")?_e(t,T,te.fromBytes(typeof e=="string"?ae(e):e)):_e(t,T,te.restore(JSON.parse(e))),t}setSender(e){x(this,T).sender=e}setSenderIfNotSet(e){x(this,T).sender||(x(this,T).sender=e)}setExpiration(e){x(this,T).expiration=e}setGasPrice(e){x(this,T).gasConfig.price=String(e)}setGasBudget(e){x(this,T).gasConfig.budget=String(e)}setGasOwner(e){x(this,T).gasConfig.owner=e}setGasPayment(e){x(this,T).gasConfig.payment=e.map(t=>Kt(t,se))}get blockData(){return x(this,T).snapshot()}get[hi](){return!0}get pure(){return Object.defineProperty(this,"pure",{enumerable:!1,value:ai((e,t)=>ut(e)?$(this,me,$e).call(this,"pure",{Pure:Array.from(e.toBytes())}):$(this,me,$e).call(this,"pure",e instanceof Uint8Array?R.Pure(e):t?R.Pure(e,t):e))}),this.pure}get gas(){return{kind:"GasCoin"}}object(e){if(typeof e=="object"&&"kind"in e)return e;const t=Vt(e),r=x(this,T).inputs.find(n=>n.type==="object"&&t===Vt(n.value));return r&&N(r.value,et)&&"Shared"in r.value.Object&&N(e,et)&&"Shared"in e.Object&&(r.value.Object.Shared.mutable=r.value.Object.Shared.mutable||e.Object.Shared.mutable),r??$(this,me,$e).call(this,"object",typeof e=="string"?M(e):e)}objectRef(...e){return this.object(R.ObjectRef(...e))}receivingRef(...e){return this.object(R.ReceivingRef(...e))}sharedObjectRef(...e){return this.object(R.SharedObjectRef(...e))}add(e){const t=x(this,T).transactions.push(e);return fi(t-1)}splitCoins(e,t){return this.add(ce.SplitCoins(typeof e=="string"?this.object(e):e,t.map(r=>typeof r=="number"||typeof r=="bigint"||typeof r=="string"?this.pure.u64(r):$(this,ye,Me).call(this,r))))}mergeCoins(e,t){return this.add(ce.MergeCoins(typeof e=="string"?this.object(e):e,t.map(r=>typeof r=="string"?this.object(r):r)))}publish({modules:e,dependencies:t}){return this.add(ce.Publish({modules:e,dependencies:t}))}upgrade({modules:e,dependencies:t,packageId:r,ticket:n}){return this.add(ce.Upgrade({modules:e,dependencies:t,packageId:r,ticket:typeof n=="string"?this.object(n):n}))}moveCall({arguments:e,typeArguments:t,target:r}){return this.add(ce.MoveCall({arguments:e==null?void 0:e.map(n=>$(this,ye,Me).call(this,n)),typeArguments:t,target:r}))}transferObjects(e,t){return this.add(ce.TransferObjects(e.map(r=>typeof r=="string"?this.object(r):r),typeof t=="string"?this.pure.address(t):$(this,ye,Me).call(this,t)))}makeMoveVec({type:e,objects:t}){return this.add(ce.MakeMoveVec({type:e,objects:t.map(r=>typeof r=="string"?this.object(r):r)}))}serialize(){return JSON.stringify(x(this,T).snapshot())}async sign(e){const{signer:t,...r}=e,n=await this.build(r);return t.signTransactionBlock(n)}async build(e={}){return await $(this,Ue,tt).call(this,e),x(this,T).build({maxSizeBytes:$(this,oe,de).call(this,"maxTxSizeBytes",e),onlyTransactionKind:e.onlyTransactionKind})}async getDigest(e={}){return await $(this,Ue,tt).call(this,e),x(this,T).getDigest()}};let Xe=rt;T=new WeakMap;me=new WeakSet;$e=function(e,t){const r=x(this,T).inputs.length,n=B({kind:"Input",value:typeof t=="bigint"?String(t):t,index:r,type:e},Te);return x(this,T).inputs.push(n),n};ye=new WeakSet;Me=function(e){return ut(e)?this.pure(e):e};oe=new WeakSet;de=function(e,{protocolConfig:t,limits:r}){if(r&&typeof r[e]=="number")return r[e];if(!t)return di[e];const n=t==null?void 0:t.attributes[He[e]];if(!n)throw new Error(`Missing expected protocol config: "${He[e]}"`);const i="u64"in n?n.u64:"u32"in n?n.u32:n.f64;if(!i)throw new Error(`Unexpected protocol config value found for: "${He[e]}"`);return Number(i)};_t=new WeakSet;br=function(e){const t=$(this,oe,de).call(this,"maxPureArgumentSize",e);x(this,T).inputs.forEach((r,n)=>{if(N(r.value,De)&&r.value.Pure.length>t)throw new Error(`Input at index ${n} is too large, max pure input size is ${t} bytes, got ${r.value.Pure.length} bytes`)})};Ct=new WeakSet;Sr=async function(e){if(x(this,T).gasConfig.payment){const i=$(this,oe,de).call(this,"maxGasObjects",e);if(x(this,T).gasConfig.payment.length>i)throw new Error(`Payment objects exceed maximum amount: ${i}`)}if(e.onlyTransactionKind||x(this,T).gasConfig.payment)return;const t=x(this,T).gasConfig.owner??x(this,T).sender,n=(await ve(e).getCoins({owner:t,coinType:An})).data.filter(i=>!x(this,T).inputs.find(a=>N(a.value,ze)&&"Object"in a.value&&"ImmOrOwned"in a.value.Object?i.coinObjectId===a.value.Object.ImmOrOwned.objectId:!1)).slice(0,$(this,oe,de).call(this,"maxGasObjects",e)-1).map(i=>({objectId:i.coinObjectId,digest:i.digest,version:i.version}));if(!n.length)throw new Error("No valid gas coins found for the transaction.");this.setGasPayment(n)};$t=new WeakSet;Tr=async function(e){e.onlyTransactionKind||x(this,T).gasConfig.price||this.setGasPrice(await ve(e).getReferenceGasPrice())};Mt=new WeakSet;vr=async function(e){const{inputs:t,transactions:r}=x(this,T),n=[],i=[];if(t.forEach(s=>{if(s.type==="object"&&typeof s.value=="string"){i.push({id:M(s.value),input:s});return}}),r.forEach(s=>{if(s.kind==="MoveCall"&&s.arguments.some(o=>o.kind==="Input"&&!N(t[o.index].value,ze))&&n.push(s),s.kind==="SplitCoins"&&s.amounts.forEach(a=>{if(a.kind==="Input"){const o=t[a.index];typeof o.value!="object"&&(o.value=R.Pure(C.U64.serialize(o.value)))}}),s.kind==="TransferObjects"&&s.address.kind==="Input"){const a=t[s.address.index];typeof a.value!="object"&&(a.value=R.Pure(C.Address.serialize(a.value)))}}),n.length&&await Promise.all(n.map(async s=>{const[a,o,u]=s.target.split("::"),d=await ve(e).getNormalizedMoveFunction({package:be(a),module:o,function:u}),g=d.parameters.length>0&&Vn(d.parameters.at(-1))?d.parameters.slice(0,d.parameters.length-1):d.parameters;if(g.length!==s.arguments.length)throw new Error("Incorrect number of arguments.");g.forEach((m,p)=>{const y=s.arguments[p];if(y.kind!=="Input")return;const S=t[y.index];if(N(S.value,ze))return;const E=S.value,A=Qe(m,E);if(A){S.value=R.Pure(E,A);return}if(at(m)!=null||typeof m=="object"&&"TypeParameter"in m){if(typeof E!="string")throw new Error(`Expect the argument to be an object id string, got ${JSON.stringify(E,null,2)}`);i.push({id:E,input:S,normalizedType:m});return}throw new Error(`Unknown call arg type ${JSON.stringify(m,null,2)} for value ${JSON.stringify(E,null,2)}`)})})),i.length){const s=[...new Set(i.map(({id:l})=>l))],a=mi(s,pi),o=(await Promise.all(a.map(l=>ve(e).multiGetObjects({ids:l,options:{showOwner:!0}})))).flat();let u=new Map(s.map((l,g)=>[l,o[g]]));const d=Array.from(u).filter(([l,g])=>g.error).map(([l,g])=>l);if(d.length)throw new Error(`The following input objects are invalid: ${d.join(", ")}`);i.forEach(({id:l,input:g,normalizedType:m})=>{var E;const p=u.get(l),y=(E=p.data)==null?void 0:E.owner,S=y&&typeof y=="object"&&"Shared"in y?y.Shared.initial_shared_version:void 0;if(S){const A=m!=null&&Ye(m)==null&&Qt(m)==null,_=ti(g.value)||A||m!=null&&Ye(m)!=null;g.value=R.SharedObjectRef({objectId:l,initialSharedVersion:S,mutable:_})}else m&&li(m)?g.value=R.ReceivingRef(zt(p)):g.value=R.ObjectRef(zt(p))})}};Ue=new WeakSet;tt=async function(e){if(!e.onlyTransactionKind&&!x(this,T).sender)throw new Error("Missing transaction sender");if(!e.protocolConfig&&!e.limits&&e.client&&(e.protocolConfig=await e.client.getProtocolConfig()),await Promise.all([$(this,$t,Tr).call(this,e),$(this,Mt,vr).call(this,e)]),!e.onlyTransactionKind&&(await $(this,Ct,Sr).call(this,e),!x(this,T).gasConfig.budget)){const t=await ve(e).dryRunTransactionBlock({transactionBlock:x(this,T).build({maxSizeBytes:$(this,oe,de).call(this,"maxTxSizeBytes",e),overrides:{gasConfig:{budget:String($(this,oe,de).call(this,"maxTxGas",e)),payment:[]}}})});if(t.effects.status.status!=="success")throw new Error(`Dry run failed, could not automatically determine a budget: ${t.effects.status.error}`,{cause:t});const r=gi*BigInt(this.blockData.gasConfig.price||1n),n=BigInt(t.effects.gasUsed.computationCost)+r,i=n+BigInt(t.effects.gasUsed.storageCost)-BigInt(t.effects.gasUsed.storageRebate);this.setGasBudget(i>n?i:n)}$(this,_t,br).call(this,e)};const yi=[["Testnet",{tokenMessengerState:"0x5252abd1137094ed1db3e0d75bc36abcd287aee4bc310f8e047727ef5682e7c2",messageTransmitterState:"0x98234bd0fa9ac12cc0a20a144a22e36d6a32f7e0a97baaeaf9c76cdc6d122d2e",usdcTreasury:"0x7170137d4a6431bf83351ac025baf462909bffe2877d87716374fb42b9629ebe"}],["Mainnet",{tokenMessengerState:"0x45993eecc0382f37419864992c12faee2238f5cfe22b98ad3bf455baf65c8a2f",messageTransmitterState:"0xf68268c3d9b1df3215f2439400c1c4ea08ac4ef4bb7d6f3ca6a2a239e17510af",usdcTreasury:"0x57d6725e7a8b49a7b2a612f6bd66ab5f39fc95332ca48be421c3229d514a6de7"}]],wi=Or(yi,[0,1]);class Ut{constructor(t,r,n,i){F(this,"network");F(this,"chain");F(this,"provider");F(this,"contracts");F(this,"usdcId");F(this,"usdcTreasuryId");F(this,"tokenMessengerId");F(this,"tokenMessengerStateId");F(this,"messageTransmitterId");F(this,"messageTransmitterStateId");var d,l,g,m;if(this.network=t,this.chain=r,this.provider=n,this.contracts=i,t==="Devnet")throw new Error("CircleBridge not supported on Devnet");const s=Ar.get(this.network,this.chain);if(!s)throw new Error(`No USDC contract configured for network=${this.network} chain=${this.chain}`);const{tokenMessengerState:a,messageTransmitterState:o,usdcTreasury:u}=wi(t);if(!((d=i.cctp)!=null&&d.tokenMessenger))throw new Error(`Circle Token Messenger contract for domain ${r} not found`);if(!((l=i.cctp)!=null&&l.messageTransmitter))throw new Error(`Circle Message Transmitter contract for domain ${r} not found`);this.usdcId=s,this.usdcTreasuryId=u,this.tokenMessengerId=(g=i.cctp)==null?void 0:g.tokenMessenger,this.messageTransmitterId=(m=i.cctp)==null?void 0:m.messageTransmitter,this.tokenMessengerStateId=a,this.messageTransmitterStateId=o}async*transfer(t,r,n){const i=new Xe,s=kr.get(this.network,r.chain),[a,...o]=await Nt.getCoins(this.provider,t,this.usdcId);if(a===void 0)throw new Error("No USDC in wallet");const u=i.object(a.coinObjectId);o.length>0&&i.mergeCoins(u,o.map(l=>i.object(l.coinObjectId)));const[d]=i.splitCoins(u,[n]);i.moveCall({target:`${this.tokenMessengerId}::deposit_for_burn::deposit_for_burn`,arguments:[d,i.pure.u32(s),i.pure.address(r.address.toUniversalAddress().toString()),i.object(this.tokenMessengerStateId),i.object(this.messageTransmitterStateId),i.object("0x403"),i.object(this.usdcTreasuryId)],typeArguments:[this.usdcId]}),yield this.createUnsignedTx(i,"Sui.CircleBridge.Transfer")}async isTransferCompleted(t){const r=new Xe;r.moveCall({target:`${this.messageTransmitterId}::state::is_nonce_used`,arguments:[r.object(this.messageTransmitterStateId),r.pure.u32(t.sourceDomain),r.pure.u64(t.nonce)]});const n=await this.provider.devInspectTransactionBlock({sender:"0x0000000000000000000000000000000000000000000000000000000000000000",transactionBlock:r});try{return!!n.results[0].returnValues[0][0][0]}catch(i){return console.error(`Error reading if nonce was used: ${i}`),!1}}async*redeem(t,r,n){const i=new Xe,[s]=i.moveCall({target:`${this.messageTransmitterId}::receive_message::receive_message`,arguments:[i.pure(Pt(Bt.serialize(r))),i.pure(Pt(_r.decode(n))),i.object(this.messageTransmitterStateId)]});if(!s)throw new Error("Failed to produce receipt");const[a]=i.moveCall({target:`${this.tokenMessengerId}::handle_receive_message::handle_receive_message`,arguments:[s,i.object(this.tokenMessengerStateId),i.object("0x403"),i.object(this.usdcTreasuryId)],typeArguments:[this.usdcId]});if(!a)throw new Error("Failed to produce stamp receipt ticket with burn message");const[o]=i.moveCall({target:`${this.tokenMessengerId}::handle_receive_message::deconstruct_stamp_receipt_ticket_with_burn_message`,arguments:[a]});if(!o)throw new Error("Failed to produce stamp receipt ticket");const[u]=i.moveCall({target:`${this.messageTransmitterId}::receive_message::stamp_receipt`,arguments:[o,i.object(this.messageTransmitterStateId)],typeArguments:[`${this.tokenMessengerId}::message_transmitter_authenticator::MessageTransmitterAuthenticator`]});if(!u)throw new Error("Failed to produce stamped receipt");i.moveCall({target:`${this.messageTransmitterId}::receive_message::complete_receive_message`,arguments:[u,i.object(this.messageTransmitterStateId)]}),yield this.createUnsignedTx(i,"Sui.CircleBridge.Redeem")}async parseTransactionDetails(t){var p;const r=await this.provider.waitForTransactionBlock({digest:t,options:{showEvents:!0,showEffects:!0,showInput:!0}});if(!r)throw new Error("Transaction not found");if(!r.events)throw new Error("Transaction events not found");const n=(p=r.events)==null?void 0:p.find(y=>y.type.includes("send_message::MessageSent"));if(!n)throw new Error("No MessageSent event found");const i=new Uint8Array((n==null?void 0:n.parsedJson).message),[s,a]=Bt.deserialize(i),{payload:o}=s,u=o.messageSender,d=o.mintRecipient,l=Rt(this.network,s.sourceDomain),g=Rt(this.network,s.destinationDomain),m={chain:l,address:o.burnToken};return{from:{chain:l,address:u},to:{chain:g,address:d},token:m,amount:o.amount,message:s,id:{hash:a}}}static async fromRpc(t,r){const[n,i]=await Nt.chainFromRpc(t),s=r[i];if(s.network!==n)throw new Error(`Network mismatch: ${s.network} != ${n}`);return new Ut(n,i,t,s.contracts)}createUnsignedTx(t,r,n=!1){return new $r(t,this.network,this.chain,r,n)}}Cr("Sui","CircleBridge",Ut);export{Ut as SuiCircleBridge};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{n as _t,s as ce,T as N,t as H,a as C,o as ot,R as Bo,p as K,y as gt}from"./index-
|
|
1
|
+
import{n as _t,s as ce,T as N,t as H,a as C,o as ot,R as Bo,p as K,y as gt}from"./index-BjxXYs1y.js";import{d as Do}from"./dijkstra-D_NXgYpA.js";import"../main.js";/**
|
|
2
2
|
* @license
|
|
3
3
|
* Copyright 2019 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var se=Object.defineProperty;var oe=(s,e,t)=>e in s?se(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var d=(s,e,t)=>oe(s,typeof e!="symbol"?e+"":e,t);import{
|
|
1
|
+
var se=Object.defineProperty;var oe=(s,e,t)=>e in s?se(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var d=(s,e,t)=>oe(s,typeof e!="symbol"?e+"":e,t);import{dk as l,dl as T,dm as y,cA as _,b2 as V,a$ as f,am as re,ae as M,dn as Q,dp as ae,aG as S,dq as ie,i as ce,bq as X,dr as N,ds as P,dt as de,du as Z,cV as pe,dv as ge,dw as ue,dx as J,cm as fe,b_ as le,c3 as he}from"../main.js";import{A as Ae}from"./algorand-vDDEz6KP.js";class ye{constructor(e,t,o,n,r=!1){d(this,"transaction");d(this,"network");d(this,"chain");d(this,"description");d(this,"parallelizable");this.transaction=e,this.network=t,this.chain=o,this.description=n,this.parallelizable=r}}const W=1002e3,j=15,Y=127,D=8,C=Y*D,ee=Y*j,K=D*ee,x={_limit:127,encodingLength:s=>{let e=0;for(;s>=128;e++)s>>=7;return e+1},encode:(s,e,t)=>{if(typeof s=="bigint"&&(s=l(s)),s<0)throw new RangeError("value must be unsigned");const o=x.encodingLength(s);if(e=e||new ArrayBuffer(o),t=t||0,e.byteLength<t+o)throw new RangeError("the buffer is too small to encode the number at the offset");const n=new Uint8Array(e,t);let r=0;for(;x._limit<s;)n[r++]=s&x._limit|128,s>>=7;return n[r]=Number(s),n},decode:(s,e=0)=>{let t=0,o=0,n;do{if(n=s[e+o],n===void 0)throw new RangeError("offset out of range");t+=(n&x._limit)<<o*7,o++}while(128<=n);return t}},g={forMessageId:(s,e)=>{const t=T(y(s)).publicKey,o=e.emitter.toUniversalAddress().toUint8Array(),n=_.toBytes(BigInt(V(e.chain)),2),r=f.concat(n,o);return g.fromData({appId:s,appAddress:t,idx:e.sequence/BigInt(K),address:r})},forWrappedAsset:(s,e)=>{if(re(e.address))throw new Error("native asset cannot be a wrapped asset");const t=T(y(s)).publicKey;return g.fromData({appId:s,appAddress:t,idx:BigInt(V(e.chain)),address:e.address.toUniversalAddress().toUint8Array()})},forNativeAsset:(s,e)=>{const t=T(y(s)).publicKey;return g.fromData({appId:s,appAddress:t,idx:e,address:f.encode("native")})},forGuardianSet:(s,e)=>{const t=T(y(s)).publicKey;return g.fromData({appId:s,appAddress:t,idx:BigInt(e),address:f.encode("guardian")})},forEmitter:(s,e)=>{const t=T(y(s)).publicKey;return g.fromData({appId:s,appAddress:t,idx:0n,address:e})},_encode:s=>typeof s=="bigint"?[M.encode(x.encode(s))]:[M.encode(x.encode(s.length)),M.encode(s)],fromData:s=>{const e=["0620010181",...g._encode(s.idx),"4880",...g._encode(s.address),"483110810612443119221244311881",...g._encode(s.appId),"1244312080",...g._encode(s.appAddress),"124431018100124431093203124431153203124422"],t=M.decode(e.join(""));return new Q(t)},decodeLocalState:async(s,e,t)=>{let o;try{const a=await s.accountApplicationInformation(t,l(e)).do();o=ae.from_obj_for_encoding(a).appLocalState}catch{return new Uint8Array}const n=S.encode("meta");let r=new Map;for(const a of o.keyValue){if(a.key===n)continue;const p=S.decode(a.key)[0],u=S.decode(a.value.bytes);r.set(p,u)}const c=[];for(let a=0;a<j;a++)r.has(a)&&c.push(r.get(a));return f.concat(...c)},checkBitsSet:async(s,e,t,o)=>{let n=!1,r;const c=await s.accountInformation(t).do(),p=ie.from_obj_for_encoding(c).appsLocalState;if(p&&p.forEach(m=>{BigInt(m.id)===e&&(r=m.keyValue)}),(r==null?void 0:r.length)===0)return n;const u=BigInt(K),A=BigInt(8),I=o/u*u,w=l(o-I),B=Math.floor(w/C),b=Math.floor((w-B*C)/8),U=S.encode(_.toBytes(B,1));return r==null||r.forEach(m=>{if(m.key===U){const v=ce.Buffer.from(m.value.bytes,"base64"),E=1<<l(o%A);n=(v[b]&E)!=0;return}}),n},storageAccountExists:async(s,e,t)=>{try{const o=await s.accountApplicationInformation(e,l(t)).do();return Object.keys(o).length>0}catch{}return!1}},i=class i{constructor(e,t,o,n){d(this,"network");d(this,"chain");d(this,"connection");d(this,"contracts");d(this,"chainId");d(this,"coreAppId");d(this,"coreAppAddress");d(this,"tokenBridgeAppId");d(this,"tokenBridgeAppAddress");if(this.network=e,this.chain=t,this.connection=o,this.contracts=n,this.chainId=V(t),!n.coreBridge)throw new Error(`Core contract address for chain ${t} not found`);const r=BigInt(n.coreBridge);if(this.coreAppId=r,this.coreAppAddress=y(r),!n.tokenBridge)throw new Error(`TokenBridge contract address for chain ${t} not found`);const c=BigInt(n.tokenBridge);this.tokenBridgeAppId=c,this.tokenBridgeAppAddress=y(c)}getGuardianSet(e){throw new Error("Method not implemented.")}async*verifyMessage(e,t,o){const n=new X(e).toString(),r=await i.submitVAAHeader(this.connection,this.coreAppId,o??this.coreAppId,t,n);for(const c of r.txs)yield this.createUnsignedTx(c,"Core.verifyMessage")}static async fromRpc(e,t){const[o,n]=await Ae.chainFromRpc(e),r=t[n];if(r.network!==o)throw new Error(`Network mismatch: ${r.network} !== ${o}`);return new i(o,n,e,r.contracts)}async*publishMessage(e,t){const o=new X(e),n=o.toString(),r=await this.connection.getTransactionParams().do(),c=g.forEmitter(this.coreAppId,o.toUint8Array()),{accounts:a,txs:p}=await i.maybeCreateStorageTx(this.connection,n,this.coreAppId,c,r);for(const A of p)yield this.createUnsignedTx(A,"Core.publishMessage",!0);const u=N({from:n,appIndex:l(this.coreAppId),appArgs:[i.publishMessage,t,_.toBytes(0n,8)],accounts:a,onComplete:P.NoOpOC,suggestedParams:r});yield this.createUnsignedTx({tx:u},"Core.publishMessage",!0)}async getMessageFee(){var n;const e=await this.connection.getApplicationByID(l(this.coreAppId)).do(),o=(n=de.from_obj_for_encoding(e).params.globalState)==null?void 0:n.find(r=>r.key===i.feeKey);return o?BigInt(o.value.uint):0n}async getGuardianSetIndex(){throw new Error("Not implemented")}async parseTransaction(e){const t=await this.connection.pendingTransactionInformation(e).do(),o=Z.from_obj_for_encoding(t);return this.parseTx(o).map(n=>({chain:n.emitterChain,emitter:n.emitterAddress,sequence:n.sequence}))}async parseMessages(e){const t=await this.connection.pendingTransactionInformation(e).do(),o=Z.from_obj_for_encoding(t);return this.parseTx(o)}parseTx(e){const t=[];if(e.innerTxns&&e.innerTxns.length>0&&t.push(...e.innerTxns.flatMap(p=>this.parseTx(p))),BigInt(e.txn.txn.apid??0)!==this.coreAppId||!e.logs||e.logs.length===0)return t;const o=e.txn.txn.apaa??[];if(o.length!==3||!f.equals(new Uint8Array(o[0]),i.publishMessage))return t;const n=_.decode(e.logs[0]),r=new X(e.txn.txn.snd).toUniversalAddress(),c=new Uint8Array(o[1]),a=_.decode(o[2]);return t.push(pe("Uint8Array",{emitterChain:this.chain,emitterAddress:r,sequence:n,guardianSet:0,timestamp:0,consistencyLevel:0,nonce:Number(a),payload:c,signatures:[]})),t}static async maybeCreateStorageTx(e,t,o,n,r){const c=y(o),a=n.address(),p=[];if(await g.storageAccountExists(e,a,o))return{accounts:[a],txs:p};r=r??await e.getTransactionParams().do();const u=ge({from:t,to:a,amount:W,suggestedParams:r});u.fee=u.fee*2,p.push({tx:u});const A=ue({from:a,appIndex:l(o),rekeyTo:c,suggestedParams:r});return A.fee=0,p.push({tx:A,signer:{address:n.address(),signTxn:I=>Promise.resolve(J(I,n).blob)}}),{accounts:[a],txs:p}}static async submitVAAHeader(e,t,o,n,r,c){c=c??await e.getTransactionParams().do();let a=[];const p=g.forMessageId(o,{chain:n.emitterChain,sequence:n.sequence,emitter:n.emitterAddress}),{accounts:u,txs:A}=await i.maybeCreateStorageTx(e,r,o,p,c);a.push(...A);const I=g.forGuardianSet(t,n.guardianSet),{accounts:[w],txs:B}=await i.maybeCreateStorageTx(e,r,t,I,c);a.push(...B);let b=[...u,w];const U=await g.decodeLocalState(e,t,w),m=fe(n.hash),v=n.signatures.length,E=Math.ceil(v/i.MAX_SIGS_PER_TXN),G=20,F=new Q(i.ALGO_VERIFY);for(let O=0;O<E;O++){const q=O*i.MAX_SIGS_PER_TXN,k=n.signatures.slice(q,q+i.MAX_SIGS_PER_TXN),te=k.length*G,H=new Uint8Array(te);for(let h=0;h<k.length;h++){const $=k[h],ne=U.slice($.guardianIndex*G+1,($.guardianIndex+1)*G+1);H.set(ne,h*20)}const z=N({appArgs:[i.verifySigs,f.concat(...k.map(h=>f.concat(new Uint8Array([h.guardianIndex]),h.signature.encode()))),H,m],accounts:b,appIndex:l(t),from:i.ALGO_VERIFY_HASH,onComplete:P.NoOpOC,suggestedParams:c});z.fee=0,a.push({tx:z,signer:{address:F.address(),signTxn:h=>Promise.resolve(J(h,F).blob)}})}const L=N({appArgs:[i.verifyVaa,le(n)],accounts:b,appIndex:l(t),from:r,onComplete:P.NoOpOC,suggestedParams:c});return L.fee=L.fee*(2+E),a.push({tx:L}),{accounts:b,txs:a}}createUnsignedTx(e,t,o=!0){return new ye(e,this.network,this.chain,t,o)}};d(i,"MAX_SIGS_PER_TXN",6),d(i,"ALGO_VERIFY_HASH","EZATROXX2HISIRZDRGXW4LRQ46Z6IUJYYIHU3PJGP7P5IQDPKVX42N767A"),d(i,"ALGO_VERIFY",new Uint8Array([6,32,4,1,0,32,20,38,1,0,49,32,50,3,18,68,49,1,35,18,68,49,16,129,6,18,68,54,26,1,54,26,3,54,26,2,136,0,3,68,34,67,53,2,53,1,53,0,40,53,240,40,53,241,52,0,21,53,5,35,53,3,35,53,4,52,3,52,5,12,65,0,68,52,1,52,0,52,3,129,65,8,34,88,23,52,0,52,3,34,8,36,88,52,0,52,3,129,33,8,36,88,7,0,53,241,53,240,52,2,52,4,37,88,52,240,52,241,80,2,87,12,20,18,68,52,3,129,66,8,53,3,52,4,37,8,53,4,66,255,180,34,137])),d(i,"feeKey",S.encode("MessageFee")),d(i,"verifyVaa",f.encode("verifyVAA")),d(i,"verifySigs",f.encode("verifySigs")),d(i,"publishMessage",f.encode("publishMessage"));let R=i;he("Algorand","WormholeCore",R);const we=Object.freeze(Object.defineProperty({__proto__:null,AlgorandWormholeCore:R,BITS_PER_BYTE:D,BITS_PER_KEY:C,MAX_BITS:K,MAX_BYTES:ee,MAX_BYTES_PER_KEY:Y,MAX_KEYS:j,SEED_AMT:W,StorageLogicSig:g,varint:x},Symbol.toStringTag,{value:"Module"}));export{R as A,g as S,ye as a,we as i};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-BjxXYs1y.js","main.js","main.css"])))=>i.map(i=>d[i]);
|
|
2
2
|
import{Q as xo,bF as Iw,i as te,s as Pw,_ as Sw}from"../main.js";import{e as bt,a as Ao}from"./events-BQoSexrB.js";import{c as q,s as Do,x as zh,r as Hh,H as Ow,a as Vh,q as Ss}from"./index-wTEu0lCN.js";import{I as lr,f as ft,t as nt,c as $u,C as Rw,r as Nw,a as Dr,g as Kh,i as _t,b as $s,d as $w,E as ze,y as Qe,q as Cs,k as Ts,h as Cw,e as Cu,j as Tw,s as xw,l as Aw,m as qo,n as xs,o as jo,p as Bt,u as Dw,v as Tu,w as qw}from"./index-BonhBCbB.js";import{o as xu}from"./browser-ponyfill-Dvo9kqwo.js";var se={};Object.defineProperty(se,"__esModule",{value:!0});se.getLocalStorage=se.getLocalStorageOrThrow=se.getCrypto=se.getCryptoOrThrow=se.getLocation=se.getLocationOrThrow=se.getNavigator=se.getNavigatorOrThrow=se.getDocument=se.getDocumentOrThrow=se.getFromWindowOrThrow=se.getFromWindow=void 0;function pr(o){let t;return typeof window<"u"&&typeof window[o]<"u"&&(t=window[o]),t}se.getFromWindow=pr;function Ur(o){const t=pr(o);if(!t)throw new Error(`${o} is not defined in Window`);return t}se.getFromWindowOrThrow=Ur;function jw(){return Ur("document")}se.getDocumentOrThrow=jw;function Uw(){return pr("document")}se.getDocument=Uw;function Mw(){return Ur("navigator")}se.getNavigatorOrThrow=Mw;function Lw(){return pr("navigator")}se.getNavigator=Lw;function kw(){return Ur("location")}se.getLocationOrThrow=kw;function zw(){return pr("location")}se.getLocation=zw;function Hw(){return Ur("crypto")}se.getCryptoOrThrow=Hw;function Vw(){return pr("crypto")}se.getCrypto=Vw;function Kw(){return Ur("localStorage")}se.getLocalStorageOrThrow=Kw;function Fw(){return pr("localStorage")}se.getLocalStorage=Fw;var Uo={};Object.defineProperty(Uo,"__esModule",{value:!0});Uo.getWindowMetadata=void 0;const Au=se;function Ww(){let o,t;try{o=Au.getDocumentOrThrow(),t=Au.getLocationOrThrow()}catch{return null}function r(){const S=o.getElementsByTagName("link"),R=[];for(let j=0;j<S.length;j++){const x=S[j],K=x.getAttribute("rel");if(K&&K.toLowerCase().indexOf("icon")>-1){const A=x.getAttribute("href");if(A)if(A.toLowerCase().indexOf("https:")===-1&&A.toLowerCase().indexOf("http:")===-1&&A.indexOf("//")!==0){let B=t.protocol+"//"+t.host;if(A.indexOf("/")===0)B+=A;else{const pe=t.pathname.split("/");pe.pop();const J=pe.join("/");B+=J+"/"+A}R.push(B)}else if(A.indexOf("//")===0){const B=t.protocol+A;R.push(B)}else R.push(A)}}return R}function s(...S){const R=o.getElementsByTagName("meta");for(let j=0;j<R.length;j++){const x=R[j],K=["itemprop","property","name"].map(A=>x.getAttribute(A)).filter(A=>A?S.includes(A):!1);if(K.length&&K){const A=x.getAttribute("content");if(A)return A}}return""}function a(){let S=s("name","og:site_name","og:title","twitter:title");return S||(S=o.title),S}function u(){return s("description","og:description","twitter:description","keywords")}const l=a(),g=u(),w=t.origin,b=r();return{description:g,url:w,icons:b,name:l}}Uo.getWindowMetadata=Ww;function Bw(o,t=[]){const r=[];return Object.keys(o).forEach(s=>{if(t.length&&!t.includes(s))return;const a=o[s];r.push(...a.accounts)}),r}const Gw={INVALID_METHOD:{message:"Invalid method.",code:1001},INVALID_EVENT:{message:"Invalid event.",code:1002},INVALID_UPDATE_REQUEST:{message:"Invalid update request.",code:1003},INVALID_EXTEND_REQUEST:{message:"Invalid extend request.",code:1004},INVALID_SESSION_SETTLE_REQUEST:{message:"Invalid session settle request.",code:1005},UNAUTHORIZED_METHOD:{message:"Unauthorized method.",code:3001},UNAUTHORIZED_EVENT:{message:"Unauthorized event.",code:3002},UNAUTHORIZED_UPDATE_REQUEST:{message:"Unauthorized update request.",code:3003},UNAUTHORIZED_EXTEND_REQUEST:{message:"Unauthorized extend request.",code:3004},USER_REJECTED:{message:"User rejected.",code:5e3},USER_REJECTED_CHAINS:{message:"User rejected chains.",code:5001},USER_REJECTED_METHODS:{message:"User rejected methods.",code:5002},USER_REJECTED_EVENTS:{message:"User rejected events.",code:5003},UNSUPPORTED_CHAINS:{message:"Unsupported chains.",code:5100},UNSUPPORTED_METHODS:{message:"Unsupported methods.",code:5101},UNSUPPORTED_EVENTS:{message:"Unsupported events.",code:5102},UNSUPPORTED_ACCOUNTS:{message:"Unsupported accounts.",code:5103},UNSUPPORTED_NAMESPACE_KEY:{message:"Unsupported namespace key.",code:5104},USER_DISCONNECTED:{message:"User disconnected.",code:6e3},SESSION_SETTLEMENT_FAILED:{message:"Session settlement failed.",code:7e3},WC_METHOD_UNSUPPORTED:{message:"Unsupported wc_ method.",code:10001}};function Qw(o,t){const{message:r,code:s}=Gw[o];return{message:r,code:s}}function mo(o,t){return!!Array.isArray(o)}var Mr={};/*! *****************************************************************************
|
|
3
3
|
Copyright (c) Microsoft Corporation.
|
|
4
4
|
|
|
@@ -44,4 +44,4 @@ __p += '`),Q&&(O+=`' +
|
|
|
44
44
|
function print() { __p += __j.call(arguments, '') }
|
|
45
45
|
`:`;
|
|
46
46
|
`)+O+`return __p
|
|
47
|
-
}`;var V=Ou(function(){return Z(d,D+"return "+O).apply(r,f)});if(V.source=O,Bn(V))throw V;return V}function Cm(e){return X(e).toLowerCase()}function Tm(e){return X(e).toUpperCase()}function xm(e,i,n){if(e=X(e),e&&(n||i===r))return qa(e);if(!e||!(i=Ke(i)))return e;var c=ct(e),h=ct(i),d=ja(c,h),f=Ua(c,h)+1;return Ft(c,d,f).join("")}function Am(e,i,n){if(e=X(e),e&&(n||i===r))return e.slice(0,La(e)+1);if(!e||!(i=Ke(i)))return e;var c=ct(e),h=Ua(c,ct(i))+1;return Ft(c,0,h).join("")}function Dm(e,i,n){if(e=X(e),e&&(n||i===r))return e.replace(Ws,"");if(!e||!(i=Ke(i)))return e;var c=ct(e),h=ja(c,ct(i));return Ft(c,h).join("")}function qm(e,i){var n=Rl,c=Nl;if(he(i)){var h="separator"in i?i.separator:h;n="length"in i?H(i.length):n,c="omission"in i?Ke(i.omission):c}e=X(e);var d=e.length;if(_r(e)){var f=ct(e);d=f.length}if(n>=d)return e;var y=n-br(c);if(y<1)return c;var m=f?Ft(f,0,y).join(""):e.slice(0,y);if(h===r)return m+c;if(f&&(y+=m.length-y),Gn(h)){if(e.slice(y).search(h)){var I,P=m;for(h.global||(h=hn(h.source,X(ia.exec(h))+"g")),h.lastIndex=0;I=h.exec(P);)var O=I.index;m=m.slice(0,O===r?y:O)}}else if(e.indexOf(Ke(h),y)!=y){var C=m.lastIndexOf(h);C>-1&&(m=m.slice(0,C))}return m+c}function jm(e){return e=X(e),e&&Wl.test(e)?e.replace(ea,hd):e}var Um=Nr(function(e,i,n){return e+(n?" ":"")+i.toUpperCase()}),Yn=Rc("toUpperCase");function Su(e,i,n){return e=X(e),i=n?r:i,i===r?nd(e)?dd(e):Jp(e):e.match(i)||[]}var Ou=F(function(e,i){try{return He(e,r,i)}catch(n){return Bn(n)?n:new k(n)}}),Mm=Rt(function(e,i){return Ye(i,function(n){n=mt(n),St(e,n,Fn(e[n],e))}),e});function Lm(e){var i=e==null?0:e.length,n=U();return e=i?ce(e,function(c){if(typeof c[1]!="function")throw new Ze(l);return[n(c[0]),c[1]]}):[],F(function(c){for(var h=-1;++h<i;){var d=e[h];if(He(d[0],this,c))return He(d[1],this,c)}})}function km(e){return lf(et(e,S))}function Zn(e){return function(){return e}}function zm(e,i){return e==null||e!==e?i:e}var Hm=$c(),Vm=$c(!0);function Ue(e){return e}function Xn(e){return nc(typeof e=="function"?e:et(e,S))}function Km(e){return ac(et(e,S))}function Fm(e,i){return cc(e,et(i,S))}var Wm=F(function(e,i){return function(n){return si(n,e,i)}}),Bm=F(function(e,i){return function(n){return si(e,n,i)}});function eo(e,i,n){var c=_e(i),h=Xi(i,c);n==null&&!(he(i)&&(h.length||!c.length))&&(n=i,i=e,e=this,h=Xi(i,_e(i)));var d=!(he(n)&&"chain"in n)||!!n.chain,f=$t(e);return Ye(h,function(y){var m=i[y];e[y]=m,f&&(e.prototype[y]=function(){var I=this.__chain__;if(d||I){var P=e(this.__wrapped__),O=P.__actions__=De(this.__actions__);return O.push({func:m,args:arguments,thisArg:e}),P.__chain__=I,P}return m.apply(e,Lt([this.value()],arguments))})}),e}function Gm(){return Ee._===this&&(Ee._=wd),this}function to(){}function Qm(e){return e=H(e),F(function(i){return uc(i,e)})}var Jm=xn(ce),Ym=xn(Ca),Zm=xn(rn);function Ru(e){return Ln(e)?sn(mt(e)):Nf(e)}function Xm(e){return function(i){return e==null?r:sr(e,i)}}var ew=Tc(),tw=Tc(!0);function ro(){return[]}function io(){return!1}function rw(){return{}}function iw(){return""}function sw(){return!0}function nw(e,i){if(e=H(e),e<1||e>Ut)return[];var n=gt,c=Se(e,gt);i=U(i),e-=gt;for(var h=an(c,i);++n<e;)i(n);return h}function ow(e){return z(e)?ce(e,mt):Fe(e)?[e]:De(Bc(X(e)))}function aw(e){var i=++vd;return X(e)+i}var cw=ns(function(e,i){return e+i},0),uw=An("ceil"),hw=ns(function(e,i){return e/i},1),lw=An("floor");function pw(e){return e&&e.length?Zi(e,Ue,mn):r}function dw(e,i){return e&&e.length?Zi(e,U(i,2),mn):r}function fw(e){return Aa(e,Ue)}function gw(e,i){return Aa(e,U(i,2))}function yw(e){return e&&e.length?Zi(e,Ue,En):r}function vw(e,i){return e&&e.length?Zi(e,U(i,2),En):r}var mw=ns(function(e,i){return e*i},1),ww=An("round"),_w=ns(function(e,i){return e-i},0);function bw(e){return e&&e.length?on(e,Ue):0}function Ew(e,i){return e&&e.length?on(e,U(i,2)):0}return p.after=Ky,p.ary=su,p.assign=Tv,p.assignIn=mu,p.assignInWith=ms,p.assignWith=xv,p.at=Av,p.before=nu,p.bind=Fn,p.bindAll=Mm,p.bindKey=ou,p.castArray=rv,p.chain=tu,p.chunk=lg,p.compact=pg,p.concat=dg,p.cond=Lm,p.conforms=km,p.constant=Zn,p.countBy=by,p.create=Dv,p.curry=au,p.curryRight=cu,p.debounce=uu,p.defaults=qv,p.defaultsDeep=jv,p.defer=Fy,p.delay=Wy,p.difference=fg,p.differenceBy=gg,p.differenceWith=yg,p.drop=vg,p.dropRight=mg,p.dropRightWhile=wg,p.dropWhile=_g,p.fill=bg,p.filter=Iy,p.flatMap=Oy,p.flatMapDeep=Ry,p.flatMapDepth=Ny,p.flatten=Yc,p.flattenDeep=Eg,p.flattenDepth=Ig,p.flip=By,p.flow=Hm,p.flowRight=Vm,p.fromPairs=Pg,p.functions=Vv,p.functionsIn=Kv,p.groupBy=$y,p.initial=Og,p.intersection=Rg,p.intersectionBy=Ng,p.intersectionWith=$g,p.invert=Wv,p.invertBy=Bv,p.invokeMap=Ty,p.iteratee=Xn,p.keyBy=xy,p.keys=_e,p.keysIn=je,p.map=ps,p.mapKeys=Qv,p.mapValues=Jv,p.matches=Km,p.matchesProperty=Fm,p.memoize=fs,p.merge=Yv,p.mergeWith=wu,p.method=Wm,p.methodOf=Bm,p.mixin=eo,p.negate=gs,p.nthArg=Qm,p.omit=Zv,p.omitBy=Xv,p.once=Gy,p.orderBy=Ay,p.over=Jm,p.overArgs=Qy,p.overEvery=Ym,p.overSome=Zm,p.partial=Wn,p.partialRight=hu,p.partition=Dy,p.pick=em,p.pickBy=_u,p.property=Ru,p.propertyOf=Xm,p.pull=Ag,p.pullAll=Xc,p.pullAllBy=Dg,p.pullAllWith=qg,p.pullAt=jg,p.range=ew,p.rangeRight=tw,p.rearg=Jy,p.reject=Uy,p.remove=Ug,p.rest=Yy,p.reverse=Vn,p.sampleSize=Ly,p.set=rm,p.setWith=im,p.shuffle=ky,p.slice=Mg,p.sortBy=Vy,p.sortedUniq=Fg,p.sortedUniqBy=Wg,p.split=Om,p.spread=Zy,p.tail=Bg,p.take=Gg,p.takeRight=Qg,p.takeRightWhile=Jg,p.takeWhile=Yg,p.tap=py,p.throttle=Xy,p.thru=ls,p.toArray=gu,p.toPairs=bu,p.toPairsIn=Eu,p.toPath=ow,p.toPlainObject=vu,p.transform=sm,p.unary=ev,p.union=Zg,p.unionBy=Xg,p.unionWith=ey,p.uniq=ty,p.uniqBy=ry,p.uniqWith=iy,p.unset=nm,p.unzip=Kn,p.unzipWith=eu,p.update=om,p.updateWith=am,p.values=Tr,p.valuesIn=cm,p.without=sy,p.words=Su,p.wrap=tv,p.xor=ny,p.xorBy=oy,p.xorWith=ay,p.zip=cy,p.zipObject=uy,p.zipObjectDeep=hy,p.zipWith=ly,p.entries=bu,p.entriesIn=Eu,p.extend=mu,p.extendWith=ms,eo(p,p),p.add=cw,p.attempt=Ou,p.camelCase=pm,p.capitalize=Iu,p.ceil=uw,p.clamp=um,p.clone=iv,p.cloneDeep=nv,p.cloneDeepWith=ov,p.cloneWith=sv,p.conformsTo=av,p.deburr=Pu,p.defaultTo=zm,p.divide=hw,p.endsWith=dm,p.eq=ht,p.escape=fm,p.escapeRegExp=gm,p.every=Ey,p.find=Py,p.findIndex=Qc,p.findKey=Uv,p.findLast=Sy,p.findLastIndex=Jc,p.findLastKey=Mv,p.floor=lw,p.forEach=ru,p.forEachRight=iu,p.forIn=Lv,p.forInRight=kv,p.forOwn=zv,p.forOwnRight=Hv,p.get=Qn,p.gt=cv,p.gte=uv,p.has=Fv,p.hasIn=Jn,p.head=Zc,p.identity=Ue,p.includes=Cy,p.indexOf=Sg,p.inRange=hm,p.invoke=Gv,p.isArguments=ar,p.isArray=z,p.isArrayBuffer=hv,p.isArrayLike=qe,p.isArrayLikeObject=fe,p.isBoolean=lv,p.isBuffer=Wt,p.isDate=pv,p.isElement=dv,p.isEmpty=fv,p.isEqual=gv,p.isEqualWith=yv,p.isError=Bn,p.isFinite=vv,p.isFunction=$t,p.isInteger=lu,p.isLength=ys,p.isMap=pu,p.isMatch=mv,p.isMatchWith=wv,p.isNaN=_v,p.isNative=bv,p.isNil=Iv,p.isNull=Ev,p.isNumber=du,p.isObject=he,p.isObjectLike=le,p.isPlainObject=hi,p.isRegExp=Gn,p.isSafeInteger=Pv,p.isSet=fu,p.isString=vs,p.isSymbol=Fe,p.isTypedArray=Cr,p.isUndefined=Sv,p.isWeakMap=Ov,p.isWeakSet=Rv,p.join=Cg,p.kebabCase=ym,p.last=rt,p.lastIndexOf=Tg,p.lowerCase=vm,p.lowerFirst=mm,p.lt=Nv,p.lte=$v,p.max=pw,p.maxBy=dw,p.mean=fw,p.meanBy=gw,p.min=yw,p.minBy=vw,p.stubArray=ro,p.stubFalse=io,p.stubObject=rw,p.stubString=iw,p.stubTrue=sw,p.multiply=mw,p.nth=xg,p.noConflict=Gm,p.noop=to,p.now=ds,p.pad=wm,p.padEnd=_m,p.padStart=bm,p.parseInt=Em,p.random=lm,p.reduce=qy,p.reduceRight=jy,p.repeat=Im,p.replace=Pm,p.result=tm,p.round=ww,p.runInContext=v,p.sample=My,p.size=zy,p.snakeCase=Sm,p.some=Hy,p.sortedIndex=Lg,p.sortedIndexBy=kg,p.sortedIndexOf=zg,p.sortedLastIndex=Hg,p.sortedLastIndexBy=Vg,p.sortedLastIndexOf=Kg,p.startCase=Rm,p.startsWith=Nm,p.subtract=_w,p.sum=bw,p.sumBy=Ew,p.template=$m,p.times=nw,p.toFinite=Ct,p.toInteger=H,p.toLength=yu,p.toLower=Cm,p.toNumber=it,p.toSafeInteger=Cv,p.toString=X,p.toUpper=Tm,p.trim=xm,p.trimEnd=Am,p.trimStart=Dm,p.truncate=qm,p.unescape=jm,p.uniqueId=aw,p.upperCase=Um,p.upperFirst=Yn,p.each=ru,p.eachRight=iu,p.first=Zc,eo(p,function(){var e={};return yt(p,function(i,n){ee.call(p.prototype,n)||(e[n]=i)}),e}(),{chain:!1}),p.VERSION=s,Ye(["bind","bindKey","curry","curryRight","partial","partialRight"],function(e){p[e].placeholder=p}),Ye(["drop","take"],function(e,i){G.prototype[e]=function(n){n=n===r?1:we(H(n),0);var c=this.__filtered__&&!i?new G(this):this.clone();return c.__filtered__?c.__takeCount__=Se(n,c.__takeCount__):c.__views__.push({size:Se(n,gt),type:e+(c.__dir__<0?"Right":"")}),c},G.prototype[e+"Right"]=function(n){return this.reverse()[e](n).reverse()}}),Ye(["filter","map","takeWhile"],function(e,i){var n=i+1,c=n==Yo||n==xl;G.prototype[e]=function(h){var d=this.clone();return d.__iteratees__.push({iteratee:U(h,3),type:n}),d.__filtered__=d.__filtered__||c,d}}),Ye(["head","last"],function(e,i){var n="take"+(i?"Right":"");G.prototype[e]=function(){return this[n](1).value()[0]}}),Ye(["initial","tail"],function(e,i){var n="drop"+(i?"":"Right");G.prototype[e]=function(){return this.__filtered__?new G(this):this[n](1)}}),G.prototype.compact=function(){return this.filter(Ue)},G.prototype.find=function(e){return this.filter(e).head()},G.prototype.findLast=function(e){return this.reverse().find(e)},G.prototype.invokeMap=F(function(e,i){return typeof e=="function"?new G(this):this.map(function(n){return si(n,e,i)})}),G.prototype.reject=function(e){return this.filter(gs(U(e)))},G.prototype.slice=function(e,i){e=H(e);var n=this;return n.__filtered__&&(e>0||i<0)?new G(n):(e<0?n=n.takeRight(-e):e&&(n=n.drop(e)),i!==r&&(i=H(i),n=i<0?n.dropRight(-i):n.take(i-e)),n)},G.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},G.prototype.toArray=function(){return this.take(gt)},yt(G.prototype,function(e,i){var n=/^(?:filter|find|map|reject)|While$/.test(i),c=/^(?:head|last)$/.test(i),h=p[c?"take"+(i=="last"?"Right":""):i],d=c||/^find/.test(i);h&&(p.prototype[i]=function(){var f=this.__wrapped__,y=c?[1]:arguments,m=f instanceof G,I=y[0],P=m||z(f),O=function(W){var Q=h.apply(p,Lt([W],y));return c&&C?Q[0]:Q};P&&n&&typeof I=="function"&&I.length!=1&&(m=P=!1);var C=this.__chain__,D=!!this.__actions__.length,M=d&&!C,V=m&&!D;if(!d&&P){f=V?f:new G(this);var L=e.apply(f,y);return L.__actions__.push({func:ls,args:[O],thisArg:r}),new Xe(L,C)}return M&&V?e.apply(this,y):(L=this.thru(O),M?c?L.value()[0]:L.value():L)})}),Ye(["pop","push","shift","sort","splice","unshift"],function(e){var i=Ui[e],n=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",c=/^(?:pop|shift)$/.test(e);p.prototype[e]=function(){var h=arguments;if(c&&!this.__chain__){var d=this.value();return i.apply(z(d)?d:[],h)}return this[n](function(f){return i.apply(z(f)?f:[],h)})}}),yt(G.prototype,function(e,i){var n=p[i];if(n){var c=n.name+"";ee.call(Sr,c)||(Sr[c]=[]),Sr[c].push({name:i,func:n})}}),Sr[ss(r,B).name]=[{name:"wrapper",func:r}],G.prototype.clone=qd,G.prototype.reverse=jd,G.prototype.value=Ud,p.prototype.at=dy,p.prototype.chain=fy,p.prototype.commit=gy,p.prototype.next=yy,p.prototype.plant=my,p.prototype.reverse=wy,p.prototype.toJSON=p.prototype.valueOf=p.prototype.value=_y,p.prototype.first=p.prototype.head,Yr&&(p.prototype[Yr]=vy),p},Er=fd();Xt?((Xt.exports=Er)._=Er,Zs._=Er):Ee._=Er}).call(vi)})($o,$o.exports);var DI=Object.defineProperty,qI=Object.defineProperties,jI=Object.getOwnPropertyDescriptors,Ah=Object.getOwnPropertySymbols,UI=Object.prototype.hasOwnProperty,MI=Object.prototype.propertyIsEnumerable,Dh=(o,t,r)=>t in o?DI(o,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[t]=r,bs=(o,t)=>{for(var r in t||(t={}))UI.call(t,r)&&Dh(o,r,t[r]);if(Ah)for(var r of Ah(t))MI.call(t,r)&&Dh(o,r,t[r]);return o},LI=(o,t)=>qI(o,jI(t));function Jt(o,t,r){var s;const a=u_(o);return((s=t.rpcMap)==null?void 0:s[a.reference])||`${AI}?chainId=${a.namespace}:${a.reference}&projectId=${r}`}function gr(o){return o.includes(":")?o.split(":")[1]:o}function Sl(o){return o.map(t=>`${t.split(":")[0]}:${t.split(":")[1]}`)}function kI(o,t){const r=Object.keys(t.namespaces).filter(a=>a.includes(o));if(!r.length)return[];const s=[];return r.forEach(a=>{const u=t.namespaces[a].accounts;s.push(...u)}),s}function zI(o={},t={}){const r=qh(o),s=qh(t);return $o.exports.merge(r,s)}function qh(o){var t,r,s,a;const u={};if(!jr(o))return u;for(const[l,g]of Object.entries(o)){const w=Ko(l)?[l]:g.chains,b=g.methods||[],N=g.events||[],S=g.rpcMap||{},R=mi(l);u[R]=LI(bs(bs({},u[R]),g),{chains:oo(w,(t=u[R])==null?void 0:t.chains),methods:oo(b,(r=u[R])==null?void 0:r.methods),events:oo(N,(s=u[R])==null?void 0:s.events),rpcMap:bs(bs({},S),(a=u[R])==null?void 0:a.rpcMap)})}return u}function HI(o){return o.includes(":")?o.split(":")[2]:o}function VI(o){const t={};for(const[r,s]of Object.entries(o)){const a=s.methods||[],u=s.events||[],l=s.accounts||[],g=Ko(r)?[r]:s.chains?s.chains:Sl(s.accounts);t[r]={chains:g,methods:a,events:u,accounts:l}}return t}function fo(o){return typeof o=="number"?o:o.includes("0x")?parseInt(o,16):o.includes(":")?Number(o.split(":")[1]):Number(o)}const Ol={},ue=o=>Ol[o],go=(o,t)=>{Ol[o]=t};class KI{constructor(t){this.name="polkadot",this.namespace=t.namespace,this.events=ue("events"),this.client=ue("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,r){this.httpProviders[t]||this.setHttpProvider(t,r),this.chainId=t,this.events.emit(qt.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`)}getAccounts(){const t=this.namespace.accounts;return t?t.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2])||[]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(r=>{var s;const a=gr(r);t[a]=this.createHttpProvider(a,(s=this.namespace.rpcMap)==null?void 0:s[r])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,r=this.httpProviders[t];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return r}setHttpProvider(t,r){const s=this.createHttpProvider(t,r);s&&(this.httpProviders[t]=s)}createHttpProvider(t,r){const s=r||Jt(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new Dt(new Yt(s,ue("disableProviderPing")))}}class FI{constructor(t){this.name="eip155",this.namespace=t.namespace,this.events=ue("events"),this.client=ue("client"),this.httpProviders=this.createHttpProviders(),this.chainId=parseInt(this.getDefaultChain())}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())}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,r){this.httpProviders[t]||this.setHttpProvider(parseInt(t),r),this.chainId=parseInt(t),this.events.emit(qt.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,r){const s=r||Jt(`${this.name}:${t}`,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new Dt(new Yt(s,ue("disableProviderPing")))}setHttpProvider(t,r){const s=this.createHttpProvider(t,r);s&&(this.httpProviders[t]=s)}createHttpProviders(){const t={};return this.namespace.chains.forEach(r=>{var s;const a=parseInt(gr(r));t[a]=this.createHttpProvider(a,(s=this.namespace.rpcMap)==null?void 0:s[r])}),t}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}getHttpProvider(){const t=this.chainId,r=this.httpProviders[t];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return r}async handleSwitchChain(t){var r,s;let a=t.request.params?(r=t.request.params[0])==null?void 0:r.chainId:"0x0";a=a.startsWith("0x")?a:`0x${a}`;const u=parseInt(a,16);if(this.isChainApproved(u))this.setDefaultChain(`${u}`);else if(this.namespace.methods.includes("wallet_switchEthereumChain"))await this.client.request({topic:t.topic,request:{method:t.request.method,params:[{chainId:a}]},chainId:(s=this.namespace.chains)==null?void 0:s[0]}),this.setDefaultChain(`${u}`);else throw new Error(`Failed to switch to chain 'eip155:${u}'. 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}`)}}class WI{constructor(t){this.name="solana",this.namespace=t.namespace,this.events=ue("events"),this.client=ue("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,r){this.httpProviders[t]||this.setHttpProvider(t,r),this.chainId=t,this.events.emit(qt.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(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(r=>{var s;const a=gr(r);t[a]=this.createHttpProvider(a,(s=this.namespace.rpcMap)==null?void 0:s[r])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,r=this.httpProviders[t];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return r}setHttpProvider(t,r){const s=this.createHttpProvider(t,r);s&&(this.httpProviders[t]=s)}createHttpProvider(t,r){const s=r||Jt(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new Dt(new Yt(s,ue("disableProviderPing")))}}class BI{constructor(t){this.name="cosmos",this.namespace=t.namespace,this.events=ue("events"),this.client=ue("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,r){this.httpProviders[t]||this.setHttpProvider(t,r),this.chainId=t,this.events.emit(qt.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(r=>{var s;const a=gr(r);t[a]=this.createHttpProvider(a,(s=this.namespace.rpcMap)==null?void 0:s[r])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,r=this.httpProviders[t];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return r}setHttpProvider(t,r){const s=this.createHttpProvider(t,r);s&&(this.httpProviders[t]=s)}createHttpProvider(t,r){const s=r||Jt(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new Dt(new Yt(s,ue("disableProviderPing")))}}class GI{constructor(t){this.name="cip34",this.namespace=t.namespace,this.events=ue("events"),this.client=ue("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,r){this.httpProviders[t]||this.setHttpProvider(t,r),this.chainId=t,this.events.emit(qt.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(r=>{const s=this.getCardanoRPCUrl(r),a=gr(r);t[a]=this.createHttpProvider(a,s)}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,r=this.httpProviders[t];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return r}getCardanoRPCUrl(t){const r=this.namespace.rpcMap;if(r)return r[t]}setHttpProvider(t,r){const s=this.createHttpProvider(t,r);s&&(this.httpProviders[t]=s)}createHttpProvider(t,r){const s=r||this.getCardanoRPCUrl(t);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new Dt(new Yt(s,ue("disableProviderPing")))}}class QI{constructor(t){this.name="elrond",this.namespace=t.namespace,this.events=ue("events"),this.client=ue("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,r){this.httpProviders[t]||this.setHttpProvider(t,r),this.chainId=t,this.events.emit(qt.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(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(r=>{var s;const a=gr(r);t[a]=this.createHttpProvider(a,(s=this.namespace.rpcMap)==null?void 0:s[r])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,r=this.httpProviders[t];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return r}setHttpProvider(t,r){const s=this.createHttpProvider(t,r);s&&(this.httpProviders[t]=s)}createHttpProvider(t,r){const s=r||Jt(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new Dt(new Yt(s,ue("disableProviderPing")))}}class JI{constructor(t){this.name="multiversx",this.namespace=t.namespace,this.events=ue("events"),this.client=ue("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,r){this.httpProviders[t]||this.setHttpProvider(t,r),this.chainId=t,this.events.emit(qt.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(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(r=>{var s;const a=gr(r);t[a]=this.createHttpProvider(a,(s=this.namespace.rpcMap)==null?void 0:s[r])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,r=this.httpProviders[t];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return r}setHttpProvider(t,r){const s=this.createHttpProvider(t,r);s&&(this.httpProviders[t]=s)}createHttpProvider(t,r){const s=r||Jt(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new Dt(new Yt(s,ue("disableProviderPing")))}}class YI{constructor(t){this.name="near",this.namespace=t.namespace,this.events=ue("events"),this.client=ue("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,r){if(this.chainId=t,!this.httpProviders[t]){const s=r||Jt(`${this.name}:${t}`,this.namespace);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);this.setHttpProvider(t,s)}this.events.emit(qt.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const t=this.namespace.accounts;return t?t.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2])||[]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(r=>{var s;t[r]=this.createHttpProvider(r,(s=this.namespace.rpcMap)==null?void 0:s[r])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,r=this.httpProviders[t];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return r}setHttpProvider(t,r){const s=this.createHttpProvider(t,r);s&&(this.httpProviders[t]=s)}createHttpProvider(t,r){const s=r||Jt(t,this.namespace);return typeof s>"u"?void 0:new Dt(new Yt(s,ue("disableProviderPing")))}}var ZI=Object.defineProperty,XI=Object.defineProperties,eP=Object.getOwnPropertyDescriptors,jh=Object.getOwnPropertySymbols,tP=Object.prototype.hasOwnProperty,rP=Object.prototype.propertyIsEnumerable,Uh=(o,t,r)=>t in o?ZI(o,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[t]=r,Es=(o,t)=>{for(var r in t||(t={}))tP.call(t,r)&&Uh(o,r,t[r]);if(jh)for(var r of jh(t))rP.call(t,r)&&Uh(o,r,t[r]);return o},yo=(o,t)=>XI(o,eP(t));class Qo{constructor(t){this.events=new Ao,this.rpcProviders={},this.shouldAbortPairingAttempt=!1,this.maxPairingAttempts=10,this.disableProviderPing=!1,this.providerOpts=t,this.logger=typeof(t==null?void 0:t.logger)<"u"&&typeof(t==null?void 0:t.logger)!="string"?t.logger:Cs(Ts({level:(t==null?void 0:t.logger)||Th})),this.disableProviderPing=(t==null?void 0:t.disableProviderPing)||!1}static async init(t){const r=new Qo(t);return await r.initialize(),r}async request(t,r){const[s,a]=this.validateChain(r);if(!this.session)throw new Error("Please call connect() before request()");return await this.getProvider(s).request({request:Es({},t),chainId:`${s}:${a}`,topic:this.session.topic})}sendAsync(t,r,s){const a=new Date().getTime();this.request(t,s).then(u=>r(null,xs(a,u))).catch(u=>r(u,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}),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:ye("USER_DISCONNECTED")}),await this.cleanup()}async connect(t){if(!this.client)throw new Error("Sign Client not initialized");if(this.setNamespaces(t),await this.cleanupPendingPairings(),!t.skipPairing)return await this.pair(t.pairingTopic)}on(t,r){this.events.on(t,r)}once(t,r){this.events.once(t,r)}removeListener(t,r){this.events.removeListener(t,r)}off(t,r){this.events.off(t,r)}get isWalletConnect(){return!0}async pair(t){this.shouldAbortPairingAttempt=!1;let r=0;do{if(this.shouldAbortPairingAttempt)throw new Error("Pairing aborted");if(r>=this.maxPairingAttempts)throw new Error("Max auto pairing attempts reached");const{uri:s,approval:a}=await this.client.connect({pairingTopic:t,requiredNamespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties});s&&(this.uri=s,this.events.emit("display_uri",s)),await a().then(u=>{this.session=u,this.namespaces||(this.namespaces=VI(u.namespaces),this.persist("namespaces",this.namespaces))}).catch(u=>{if(u.message!==Il)throw u;r++})}while(!this.session);return this.onConnect(),this.session}setDefaultChain(t,r){try{if(!this.session)return;const[s,a]=this.validateChain(t);this.getProvider(s).setDefaultChain(a,r)}catch(s){if(!/Please call connect/.test(s.message))throw s}}async cleanupPendingPairings(t={}){this.logger.info("Cleaning up inactive pairings...");const r=this.client.pairing.getAll();if(hr(r)){for(const s of r)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: ${r.length}`)}}abortPairingAttempt(){this.shouldAbortPairingAttempt=!0}async checkStorage(){if(this.namespaces=await this.getFromStore("namespaces"),this.optionalNamespaces=await this.getFromStore("optionalNamespaces")||{},this.client.session.length){const t=this.client.session.keys.length-1;this.session=this.client.session.get(this.client.session.keys[t]),this.createProviders()}}async initialize(){this.logger.trace("Initialized"),await this.createClient(),await this.checkStorage(),this.registerEventListeners()}async createClient(){this.client=this.providerOpts.client||await wI.init({logger:this.providerOpts.logger||Th,relayUrl:this.providerOpts.relayUrl||CI,projectId:this.providerOpts.projectId,metadata:this.providerOpts.metadata,storageOptions:this.providerOpts.storageOptions,storage:this.providerOpts.storage,name:this.providerOpts.name}),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(r=>mi(r)))];go("client",this.client),go("events",this.events),go("disableProviderPing",this.disableProviderPing),t.forEach(r=>{if(!this.session)return;const s=kI(r,this.session),a=Sl(s),u=zI(this.namespaces,this.optionalNamespaces),l=yo(Es({},u[r]),{accounts:s,chains:a});switch(r){case"eip155":this.rpcProviders[r]=new FI({namespace:l});break;case"solana":this.rpcProviders[r]=new WI({namespace:l});break;case"cosmos":this.rpcProviders[r]=new BI({namespace:l});break;case"polkadot":this.rpcProviders[r]=new KI({namespace:l});break;case"cip34":this.rpcProviders[r]=new GI({namespace:l});break;case"elrond":this.rpcProviders[r]=new QI({namespace:l});break;case"multiversx":this.rpcProviders[r]=new JI({namespace:l});break;case"near":this.rpcProviders[r]=new YI({namespace:l});break}})}registerEventListeners(){if(typeof this.client>"u")throw new Error("Sign Client is not initialized");this.client.on("session_ping",t=>{this.events.emit("session_ping",t)}),this.client.on("session_event",t=>{const{params:r}=t,{event:s}=r;if(s.name==="accountsChanged"){const a=s.data;a&&hr(a)&&this.events.emit("accountsChanged",a.map(HI))}else if(s.name==="chainChanged"){const a=r.chainId,u=r.event.data,l=mi(a),g=fo(a)!==fo(u)?`${l}:${fo(u)}`:a;this.onChainChanged(g)}else this.events.emit(s.name,s.data);this.events.emit("session_event",t)}),this.client.on("session_update",({topic:t,params:r})=>{var s;const{namespaces:a}=r,u=(s=this.client)==null?void 0:s.session.get(t);this.session=yo(Es({},u),{namespaces:a}),this.onSessionUpdate(),this.events.emit("session_update",{topic:t,params:r})}),this.client.on("session_delete",async t=>{await this.cleanup(),this.events.emit("session_delete",t),this.events.emit("disconnect",yo(Es({},ye("USER_DISCONNECTED")),{data:t.topic}))}),this.on(qt.DEFAULT_CHAIN_CHANGED,t=>{this.onChainChanged(t,!0)})}getProvider(t){if(!this.rpcProviders[t])throw new Error(`Provider not found: ${t}`);return this.rpcProviders[t]}onSessionUpdate(){Object.keys(this.rpcProviders).forEach(t=>{var r;this.getProvider(t).updateNamespace((r=this.session)==null?void 0:r.namespaces[t])})}setNamespaces(t){const{namespaces:r,optionalNamespaces:s,sessionProperties:a}=t;r&&Object.keys(r).length&&(this.namespaces=r),s&&Object.keys(s).length&&(this.optionalNamespaces=s),this.sessionProperties=a,this.persist("namespaces",r),this.persist("optionalNamespaces",s)}validateChain(t){const[r,s]=(t==null?void 0:t.split(":"))||["",""];if(!this.namespaces||!Object.keys(this.namespaces).length)return[r,s];if(r&&!Object.keys(this.namespaces||{}).map(l=>mi(l)).includes(r))throw new Error(`Namespace '${r}' is not configured. Please call connect() first with namespace config.`);if(r&&s)return[r,s];const a=mi(Object.keys(this.namespaces)[0]),u=this.rpcProviders[a].getDefaultChain();return[a,u]}async requestAccounts(){const[t]=this.validateChain();return await this.getProvider(t).requestAccounts()}onChainChanged(t,r=!1){var s;if(!this.namespaces)return;const[a,u]=this.validateChain(t);r||this.getProvider(a).setDefaultChain(u),((s=this.namespaces[a])!=null?s:this.namespaces[`${a}:${u}`]).defaultChain=u,this.persist("namespaces",this.namespaces),this.events.emit("chainChanged",u)}onConnect(){this.createProviders(),this.events.emit("connect",{session:this.session})}async cleanup(){this.session=void 0,this.namespaces=void 0,this.optionalNamespaces=void 0,this.sessionProperties=void 0,this.persist("namespaces",void 0),this.persist("optionalNamespaces",void 0),this.persist("sessionProperties",void 0),await this.cleanupPendingPairings({deletePairings:!0})}persist(t,r){this.client.core.storage.setItem(`${xh}/${t}`,r)}async getFromStore(t){return await this.client.core.storage.getItem(`${xh}/${t}`)}}const iP=Qo,sP="wc",nP="ethereum_provider",oP=`${sP}@2:${nP}:`,aP="https://rpc.walletconnect.com/v1/",Co=["eth_sendTransaction","personal_sign"],cP=["eth_accounts","eth_requestAccounts","eth_sendRawTransaction","eth_sign","eth_signTransaction","eth_signTypedData","eth_signTypedData_v3","eth_signTypedData_v4","eth_sendTransaction","personal_sign","wallet_switchEthereumChain","wallet_addEthereumChain","wallet_getPermissions","wallet_requestPermissions","wallet_registerOnboarding","wallet_watchAsset","wallet_scanQRCode"],To=["chainChanged","accountsChanged"],uP=["chainChanged","accountsChanged","message","disconnect","connect"];var hP=Object.defineProperty,lP=Object.defineProperties,pP=Object.getOwnPropertyDescriptors,Mh=Object.getOwnPropertySymbols,dP=Object.prototype.hasOwnProperty,fP=Object.prototype.propertyIsEnumerable,Lh=(o,t,r)=>t in o?hP(o,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[t]=r,_i=(o,t)=>{for(var r in t||(t={}))dP.call(t,r)&&Lh(o,r,t[r]);if(Mh)for(var r of Mh(t))fP.call(t,r)&&Lh(o,r,t[r]);return o},kh=(o,t)=>lP(o,pP(t));function Ns(o){return Number(o[0].split(":")[1])}function vo(o){return`0x${o.toString(16)}`}function gP(o){const{chains:t,optionalChains:r,methods:s,optionalMethods:a,events:u,optionalEvents:l,rpcMap:g}=o;if(!mo(t))throw new Error("Invalid chains");const w={chains:t,methods:s||Co,events:u||To,rpcMap:_i({},t.length?{[Ns(t)]:g[Ns(t)]}:{})},b=u==null?void 0:u.filter(j=>!To.includes(j)),N=s==null?void 0:s.filter(j=>!Co.includes(j));if(!r&&!l&&!a&&!(b!=null&&b.length)&&!(N!=null&&N.length))return{required:t.length?w:void 0};const S=(b==null?void 0:b.length)&&(N==null?void 0:N.length)||!r,R={chains:[...new Set(S?w.chains.concat(r||[]):r)],methods:[...new Set(w.methods.concat(a!=null&&a.length?a:cP))],events:[...new Set(w.events.concat(l!=null&&l.length?l:uP))],rpcMap:g};return{required:t.length?w:void 0,optional:r.length?R:void 0}}class Jo{constructor(){this.events=new bt.EventEmitter,this.namespace="eip155",this.accounts=[],this.chainId=1,this.STORAGE_KEY=oP,this.on=(t,r)=>(this.events.on(t,r),this),this.once=(t,r)=>(this.events.once(t,r),this),this.removeListener=(t,r)=>(this.events.removeListener(t,r),this),this.off=(t,r)=>(this.events.off(t,r),this),this.parseAccount=t=>this.isCompatibleChainId(t)?this.parseAccountId(t).address:t,this.signer={},this.rpc={}}static async init(t){const r=new Jo;return await r.initialize(t),r}async request(t){return await this.signer.request(t,this.formatChainId(this.chainId))}sendAsync(t,r){this.signer.sendAsync(t,r,this.formatChainId(this.chainId))}get connected(){return this.signer.client?this.signer.client.core.relayer.connected:!1}get connecting(){return this.signer.client?this.signer.client.core.relayer.connecting:!1}async enable(){return this.session||await this.connect(),await this.request({method:"eth_requestAccounts"})}async connect(t){if(!this.signer.client)throw new Error("Provider not initialized. Call init() first");this.loadConnectOpts(t);const{required:r,optional:s}=gP(this.rpc);try{const a=await new Promise(async(l,g)=>{var w;this.rpc.showQrModal&&((w=this.modal)==null||w.subscribeModal(b=>{!b.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),g(new Error("Connection request reset. Please try again.")))})),await this.signer.connect(kh(_i({namespaces:_i({},r&&{[this.namespace]:r})},s&&{optionalNamespaces:{[this.namespace]:s}}),{pairingTopic:t==null?void 0:t.pairingTopic})).then(b=>{l(b)}).catch(b=>{g(new Error(b.message))})});if(!a)return;const u=Bw(a.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:u),this.setAccounts(u),this.events.emit("connect",{chainId:vo(this.chainId)})}catch(a){throw this.signer.logger.error(a),a}finally{this.modal&&this.modal.closeModal()}}async disconnect(){this.session&&await this.signer.disconnect(),this.reset()}get isWalletConnect(){return!0}get session(){return this.signer.session}registerEventListeners(){this.signer.on("session_event",t=>{const{params:r}=t,{event:s}=r;s.name==="accountsChanged"?(this.accounts=this.parseAccounts(s.data),this.events.emit("accountsChanged",this.accounts)):s.name==="chainChanged"?this.setChainId(this.formatChainId(s.data)):this.events.emit(s.name,s.data),this.events.emit("session_event",t)}),this.signer.on("chainChanged",t=>{const r=parseInt(t);this.chainId=r,this.events.emit("chainChanged",vo(this.chainId)),this.persist()}),this.signer.on("session_update",t=>{this.events.emit("session_update",t)}),this.signer.on("session_delete",t=>{this.reset(),this.events.emit("session_delete",t),this.events.emit("disconnect",kh(_i({},Qw("USER_DISCONNECTED")),{data:t.topic,name:"USER_DISCONNECTED"}))}),this.signer.on("display_uri",t=>{var r,s;this.rpc.showQrModal&&((r=this.modal)==null||r.closeModal(),(s=this.modal)==null||s.openModal({uri:t})),this.events.emit("display_uri",t)})}switchEthereumChain(t){this.request({method:"wallet_switchEthereumChain",params:[{chainId:t.toString(16)}]})}isCompatibleChainId(t){return typeof t=="string"?t.startsWith(`${this.namespace}:`):!1}formatChainId(t){return`${this.namespace}:${t}`}parseChainId(t){return Number(t.split(":")[1])}setChainIds(t){const r=t.filter(s=>this.isCompatibleChainId(s)).map(s=>this.parseChainId(s));r.length&&(this.chainId=r[0],this.events.emit("chainChanged",vo(this.chainId)),this.persist())}setChainId(t){if(this.isCompatibleChainId(t)){const r=this.parseChainId(t);this.chainId=r,this.switchEthereumChain(r)}}parseAccountId(t){const[r,s,a]=t.split(":");return{chainId:`${r}:${s}`,address:a}}setAccounts(t){this.accounts=t.filter(r=>this.parseChainId(this.parseAccountId(r).chainId)===this.chainId).map(r=>this.parseAccountId(r).address),this.events.emit("accountsChanged",this.accounts)}getRpcConfig(t){var r,s;const a=(r=t==null?void 0:t.chains)!=null?r:[],u=(s=t==null?void 0:t.optionalChains)!=null?s:[],l=a.concat(u);if(!l.length)throw new Error("No chains specified in either `chains` or `optionalChains`");const g=a.length?(t==null?void 0:t.methods)||Co:[],w=a.length?(t==null?void 0:t.events)||To:[],b=(t==null?void 0:t.optionalMethods)||[],N=(t==null?void 0:t.optionalEvents)||[],S=(t==null?void 0:t.rpcMap)||this.buildRpcMap(l,t.projectId),R=(t==null?void 0:t.qrModalOptions)||void 0;return{chains:a==null?void 0:a.map(j=>this.formatChainId(j)),optionalChains:u.map(j=>this.formatChainId(j)),methods:g,events:w,optionalMethods:b,optionalEvents:N,rpcMap:S,showQrModal:!!(t!=null&&t.showQrModal),qrModalOptions:R,projectId:t.projectId,metadata:t.metadata}}buildRpcMap(t,r){const s={};return t.forEach(a=>{s[a]=this.getRpcUrl(a,r)}),s}async initialize(t){if(this.rpc=this.getRpcConfig(t),this.chainId=this.rpc.chains.length?Ns(this.rpc.chains):Ns(this.rpc.optionalChains),this.signer=await iP.init({projectId:this.rpc.projectId,metadata:this.rpc.metadata,disableProviderPing:t.disableProviderPing,relayUrl:t.relayUrl,storageOptions:t.storageOptions}),this.registerEventListeners(),await this.loadPersistedSession(),this.rpc.showQrModal){let r;try{const{WalletConnectModal:s}=await Sw(()=>import("./index-CI40JjNh.js").then(a=>a.i),__vite__mapDeps([0,1,2]));r=s}catch{throw new Error("To use QR modal, please install @walletconnect/modal package")}if(r)try{this.modal=new r(_i({projectId:this.rpc.projectId},this.rpc.qrModalOptions))}catch(s){throw this.signer.logger.error(s),new Error("Could not generate WalletConnectModal Instance")}}}loadConnectOpts(t){if(!t)return;const{chains:r,optionalChains:s,rpcMap:a}=t;r&&mo(r)&&(this.rpc.chains=r.map(u=>this.formatChainId(u)),r.forEach(u=>{this.rpc.rpcMap[u]=(a==null?void 0:a[u])||this.getRpcUrl(u)})),s&&mo(s)&&(this.rpc.optionalChains=[],this.rpc.optionalChains=s==null?void 0:s.map(u=>this.formatChainId(u)),s.forEach(u=>{this.rpc.rpcMap[u]=(a==null?void 0:a[u])||this.getRpcUrl(u)}))}getRpcUrl(t,r){var s;return((s=this.rpc.rpcMap)==null?void 0:s[t])||`${aP}?chainId=eip155:${t}&projectId=${r||this.rpc.projectId}`}async loadPersistedSession(){if(!this.session)return;const t=await this.signer.client.core.storage.getItem(`${this.STORAGE_KEY}/chainId`),r=this.session.namespaces[`${this.namespace}:${t}`]?this.session.namespaces[`${this.namespace}:${t}`]:this.session.namespaces[this.namespace];this.setChainIds(t?[this.formatChainId(t)]:r==null?void 0:r.accounts),this.setAccounts(r==null?void 0:r.accounts)}reset(){this.chainId=1,this.accounts=[]}persist(){this.session&&this.signer.client.core.storage.setItem(`${this.STORAGE_KEY}/chainId`,this.chainId)}parseAccounts(t){return typeof t=="string"||t instanceof String?[this.parseAccount(t)]:t.map(r=>this.parseAccount(r))}}const AP=Jo;export{AP as EthereumProvider,uP as OPTIONAL_EVENTS,cP as OPTIONAL_METHODS,To as REQUIRED_EVENTS,Co as REQUIRED_METHODS,Jo as default};
|
|
47
|
+
}`;var V=Ou(function(){return Z(d,D+"return "+O).apply(r,f)});if(V.source=O,Bn(V))throw V;return V}function Cm(e){return X(e).toLowerCase()}function Tm(e){return X(e).toUpperCase()}function xm(e,i,n){if(e=X(e),e&&(n||i===r))return qa(e);if(!e||!(i=Ke(i)))return e;var c=ct(e),h=ct(i),d=ja(c,h),f=Ua(c,h)+1;return Ft(c,d,f).join("")}function Am(e,i,n){if(e=X(e),e&&(n||i===r))return e.slice(0,La(e)+1);if(!e||!(i=Ke(i)))return e;var c=ct(e),h=Ua(c,ct(i))+1;return Ft(c,0,h).join("")}function Dm(e,i,n){if(e=X(e),e&&(n||i===r))return e.replace(Ws,"");if(!e||!(i=Ke(i)))return e;var c=ct(e),h=ja(c,ct(i));return Ft(c,h).join("")}function qm(e,i){var n=Rl,c=Nl;if(he(i)){var h="separator"in i?i.separator:h;n="length"in i?H(i.length):n,c="omission"in i?Ke(i.omission):c}e=X(e);var d=e.length;if(_r(e)){var f=ct(e);d=f.length}if(n>=d)return e;var y=n-br(c);if(y<1)return c;var m=f?Ft(f,0,y).join(""):e.slice(0,y);if(h===r)return m+c;if(f&&(y+=m.length-y),Gn(h)){if(e.slice(y).search(h)){var I,P=m;for(h.global||(h=hn(h.source,X(ia.exec(h))+"g")),h.lastIndex=0;I=h.exec(P);)var O=I.index;m=m.slice(0,O===r?y:O)}}else if(e.indexOf(Ke(h),y)!=y){var C=m.lastIndexOf(h);C>-1&&(m=m.slice(0,C))}return m+c}function jm(e){return e=X(e),e&&Wl.test(e)?e.replace(ea,hd):e}var Um=Nr(function(e,i,n){return e+(n?" ":"")+i.toUpperCase()}),Yn=Rc("toUpperCase");function Su(e,i,n){return e=X(e),i=n?r:i,i===r?nd(e)?dd(e):Jp(e):e.match(i)||[]}var Ou=F(function(e,i){try{return He(e,r,i)}catch(n){return Bn(n)?n:new k(n)}}),Mm=Rt(function(e,i){return Ye(i,function(n){n=mt(n),St(e,n,Fn(e[n],e))}),e});function Lm(e){var i=e==null?0:e.length,n=U();return e=i?ce(e,function(c){if(typeof c[1]!="function")throw new Ze(l);return[n(c[0]),c[1]]}):[],F(function(c){for(var h=-1;++h<i;){var d=e[h];if(He(d[0],this,c))return He(d[1],this,c)}})}function km(e){return lf(et(e,S))}function Zn(e){return function(){return e}}function zm(e,i){return e==null||e!==e?i:e}var Hm=$c(),Vm=$c(!0);function Ue(e){return e}function Xn(e){return nc(typeof e=="function"?e:et(e,S))}function Km(e){return ac(et(e,S))}function Fm(e,i){return cc(e,et(i,S))}var Wm=F(function(e,i){return function(n){return si(n,e,i)}}),Bm=F(function(e,i){return function(n){return si(e,n,i)}});function eo(e,i,n){var c=_e(i),h=Xi(i,c);n==null&&!(he(i)&&(h.length||!c.length))&&(n=i,i=e,e=this,h=Xi(i,_e(i)));var d=!(he(n)&&"chain"in n)||!!n.chain,f=$t(e);return Ye(h,function(y){var m=i[y];e[y]=m,f&&(e.prototype[y]=function(){var I=this.__chain__;if(d||I){var P=e(this.__wrapped__),O=P.__actions__=De(this.__actions__);return O.push({func:m,args:arguments,thisArg:e}),P.__chain__=I,P}return m.apply(e,Lt([this.value()],arguments))})}),e}function Gm(){return Ee._===this&&(Ee._=wd),this}function to(){}function Qm(e){return e=H(e),F(function(i){return uc(i,e)})}var Jm=xn(ce),Ym=xn(Ca),Zm=xn(rn);function Ru(e){return Ln(e)?sn(mt(e)):Nf(e)}function Xm(e){return function(i){return e==null?r:sr(e,i)}}var ew=Tc(),tw=Tc(!0);function ro(){return[]}function io(){return!1}function rw(){return{}}function iw(){return""}function sw(){return!0}function nw(e,i){if(e=H(e),e<1||e>Ut)return[];var n=gt,c=Se(e,gt);i=U(i),e-=gt;for(var h=an(c,i);++n<e;)i(n);return h}function ow(e){return z(e)?ce(e,mt):Fe(e)?[e]:De(Bc(X(e)))}function aw(e){var i=++vd;return X(e)+i}var cw=ns(function(e,i){return e+i},0),uw=An("ceil"),hw=ns(function(e,i){return e/i},1),lw=An("floor");function pw(e){return e&&e.length?Zi(e,Ue,mn):r}function dw(e,i){return e&&e.length?Zi(e,U(i,2),mn):r}function fw(e){return Aa(e,Ue)}function gw(e,i){return Aa(e,U(i,2))}function yw(e){return e&&e.length?Zi(e,Ue,En):r}function vw(e,i){return e&&e.length?Zi(e,U(i,2),En):r}var mw=ns(function(e,i){return e*i},1),ww=An("round"),_w=ns(function(e,i){return e-i},0);function bw(e){return e&&e.length?on(e,Ue):0}function Ew(e,i){return e&&e.length?on(e,U(i,2)):0}return p.after=Ky,p.ary=su,p.assign=Tv,p.assignIn=mu,p.assignInWith=ms,p.assignWith=xv,p.at=Av,p.before=nu,p.bind=Fn,p.bindAll=Mm,p.bindKey=ou,p.castArray=rv,p.chain=tu,p.chunk=lg,p.compact=pg,p.concat=dg,p.cond=Lm,p.conforms=km,p.constant=Zn,p.countBy=by,p.create=Dv,p.curry=au,p.curryRight=cu,p.debounce=uu,p.defaults=qv,p.defaultsDeep=jv,p.defer=Fy,p.delay=Wy,p.difference=fg,p.differenceBy=gg,p.differenceWith=yg,p.drop=vg,p.dropRight=mg,p.dropRightWhile=wg,p.dropWhile=_g,p.fill=bg,p.filter=Iy,p.flatMap=Oy,p.flatMapDeep=Ry,p.flatMapDepth=Ny,p.flatten=Yc,p.flattenDeep=Eg,p.flattenDepth=Ig,p.flip=By,p.flow=Hm,p.flowRight=Vm,p.fromPairs=Pg,p.functions=Vv,p.functionsIn=Kv,p.groupBy=$y,p.initial=Og,p.intersection=Rg,p.intersectionBy=Ng,p.intersectionWith=$g,p.invert=Wv,p.invertBy=Bv,p.invokeMap=Ty,p.iteratee=Xn,p.keyBy=xy,p.keys=_e,p.keysIn=je,p.map=ps,p.mapKeys=Qv,p.mapValues=Jv,p.matches=Km,p.matchesProperty=Fm,p.memoize=fs,p.merge=Yv,p.mergeWith=wu,p.method=Wm,p.methodOf=Bm,p.mixin=eo,p.negate=gs,p.nthArg=Qm,p.omit=Zv,p.omitBy=Xv,p.once=Gy,p.orderBy=Ay,p.over=Jm,p.overArgs=Qy,p.overEvery=Ym,p.overSome=Zm,p.partial=Wn,p.partialRight=hu,p.partition=Dy,p.pick=em,p.pickBy=_u,p.property=Ru,p.propertyOf=Xm,p.pull=Ag,p.pullAll=Xc,p.pullAllBy=Dg,p.pullAllWith=qg,p.pullAt=jg,p.range=ew,p.rangeRight=tw,p.rearg=Jy,p.reject=Uy,p.remove=Ug,p.rest=Yy,p.reverse=Vn,p.sampleSize=Ly,p.set=rm,p.setWith=im,p.shuffle=ky,p.slice=Mg,p.sortBy=Vy,p.sortedUniq=Fg,p.sortedUniqBy=Wg,p.split=Om,p.spread=Zy,p.tail=Bg,p.take=Gg,p.takeRight=Qg,p.takeRightWhile=Jg,p.takeWhile=Yg,p.tap=py,p.throttle=Xy,p.thru=ls,p.toArray=gu,p.toPairs=bu,p.toPairsIn=Eu,p.toPath=ow,p.toPlainObject=vu,p.transform=sm,p.unary=ev,p.union=Zg,p.unionBy=Xg,p.unionWith=ey,p.uniq=ty,p.uniqBy=ry,p.uniqWith=iy,p.unset=nm,p.unzip=Kn,p.unzipWith=eu,p.update=om,p.updateWith=am,p.values=Tr,p.valuesIn=cm,p.without=sy,p.words=Su,p.wrap=tv,p.xor=ny,p.xorBy=oy,p.xorWith=ay,p.zip=cy,p.zipObject=uy,p.zipObjectDeep=hy,p.zipWith=ly,p.entries=bu,p.entriesIn=Eu,p.extend=mu,p.extendWith=ms,eo(p,p),p.add=cw,p.attempt=Ou,p.camelCase=pm,p.capitalize=Iu,p.ceil=uw,p.clamp=um,p.clone=iv,p.cloneDeep=nv,p.cloneDeepWith=ov,p.cloneWith=sv,p.conformsTo=av,p.deburr=Pu,p.defaultTo=zm,p.divide=hw,p.endsWith=dm,p.eq=ht,p.escape=fm,p.escapeRegExp=gm,p.every=Ey,p.find=Py,p.findIndex=Qc,p.findKey=Uv,p.findLast=Sy,p.findLastIndex=Jc,p.findLastKey=Mv,p.floor=lw,p.forEach=ru,p.forEachRight=iu,p.forIn=Lv,p.forInRight=kv,p.forOwn=zv,p.forOwnRight=Hv,p.get=Qn,p.gt=cv,p.gte=uv,p.has=Fv,p.hasIn=Jn,p.head=Zc,p.identity=Ue,p.includes=Cy,p.indexOf=Sg,p.inRange=hm,p.invoke=Gv,p.isArguments=ar,p.isArray=z,p.isArrayBuffer=hv,p.isArrayLike=qe,p.isArrayLikeObject=fe,p.isBoolean=lv,p.isBuffer=Wt,p.isDate=pv,p.isElement=dv,p.isEmpty=fv,p.isEqual=gv,p.isEqualWith=yv,p.isError=Bn,p.isFinite=vv,p.isFunction=$t,p.isInteger=lu,p.isLength=ys,p.isMap=pu,p.isMatch=mv,p.isMatchWith=wv,p.isNaN=_v,p.isNative=bv,p.isNil=Iv,p.isNull=Ev,p.isNumber=du,p.isObject=he,p.isObjectLike=le,p.isPlainObject=hi,p.isRegExp=Gn,p.isSafeInteger=Pv,p.isSet=fu,p.isString=vs,p.isSymbol=Fe,p.isTypedArray=Cr,p.isUndefined=Sv,p.isWeakMap=Ov,p.isWeakSet=Rv,p.join=Cg,p.kebabCase=ym,p.last=rt,p.lastIndexOf=Tg,p.lowerCase=vm,p.lowerFirst=mm,p.lt=Nv,p.lte=$v,p.max=pw,p.maxBy=dw,p.mean=fw,p.meanBy=gw,p.min=yw,p.minBy=vw,p.stubArray=ro,p.stubFalse=io,p.stubObject=rw,p.stubString=iw,p.stubTrue=sw,p.multiply=mw,p.nth=xg,p.noConflict=Gm,p.noop=to,p.now=ds,p.pad=wm,p.padEnd=_m,p.padStart=bm,p.parseInt=Em,p.random=lm,p.reduce=qy,p.reduceRight=jy,p.repeat=Im,p.replace=Pm,p.result=tm,p.round=ww,p.runInContext=v,p.sample=My,p.size=zy,p.snakeCase=Sm,p.some=Hy,p.sortedIndex=Lg,p.sortedIndexBy=kg,p.sortedIndexOf=zg,p.sortedLastIndex=Hg,p.sortedLastIndexBy=Vg,p.sortedLastIndexOf=Kg,p.startCase=Rm,p.startsWith=Nm,p.subtract=_w,p.sum=bw,p.sumBy=Ew,p.template=$m,p.times=nw,p.toFinite=Ct,p.toInteger=H,p.toLength=yu,p.toLower=Cm,p.toNumber=it,p.toSafeInteger=Cv,p.toString=X,p.toUpper=Tm,p.trim=xm,p.trimEnd=Am,p.trimStart=Dm,p.truncate=qm,p.unescape=jm,p.uniqueId=aw,p.upperCase=Um,p.upperFirst=Yn,p.each=ru,p.eachRight=iu,p.first=Zc,eo(p,function(){var e={};return yt(p,function(i,n){ee.call(p.prototype,n)||(e[n]=i)}),e}(),{chain:!1}),p.VERSION=s,Ye(["bind","bindKey","curry","curryRight","partial","partialRight"],function(e){p[e].placeholder=p}),Ye(["drop","take"],function(e,i){G.prototype[e]=function(n){n=n===r?1:we(H(n),0);var c=this.__filtered__&&!i?new G(this):this.clone();return c.__filtered__?c.__takeCount__=Se(n,c.__takeCount__):c.__views__.push({size:Se(n,gt),type:e+(c.__dir__<0?"Right":"")}),c},G.prototype[e+"Right"]=function(n){return this.reverse()[e](n).reverse()}}),Ye(["filter","map","takeWhile"],function(e,i){var n=i+1,c=n==Yo||n==xl;G.prototype[e]=function(h){var d=this.clone();return d.__iteratees__.push({iteratee:U(h,3),type:n}),d.__filtered__=d.__filtered__||c,d}}),Ye(["head","last"],function(e,i){var n="take"+(i?"Right":"");G.prototype[e]=function(){return this[n](1).value()[0]}}),Ye(["initial","tail"],function(e,i){var n="drop"+(i?"":"Right");G.prototype[e]=function(){return this.__filtered__?new G(this):this[n](1)}}),G.prototype.compact=function(){return this.filter(Ue)},G.prototype.find=function(e){return this.filter(e).head()},G.prototype.findLast=function(e){return this.reverse().find(e)},G.prototype.invokeMap=F(function(e,i){return typeof e=="function"?new G(this):this.map(function(n){return si(n,e,i)})}),G.prototype.reject=function(e){return this.filter(gs(U(e)))},G.prototype.slice=function(e,i){e=H(e);var n=this;return n.__filtered__&&(e>0||i<0)?new G(n):(e<0?n=n.takeRight(-e):e&&(n=n.drop(e)),i!==r&&(i=H(i),n=i<0?n.dropRight(-i):n.take(i-e)),n)},G.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},G.prototype.toArray=function(){return this.take(gt)},yt(G.prototype,function(e,i){var n=/^(?:filter|find|map|reject)|While$/.test(i),c=/^(?:head|last)$/.test(i),h=p[c?"take"+(i=="last"?"Right":""):i],d=c||/^find/.test(i);h&&(p.prototype[i]=function(){var f=this.__wrapped__,y=c?[1]:arguments,m=f instanceof G,I=y[0],P=m||z(f),O=function(W){var Q=h.apply(p,Lt([W],y));return c&&C?Q[0]:Q};P&&n&&typeof I=="function"&&I.length!=1&&(m=P=!1);var C=this.__chain__,D=!!this.__actions__.length,M=d&&!C,V=m&&!D;if(!d&&P){f=V?f:new G(this);var L=e.apply(f,y);return L.__actions__.push({func:ls,args:[O],thisArg:r}),new Xe(L,C)}return M&&V?e.apply(this,y):(L=this.thru(O),M?c?L.value()[0]:L.value():L)})}),Ye(["pop","push","shift","sort","splice","unshift"],function(e){var i=Ui[e],n=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",c=/^(?:pop|shift)$/.test(e);p.prototype[e]=function(){var h=arguments;if(c&&!this.__chain__){var d=this.value();return i.apply(z(d)?d:[],h)}return this[n](function(f){return i.apply(z(f)?f:[],h)})}}),yt(G.prototype,function(e,i){var n=p[i];if(n){var c=n.name+"";ee.call(Sr,c)||(Sr[c]=[]),Sr[c].push({name:i,func:n})}}),Sr[ss(r,B).name]=[{name:"wrapper",func:r}],G.prototype.clone=qd,G.prototype.reverse=jd,G.prototype.value=Ud,p.prototype.at=dy,p.prototype.chain=fy,p.prototype.commit=gy,p.prototype.next=yy,p.prototype.plant=my,p.prototype.reverse=wy,p.prototype.toJSON=p.prototype.valueOf=p.prototype.value=_y,p.prototype.first=p.prototype.head,Yr&&(p.prototype[Yr]=vy),p},Er=fd();Xt?((Xt.exports=Er)._=Er,Zs._=Er):Ee._=Er}).call(vi)})($o,$o.exports);var DI=Object.defineProperty,qI=Object.defineProperties,jI=Object.getOwnPropertyDescriptors,Ah=Object.getOwnPropertySymbols,UI=Object.prototype.hasOwnProperty,MI=Object.prototype.propertyIsEnumerable,Dh=(o,t,r)=>t in o?DI(o,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[t]=r,bs=(o,t)=>{for(var r in t||(t={}))UI.call(t,r)&&Dh(o,r,t[r]);if(Ah)for(var r of Ah(t))MI.call(t,r)&&Dh(o,r,t[r]);return o},LI=(o,t)=>qI(o,jI(t));function Jt(o,t,r){var s;const a=u_(o);return((s=t.rpcMap)==null?void 0:s[a.reference])||`${AI}?chainId=${a.namespace}:${a.reference}&projectId=${r}`}function gr(o){return o.includes(":")?o.split(":")[1]:o}function Sl(o){return o.map(t=>`${t.split(":")[0]}:${t.split(":")[1]}`)}function kI(o,t){const r=Object.keys(t.namespaces).filter(a=>a.includes(o));if(!r.length)return[];const s=[];return r.forEach(a=>{const u=t.namespaces[a].accounts;s.push(...u)}),s}function zI(o={},t={}){const r=qh(o),s=qh(t);return $o.exports.merge(r,s)}function qh(o){var t,r,s,a;const u={};if(!jr(o))return u;for(const[l,g]of Object.entries(o)){const w=Ko(l)?[l]:g.chains,b=g.methods||[],N=g.events||[],S=g.rpcMap||{},R=mi(l);u[R]=LI(bs(bs({},u[R]),g),{chains:oo(w,(t=u[R])==null?void 0:t.chains),methods:oo(b,(r=u[R])==null?void 0:r.methods),events:oo(N,(s=u[R])==null?void 0:s.events),rpcMap:bs(bs({},S),(a=u[R])==null?void 0:a.rpcMap)})}return u}function HI(o){return o.includes(":")?o.split(":")[2]:o}function VI(o){const t={};for(const[r,s]of Object.entries(o)){const a=s.methods||[],u=s.events||[],l=s.accounts||[],g=Ko(r)?[r]:s.chains?s.chains:Sl(s.accounts);t[r]={chains:g,methods:a,events:u,accounts:l}}return t}function fo(o){return typeof o=="number"?o:o.includes("0x")?parseInt(o,16):o.includes(":")?Number(o.split(":")[1]):Number(o)}const Ol={},ue=o=>Ol[o],go=(o,t)=>{Ol[o]=t};class KI{constructor(t){this.name="polkadot",this.namespace=t.namespace,this.events=ue("events"),this.client=ue("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,r){this.httpProviders[t]||this.setHttpProvider(t,r),this.chainId=t,this.events.emit(qt.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`)}getAccounts(){const t=this.namespace.accounts;return t?t.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2])||[]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(r=>{var s;const a=gr(r);t[a]=this.createHttpProvider(a,(s=this.namespace.rpcMap)==null?void 0:s[r])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,r=this.httpProviders[t];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return r}setHttpProvider(t,r){const s=this.createHttpProvider(t,r);s&&(this.httpProviders[t]=s)}createHttpProvider(t,r){const s=r||Jt(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new Dt(new Yt(s,ue("disableProviderPing")))}}class FI{constructor(t){this.name="eip155",this.namespace=t.namespace,this.events=ue("events"),this.client=ue("client"),this.httpProviders=this.createHttpProviders(),this.chainId=parseInt(this.getDefaultChain())}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())}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,r){this.httpProviders[t]||this.setHttpProvider(parseInt(t),r),this.chainId=parseInt(t),this.events.emit(qt.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,r){const s=r||Jt(`${this.name}:${t}`,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new Dt(new Yt(s,ue("disableProviderPing")))}setHttpProvider(t,r){const s=this.createHttpProvider(t,r);s&&(this.httpProviders[t]=s)}createHttpProviders(){const t={};return this.namespace.chains.forEach(r=>{var s;const a=parseInt(gr(r));t[a]=this.createHttpProvider(a,(s=this.namespace.rpcMap)==null?void 0:s[r])}),t}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}getHttpProvider(){const t=this.chainId,r=this.httpProviders[t];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return r}async handleSwitchChain(t){var r,s;let a=t.request.params?(r=t.request.params[0])==null?void 0:r.chainId:"0x0";a=a.startsWith("0x")?a:`0x${a}`;const u=parseInt(a,16);if(this.isChainApproved(u))this.setDefaultChain(`${u}`);else if(this.namespace.methods.includes("wallet_switchEthereumChain"))await this.client.request({topic:t.topic,request:{method:t.request.method,params:[{chainId:a}]},chainId:(s=this.namespace.chains)==null?void 0:s[0]}),this.setDefaultChain(`${u}`);else throw new Error(`Failed to switch to chain 'eip155:${u}'. 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}`)}}class WI{constructor(t){this.name="solana",this.namespace=t.namespace,this.events=ue("events"),this.client=ue("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,r){this.httpProviders[t]||this.setHttpProvider(t,r),this.chainId=t,this.events.emit(qt.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(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(r=>{var s;const a=gr(r);t[a]=this.createHttpProvider(a,(s=this.namespace.rpcMap)==null?void 0:s[r])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,r=this.httpProviders[t];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return r}setHttpProvider(t,r){const s=this.createHttpProvider(t,r);s&&(this.httpProviders[t]=s)}createHttpProvider(t,r){const s=r||Jt(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new Dt(new Yt(s,ue("disableProviderPing")))}}class BI{constructor(t){this.name="cosmos",this.namespace=t.namespace,this.events=ue("events"),this.client=ue("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,r){this.httpProviders[t]||this.setHttpProvider(t,r),this.chainId=t,this.events.emit(qt.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(r=>{var s;const a=gr(r);t[a]=this.createHttpProvider(a,(s=this.namespace.rpcMap)==null?void 0:s[r])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,r=this.httpProviders[t];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return r}setHttpProvider(t,r){const s=this.createHttpProvider(t,r);s&&(this.httpProviders[t]=s)}createHttpProvider(t,r){const s=r||Jt(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new Dt(new Yt(s,ue("disableProviderPing")))}}class GI{constructor(t){this.name="cip34",this.namespace=t.namespace,this.events=ue("events"),this.client=ue("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,r){this.httpProviders[t]||this.setHttpProvider(t,r),this.chainId=t,this.events.emit(qt.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(r=>{const s=this.getCardanoRPCUrl(r),a=gr(r);t[a]=this.createHttpProvider(a,s)}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,r=this.httpProviders[t];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return r}getCardanoRPCUrl(t){const r=this.namespace.rpcMap;if(r)return r[t]}setHttpProvider(t,r){const s=this.createHttpProvider(t,r);s&&(this.httpProviders[t]=s)}createHttpProvider(t,r){const s=r||this.getCardanoRPCUrl(t);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new Dt(new Yt(s,ue("disableProviderPing")))}}class QI{constructor(t){this.name="elrond",this.namespace=t.namespace,this.events=ue("events"),this.client=ue("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,r){this.httpProviders[t]||this.setHttpProvider(t,r),this.chainId=t,this.events.emit(qt.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(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(r=>{var s;const a=gr(r);t[a]=this.createHttpProvider(a,(s=this.namespace.rpcMap)==null?void 0:s[r])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,r=this.httpProviders[t];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return r}setHttpProvider(t,r){const s=this.createHttpProvider(t,r);s&&(this.httpProviders[t]=s)}createHttpProvider(t,r){const s=r||Jt(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new Dt(new Yt(s,ue("disableProviderPing")))}}class JI{constructor(t){this.name="multiversx",this.namespace=t.namespace,this.events=ue("events"),this.client=ue("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,r){this.httpProviders[t]||this.setHttpProvider(t,r),this.chainId=t,this.events.emit(qt.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(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(r=>{var s;const a=gr(r);t[a]=this.createHttpProvider(a,(s=this.namespace.rpcMap)==null?void 0:s[r])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,r=this.httpProviders[t];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return r}setHttpProvider(t,r){const s=this.createHttpProvider(t,r);s&&(this.httpProviders[t]=s)}createHttpProvider(t,r){const s=r||Jt(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new Dt(new Yt(s,ue("disableProviderPing")))}}class YI{constructor(t){this.name="near",this.namespace=t.namespace,this.events=ue("events"),this.client=ue("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,r){if(this.chainId=t,!this.httpProviders[t]){const s=r||Jt(`${this.name}:${t}`,this.namespace);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);this.setHttpProvider(t,s)}this.events.emit(qt.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const t=this.namespace.accounts;return t?t.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2])||[]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(r=>{var s;t[r]=this.createHttpProvider(r,(s=this.namespace.rpcMap)==null?void 0:s[r])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,r=this.httpProviders[t];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return r}setHttpProvider(t,r){const s=this.createHttpProvider(t,r);s&&(this.httpProviders[t]=s)}createHttpProvider(t,r){const s=r||Jt(t,this.namespace);return typeof s>"u"?void 0:new Dt(new Yt(s,ue("disableProviderPing")))}}var ZI=Object.defineProperty,XI=Object.defineProperties,eP=Object.getOwnPropertyDescriptors,jh=Object.getOwnPropertySymbols,tP=Object.prototype.hasOwnProperty,rP=Object.prototype.propertyIsEnumerable,Uh=(o,t,r)=>t in o?ZI(o,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[t]=r,Es=(o,t)=>{for(var r in t||(t={}))tP.call(t,r)&&Uh(o,r,t[r]);if(jh)for(var r of jh(t))rP.call(t,r)&&Uh(o,r,t[r]);return o},yo=(o,t)=>XI(o,eP(t));class Qo{constructor(t){this.events=new Ao,this.rpcProviders={},this.shouldAbortPairingAttempt=!1,this.maxPairingAttempts=10,this.disableProviderPing=!1,this.providerOpts=t,this.logger=typeof(t==null?void 0:t.logger)<"u"&&typeof(t==null?void 0:t.logger)!="string"?t.logger:Cs(Ts({level:(t==null?void 0:t.logger)||Th})),this.disableProviderPing=(t==null?void 0:t.disableProviderPing)||!1}static async init(t){const r=new Qo(t);return await r.initialize(),r}async request(t,r){const[s,a]=this.validateChain(r);if(!this.session)throw new Error("Please call connect() before request()");return await this.getProvider(s).request({request:Es({},t),chainId:`${s}:${a}`,topic:this.session.topic})}sendAsync(t,r,s){const a=new Date().getTime();this.request(t,s).then(u=>r(null,xs(a,u))).catch(u=>r(u,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}),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:ye("USER_DISCONNECTED")}),await this.cleanup()}async connect(t){if(!this.client)throw new Error("Sign Client not initialized");if(this.setNamespaces(t),await this.cleanupPendingPairings(),!t.skipPairing)return await this.pair(t.pairingTopic)}on(t,r){this.events.on(t,r)}once(t,r){this.events.once(t,r)}removeListener(t,r){this.events.removeListener(t,r)}off(t,r){this.events.off(t,r)}get isWalletConnect(){return!0}async pair(t){this.shouldAbortPairingAttempt=!1;let r=0;do{if(this.shouldAbortPairingAttempt)throw new Error("Pairing aborted");if(r>=this.maxPairingAttempts)throw new Error("Max auto pairing attempts reached");const{uri:s,approval:a}=await this.client.connect({pairingTopic:t,requiredNamespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties});s&&(this.uri=s,this.events.emit("display_uri",s)),await a().then(u=>{this.session=u,this.namespaces||(this.namespaces=VI(u.namespaces),this.persist("namespaces",this.namespaces))}).catch(u=>{if(u.message!==Il)throw u;r++})}while(!this.session);return this.onConnect(),this.session}setDefaultChain(t,r){try{if(!this.session)return;const[s,a]=this.validateChain(t);this.getProvider(s).setDefaultChain(a,r)}catch(s){if(!/Please call connect/.test(s.message))throw s}}async cleanupPendingPairings(t={}){this.logger.info("Cleaning up inactive pairings...");const r=this.client.pairing.getAll();if(hr(r)){for(const s of r)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: ${r.length}`)}}abortPairingAttempt(){this.shouldAbortPairingAttempt=!0}async checkStorage(){if(this.namespaces=await this.getFromStore("namespaces"),this.optionalNamespaces=await this.getFromStore("optionalNamespaces")||{},this.client.session.length){const t=this.client.session.keys.length-1;this.session=this.client.session.get(this.client.session.keys[t]),this.createProviders()}}async initialize(){this.logger.trace("Initialized"),await this.createClient(),await this.checkStorage(),this.registerEventListeners()}async createClient(){this.client=this.providerOpts.client||await wI.init({logger:this.providerOpts.logger||Th,relayUrl:this.providerOpts.relayUrl||CI,projectId:this.providerOpts.projectId,metadata:this.providerOpts.metadata,storageOptions:this.providerOpts.storageOptions,storage:this.providerOpts.storage,name:this.providerOpts.name}),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(r=>mi(r)))];go("client",this.client),go("events",this.events),go("disableProviderPing",this.disableProviderPing),t.forEach(r=>{if(!this.session)return;const s=kI(r,this.session),a=Sl(s),u=zI(this.namespaces,this.optionalNamespaces),l=yo(Es({},u[r]),{accounts:s,chains:a});switch(r){case"eip155":this.rpcProviders[r]=new FI({namespace:l});break;case"solana":this.rpcProviders[r]=new WI({namespace:l});break;case"cosmos":this.rpcProviders[r]=new BI({namespace:l});break;case"polkadot":this.rpcProviders[r]=new KI({namespace:l});break;case"cip34":this.rpcProviders[r]=new GI({namespace:l});break;case"elrond":this.rpcProviders[r]=new QI({namespace:l});break;case"multiversx":this.rpcProviders[r]=new JI({namespace:l});break;case"near":this.rpcProviders[r]=new YI({namespace:l});break}})}registerEventListeners(){if(typeof this.client>"u")throw new Error("Sign Client is not initialized");this.client.on("session_ping",t=>{this.events.emit("session_ping",t)}),this.client.on("session_event",t=>{const{params:r}=t,{event:s}=r;if(s.name==="accountsChanged"){const a=s.data;a&&hr(a)&&this.events.emit("accountsChanged",a.map(HI))}else if(s.name==="chainChanged"){const a=r.chainId,u=r.event.data,l=mi(a),g=fo(a)!==fo(u)?`${l}:${fo(u)}`:a;this.onChainChanged(g)}else this.events.emit(s.name,s.data);this.events.emit("session_event",t)}),this.client.on("session_update",({topic:t,params:r})=>{var s;const{namespaces:a}=r,u=(s=this.client)==null?void 0:s.session.get(t);this.session=yo(Es({},u),{namespaces:a}),this.onSessionUpdate(),this.events.emit("session_update",{topic:t,params:r})}),this.client.on("session_delete",async t=>{await this.cleanup(),this.events.emit("session_delete",t),this.events.emit("disconnect",yo(Es({},ye("USER_DISCONNECTED")),{data:t.topic}))}),this.on(qt.DEFAULT_CHAIN_CHANGED,t=>{this.onChainChanged(t,!0)})}getProvider(t){if(!this.rpcProviders[t])throw new Error(`Provider not found: ${t}`);return this.rpcProviders[t]}onSessionUpdate(){Object.keys(this.rpcProviders).forEach(t=>{var r;this.getProvider(t).updateNamespace((r=this.session)==null?void 0:r.namespaces[t])})}setNamespaces(t){const{namespaces:r,optionalNamespaces:s,sessionProperties:a}=t;r&&Object.keys(r).length&&(this.namespaces=r),s&&Object.keys(s).length&&(this.optionalNamespaces=s),this.sessionProperties=a,this.persist("namespaces",r),this.persist("optionalNamespaces",s)}validateChain(t){const[r,s]=(t==null?void 0:t.split(":"))||["",""];if(!this.namespaces||!Object.keys(this.namespaces).length)return[r,s];if(r&&!Object.keys(this.namespaces||{}).map(l=>mi(l)).includes(r))throw new Error(`Namespace '${r}' is not configured. Please call connect() first with namespace config.`);if(r&&s)return[r,s];const a=mi(Object.keys(this.namespaces)[0]),u=this.rpcProviders[a].getDefaultChain();return[a,u]}async requestAccounts(){const[t]=this.validateChain();return await this.getProvider(t).requestAccounts()}onChainChanged(t,r=!1){var s;if(!this.namespaces)return;const[a,u]=this.validateChain(t);r||this.getProvider(a).setDefaultChain(u),((s=this.namespaces[a])!=null?s:this.namespaces[`${a}:${u}`]).defaultChain=u,this.persist("namespaces",this.namespaces),this.events.emit("chainChanged",u)}onConnect(){this.createProviders(),this.events.emit("connect",{session:this.session})}async cleanup(){this.session=void 0,this.namespaces=void 0,this.optionalNamespaces=void 0,this.sessionProperties=void 0,this.persist("namespaces",void 0),this.persist("optionalNamespaces",void 0),this.persist("sessionProperties",void 0),await this.cleanupPendingPairings({deletePairings:!0})}persist(t,r){this.client.core.storage.setItem(`${xh}/${t}`,r)}async getFromStore(t){return await this.client.core.storage.getItem(`${xh}/${t}`)}}const iP=Qo,sP="wc",nP="ethereum_provider",oP=`${sP}@2:${nP}:`,aP="https://rpc.walletconnect.com/v1/",Co=["eth_sendTransaction","personal_sign"],cP=["eth_accounts","eth_requestAccounts","eth_sendRawTransaction","eth_sign","eth_signTransaction","eth_signTypedData","eth_signTypedData_v3","eth_signTypedData_v4","eth_sendTransaction","personal_sign","wallet_switchEthereumChain","wallet_addEthereumChain","wallet_getPermissions","wallet_requestPermissions","wallet_registerOnboarding","wallet_watchAsset","wallet_scanQRCode"],To=["chainChanged","accountsChanged"],uP=["chainChanged","accountsChanged","message","disconnect","connect"];var hP=Object.defineProperty,lP=Object.defineProperties,pP=Object.getOwnPropertyDescriptors,Mh=Object.getOwnPropertySymbols,dP=Object.prototype.hasOwnProperty,fP=Object.prototype.propertyIsEnumerable,Lh=(o,t,r)=>t in o?hP(o,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[t]=r,_i=(o,t)=>{for(var r in t||(t={}))dP.call(t,r)&&Lh(o,r,t[r]);if(Mh)for(var r of Mh(t))fP.call(t,r)&&Lh(o,r,t[r]);return o},kh=(o,t)=>lP(o,pP(t));function Ns(o){return Number(o[0].split(":")[1])}function vo(o){return`0x${o.toString(16)}`}function gP(o){const{chains:t,optionalChains:r,methods:s,optionalMethods:a,events:u,optionalEvents:l,rpcMap:g}=o;if(!mo(t))throw new Error("Invalid chains");const w={chains:t,methods:s||Co,events:u||To,rpcMap:_i({},t.length?{[Ns(t)]:g[Ns(t)]}:{})},b=u==null?void 0:u.filter(j=>!To.includes(j)),N=s==null?void 0:s.filter(j=>!Co.includes(j));if(!r&&!l&&!a&&!(b!=null&&b.length)&&!(N!=null&&N.length))return{required:t.length?w:void 0};const S=(b==null?void 0:b.length)&&(N==null?void 0:N.length)||!r,R={chains:[...new Set(S?w.chains.concat(r||[]):r)],methods:[...new Set(w.methods.concat(a!=null&&a.length?a:cP))],events:[...new Set(w.events.concat(l!=null&&l.length?l:uP))],rpcMap:g};return{required:t.length?w:void 0,optional:r.length?R:void 0}}class Jo{constructor(){this.events=new bt.EventEmitter,this.namespace="eip155",this.accounts=[],this.chainId=1,this.STORAGE_KEY=oP,this.on=(t,r)=>(this.events.on(t,r),this),this.once=(t,r)=>(this.events.once(t,r),this),this.removeListener=(t,r)=>(this.events.removeListener(t,r),this),this.off=(t,r)=>(this.events.off(t,r),this),this.parseAccount=t=>this.isCompatibleChainId(t)?this.parseAccountId(t).address:t,this.signer={},this.rpc={}}static async init(t){const r=new Jo;return await r.initialize(t),r}async request(t){return await this.signer.request(t,this.formatChainId(this.chainId))}sendAsync(t,r){this.signer.sendAsync(t,r,this.formatChainId(this.chainId))}get connected(){return this.signer.client?this.signer.client.core.relayer.connected:!1}get connecting(){return this.signer.client?this.signer.client.core.relayer.connecting:!1}async enable(){return this.session||await this.connect(),await this.request({method:"eth_requestAccounts"})}async connect(t){if(!this.signer.client)throw new Error("Provider not initialized. Call init() first");this.loadConnectOpts(t);const{required:r,optional:s}=gP(this.rpc);try{const a=await new Promise(async(l,g)=>{var w;this.rpc.showQrModal&&((w=this.modal)==null||w.subscribeModal(b=>{!b.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),g(new Error("Connection request reset. Please try again.")))})),await this.signer.connect(kh(_i({namespaces:_i({},r&&{[this.namespace]:r})},s&&{optionalNamespaces:{[this.namespace]:s}}),{pairingTopic:t==null?void 0:t.pairingTopic})).then(b=>{l(b)}).catch(b=>{g(new Error(b.message))})});if(!a)return;const u=Bw(a.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:u),this.setAccounts(u),this.events.emit("connect",{chainId:vo(this.chainId)})}catch(a){throw this.signer.logger.error(a),a}finally{this.modal&&this.modal.closeModal()}}async disconnect(){this.session&&await this.signer.disconnect(),this.reset()}get isWalletConnect(){return!0}get session(){return this.signer.session}registerEventListeners(){this.signer.on("session_event",t=>{const{params:r}=t,{event:s}=r;s.name==="accountsChanged"?(this.accounts=this.parseAccounts(s.data),this.events.emit("accountsChanged",this.accounts)):s.name==="chainChanged"?this.setChainId(this.formatChainId(s.data)):this.events.emit(s.name,s.data),this.events.emit("session_event",t)}),this.signer.on("chainChanged",t=>{const r=parseInt(t);this.chainId=r,this.events.emit("chainChanged",vo(this.chainId)),this.persist()}),this.signer.on("session_update",t=>{this.events.emit("session_update",t)}),this.signer.on("session_delete",t=>{this.reset(),this.events.emit("session_delete",t),this.events.emit("disconnect",kh(_i({},Qw("USER_DISCONNECTED")),{data:t.topic,name:"USER_DISCONNECTED"}))}),this.signer.on("display_uri",t=>{var r,s;this.rpc.showQrModal&&((r=this.modal)==null||r.closeModal(),(s=this.modal)==null||s.openModal({uri:t})),this.events.emit("display_uri",t)})}switchEthereumChain(t){this.request({method:"wallet_switchEthereumChain",params:[{chainId:t.toString(16)}]})}isCompatibleChainId(t){return typeof t=="string"?t.startsWith(`${this.namespace}:`):!1}formatChainId(t){return`${this.namespace}:${t}`}parseChainId(t){return Number(t.split(":")[1])}setChainIds(t){const r=t.filter(s=>this.isCompatibleChainId(s)).map(s=>this.parseChainId(s));r.length&&(this.chainId=r[0],this.events.emit("chainChanged",vo(this.chainId)),this.persist())}setChainId(t){if(this.isCompatibleChainId(t)){const r=this.parseChainId(t);this.chainId=r,this.switchEthereumChain(r)}}parseAccountId(t){const[r,s,a]=t.split(":");return{chainId:`${r}:${s}`,address:a}}setAccounts(t){this.accounts=t.filter(r=>this.parseChainId(this.parseAccountId(r).chainId)===this.chainId).map(r=>this.parseAccountId(r).address),this.events.emit("accountsChanged",this.accounts)}getRpcConfig(t){var r,s;const a=(r=t==null?void 0:t.chains)!=null?r:[],u=(s=t==null?void 0:t.optionalChains)!=null?s:[],l=a.concat(u);if(!l.length)throw new Error("No chains specified in either `chains` or `optionalChains`");const g=a.length?(t==null?void 0:t.methods)||Co:[],w=a.length?(t==null?void 0:t.events)||To:[],b=(t==null?void 0:t.optionalMethods)||[],N=(t==null?void 0:t.optionalEvents)||[],S=(t==null?void 0:t.rpcMap)||this.buildRpcMap(l,t.projectId),R=(t==null?void 0:t.qrModalOptions)||void 0;return{chains:a==null?void 0:a.map(j=>this.formatChainId(j)),optionalChains:u.map(j=>this.formatChainId(j)),methods:g,events:w,optionalMethods:b,optionalEvents:N,rpcMap:S,showQrModal:!!(t!=null&&t.showQrModal),qrModalOptions:R,projectId:t.projectId,metadata:t.metadata}}buildRpcMap(t,r){const s={};return t.forEach(a=>{s[a]=this.getRpcUrl(a,r)}),s}async initialize(t){if(this.rpc=this.getRpcConfig(t),this.chainId=this.rpc.chains.length?Ns(this.rpc.chains):Ns(this.rpc.optionalChains),this.signer=await iP.init({projectId:this.rpc.projectId,metadata:this.rpc.metadata,disableProviderPing:t.disableProviderPing,relayUrl:t.relayUrl,storageOptions:t.storageOptions}),this.registerEventListeners(),await this.loadPersistedSession(),this.rpc.showQrModal){let r;try{const{WalletConnectModal:s}=await Sw(()=>import("./index-BjxXYs1y.js").then(a=>a.i),__vite__mapDeps([0,1,2]));r=s}catch{throw new Error("To use QR modal, please install @walletconnect/modal package")}if(r)try{this.modal=new r(_i({projectId:this.rpc.projectId},this.rpc.qrModalOptions))}catch(s){throw this.signer.logger.error(s),new Error("Could not generate WalletConnectModal Instance")}}}loadConnectOpts(t){if(!t)return;const{chains:r,optionalChains:s,rpcMap:a}=t;r&&mo(r)&&(this.rpc.chains=r.map(u=>this.formatChainId(u)),r.forEach(u=>{this.rpc.rpcMap[u]=(a==null?void 0:a[u])||this.getRpcUrl(u)})),s&&mo(s)&&(this.rpc.optionalChains=[],this.rpc.optionalChains=s==null?void 0:s.map(u=>this.formatChainId(u)),s.forEach(u=>{this.rpc.rpcMap[u]=(a==null?void 0:a[u])||this.getRpcUrl(u)}))}getRpcUrl(t,r){var s;return((s=this.rpc.rpcMap)==null?void 0:s[t])||`${aP}?chainId=eip155:${t}&projectId=${r||this.rpc.projectId}`}async loadPersistedSession(){if(!this.session)return;const t=await this.signer.client.core.storage.getItem(`${this.STORAGE_KEY}/chainId`),r=this.session.namespaces[`${this.namespace}:${t}`]?this.session.namespaces[`${this.namespace}:${t}`]:this.session.namespaces[this.namespace];this.setChainIds(t?[this.formatChainId(t)]:r==null?void 0:r.accounts),this.setAccounts(r==null?void 0:r.accounts)}reset(){this.chainId=1,this.accounts=[]}persist(){this.session&&this.signer.client.core.storage.setItem(`${this.STORAGE_KEY}/chainId`,this.chainId)}parseAccounts(t){return typeof t=="string"||t instanceof String?[this.parseAccount(t)]:t.map(r=>this.parseAccount(r))}}const AP=Jo;export{AP as EthereumProvider,uP as OPTIONAL_EVENTS,cP as OPTIONAL_METHODS,To as REQUIRED_EVENTS,Co as REQUIRED_METHODS,Jo as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["main.js","main.css","assets/index-Doeqvjk3.js","assets/index-CPcZG-Ab.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{a6 as t,a7 as e,_ as o,a8 as _,a4 as n,a9 as s}from"../main.js";import{g as d}from"./signer-DxP8pZnG.js";const m={Address:t,Platform:e,getSigner:d,protocols:{WormholeCore:()=>o(()=>import("../main.js").then(a=>a.
|
|
2
|
+
import{a6 as t,a7 as e,_ as o,a8 as _,a4 as n,a9 as s}from"../main.js";import{g as d}from"./signer-DxP8pZnG.js";const m={Address:t,Platform:e,getSigner:d,protocols:{WormholeCore:()=>o(()=>import("../main.js").then(a=>a.dE),__vite__mapDeps([0,1])),TokenBridge:()=>o(()=>import("./index-Doeqvjk3.js"),__vite__mapDeps([2,0,1])),CircleBridge:()=>o(()=>import("./index-CPcZG-Ab.js"),__vite__mapDeps([3,0,1]))},getChain:(a,r,i)=>new _(r,new e(a,n(a,s,{[r]:i})))};export{m as default};
|