@wormhole-foundation/wormhole-connect 0.3.19-beta.1-development → 0.3.19-beta.3-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/{ccip-CC5KdnX-.js → ccip-B8sh0red.js} +1 -1
- package/dist/assets/cosmos-CZk6ggNU.js +37 -0
- package/dist/assets/{cosmwasm-D6dc3HhR.js → cosmwasm-BRgXJAEm.js} +3 -3
- package/dist/assets/{ens-validation.es6-JeiZhPFM.js → ens-validation.es6-CEldkK56.js} +1 -1
- package/dist/assets/{evm-scnxy1Tm.js → evm-B3YdeaCI.js} +4 -4
- package/dist/assets/{index-DcrZhJuV.js → index-1ZJmfQkw.js} +2 -2
- package/dist/assets/{index-CfFB0O_w.js → index-2haya2pd.js} +1 -1
- package/dist/assets/{index-DdlsdoUO.js → index-BSZP2fsz.js} +1 -1
- package/dist/assets/{index-CYsDCGyL.js → index-BUfxN-fw.js} +1 -1
- package/dist/assets/index-CoAwWRVw.js +3 -0
- package/dist/assets/{index-CZGBtcJ2.js → index-moDeJTxm.js} +1 -1
- package/dist/assets/{index.es-CkKy_bC0.js → index.es-CXmj0UJy.js} +2 -2
- package/dist/assets/{solana-DJERwdo1.js → solana-ClUmAbQX.js} +2 -2
- package/dist/assets/{solanaEmbed.esm-CYzxDEiX.js → solanaEmbed.esm-BpCHncZo.js} +1 -1
- package/dist/assets/{unsignedTransaction-Bbs3hbtB.js → unsignedTransaction-C5QlrOSq.js} +1 -1
- package/dist/main.js +10 -10
- package/dist/src/components/TokensModal.d.ts.map +1 -1
- package/dist/src/telemetry/types.d.ts +1 -0
- package/dist/src/telemetry/types.d.ts.map +1 -1
- package/dist/src/views/Bridge/Send.d.ts.map +1 -1
- package/lib/{algorand-BEj3eMlU.js → algorand-BDR3KPTJ.js} +1 -1
- package/lib/{algorand-Cn2ASQM8.mjs → algorand-CNPRWbNB.mjs} +4 -4
- package/lib/{aptos-B4K8HU4y.mjs → aptos-BPs26BCC.mjs} +1 -1
- package/lib/{aptos-C5usxwjg.js → aptos-Br9Q1n2N.js} +1 -1
- package/lib/{aptos-r2dqWkwd.mjs → aptos-t3uXFwih.mjs} +4 -4
- package/lib/{aptos-CgcrUUs6.js → aptos-tCZHrDAP.js} +2 -2
- package/lib/{browser-CqNEk73A.mjs → browser-33Nc32cs.mjs} +2 -2
- package/lib/{browser-9qSlzcs1.js → browser-Cz60hQ-L.js} +1 -1
- package/lib/{ccip-Cg8GiGjJ.mjs → ccip-CE49B2YD.mjs} +1 -1
- package/lib/{ccip-DiTkor0v.js → ccip-CtmuOQGX.js} +1 -1
- package/lib/{chain-BS9tnRQF.js → chain-BT07YJHt.js} +1 -1
- package/lib/{chain-CNimQoal.mjs → chain-CbwtJlkc.mjs} +1 -1
- package/lib/{cosmos-kdBLlX5J.mjs → cosmos-LlwNYP69.mjs} +6 -6
- package/lib/cosmos-t65H2NQC.js +37 -0
- package/lib/{cosmwasm-BdmGrQe2.mjs → cosmwasm-CbTKetWD.mjs} +6 -6
- package/lib/{cosmwasm-t4y0gzD9.js → cosmwasm-CiJ3I3AY.js} +2 -2
- package/lib/{create-BC4-6NQa.js → create-Chqnlpoq.js} +1 -1
- package/lib/{create-Bh45gqri.mjs → create-HNw0Emrd.mjs} +1 -1
- package/lib/{ens-validation.es6-B5lcZ1z0.js → ens-validation.es6-BaZUabxu.js} +1 -1
- package/lib/{ens-validation.es6-BBk1nSK3.mjs → ens-validation.es6-CyEOHc9J.mjs} +2 -2
- package/lib/{evm-ByfaloPB.js → evm-3AGyBI-h.js} +2 -2
- package/lib/{evm-Cplwt-Uu.js → evm-CNC7JHe1.js} +4 -4
- package/lib/{evm-CI9jvgpD.mjs → evm-CjvzIUCn.mjs} +6 -6
- package/lib/{evm-BdLUkbt8.mjs → evm-lHNM4jqm.mjs} +6 -6
- package/lib/{index-CitMOybO.js → index-0t31FGKV.js} +1 -1
- package/lib/{index-CeYAnGJU.js → index-35qsyZLz.js} +1 -1
- package/lib/{index-Bjg2w3Jp.mjs → index-B6m0ovID.mjs} +2 -2
- package/lib/{index-DuPl6mJy.mjs → index-B9L2kltl.mjs} +4 -4
- package/lib/{index-D3leTI6y.js → index-B9gw1I6s.js} +1 -1
- package/lib/{index-tFdU3m1V.js → index-BBtf8VGl.js} +1 -1
- package/lib/{index-LbkpxbxU.js → index-BCSt_UXY.js} +1 -1
- package/lib/{index-dgxqH4Al.mjs → index-BCnyHegg.mjs} +4 -4
- package/lib/{index-DHNJ7dTI.mjs → index-BH5gBrJu.mjs} +3 -3
- package/lib/{index-BTJEpkGu.mjs → index-BS1tjK_Z.mjs} +5 -5
- package/lib/{index-DKqdtMJw.mjs → index-BWsL77BI.mjs} +3 -3
- package/lib/{index-v5JYqN5T.js → index-Bfw-brA6.js} +1 -1
- package/lib/{index-JCeZURsa.mjs → index-Bk7wdRtH.mjs} +3 -3
- package/lib/index-Bp0NhDcb.js +3 -0
- package/lib/{index-D2283Eib.js → index-BpuXk_6h.js} +1 -1
- package/lib/{index-RHlQCTsY.js → index-BqGvvv6N.js} +1 -1
- package/lib/{index-_ey36AjY.mjs → index-C4kvGnSA.mjs} +2 -2
- package/lib/{index-Vqfiz4gq.js → index-CACyup9A.js} +1 -1
- package/lib/{index-DULgLsXD.mjs → index-CGLAoOXl.mjs} +4 -4
- package/lib/{index-DWqHObYQ.js → index-CO9tmWap.js} +1 -1
- package/lib/{index-DO9Aqf4O.js → index-CYap2RXm.js} +1 -1
- package/lib/{index-6SYLbVVC.mjs → index-CbCfazgA.mjs} +5 -5
- package/lib/{index-DjJSdBO_.mjs → index-CdSy2Lfd.mjs} +101 -91
- package/lib/{index-B11tXNbe.mjs → index-CjyrCdi_.mjs} +72 -72
- package/lib/{index-W5vGD3Jp.js → index-Cofatf_w.js} +1 -1
- package/lib/{index-D10P63La.mjs → index-CokIAiMa.mjs} +4 -4
- package/lib/{index-CLqwNevH.mjs → index-Cp5np38p.mjs} +1 -1
- package/lib/{index-BAfpfiMg.mjs → index-D1dHZqit.mjs} +4 -4
- package/lib/{index-CyoAaX76.js → index-DCPwTd_i.js} +1 -1
- package/lib/{index-Cms5l5e9.mjs → index-DGRaAUXo.mjs} +2 -2
- package/lib/{index-DonnLcua.mjs → index-DJzhcNDU.mjs} +6 -6
- package/lib/{index-BskUJ6-F.js → index-DPNt5r2L.js} +1 -1
- package/lib/{index-DVzNMQU2.mjs → index-DRTx-Ru8.mjs} +4 -4
- package/lib/{index-D4polzlG.mjs → index-DVH-ZIP6.mjs} +4 -4
- package/lib/{index-D05MUiKM.js → index-DVVJw5ml.js} +1 -1
- package/lib/{index-DC95G-Xg.js → index-Dbwiqljw.js} +1 -1
- package/lib/{index-DJoVr9ew.mjs → index-DfJLd65b.mjs} +4 -4
- package/lib/{index-DkHNYEwj.js → index-DrncQYMG.js} +1 -1
- package/lib/{index-ClpF6w41.mjs → index-DvUq-nIQ.mjs} +5 -5
- package/lib/{index-Cpfo_13K.js → index-Tl7zYqHL.js} +9 -9
- package/lib/{index-CZM1nqSC.js → index-UOSBfEgg.js} +1 -1
- package/lib/{index-CiNv_vqX.js → index-abvwfKBf.js} +1 -1
- package/lib/{index-Cc-SRhQH.mjs → index-dJMYtBle.mjs} +4 -4
- package/lib/{index--XOWHvs8.js → index-l_e-RUun.js} +1 -1
- package/lib/{index-L-oyxcKw.mjs → index-zKUpU-3R.mjs} +4 -4
- package/lib/{index-BdZfdhLf.js → index-ztQgUCWf.js} +1 -1
- package/lib/{index.es-D641bRIm.js → index.es-494n2GDU.js} +2 -2
- package/lib/{index.es-CE_sbvG3.mjs → index.es-DnXnnX-i.mjs} +4 -4
- package/lib/index.js +1 -1
- package/lib/index.mjs +1 -1
- package/lib/{libsodium-wrappers-DLsfT6wH.mjs → libsodium-wrappers-9p7NdjLu.mjs} +1 -1
- package/lib/{libsodium-wrappers-Dv4avoYQ.js → libsodium-wrappers-Dechaffz.js} +1 -1
- package/lib/{sei-BgefK64I.js → sei-DORxBQd-.js} +1 -1
- package/lib/{sei-DSmG2Vzd.mjs → sei-SWKTnPTF.mjs} +2 -2
- package/lib/{solana-cDD0Ny2l.js → solana-Bd9eRY8E.js} +2 -2
- package/lib/{solana--NAZIp_H.mjs → solana-DvbMa7B_.mjs} +3 -3
- package/lib/{solana-D-xykBVb.js → solana-KhBV5LOd.js} +1 -1
- package/lib/{solana-DGHdzU4Y.mjs → solana-T2pgCVfU.mjs} +6 -6
- package/lib/{solanaEmbed.esm-CvJOxxKf.mjs → solanaEmbed.esm-8eZSo5K2.mjs} +2 -2
- package/lib/{solanaEmbed.esm-SQGeqX2v.js → solanaEmbed.esm-CnKFJhsj.js} +1 -1
- package/lib/src/components/TokensModal.d.ts.map +1 -1
- package/lib/src/telemetry/types.d.ts +1 -0
- package/lib/src/telemetry/types.d.ts.map +1 -1
- package/lib/src/views/Bridge/Send.d.ts.map +1 -1
- package/lib/{sui-CitobCk-.js → sui-B382sZz0.js} +1 -1
- package/lib/{sui-CabK_MAW.mjs → sui-CjRGl9Gg.mjs} +1 -1
- package/lib/{sui-CnL17qoE.mjs → sui-DDu4a1uc.mjs} +4 -4
- package/lib/{sui-Bn1nWU88.js → sui-DwH1wYGH.js} +2 -2
- package/lib/{unsignedTransaction-Bl6mVw94.mjs → unsignedTransaction-BbAfXtog.mjs} +2 -2
- package/lib/{unsignedTransaction-wkSutsdc.js → unsignedTransaction-mu6HJcHt.js} +1 -1
- package/package.json +1 -1
- package/dist/assets/cosmos-CKUC0334.js +0 -37
- package/dist/assets/index-DTubKMVE.js +0 -3
- package/lib/cosmos-DAYdruCU.js +0 -37
- package/lib/index-DTYdWw1E.js +0 -3
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
var Hs = Object.defineProperty;
|
|
2
2
|
var Gs = (i, e, t) => e in i ? Hs(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
|
|
3
3
|
var M = (i, e, t) => (Gs(i, typeof e != "symbol" ? e + "" : e, t), t);
|
|
4
|
-
import { n as B, aH as se, aI as P, aJ as R, aK as he, aL as q, aM as re, aN as ze, aO as ge, aP as Gt, aQ as J, a2 as ne, aF as bt, aG as Sn, aR as je, aS as js, aT as Ys, aU as Js, aV as Xs, aW as Vn, c7 as wn, aX as Zs, aY as Qs, aZ as er, cf as In, cg as tr, d as F, ab as nr, o as An, $ as sr, ch as _n, a_ as rr, ce as ir, bp as Ye, ci as or, c6 as ar } from "./index-
|
|
4
|
+
import { n as B, aH as se, aI as P, aJ as R, aK as he, aL as q, aM as re, aN as ze, aO as ge, aP as Gt, aQ as J, a2 as ne, aF as bt, aG as Sn, aR as je, aS as js, aT as Ys, aU as Js, aV as Xs, aW as Vn, c7 as wn, aX as Zs, aY as Qs, aZ as er, cf as In, cg as tr, d as F, ab as nr, o as An, $ as sr, ch as _n, a_ as rr, ce as ir, bp as Ye, ci as or, c6 as ar } from "./index-CdSy2Lfd.mjs";
|
|
5
5
|
import { c as cr } from "./index-DpFNxVts.mjs";
|
|
6
|
-
import { P as He, a as yt, S as ur, b as dr, _ as lr } from "./solana-
|
|
7
|
-
import { c as hr } from "./create-
|
|
8
|
-
import { r as fr } from "./chain-
|
|
6
|
+
import { P as He, a as yt, S as ur, b as dr, _ as lr } from "./solana-T2pgCVfU.mjs";
|
|
7
|
+
import { c as hr } from "./create-HNw0Emrd.mjs";
|
|
8
|
+
import { r as fr } from "./chain-CbwtJlkc.mjs";
|
|
9
9
|
function Te(i, e) {
|
|
10
10
|
return He.findProgramAddressSync(i, new He(e))[0];
|
|
11
11
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var _=Object.defineProperty;var v=(h,e,t)=>e in h?_(h,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):h[e]=t;var c=(h,e,t)=>(v(h,typeof e!="symbol"?e+"":e,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./index-
|
|
1
|
+
"use strict";var _=Object.defineProperty;var v=(h,e,t)=>e in h?_(h,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):h[e]=t;var c=(h,e,t)=>(v(h,typeof e!="symbol"?e+"":e,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./index-DVVJw5ml.js");const i=require("./cosmwasm-CiJ3I3AY.js"),o=require("./unsignedTransaction-mu6HJcHt.js"),r=require("./index-Tl7zYqHL.js"),C=require("./chain-BT07YJHt.js");class l{constructor(e,t,s,n){c(this,"network");c(this,"chain");c(this,"rpc");c(this,"contracts");c(this,"tokenBridge");c(this,"translator");this.network=e,this.chain=t,this.rpc=s,this.contracts=n;const a=this.contracts.tokenBridge;if(!a)throw new Error(`Wormhole Token Bridge contract for domain ${t} not found`);if(this.tokenBridge=a,this.translator=this.contracts.translator,this.translator!==void 0&&this.translator==="")throw new Error("Translator address may be undefined but not empty string")}static async fromRpc(e,t){const[s,n]=await i.CosmwasmPlatform.chainFromRpc(e),a=t[n];if(a.network!==s)throw new Error(`Network mismatch: ${a.network} != ${s}`);return new l(s,n,e,t[n].contracts)}async isWrappedAsset(e){try{return await this.getOriginalAsset(e),!0}catch{}return!1}async hasWrappedAsset(e){try{return await this.getWrappedAsset(e),!0}catch{}return!1}async getWrappedAsset(e){if(e.chain===this.chain)throw new Error(`Expected foreign chain, got ${e.chain}`);if(r.isNative(e.address))throw new Error("Native asset cannot be a wrapped asset");const t=r.b64.encode(e.address.toUniversalAddress().toUint8Array()),{address:s}=await this.rpc.queryContractSmart(this.tokenBridge,{wrapped_registry:{chain:r.toChainId(e.chain),address:t}});return r.toNative(this.chain,s)}async getOriginalAsset(e){let t=new i.CosmwasmAddress(e);t.denomType==="factory"&&(t=i.Gateway.factoryToCw20(t));const s=await this.rpc.queryContractSmart(t.toString(),{wrapped_asset_info:{}}),n=r.toChain(s.asset_chain),a=r.b64.decode(s.asset_address);return{chain:n,address:new r.UniversalAddress(new Uint8Array(a))}}async isTransferCompleted(e){const t=r.b64.encode(r.serialize(e));return(await this.rpc.queryContractSmart(this.tokenBridge,{is_vaa_redeemed:{vaa:t}})).is_redeemed}async*createAttestation(e,t){if(!t)throw new Error("Payer required to create attestation");const s=new i.CosmwasmAddress(e).toString(),n=new i.CosmwasmAddress(t).toString(),a=0,w=r.isNative(e)?{native_token:{denom:i.CosmwasmPlatform.getNativeDenom(this.network,this.chain)}}:{token:{contract_addr:s}};yield this.createUnsignedTx({msgs:[o.buildExecuteMsg(n,this.tokenBridge,{create_asset_meta:{asset_info:w,nonce:a}})],fee:o.computeFee(this.network,this.chain),memo:"Wormhole - Create Attestation"},"TokenBridge.createAttestation")}async*submitAttestation(e,t){if(!t)throw new Error("Payer required to submit attestation");const s=new i.CosmwasmAddress(t).toString();yield this.createUnsignedTx({msgs:[o.buildExecuteMsg(s,this.tokenBridge,{submit_vaa:{data:r.serialize(e)}})],fee:o.computeFee(this.network,this.chain),memo:"Wormhole - Submit Attestation"},"TokenBridge.submitAttestation")}async*transfer(e,t,s,n,a){const w=Math.round(Math.random()*1e5),u="0",k=r.toChainId(t.chain),A=r.b64.encode(t.address.toUniversalAddress().toUint8Array()),T=i.CosmwasmPlatform.getNativeDenom(this.network,this.chain),f=r.isNative(s);let d=f?T:s.toString();d.startsWith("factory")&&(d=i.Gateway.factoryToCw20(new i.CosmwasmAddress(d)).toString());const g=new i.CosmwasmAddress(e).toString(),p=m=>{const y={asset:{amount:n.toString(),info:m},recipient_chain:k,recipient:A,fee:u,nonce:w};return a?{initiate_transfer_with_payload:{...y,payload:r.b64.encode(a)}}:{initiate_transfer:y}};if(f){const m=[o.buildExecuteMsg(g,this.tokenBridge,{deposit_tokens:{}},[{amount:n.toString(),denom:d}]),o.buildExecuteMsg(g,this.tokenBridge,p({native_token:{denom:d}}))];yield this.createUnsignedTx({msgs:m,fee:o.computeFee(this.network,this.chain),memo:"Wormhole - Initiate Native Transfer"},"TokenBridge.transferNative")}else{const m=[o.buildExecuteMsg(g,d,{increase_allowance:{spender:this.tokenBridge,amount:n.toString(),expires:{never:{}}}}),o.buildExecuteMsg(g,this.tokenBridge,p({token:{contract_addr:d}}),[{amount:n.toString(),denom:d}])];yield this.createUnsignedTx({msgs:m,fee:o.computeFee(this.network,this.chain),memo:"Wormhole - Initiate Transfer"},"TokenBridge.transfer")}}async*redeem(e,t,s=!0){const n=r.b64.encode(r.serialize(t)),a=new i.CosmwasmAddress(e).toString(),u=this.translator&&new i.CosmwasmAddress(this.translator).toUniversalAddress().equals(t.payload.to.address)?o.buildExecuteMsg(a,this.translator,{complete_transfer_and_convert:{vaa:n}}):o.buildExecuteMsg(a,this.tokenBridge,{submit_vaa:{data:n}});yield this.createUnsignedTx({msgs:[u],fee:o.computeFee(this.network,this.chain),memo:"Wormhole - Complete Transfer"},"TokenBridge.redeem")}async parseTransactionDetails(e){throw new Error("Not implemented")}async getWrappedNative(){return r.toNative(this.chain,i.CosmwasmPlatform.getNativeDenom(this.network,this.chain))}createUnsignedTx(e,t,s=!1){return new o.CosmwasmUnsignedTransaction(e,this.network,this.chain,t,s)}}C.registerProtocol(i._platform,"TokenBridge",l);exports.CosmwasmTokenBridge=l;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
var V = Object.defineProperty;
|
|
2
2
|
var Q = (O, s, t) => s in O ? V(O, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : O[s] = t;
|
|
3
3
|
var d = (O, s, t) => (Q(O, typeof s != "symbol" ? s + "" : s, t), t);
|
|
4
|
-
import { A as S, S as g, a as X } from "./index-
|
|
5
|
-
import { cG as Y, b5 as C, bp as $, cv as q, cH as _, cy as D, c6 as Z, aC as b, au as tt, bO as z, cz as y, cA as k, cD as W, b_ as L, az as et, bG as H, cI as st, cJ as K, cK as ot } from "./index-
|
|
6
|
-
import { a as nt, A as l, s as u, _ as rt } from "./algorand-
|
|
7
|
-
import { r as at } from "./chain-
|
|
4
|
+
import { A as S, S as g, a as X } from "./index-DVH-ZIP6.mjs";
|
|
5
|
+
import { cG as Y, b5 as C, bp as $, cv as q, cH as _, cy as D, c6 as Z, aC as b, au as tt, bO as z, cz as y, cA as k, cD as W, b_ as L, az as et, bG as H, cI as st, cJ as K, cK as ot } from "./index-CdSy2Lfd.mjs";
|
|
6
|
+
import { a as nt, A as l, s as u, _ as rt } from "./algorand-CNPRWbNB.mjs";
|
|
7
|
+
import { r as at } from "./chain-CbwtJlkc.mjs";
|
|
8
8
|
const G = Y.fromSignature("portal_transfer(byte[])byte[]"), c = class c {
|
|
9
9
|
constructor(s, t, n, o) {
|
|
10
10
|
d(this, "network");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var Ir=Object.defineProperty;var xr=(e,t,r)=>t in e?Ir(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var V=(e,t,r)=>(xr(e,typeof t!="symbol"?t+"":t,r),r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const B=require("./index-Cpfo_13K.js"),S=require("./sui-Bn1nWU88.js");require("./index-Vqfiz4gq.js");const Ar=require("./chain-BS9tnRQF.js");class _r{constructor(t,r,n,i,s=!1){V(this,"transaction");V(this,"network");V(this,"chain");V(this,"description");V(this,"parallelizable");this.transaction=t,this.network=r,this.chain=n,this.description=i,this.parallelizable=s}}class Cr extends TypeError{constructor(t,r){let n;const{message:i,explanation:s,...o}=t,{path:a}=t,c=a.length===0?i:`At path: ${a.join(".")} -- ${i}`;super(s??c),s!=null&&(this.cause=c),Object.assign(this,o),this.name=this.constructor.name,this.failures=()=>n??(n=[t,...r()])}}function Br(e){return K(e)&&typeof e[Symbol.iterator]=="function"}function K(e){return typeof e=="object"&&e!=null}function J(e){return typeof e=="symbol"?e.toString():typeof e=="string"?JSON.stringify(e):`${e}`}function $r(e){const{done:t,value:r}=e.next();return t?void 0:r}function Ur(e,t,r,n){if(e===!0)return;e===!1?e={}:typeof e=="string"&&(e={message:e});const{path:i,branch:s}=t,{type:o}=r,{refinement:a,message:c=`Expected a value of type \`${o}\`${a?` with refinement \`${a}\``:""}, but received: \`${J(n)}\``}=e;return{value:n,type:o,refinement:a,key:i[i.length-1],path:i,branch:s,...e,message:c}}function*Vt(e,t,r,n){Br(e)||(e=[e]);for(const i of e){const s=Ur(i,t,r,n);s&&(yield s)}}function*ut(e,t,r={}){const{path:n=[],branch:i=[e],coerce:s=!1,mask:o=!1}=r,a={path:n,branch:i};if(s&&(e=t.coercer(e,a),o&&t.type!=="type"&&K(t.schema)&&K(e)&&!Array.isArray(e)))for(const d in e)t.schema[d]===void 0&&delete e[d];let c="valid";for(const d of t.validator(e,a))d.explanation=r.message,c="not_valid",yield[d,void 0];for(let[d,l,g]of t.entries(e,a)){const m=ut(l,g,{path:d===void 0?n:[...n,d],branch:d===void 0?i:[...i,l],coerce:s,mask:o,message:r.message});for(const y of m)y[0]?(c=y[0].refinement!=null?"not_refined":"not_valid",yield[y[0],void 0]):s&&(l=y[1],d===void 0?e=l:e instanceof Map?e.set(d,l):e instanceof Set?e.add(l):K(e)&&(l!==void 0||d in e)&&(e[d]=l))}if(c!=="not_valid")for(const d of t.refiner(e,a))d.explanation=r.message,c="not_refined",yield[d,void 0];c==="valid"&&(yield[void 0,e])}class te{constructor(t){const{type:r,schema:n,validator:i,refiner:s,coercer:o=c=>c,entries:a=function*(){}}=t;this.type=r,this.schema=n,this.entries=a,this.coercer=o,i?this.validator=(c,d)=>{const l=i(c,d);return Vt(l,d,this,c)}:this.validator=()=>[],s?this.refiner=(c,d)=>{const l=s(c,d);return Vt(l,d,this,c)}:this.refiner=()=>[]}assert(t,r){return tt(t,this,r)}create(t,r){return Kt(t,this,r)}is(t){return L(t,this)}mask(t,r){return Jt(t,this,r)}validate(t,r={}){return Ie(t,this,r)}}function tt(e,t,r){const n=Ie(e,t,{message:r});if(n[0])throw n[0]}function Kt(e,t,r){const n=Ie(e,t,{coerce:!0,message:r});if(n[0])throw n[0];return n[1]}function Jt(e,t,r){const n=Ie(e,t,{coerce:!0,mask:!0,message:r});if(n[0])throw n[0];return n[1]}function L(e,t){return!Ie(e,t)[0]}function Ie(e,t,r={}){const n=ut(e,t,r),i=$r(n);return i[0]?[new Cr(i[0],function*(){for(const o of n)o[0]&&(yield o[0])}),void 0]:[void 0,i[1]]}function je(...e){const t=e[0].type==="type",r=e.map(i=>i.schema),n=Object.assign({},...r);return t?Rr(n):p(n)}function W(e,t){return new te({type:e,schema:null,validator:t})}function rt(){return W("any",()=>!0)}function E(e){return new te({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: ${J(t)}`}})}function Mr(){return W("bigint",e=>typeof e=="bigint")}function z(){return W("boolean",e=>typeof e=="boolean")}function ee(){return W("integer",e=>typeof e=="number"&&!isNaN(e)&&Number.isInteger(e)||`Expected an integer, but received: ${J(e)}`)}function v(e){const t=J(e),r=typeof e;return new te({type:"literal",schema:r==="string"||r==="number"||r==="boolean"?e:null,validator(n){return n===e||`Expected the literal \`${t}\`, but received: ${J(n)}`}})}function qt(){return W("never",()=>!1)}function $(e){return new te({...e,validator:(t,r)=>t===null||e.validator(t,r),refiner:(t,r)=>t===null||e.refiner(t,r)})}function le(){return W("number",e=>typeof e=="number"&&!isNaN(e)||`Expected a number, but received: ${J(e)}`)}function p(e){const t=e?Object.keys(e):[],r=qt();return new te({type:"object",schema:e||null,*entries(n){if(e&&K(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 K(n)||`Expected an object, but received: ${J(n)}`},coercer(n){return K(n)?{...n}:n}})}function T(e){return new te({...e,validator:(t,r)=>t===void 0||e.validator(t,r),refiner:(t,r)=>t===void 0||e.refiner(t,r)})}function Q(e,t){return new te({type:"record",schema:null,*entries(r){if(K(r))for(const n in r){const i=r[n];yield[n,n,e],yield[n,i,t]}},validator(r){return K(r)||`Expected an object, but received: ${J(r)}`}})}function h(){return W("string",e=>typeof e=="string"||`Expected a string, but received: ${J(e)}`)}function Ht(e){const t=qt();return new te({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: ${J(r)}`}})}function Rr(e){const t=Object.keys(e);return new te({type:"type",schema:e,*entries(r){if(K(r))for(const n of t)yield[n,r[n],e[n]]},validator(r){return K(r)||`Expected an object, but received: ${J(r)}`},coercer(r){return K(r)?{...r}:r}})}function U(e){const t=e.map(r=>r.type).join(" | ");return new te({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[...o]=ut(r,s,n),[a]=o;if(a[0])for(const[c]of o)c&&i.push(c);else return[]}return[`Expected the value to satisfy a union of \`${t}\`, but received: ${J(r)}`,...i]}})}function Xt(){return W("unknown",()=>!0)}const dt=U([p({AddressOwner:h()}),p({ObjectOwner:h()}),p({Shared:p({initial_shared_version:$(h())})}),v("Immutable")]);W("SuiJsonValue",()=>!0);const Pr=U([p({u32:h()}),p({u64:h()}),p({f64:h()})]);p({attributes:Q(h(),$(Pr)),featureFlags:Q(h(),z()),maxSupportedProtocolVersion:h(),minSupportedProtocolVersion:h(),protocolVersion:h()});U([h(),v("package")]);const oe=p({digest:h(),objectId:h(),version:U([le(),h(),Mr()])});p({owner:dt,reference:oe});p({objectId:h(),sequenceNumber:h()});p({payment:E(oe),owner:h(),price:h(),budget:h()});const Nr=je(oe,p({type:h(),owner:dt,previousTransaction:h()})),Dr=Q(h(),rt()),zr=Q(h(),Xt()),Vr=p({type:h(),fields:Dr,hasPublicTransfer:z()}),Fr=p({disassembled:zr}),Gr=U([je(Vr,p({dataType:v("moveObject")})),je(Fr,p({dataType:v("package")}))]),Lr=p({type:h(),hasPublicTransfer:z(),version:h(),bcsBytes:h()}),Wr=p({id:h(),moduleMap:Q(h(),h())}),Kr=U([je(Lr,p({dataType:v("moveObject")})),je(Wr,p({dataType:v("package")}))]);BigInt(1e9);const Zt=p({code:h(),error:T(h()),object_id:T(h()),parent_object_id:T(h()),version:T(h()),digest:T(h())}),Jr=p({data:$(T(Q(h(),h()))),error:$(T(Zt))}),qr=U([Jr,T(Q(h(),h()))]),Yt=p({objectId:h(),version:h(),digest:h(),type:$(T(h())),content:$(T(Gr)),bcs:$(T(Kr)),owner:$(T(dt)),previousTransaction:$(T(h())),storageRebate:$(T(h())),display:$(T(qr))});p({showType:$(T(z())),showContent:$(T(z())),showBcs:$(T(z())),showOwner:$(T(z())),showPreviousTransaction:$(T(z())),showStorageRebate:$(T(z())),showDisplay:$(T(z()))});U([v("Exists"),v("notExists"),v("Deleted")]);E(Nr);const Hr=p({data:$(T(Yt)),error:$(T(Zt))});function Xr(e){return e.data}function Zr(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 Ft(e){if("reference"in e)return e.reference;const t=Xr(e);return t?{objectId:t.objectId,version:t.version,digest:t.digest}:Zr(e)}p({objectId:h(),atCheckpoint:T(le())});p({data:E(Hr),nextCursor:T($(h())),hasNextPage:z()});U([p({details:Yt,status:v("VersionFound")}),p({details:h(),status:v("ObjectNotExists")}),p({details:oe,status:v("ObjectDeleted")}),p({details:Ht([h(),le()]),status:v("VersionNotFound")}),p({details:p({asked_version:le(),latest_version:le(),object_id:h()}),status:v("VersionTooHigh")})]);const Yr=U([h(),p({Object:h()})]);E(Yr);const Qr=p({address:h(),name:h()}),en=U([v("Private"),v("Public"),v("Friend")]),lt=p({abilities:E(h())}),tn=p({constraints:lt,isPhantom:z()}),rn=p({TypeParameter:le()}),qe=Ht([p({module:h(),package:h(),function:h()}),h()]);p({rank3Days:E(qe),rank7Days:E(qe),rank30Days:E(qe)});function Qt(e){if(!e)return!1;if(typeof e=="string"||L(e,rn)||er(e))return!0;if(typeof e!="object")return!1;const t=e;return!!(L(t.Reference,pe)||L(t.MutableReference,pe)||L(t.Vector,pe))}const pe=W("SuiMoveNormalizedType",Qt);function er(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=>Qt(n)))}W("SuiMoveNormalizedStructType",er);const nn=p({visibility:en,isEntry:z(),typeParameters:E(lt),parameters:E(pe),return:E(pe)}),sn=p({name:h(),type:pe}),an=p({abilities:lt,typeParameters:E(tn),fields:E(sn)}),on=p({fileFormatVersion:le(),address:h(),name:h(),friends:E(Qr),structs:Q(h(),an),exposedFunctions:Q(h(),nn)});Q(h(),on);function nt(e){return typeof e=="object"&&"MutableReference"in e?e.MutableReference:void 0}function tr(e){return typeof e=="object"&&"Reference"in e?e.Reference:void 0}function ft(e){if(typeof e=="object"&&"Struct"in e)return e;const t=tr(e),r=nt(e);if(typeof t=="object"&&"Struct"in t)return t;if(typeof r=="object"&&"Struct"in r)return r}function cn(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 o=e.length,a=e.charAt(0),c=Math.log(o)/Math.log(256),d=Math.log(256)/Math.log(o);function l(y){if(y instanceof Uint8Array||(ArrayBuffer.isView(y)?y=new Uint8Array(y.buffer,y.byteOffset,y.byteLength):Array.isArray(y)&&(y=Uint8Array.from(y))),!(y instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(y.length===0)return"";for(var w=0,b=0,f=0,x=y.length;f!==x&&y[f]===0;)f++,w++;for(var C=(x-f)*d+1>>>0,P=new Uint8Array(C);f!==x;){for(var A=y[f],k=0,N=C-1;(A!==0||k<b)&&N!==-1;N--,k++)A+=256*P[N]>>>0,P[N]=A%o>>>0,A=A/o>>>0;if(A!==0)throw new Error("Non-zero carry");b=k,f++}for(var q=C-b;q!==C&&P[q]===0;)q++;for(var he=a.repeat(w);q<C;++q)he+=e.charAt(P[q]);return he}function g(y){if(typeof y!="string")throw new TypeError("Expected String");if(y.length===0)return new Uint8Array;for(var w=0,b=0,f=0;y[w]===a;)b++,w++;for(var x=(y.length-w)*c+1>>>0,C=new Uint8Array(x);y[w];){var P=t[y.charCodeAt(w)];if(P===255)return;for(var A=0,k=x-1;(P!==0||A<f)&&k!==-1;k--,A++)P+=o*C[k]>>>0,C[k]=P%256>>>0,P=P/256>>>0;if(P!==0)throw new Error("Non-zero carry");f=A,w++}for(var N=x-f;N!==x&&C[N]===0;)N++;for(var q=new Uint8Array(b+(x-N)),he=b;N!==x;)q[he++]=C[N++];return q}function m(y){var w=g(y);if(w)return w;throw new Error("Non-base"+o+" character")}return{encode:l,decodeUnsafe:g,decode:m}}var un=cn;const dn=un,ln="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";var fn=dn(ln);const rr=B.getDefaultExportFromCjs(fn),xe=e=>rr.encode(e),ht=e=>rr.decode(e);function ce(e){return Uint8Array.from(atob(e),t=>t.charCodeAt(0))}const He=8192;function Ae(e){if(e.length<He)return btoa(String.fromCharCode(...e));let t="";for(var r=0;r<e.length;r+=He){const n=e.slice(r,r+He);t+=String.fromCharCode(...n)}return btoa(t)}function Ke(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 _e(e){return e.reduce((t,r)=>t+r.toString(16).padStart(2,"0"),"")}function gt(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 hn(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 nr{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}=hn(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 gn(e,t){switch(t){case"base58":return xe(e);case"base64":return Ae(e);case"hex":return _e(e);default:throw new Error("Unsupported encoding, supported values are: base64, hex")}}function pn(e,t){switch(t){case"base58":return ht(e);case"base64":return ce(e);case"hex":return Ke(e);default:throw new Error("Unsupported encoding, supported values are: base64, hex")}}function ir(e,t=["<",">"]){const[r,n]=t,i=[];let s="",o=0;for(let a=0;a<e.length;a++){const c=e[a];if(c===r&&o++,c===n&&o--,o===0&&c===","){i.push(s.trim()),s="";continue}s+=c}return i.push(s.trim()),i}class sr{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 Xe(BigInt(t),8).forEach(r=>this.write8(r)),this}write128(t){return Xe(BigInt(t),16).forEach(r=>this.write8(r)),this}write256(t){return Xe(BigInt(t),32).forEach(r=>this.write8(r)),this}writeULEB(t){return gt(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 gn(this.toBytes(),t)}}function Xe(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 ar=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},X=(e,t,r)=>(ar(e,t,"read from private field"),r?r.call(e):t.get(e)),ze=(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)},Ve=(e,t,r,n)=>(ar(e,t,"write to private field"),t.set(e,r),r),ge,be,Me,ae;const or=class{constructor(e){ze(this,ge,void 0),ze(this,be,void 0),this.name=e.name,this.read=e.read,this.serializedSize=e.serializedSize??(()=>null),Ve(this,ge,e.write),Ve(this,be,e.serialize??((t,r)=>{const n=new sr({size:this.serializedSize(t)??void 0,...r});return X(this,ge).call(this,t,n),n.toBytes()})),this.validate=e.validate??(()=>{})}write(e,t){this.validate(e),X(this,ge).call(this,e,t)}serialize(e,t){return this.validate(e),new yn(this,X(this,be).call(this,e,t))}parse(e){const t=new nr(e);return this.read(t)}transform({name:e,input:t,output:r}){return new or({name:e??this.name,read:n=>r(this.read(n)),write:(n,i)=>X(this,ge).call(this,t(n),i),serializedSize:n=>this.serializedSize(t(n)),serialize:(n,i)=>X(this,be).call(this,t(n),i),validate:n=>this.validate(t(n))})}};let Z=or;ge=new WeakMap;be=new WeakMap;const cr=Symbol.for("@mysten/serialized-bcs");function pt(e){return!!e&&typeof e=="object"&&e[cr]===!0}class yn{constructor(t,r){ze(this,Me,void 0),ze(this,ae,void 0),Ve(this,Me,t),Ve(this,ae,r)}get[cr](){return!0}toBytes(){return X(this,ae)}toHex(){return _e(X(this,ae))}toBase64(){return Ae(X(this,ae))}toBase58(){return xe(X(this,ae))}parse(){return X(this,Me).parse(X(this,ae))}}Me=new WeakMap;ae=new WeakMap;function Fe({size:e,...t}){return new Z({...t,serializedSize:()=>e})}function Ze({readMethod:e,writeMethod:t,...r}){return Fe({...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 Ye({readMethod:e,writeMethod:t,...r}){return Fe({...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 mn({serialize:e,...t}){const r=new Z({...t,serialize:e,write:(n,i)=>{for(const s of r.serialize(n).toBytes())i.write8(s)}});return r}function wn({toBytes:e,fromBytes:t,...r}){return new Z({...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 o=0;o<s.length;o++)i.write8(s[o])},serialize:n=>{const i=e(n),s=gt(i.length),o=new Uint8Array(s.length+i.length);return o.set(s,0),o.set(i,s.length),o},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 bn(e){let t=null;function r(){return t||(t=e()),t}return new Z({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 u={u8(e){return Ze({name:"u8",readMethod:"read8",writeMethod:"write8",size:1,maxValue:2**8-1,...e})},u16(e){return Ze({name:"u16",readMethod:"read16",writeMethod:"write16",size:2,maxValue:2**16-1,...e})},u32(e){return Ze({name:"u32",readMethod:"read32",writeMethod:"write32",size:4,maxValue:2**32-1,...e})},u64(e){return Ye({name:"u64",readMethod:"read64",writeMethod:"write64",size:8,maxValue:2n**64n-1n,...e})},u128(e){return Ye({name:"u128",readMethod:"read128",writeMethod:"write128",size:16,maxValue:2n**128n-1n,...e})},u256(e){return Ye({name:"u256",readMethod:"read256",writeMethod:"write256",size:32,maxValue:2n**256n-1n,...e})},bool(e){return Fe({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 mn({name:"uleb128",read:t=>t.readULEB(),serialize:t=>Uint8Array.from(gt(t)),...e})},bytes(e,t){return Fe({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 wn({name:"string",toBytes:t=>new TextEncoder().encode(t),fromBytes:t=>new TextDecoder().decode(t),...e})},fixedArray(e,t,r){return new Z({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 u.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 Z({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 Z({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 Z({name:e,serializedSize:i=>{let s=0;for(const[o,a]of n){const c=a.serializedSize(i[o]);if(c==null)return null;s+=c}return s},read:i=>{const s={};for(const[o,a]of n)s[o]=a.read(i);return s},write:(i,s)=>{for(const[o,a]of n)a.write(i[o],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 Z({name:e,read:i=>{const s=i.readULEB(),[o,a]=n[s];return{[o]:(a==null?void 0:a.read(i))??!0}},write:(i,s)=>{const[o,a]=Object.entries(i)[0];for(let c=0;c<n.length;c++){const[d,l]=n[c];if(d===o){s.writeULEB(c),l==null||l.write(a,s);return}}},...r,validate:i=>{var a;if((a=r==null?void 0:r.validate)==null||a.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[o]=s;if(!Object.hasOwn(t,o))throw new TypeError(`Invalid enum variant ${o}`)}})},map(e,t){return u.vector(u.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 bn(e)}},Sn=32,Se=class{constructor(e){if(this.types=new Map,this.counter=0,e instanceof Se){this.schema=e.schema,this.types=new Map(e.types);return}if(this.schema=e,this.registerAddressType(Se.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&&Tn(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 Se(this).registerStructType(n,e).ser(n,t,r)}throw new Error(`Incorrect type passed into the '.ser()' function.
|
|
1
|
+
"use strict";var Ir=Object.defineProperty;var xr=(e,t,r)=>t in e?Ir(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var V=(e,t,r)=>(xr(e,typeof t!="symbol"?t+"":t,r),r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const B=require("./index-Tl7zYqHL.js"),S=require("./sui-DwH1wYGH.js");require("./index-CACyup9A.js");const Ar=require("./chain-BT07YJHt.js");class _r{constructor(t,r,n,i,s=!1){V(this,"transaction");V(this,"network");V(this,"chain");V(this,"description");V(this,"parallelizable");this.transaction=t,this.network=r,this.chain=n,this.description=i,this.parallelizable=s}}class Cr extends TypeError{constructor(t,r){let n;const{message:i,explanation:s,...o}=t,{path:a}=t,c=a.length===0?i:`At path: ${a.join(".")} -- ${i}`;super(s??c),s!=null&&(this.cause=c),Object.assign(this,o),this.name=this.constructor.name,this.failures=()=>n??(n=[t,...r()])}}function Br(e){return K(e)&&typeof e[Symbol.iterator]=="function"}function K(e){return typeof e=="object"&&e!=null}function J(e){return typeof e=="symbol"?e.toString():typeof e=="string"?JSON.stringify(e):`${e}`}function $r(e){const{done:t,value:r}=e.next();return t?void 0:r}function Ur(e,t,r,n){if(e===!0)return;e===!1?e={}:typeof e=="string"&&(e={message:e});const{path:i,branch:s}=t,{type:o}=r,{refinement:a,message:c=`Expected a value of type \`${o}\`${a?` with refinement \`${a}\``:""}, but received: \`${J(n)}\``}=e;return{value:n,type:o,refinement:a,key:i[i.length-1],path:i,branch:s,...e,message:c}}function*Vt(e,t,r,n){Br(e)||(e=[e]);for(const i of e){const s=Ur(i,t,r,n);s&&(yield s)}}function*ut(e,t,r={}){const{path:n=[],branch:i=[e],coerce:s=!1,mask:o=!1}=r,a={path:n,branch:i};if(s&&(e=t.coercer(e,a),o&&t.type!=="type"&&K(t.schema)&&K(e)&&!Array.isArray(e)))for(const d in e)t.schema[d]===void 0&&delete e[d];let c="valid";for(const d of t.validator(e,a))d.explanation=r.message,c="not_valid",yield[d,void 0];for(let[d,l,g]of t.entries(e,a)){const m=ut(l,g,{path:d===void 0?n:[...n,d],branch:d===void 0?i:[...i,l],coerce:s,mask:o,message:r.message});for(const y of m)y[0]?(c=y[0].refinement!=null?"not_refined":"not_valid",yield[y[0],void 0]):s&&(l=y[1],d===void 0?e=l:e instanceof Map?e.set(d,l):e instanceof Set?e.add(l):K(e)&&(l!==void 0||d in e)&&(e[d]=l))}if(c!=="not_valid")for(const d of t.refiner(e,a))d.explanation=r.message,c="not_refined",yield[d,void 0];c==="valid"&&(yield[void 0,e])}class te{constructor(t){const{type:r,schema:n,validator:i,refiner:s,coercer:o=c=>c,entries:a=function*(){}}=t;this.type=r,this.schema=n,this.entries=a,this.coercer=o,i?this.validator=(c,d)=>{const l=i(c,d);return Vt(l,d,this,c)}:this.validator=()=>[],s?this.refiner=(c,d)=>{const l=s(c,d);return Vt(l,d,this,c)}:this.refiner=()=>[]}assert(t,r){return tt(t,this,r)}create(t,r){return Kt(t,this,r)}is(t){return L(t,this)}mask(t,r){return Jt(t,this,r)}validate(t,r={}){return Ie(t,this,r)}}function tt(e,t,r){const n=Ie(e,t,{message:r});if(n[0])throw n[0]}function Kt(e,t,r){const n=Ie(e,t,{coerce:!0,message:r});if(n[0])throw n[0];return n[1]}function Jt(e,t,r){const n=Ie(e,t,{coerce:!0,mask:!0,message:r});if(n[0])throw n[0];return n[1]}function L(e,t){return!Ie(e,t)[0]}function Ie(e,t,r={}){const n=ut(e,t,r),i=$r(n);return i[0]?[new Cr(i[0],function*(){for(const o of n)o[0]&&(yield o[0])}),void 0]:[void 0,i[1]]}function je(...e){const t=e[0].type==="type",r=e.map(i=>i.schema),n=Object.assign({},...r);return t?Rr(n):p(n)}function W(e,t){return new te({type:e,schema:null,validator:t})}function rt(){return W("any",()=>!0)}function E(e){return new te({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: ${J(t)}`}})}function Mr(){return W("bigint",e=>typeof e=="bigint")}function z(){return W("boolean",e=>typeof e=="boolean")}function ee(){return W("integer",e=>typeof e=="number"&&!isNaN(e)&&Number.isInteger(e)||`Expected an integer, but received: ${J(e)}`)}function v(e){const t=J(e),r=typeof e;return new te({type:"literal",schema:r==="string"||r==="number"||r==="boolean"?e:null,validator(n){return n===e||`Expected the literal \`${t}\`, but received: ${J(n)}`}})}function qt(){return W("never",()=>!1)}function $(e){return new te({...e,validator:(t,r)=>t===null||e.validator(t,r),refiner:(t,r)=>t===null||e.refiner(t,r)})}function le(){return W("number",e=>typeof e=="number"&&!isNaN(e)||`Expected a number, but received: ${J(e)}`)}function p(e){const t=e?Object.keys(e):[],r=qt();return new te({type:"object",schema:e||null,*entries(n){if(e&&K(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 K(n)||`Expected an object, but received: ${J(n)}`},coercer(n){return K(n)?{...n}:n}})}function T(e){return new te({...e,validator:(t,r)=>t===void 0||e.validator(t,r),refiner:(t,r)=>t===void 0||e.refiner(t,r)})}function Q(e,t){return new te({type:"record",schema:null,*entries(r){if(K(r))for(const n in r){const i=r[n];yield[n,n,e],yield[n,i,t]}},validator(r){return K(r)||`Expected an object, but received: ${J(r)}`}})}function h(){return W("string",e=>typeof e=="string"||`Expected a string, but received: ${J(e)}`)}function Ht(e){const t=qt();return new te({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: ${J(r)}`}})}function Rr(e){const t=Object.keys(e);return new te({type:"type",schema:e,*entries(r){if(K(r))for(const n of t)yield[n,r[n],e[n]]},validator(r){return K(r)||`Expected an object, but received: ${J(r)}`},coercer(r){return K(r)?{...r}:r}})}function U(e){const t=e.map(r=>r.type).join(" | ");return new te({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[...o]=ut(r,s,n),[a]=o;if(a[0])for(const[c]of o)c&&i.push(c);else return[]}return[`Expected the value to satisfy a union of \`${t}\`, but received: ${J(r)}`,...i]}})}function Xt(){return W("unknown",()=>!0)}const dt=U([p({AddressOwner:h()}),p({ObjectOwner:h()}),p({Shared:p({initial_shared_version:$(h())})}),v("Immutable")]);W("SuiJsonValue",()=>!0);const Pr=U([p({u32:h()}),p({u64:h()}),p({f64:h()})]);p({attributes:Q(h(),$(Pr)),featureFlags:Q(h(),z()),maxSupportedProtocolVersion:h(),minSupportedProtocolVersion:h(),protocolVersion:h()});U([h(),v("package")]);const oe=p({digest:h(),objectId:h(),version:U([le(),h(),Mr()])});p({owner:dt,reference:oe});p({objectId:h(),sequenceNumber:h()});p({payment:E(oe),owner:h(),price:h(),budget:h()});const Nr=je(oe,p({type:h(),owner:dt,previousTransaction:h()})),Dr=Q(h(),rt()),zr=Q(h(),Xt()),Vr=p({type:h(),fields:Dr,hasPublicTransfer:z()}),Fr=p({disassembled:zr}),Gr=U([je(Vr,p({dataType:v("moveObject")})),je(Fr,p({dataType:v("package")}))]),Lr=p({type:h(),hasPublicTransfer:z(),version:h(),bcsBytes:h()}),Wr=p({id:h(),moduleMap:Q(h(),h())}),Kr=U([je(Lr,p({dataType:v("moveObject")})),je(Wr,p({dataType:v("package")}))]);BigInt(1e9);const Zt=p({code:h(),error:T(h()),object_id:T(h()),parent_object_id:T(h()),version:T(h()),digest:T(h())}),Jr=p({data:$(T(Q(h(),h()))),error:$(T(Zt))}),qr=U([Jr,T(Q(h(),h()))]),Yt=p({objectId:h(),version:h(),digest:h(),type:$(T(h())),content:$(T(Gr)),bcs:$(T(Kr)),owner:$(T(dt)),previousTransaction:$(T(h())),storageRebate:$(T(h())),display:$(T(qr))});p({showType:$(T(z())),showContent:$(T(z())),showBcs:$(T(z())),showOwner:$(T(z())),showPreviousTransaction:$(T(z())),showStorageRebate:$(T(z())),showDisplay:$(T(z()))});U([v("Exists"),v("notExists"),v("Deleted")]);E(Nr);const Hr=p({data:$(T(Yt)),error:$(T(Zt))});function Xr(e){return e.data}function Zr(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 Ft(e){if("reference"in e)return e.reference;const t=Xr(e);return t?{objectId:t.objectId,version:t.version,digest:t.digest}:Zr(e)}p({objectId:h(),atCheckpoint:T(le())});p({data:E(Hr),nextCursor:T($(h())),hasNextPage:z()});U([p({details:Yt,status:v("VersionFound")}),p({details:h(),status:v("ObjectNotExists")}),p({details:oe,status:v("ObjectDeleted")}),p({details:Ht([h(),le()]),status:v("VersionNotFound")}),p({details:p({asked_version:le(),latest_version:le(),object_id:h()}),status:v("VersionTooHigh")})]);const Yr=U([h(),p({Object:h()})]);E(Yr);const Qr=p({address:h(),name:h()}),en=U([v("Private"),v("Public"),v("Friend")]),lt=p({abilities:E(h())}),tn=p({constraints:lt,isPhantom:z()}),rn=p({TypeParameter:le()}),qe=Ht([p({module:h(),package:h(),function:h()}),h()]);p({rank3Days:E(qe),rank7Days:E(qe),rank30Days:E(qe)});function Qt(e){if(!e)return!1;if(typeof e=="string"||L(e,rn)||er(e))return!0;if(typeof e!="object")return!1;const t=e;return!!(L(t.Reference,pe)||L(t.MutableReference,pe)||L(t.Vector,pe))}const pe=W("SuiMoveNormalizedType",Qt);function er(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=>Qt(n)))}W("SuiMoveNormalizedStructType",er);const nn=p({visibility:en,isEntry:z(),typeParameters:E(lt),parameters:E(pe),return:E(pe)}),sn=p({name:h(),type:pe}),an=p({abilities:lt,typeParameters:E(tn),fields:E(sn)}),on=p({fileFormatVersion:le(),address:h(),name:h(),friends:E(Qr),structs:Q(h(),an),exposedFunctions:Q(h(),nn)});Q(h(),on);function nt(e){return typeof e=="object"&&"MutableReference"in e?e.MutableReference:void 0}function tr(e){return typeof e=="object"&&"Reference"in e?e.Reference:void 0}function ft(e){if(typeof e=="object"&&"Struct"in e)return e;const t=tr(e),r=nt(e);if(typeof t=="object"&&"Struct"in t)return t;if(typeof r=="object"&&"Struct"in r)return r}function cn(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 o=e.length,a=e.charAt(0),c=Math.log(o)/Math.log(256),d=Math.log(256)/Math.log(o);function l(y){if(y instanceof Uint8Array||(ArrayBuffer.isView(y)?y=new Uint8Array(y.buffer,y.byteOffset,y.byteLength):Array.isArray(y)&&(y=Uint8Array.from(y))),!(y instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(y.length===0)return"";for(var w=0,b=0,f=0,x=y.length;f!==x&&y[f]===0;)f++,w++;for(var C=(x-f)*d+1>>>0,P=new Uint8Array(C);f!==x;){for(var A=y[f],k=0,N=C-1;(A!==0||k<b)&&N!==-1;N--,k++)A+=256*P[N]>>>0,P[N]=A%o>>>0,A=A/o>>>0;if(A!==0)throw new Error("Non-zero carry");b=k,f++}for(var q=C-b;q!==C&&P[q]===0;)q++;for(var he=a.repeat(w);q<C;++q)he+=e.charAt(P[q]);return he}function g(y){if(typeof y!="string")throw new TypeError("Expected String");if(y.length===0)return new Uint8Array;for(var w=0,b=0,f=0;y[w]===a;)b++,w++;for(var x=(y.length-w)*c+1>>>0,C=new Uint8Array(x);y[w];){var P=t[y.charCodeAt(w)];if(P===255)return;for(var A=0,k=x-1;(P!==0||A<f)&&k!==-1;k--,A++)P+=o*C[k]>>>0,C[k]=P%256>>>0,P=P/256>>>0;if(P!==0)throw new Error("Non-zero carry");f=A,w++}for(var N=x-f;N!==x&&C[N]===0;)N++;for(var q=new Uint8Array(b+(x-N)),he=b;N!==x;)q[he++]=C[N++];return q}function m(y){var w=g(y);if(w)return w;throw new Error("Non-base"+o+" character")}return{encode:l,decodeUnsafe:g,decode:m}}var un=cn;const dn=un,ln="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";var fn=dn(ln);const rr=B.getDefaultExportFromCjs(fn),xe=e=>rr.encode(e),ht=e=>rr.decode(e);function ce(e){return Uint8Array.from(atob(e),t=>t.charCodeAt(0))}const He=8192;function Ae(e){if(e.length<He)return btoa(String.fromCharCode(...e));let t="";for(var r=0;r<e.length;r+=He){const n=e.slice(r,r+He);t+=String.fromCharCode(...n)}return btoa(t)}function Ke(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 _e(e){return e.reduce((t,r)=>t+r.toString(16).padStart(2,"0"),"")}function gt(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 hn(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 nr{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}=hn(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 gn(e,t){switch(t){case"base58":return xe(e);case"base64":return Ae(e);case"hex":return _e(e);default:throw new Error("Unsupported encoding, supported values are: base64, hex")}}function pn(e,t){switch(t){case"base58":return ht(e);case"base64":return ce(e);case"hex":return Ke(e);default:throw new Error("Unsupported encoding, supported values are: base64, hex")}}function ir(e,t=["<",">"]){const[r,n]=t,i=[];let s="",o=0;for(let a=0;a<e.length;a++){const c=e[a];if(c===r&&o++,c===n&&o--,o===0&&c===","){i.push(s.trim()),s="";continue}s+=c}return i.push(s.trim()),i}class sr{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 Xe(BigInt(t),8).forEach(r=>this.write8(r)),this}write128(t){return Xe(BigInt(t),16).forEach(r=>this.write8(r)),this}write256(t){return Xe(BigInt(t),32).forEach(r=>this.write8(r)),this}writeULEB(t){return gt(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 gn(this.toBytes(),t)}}function Xe(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 ar=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},X=(e,t,r)=>(ar(e,t,"read from private field"),r?r.call(e):t.get(e)),ze=(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)},Ve=(e,t,r,n)=>(ar(e,t,"write to private field"),t.set(e,r),r),ge,be,Me,ae;const or=class{constructor(e){ze(this,ge,void 0),ze(this,be,void 0),this.name=e.name,this.read=e.read,this.serializedSize=e.serializedSize??(()=>null),Ve(this,ge,e.write),Ve(this,be,e.serialize??((t,r)=>{const n=new sr({size:this.serializedSize(t)??void 0,...r});return X(this,ge).call(this,t,n),n.toBytes()})),this.validate=e.validate??(()=>{})}write(e,t){this.validate(e),X(this,ge).call(this,e,t)}serialize(e,t){return this.validate(e),new yn(this,X(this,be).call(this,e,t))}parse(e){const t=new nr(e);return this.read(t)}transform({name:e,input:t,output:r}){return new or({name:e??this.name,read:n=>r(this.read(n)),write:(n,i)=>X(this,ge).call(this,t(n),i),serializedSize:n=>this.serializedSize(t(n)),serialize:(n,i)=>X(this,be).call(this,t(n),i),validate:n=>this.validate(t(n))})}};let Z=or;ge=new WeakMap;be=new WeakMap;const cr=Symbol.for("@mysten/serialized-bcs");function pt(e){return!!e&&typeof e=="object"&&e[cr]===!0}class yn{constructor(t,r){ze(this,Me,void 0),ze(this,ae,void 0),Ve(this,Me,t),Ve(this,ae,r)}get[cr](){return!0}toBytes(){return X(this,ae)}toHex(){return _e(X(this,ae))}toBase64(){return Ae(X(this,ae))}toBase58(){return xe(X(this,ae))}parse(){return X(this,Me).parse(X(this,ae))}}Me=new WeakMap;ae=new WeakMap;function Fe({size:e,...t}){return new Z({...t,serializedSize:()=>e})}function Ze({readMethod:e,writeMethod:t,...r}){return Fe({...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 Ye({readMethod:e,writeMethod:t,...r}){return Fe({...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 mn({serialize:e,...t}){const r=new Z({...t,serialize:e,write:(n,i)=>{for(const s of r.serialize(n).toBytes())i.write8(s)}});return r}function wn({toBytes:e,fromBytes:t,...r}){return new Z({...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 o=0;o<s.length;o++)i.write8(s[o])},serialize:n=>{const i=e(n),s=gt(i.length),o=new Uint8Array(s.length+i.length);return o.set(s,0),o.set(i,s.length),o},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 bn(e){let t=null;function r(){return t||(t=e()),t}return new Z({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 u={u8(e){return Ze({name:"u8",readMethod:"read8",writeMethod:"write8",size:1,maxValue:2**8-1,...e})},u16(e){return Ze({name:"u16",readMethod:"read16",writeMethod:"write16",size:2,maxValue:2**16-1,...e})},u32(e){return Ze({name:"u32",readMethod:"read32",writeMethod:"write32",size:4,maxValue:2**32-1,...e})},u64(e){return Ye({name:"u64",readMethod:"read64",writeMethod:"write64",size:8,maxValue:2n**64n-1n,...e})},u128(e){return Ye({name:"u128",readMethod:"read128",writeMethod:"write128",size:16,maxValue:2n**128n-1n,...e})},u256(e){return Ye({name:"u256",readMethod:"read256",writeMethod:"write256",size:32,maxValue:2n**256n-1n,...e})},bool(e){return Fe({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 mn({name:"uleb128",read:t=>t.readULEB(),serialize:t=>Uint8Array.from(gt(t)),...e})},bytes(e,t){return Fe({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 wn({name:"string",toBytes:t=>new TextEncoder().encode(t),fromBytes:t=>new TextDecoder().decode(t),...e})},fixedArray(e,t,r){return new Z({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 u.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 Z({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 Z({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 Z({name:e,serializedSize:i=>{let s=0;for(const[o,a]of n){const c=a.serializedSize(i[o]);if(c==null)return null;s+=c}return s},read:i=>{const s={};for(const[o,a]of n)s[o]=a.read(i);return s},write:(i,s)=>{for(const[o,a]of n)a.write(i[o],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 Z({name:e,read:i=>{const s=i.readULEB(),[o,a]=n[s];return{[o]:(a==null?void 0:a.read(i))??!0}},write:(i,s)=>{const[o,a]=Object.entries(i)[0];for(let c=0;c<n.length;c++){const[d,l]=n[c];if(d===o){s.writeULEB(c),l==null||l.write(a,s);return}}},...r,validate:i=>{var a;if((a=r==null?void 0:r.validate)==null||a.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[o]=s;if(!Object.hasOwn(t,o))throw new TypeError(`Invalid enum variant ${o}`)}})},map(e,t){return u.vector(u.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 bn(e)}},Sn=32,Se=class{constructor(e){if(this.types=new Map,this.counter=0,e instanceof Se){this.schema=e.schema,this.types=new Map(e.types);return}if(this.schema=e,this.registerAddressType(Se.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&&Tn(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 Se(this).registerStructType(n,e).ser(n,t,r)}throw new Error(`Incorrect type passed into the '.ser()' function.
|
|
2
2
|
${JSON.stringify(e)}`)}de(e,t,r){if(typeof t=="string")if(r)t=pn(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 Se(this),i=this.tempKey();return n.registerStructType(i,e).de(i,t,r)}throw new Error(`Incorrect type passed into the '.de()' function.
|
|
3
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(o,a,c,d){const l=s.reduce((g,m,y)=>Object.assign(g,{[m]:d[y]}),{});return this._encodeRaw.call(o,new sr(c),a,d,l)},decode(o,a,c){const d=s.reduce((l,g,m)=>Object.assign(l,{[g]:c[m]}),{});return this._decodeRaw.call(o,new nr(a),c,d)},_encodeRaw(o,a,c,d){if(n(a))return t.call(this,o,a,c,d);throw new Error(`Validation failed for type ${i}, data: ${a}`)},_decodeRaw(o,a,c){return r.call(this,o,a,c)}}),this}registerBcsType(e,t){return this.registerType(e,(r,n,i)=>{const s=i.map(o=>new Z({name:String(o),write:(a,c)=>{const{name:d,params:l}=this.parseTypeName(o),g=this.getTypeInterface(d),m=l.reduce((y,w,b)=>Object.assign(y,{[w]:i[b]}),{});return g._encodeRaw.call(this,c,a,l,m)},read:()=>{throw new Error("Not implemented")}}));return t(...s).write(n,r),r},(r,n)=>{const i=n.map(s=>new Z({name:String(s),write:(o,a)=>{throw new Error("Not implemented")},read:o=>{const{name:a,params:c}=this.parseTypeName(s),d=this.getTypeInterface(a),l=c.reduce((g,m,y)=>Object.assign(g,{[m]:n[y]}),{});return d._decodeRaw.call(this,o,c,l)}}));return t(...i).read(r)}),this}registerAddressType(e,t,r="hex"){switch(r){case"base64":return this.registerType(e,function(i,s){return ce(s).reduce((o,a)=>o.write8(a),i)},function(i){return Ae(i.readBytes(t))});case"hex":return this.registerType(e,function(i,s){return Ke(s).reduce((o,a)=>o.write8(a),i)},function(i){return _e(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,o,a){return i.writeVec(s,(c,d)=>{let l=o[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,c,d,m,a);if(!(g in a))throw new Error(`Unable to find a matching type definition for ${g} in vector; make sure you passed a generic`);let{name:y,params:w}=this.parseTypeName(a[g]);return this.getTypeInterface(y)._encodeRaw.call(this,c,d,w,a)})},function(i,s,o){return i.readVec(a=>{let c=s[0];if(!c)throw new Error(`Incorrect number of type parameters passed to a vector '${e}'`);let{name:d,params:l}=this.parseTypeName(c);if(this.hasType(d))return this.getTypeInterface(d)._decodeRaw.call(this,a,l,o);if(!(d in o))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(o[d]);return this.getTypeInterface(g)._decodeRaw.call(this,a,m,o)})})}registerStructType(e,t){for(let o in t){let a=this.tempKey(),c=t[o];!Array.isArray(c)&&typeof c!="string"&&(t[o]=a,this.registerStructType(a,c))}let r=Object.freeze(t),n=Object.keys(r),{name:i,params:s}=this.parseTypeName(e);return this.registerType(e,function(a,c,d,l){if(!c||c.constructor!==Object)throw new Error(`Expected ${i} to be an Object, got: ${c}`);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 c))throw new Error(`Struct ${i} requires field ${g}:${r[g]}`);const{name:m,params:y}=this.parseTypeName(r[g]);if(!s.includes(m))this.getTypeInterface(m)._encodeRaw.call(this,a,c[g],y,l);else{const w=s.indexOf(m);let{name:b,params:f}=this.parseTypeName(d[w]);if(this.hasType(b)){this.getTypeInterface(b)._encodeRaw.call(this,a,c[g],f,l);continue}if(!(b in l))throw new Error(`Unable to find a matching type definition for ${b} in ${i}; make sure you passed a generic`);let{name:x,params:C}=this.parseTypeName(l[b]);this.getTypeInterface(x)._encodeRaw.call(this,a,c[g],C,l)}}return a},function(a,c,d){if(c.length!==s.length)throw new Error(`Incorrect number of generic parameters passed; expected: ${s.length}, got: ${c.length}`);let l={};for(let g of n){const{name:m,params:y}=this.parseTypeName(r[g]);if(!s.includes(m))l[g]=this.getTypeInterface(m)._decodeRaw.call(this,a,y,d);else{const w=s.indexOf(m);let{name:b,params:f}=this.parseTypeName(c[w]);if(this.hasType(b)){l[g]=this.getTypeInterface(b)._decodeRaw.call(this,a,f,d);continue}if(!(b in d))throw new Error(`Unable to find a matching type definition for ${b} in ${i}; make sure you passed a generic`);let{name:x,params:C}=this.parseTypeName(d[b]);l[g]=this.getTypeInterface(x)._decodeRaw.call(this,a,C,d)}}return l})}registerEnumType(e,t){for(let o in t){let a=this.tempKey(),c=t[o];c!==null&&!Array.isArray(c)&&typeof c!="string"&&(t[o]=a,this.registerStructType(a,c))}let r=Object.freeze(t),n=Object.keys(r),{name:i,params:s}=this.parseTypeName(e);return this.registerType(e,function(a,c,d,l){if(!c)throw new Error(`Unable to write enum "${i}", missing data.
|
|
4
4
|
Received: "${c}"`);if(typeof c!="object")throw new Error(`Incorrect data passed into enum "${i}", expected object with properties: "${n.join(" | ")}".
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const H=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const H=require("./index-Tl7zYqHL.js"),F=require("./index-Bfw-brA6.js"),I=require("./browser-Cz60hQ-L.js");var le={};Object.defineProperty(le,"__esModule",{value:!0});le.getLocalStorage=le.getLocalStorageOrThrow=le.getCrypto=le.getCryptoOrThrow=le.getLocation=le.getLocationOrThrow=le.getNavigator=le.getNavigatorOrThrow=le.getDocument=le.getDocumentOrThrow=le.getFromWindowOrThrow=le.getFromWindow=void 0;function lr(o){let t;return typeof window<"u"&&typeof window[o]<"u"&&(t=window[o]),t}le.getFromWindow=lr;function Fr(o){const t=lr(o);if(!t)throw new Error(`${o} is not defined in Window`);return t}le.getFromWindowOrThrow=Fr;function nw(){return Fr("document")}le.getDocumentOrThrow=nw;function ow(){return lr("document")}le.getDocument=ow;function aw(){return Fr("navigator")}le.getNavigatorOrThrow=aw;function cw(){return lr("navigator")}le.getNavigator=cw;function uw(){return Fr("location")}le.getLocationOrThrow=uw;function hw(){return lr("location")}le.getLocation=hw;function lw(){return Fr("crypto")}le.getCryptoOrThrow=lw;function pw(){return lr("crypto")}le.getCrypto=pw;function dw(){return Fr("localStorage")}le.getLocalStorageOrThrow=dw;function fw(){return lr("localStorage")}le.getLocalStorage=fw;var $o={};Object.defineProperty($o,"__esModule",{value:!0});$o.getWindowMetadata=void 0;const Pu=le;function gw(){let o,t;try{o=Pu.getDocumentOrThrow(),t=Pu.getLocationOrThrow()}catch{return null}function r(){const R=o.getElementsByTagName("link"),N=[];for(let M=0;M<R.length;M++){const C=R[M],V=C.getAttribute("rel");if(V&&V.toLowerCase().indexOf("icon")>-1){const q=C.getAttribute("href");if(q)if(q.toLowerCase().indexOf("https:")===-1&&q.toLowerCase().indexOf("http:")===-1&&q.indexOf("//")!==0){let Y=t.protocol+"//"+t.host;if(q.indexOf("/")===0)Y+=q;else{const me=t.pathname.split("/");me.pop();const te=me.join("/");Y+=te+"/"+q}N.push(Y)}else if(q.indexOf("//")===0){const Y=t.protocol+q;N.push(Y)}else N.push(q)}}return N}function s(...R){const N=o.getElementsByTagName("meta");for(let M=0;M<N.length;M++){const C=N[M],V=["itemprop","property","name"].map(q=>C.getAttribute(q)).filter(q=>q?R.includes(q):!1);if(V.length&&V){const q=C.getAttribute("content");if(q)return q}}return""}function a(){let R=s("name","og:site_name","og:title","twitter:title");return R||(R=o.title),R}function u(){return s("description","og:description","twitter:description","keywords")}const l=a(),f=u(),w=t.origin,_=r();return{description:f,url:w,icons:_,name:l}}$o.getWindowMetadata=gw;function yw(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 mw={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 vw(o,t){const{message:r,code:s}=mw[o];return{message:r,code:s}}function wo(o,t){return!!Array.isArray(o)}const ww=o=>JSON.stringify(o,(t,r)=>typeof r=="bigint"?r.toString()+"n":r),bw=o=>{const t=/([\[:])?(\d{17,}|(?:[9](?:[1-9]07199254740991|0[1-9]7199254740991|00[8-9]199254740991|007[2-9]99254740991|007199[3-9]54740991|0071992[6-9]4740991|00719925[5-9]740991|007199254[8-9]40991|0071992547[5-9]0991|00719925474[1-9]991|00719925474099[2-9])))([,\}\]])/g,r=o.replace(t,'$1"$2n"$3');return JSON.parse(r,(s,a)=>typeof a=="string"&&a.match(/^\d+n$/)?BigInt(a.substring(0,a.length-1)):a)};function xo(o){if(typeof o!="string")throw new Error(`Cannot safe json parse value of type ${typeof o}`);try{return bw(o)}catch{return o}}function Do(o){return typeof o=="string"?o:ww(o)||""}const _w="idb-keyval";var Ew=(o={})=>{const t=o.base&&o.base.length>0?`${o.base}:`:"",r=a=>t+a;let s;return o.dbName&&o.storeName&&(s=I.createStore(o.dbName,o.storeName)),{name:_w,options:o,async hasItem(a){return!(typeof await I.get(r(a),s)>"u")},async getItem(a){return await I.get(r(a),s)??null},setItem(a,u){return I.set(r(a),u,s)},removeItem(a){return I.del(r(a),s)},getKeys(){return I.keys(s)},clear(){return I.clear(s)}}};const Iw="WALLET_CONNECT_V2_INDEXED_DB",Pw="keyvaluestorage";let Sw=class{constructor(){this.indexedDb=I.createStorage({driver:Ew({dbName:Iw,storeName:Pw})})}async getKeys(){return this.indexedDb.getKeys()}async getEntries(){return(await this.indexedDb.getItems(await this.indexedDb.getKeys())).map(t=>[t.key,t.value])}async getItem(t){const r=await this.indexedDb.getItem(t);if(r!==null)return r}async setItem(t,r){await this.indexedDb.setItem(t,Do(r))}async removeItem(t){await this.indexedDb.removeItem(t)}};var so=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof H.dist.global<"u"?H.dist.global:typeof self<"u"?self:{},Es={exports:{}};(function(){let o;function t(){}o=t,o.prototype.getItem=function(r){return this.hasOwnProperty(r)?String(this[r]):null},o.prototype.setItem=function(r,s){this[r]=String(s)},o.prototype.removeItem=function(r){delete this[r]},o.prototype.clear=function(){const r=this;Object.keys(r).forEach(function(s){r[s]=void 0,delete r[s]})},o.prototype.key=function(r){return r=r||0,Object.keys(this)[r]},o.prototype.__defineGetter__("length",function(){return Object.keys(this).length}),typeof so<"u"&&so.localStorage?Es.exports=so.localStorage:typeof window<"u"&&window.localStorage?Es.exports=window.localStorage:Es.exports=new t})();function Ow(o){var t;return[o[0],xo((t=o[1])!=null?t:"")]}let Rw=class{constructor(){this.localStorage=Es.exports}async getKeys(){return Object.keys(this.localStorage)}async getEntries(){return Object.entries(this.localStorage).map(Ow)}async getItem(t){const r=this.localStorage.getItem(t);if(r!==null)return xo(r)}async setItem(t,r){this.localStorage.setItem(t,Do(r))}async removeItem(t){this.localStorage.removeItem(t)}};const Aw="wc_storage_version",Su=1,Nw=async(o,t,r)=>{const s=Aw,a=await t.getItem(s);if(a&&a>=Su){r(t);return}const u=await o.getKeys();if(!u.length){r(t);return}const l=[];for(;u.length;){const f=u.shift();if(!f)continue;const w=f.toLowerCase();if(w.includes("wc@")||w.includes("walletconnect")||w.includes("wc_")||w.includes("wallet_connect")){const _=await o.getItem(f);await t.setItem(f,_),l.push(f)}}await t.setItem(s,Su),r(t),Tw(o,l)},Tw=async(o,t)=>{t.length&&t.forEach(async r=>{await o.removeItem(r)})};let Cw=class{constructor(){this.initialized=!1,this.setInitialized=r=>{this.storage=r,this.initialized=!0};const t=new Rw;this.storage=t;try{const r=new Sw;Nw(t,r,this.setInitialized)}catch{this.initialized=!0}}async getKeys(){return await this.initialize(),this.storage.getKeys()}async getEntries(){return await this.initialize(),this.storage.getEntries()}async getItem(t){return await this.initialize(),this.storage.getItem(t)}async setItem(t,r){return await this.initialize(),this.storage.setItem(t,r)}async removeItem(t){return await this.initialize(),this.storage.removeItem(t)}async initialize(){this.initialized||await new Promise(t=>{const r=setInterval(()=>{this.initialized&&(clearInterval(r),t())},20)})}};var jr={};/*! *****************************************************************************
|
|
2
2
|
Copyright (c) Microsoft Corporation.
|
|
3
3
|
|
|
4
4
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
@@ -43,4 +43,4 @@ __p += '`),ee&&(A+=`' +
|
|
|
43
43
|
function print() { __p += __j.call(arguments, '') }
|
|
44
44
|
`:`;
|
|
45
45
|
`)+A+`return __p
|
|
46
|
-
}`;var G=_u(function(){return ie(d,U+"return "+A).apply(r,g)});if(G.source=A,Wn(G))throw G;return G}function pv(e){return se(e).toLowerCase()}function dv(e){return se(e).toUpperCase()}function fv(e,i,n){if(e=se(e),e&&(n||i===r))return Ta(e);if(!e||!(i=Ye(i)))return e;var c=ft(e),h=ft(i),d=Ca(c,h),g=$a(c,h)+1;return Wt(c,d,g).join("")}function gv(e,i,n){if(e=se(e),e&&(n||i===r))return e.slice(0,Da(e)+1);if(!e||!(i=Ye(i)))return e;var c=ft(e),h=$a(c,ft(i))+1;return Wt(c,0,h).join("")}function yv(e,i,n){if(e=se(e),e&&(n||i===r))return e.replace(Ks,"");if(!e||!(i=Ye(i)))return e;var c=ft(e),h=Ca(c,ft(i));return Wt(c,h).join("")}function mv(e,i){var n=Ds,c=rt;if(be(i)){var h="separator"in i?i.separator:h;n="length"in i?W(i.length):n,c="omission"in i?Ye(i.omission):c}e=se(e);var d=e.length;if(wr(e)){var g=ft(e);d=g.length}if(n>=d)return e;var y=n-br(c);if(y<1)return c;var v=g?Wt(g,0,y).join(""):e.slice(0,y);if(h===r)return v+c;if(g&&(y+=v.length-y),Jn(h)){if(e.slice(y).search(h)){var S,O=v;for(h.global||(h=hn(h.source,se(Zo.exec(h))+"g")),h.lastIndex=0;S=h.exec(O);)var A=S.index;v=v.slice(0,A===r?y:A)}}else if(e.indexOf(Ye(h),y)!=y){var D=v.lastIndexOf(h);D>-1&&(v=v.slice(0,D))}return v+c}function vv(e){return e=se(e),e&&Al.test(e)?e.replace(Go,Kp):e}var wv=Rr(function(e,i,n){return e+(n?" ":"")+i.toUpperCase()}),Yn=Ec("toUpperCase");function bu(e,i,n){return e=se(e),i=n?r:i,i===r?kp(e)?Gp(e):$p(e):e.match(i)||[]}var _u=Q(function(e,i){try{return Ge(e,r,i)}catch(n){return Wn(n)?n:new B(n)}}),bv=Ct(function(e,i){return st(i,function(n){n=It(n),Nt(e,n,Vn(e[n],e))}),e});function _v(e){var i=e==null?0:e.length,n=L();return e=i?ge(e,function(c){if(typeof c[1]!="function")throw new nt(l);return[n(c[0]),c[1]]}):[],Q(function(c){for(var h=-1;++h<i;){var d=e[h];if(Ge(d[0],this,c))return Ge(d[1],this,c)}})}function Ev(e){return Kd(at(e,R))}function Zn(e){return function(){return e}}function Iv(e,i){return e==null||e!==e?i:e}var Pv=Pc(),Sv=Pc(!0);function Ve(e){return e}function Xn(e){return ec(typeof e=="function"?e:at(e,R))}function Ov(e){return rc(at(e,R))}function Rv(e,i){return ic(e,at(i,R))}var Av=Q(function(e,i){return function(n){return si(n,e,i)}}),Nv=Q(function(e,i){return function(n){return si(e,n,i)}});function eo(e,i,n){var c=Ae(i),h=Zi(i,c);n==null&&!(be(i)&&(h.length||!c.length))&&(n=i,i=e,e=this,h=Zi(i,Ae(i)));var d=!(be(n)&&"chain"in n)||!!n.chain,g=xt(e);return st(h,function(y){var v=i[y];e[y]=v,g&&(e.prototype[y]=function(){var S=this.__chain__;if(d||S){var O=e(this.__wrapped__),A=O.__actions__=ze(this.__actions__);return A.push({func:v,args:arguments,thisArg:e}),O.__chain__=S,O}return v.apply(e,kt([this.value()],arguments))})}),e}function Tv(){return Ce._===this&&(Ce._=td),this}function to(){}function Cv(e){return e=W(e),Q(function(i){return sc(i,e)})}var $v=$n(ge),xv=$n(Sa),Dv=$n(rn);function Eu(e){return Mn(e)?sn(It(e)):hf(e)}function Fv(e){return function(i){return e==null?r:sr(e,i)}}var jv=Oc(),qv=Oc(!0);function ro(){return[]}function io(){return!1}function Uv(){return{}}function Mv(){return""}function Lv(){return!0}function kv(e,i){if(e=W(e),e<1||e>ue)return[];var n=De,c=Fe(e,De);i=L(i),e-=De;for(var h=an(c,i);++n<e;)i(n);return h}function zv(e){return K(e)?ge(e,It):Ze(e)?[e]:ze(zc(se(e)))}function Hv(e){var i=++Xp;return se(e)+i}var Bv=ss(function(e,i){return e+i},0),Vv=xn("ceil"),Kv=ss(function(e,i){return e/i},1),Wv=xn("floor");function Jv(e){return e&&e.length?Yi(e,Ve,vn):r}function Gv(e,i){return e&&e.length?Yi(e,L(i,2),vn):r}function Qv(e){return Aa(e,Ve)}function Yv(e,i){return Aa(e,L(i,2))}function Zv(e){return e&&e.length?Yi(e,Ve,En):r}function Xv(e,i){return e&&e.length?Yi(e,L(i,2),En):r}var ew=ss(function(e,i){return e*i},1),tw=xn("round"),rw=ss(function(e,i){return e-i},0);function iw(e){return e&&e.length?on(e,Ve):0}function sw(e,i){return e&&e.length?on(e,L(i,2)):0}return p.after=Oy,p.ary=Xc,p.assign=dm,p.assignIn=du,p.assignInWith=ms,p.assignWith=fm,p.at=gm,p.before=eu,p.bind=Vn,p.bindAll=bv,p.bindKey=tu,p.castArray=Uy,p.chain=Qc,p.chunk=Wf,p.compact=Jf,p.concat=Gf,p.cond=_v,p.conforms=Ev,p.constant=Zn,p.countBy=iy,p.create=ym,p.curry=ru,p.curryRight=iu,p.debounce=su,p.defaults=mm,p.defaultsDeep=vm,p.defer=Ry,p.delay=Ay,p.difference=Qf,p.differenceBy=Yf,p.differenceWith=Zf,p.drop=Xf,p.dropRight=eg,p.dropRightWhile=tg,p.dropWhile=rg,p.fill=ig,p.filter=ny,p.flatMap=cy,p.flatMapDeep=uy,p.flatMapDepth=hy,p.flatten=Kc,p.flattenDeep=sg,p.flattenDepth=ng,p.flip=Ny,p.flow=Pv,p.flowRight=Sv,p.fromPairs=og,p.functions=Sm,p.functionsIn=Om,p.groupBy=ly,p.initial=cg,p.intersection=ug,p.intersectionBy=hg,p.intersectionWith=lg,p.invert=Am,p.invertBy=Nm,p.invokeMap=dy,p.iteratee=Xn,p.keyBy=fy,p.keys=Ae,p.keysIn=Be,p.map=ls,p.mapKeys=Cm,p.mapValues=$m,p.matches=Ov,p.matchesProperty=Rv,p.memoize=ds,p.merge=xm,p.mergeWith=fu,p.method=Av,p.methodOf=Nv,p.mixin=eo,p.negate=fs,p.nthArg=Cv,p.omit=Dm,p.omitBy=Fm,p.once=Ty,p.orderBy=gy,p.over=$v,p.overArgs=Cy,p.overEvery=xv,p.overSome=Dv,p.partial=Kn,p.partialRight=nu,p.partition=yy,p.pick=jm,p.pickBy=gu,p.property=Eu,p.propertyOf=Fv,p.pull=gg,p.pullAll=Jc,p.pullAllBy=yg,p.pullAllWith=mg,p.pullAt=vg,p.range=jv,p.rangeRight=qv,p.rearg=$y,p.reject=wy,p.remove=wg,p.rest=xy,p.reverse=Hn,p.sampleSize=_y,p.set=Um,p.setWith=Mm,p.shuffle=Ey,p.slice=bg,p.sortBy=Sy,p.sortedUniq=Rg,p.sortedUniqBy=Ag,p.split=cv,p.spread=Dy,p.tail=Ng,p.take=Tg,p.takeRight=Cg,p.takeRightWhile=$g,p.takeWhile=xg,p.tap=Jg,p.throttle=Fy,p.thru=hs,p.toArray=hu,p.toPairs=yu,p.toPairsIn=mu,p.toPath=zv,p.toPlainObject=pu,p.transform=Lm,p.unary=jy,p.union=Dg,p.unionBy=Fg,p.unionWith=jg,p.uniq=qg,p.uniqBy=Ug,p.uniqWith=Mg,p.unset=km,p.unzip=Bn,p.unzipWith=Gc,p.update=zm,p.updateWith=Hm,p.values=Tr,p.valuesIn=Bm,p.without=Lg,p.words=bu,p.wrap=qy,p.xor=kg,p.xorBy=zg,p.xorWith=Hg,p.zip=Bg,p.zipObject=Vg,p.zipObjectDeep=Kg,p.zipWith=Wg,p.entries=yu,p.entriesIn=mu,p.extend=du,p.extendWith=ms,eo(p,p),p.add=Bv,p.attempt=_u,p.camelCase=Jm,p.capitalize=vu,p.ceil=Vv,p.clamp=Vm,p.clone=My,p.cloneDeep=ky,p.cloneDeepWith=zy,p.cloneWith=Ly,p.conformsTo=Hy,p.deburr=wu,p.defaultTo=Iv,p.divide=Kv,p.endsWith=Gm,p.eq=yt,p.escape=Qm,p.escapeRegExp=Ym,p.every=sy,p.find=oy,p.findIndex=Bc,p.findKey=wm,p.findLast=ay,p.findLastIndex=Vc,p.findLastKey=bm,p.floor=Wv,p.forEach=Yc,p.forEachRight=Zc,p.forIn=_m,p.forInRight=Em,p.forOwn=Im,p.forOwnRight=Pm,p.get=Gn,p.gt=By,p.gte=Vy,p.has=Rm,p.hasIn=Qn,p.head=Wc,p.identity=Ve,p.includes=py,p.indexOf=ag,p.inRange=Km,p.invoke=Tm,p.isArguments=ar,p.isArray=K,p.isArrayBuffer=Ky,p.isArrayLike=He,p.isArrayLikeObject=Ee,p.isBoolean=Wy,p.isBuffer=Jt,p.isDate=Jy,p.isElement=Gy,p.isEmpty=Qy,p.isEqual=Yy,p.isEqualWith=Zy,p.isError=Wn,p.isFinite=Xy,p.isFunction=xt,p.isInteger=ou,p.isLength=gs,p.isMap=au,p.isMatch=em,p.isMatchWith=tm,p.isNaN=rm,p.isNative=im,p.isNil=nm,p.isNull=sm,p.isNumber=cu,p.isObject=be,p.isObjectLike=_e,p.isPlainObject=hi,p.isRegExp=Jn,p.isSafeInteger=om,p.isSet=uu,p.isString=ys,p.isSymbol=Ze,p.isTypedArray=Nr,p.isUndefined=am,p.isWeakMap=cm,p.isWeakSet=um,p.join=pg,p.kebabCase=Zm,p.last=ut,p.lastIndexOf=dg,p.lowerCase=Xm,p.lowerFirst=ev,p.lt=hm,p.lte=lm,p.max=Jv,p.maxBy=Gv,p.mean=Qv,p.meanBy=Yv,p.min=Zv,p.minBy=Xv,p.stubArray=ro,p.stubFalse=io,p.stubObject=Uv,p.stubString=Mv,p.stubTrue=Lv,p.multiply=ew,p.nth=fg,p.noConflict=Tv,p.noop=to,p.now=ps,p.pad=tv,p.padEnd=rv,p.padStart=iv,p.parseInt=sv,p.random=Wm,p.reduce=my,p.reduceRight=vy,p.repeat=nv,p.replace=ov,p.result=qm,p.round=tw,p.runInContext=m,p.sample=by,p.size=Iy,p.snakeCase=av,p.some=Py,p.sortedIndex=_g,p.sortedIndexBy=Eg,p.sortedIndexOf=Ig,p.sortedLastIndex=Pg,p.sortedLastIndexBy=Sg,p.sortedLastIndexOf=Og,p.startCase=uv,p.startsWith=hv,p.subtract=rw,p.sum=iw,p.sumBy=sw,p.template=lv,p.times=kv,p.toFinite=Dt,p.toInteger=W,p.toLength=lu,p.toLower=pv,p.toNumber=ht,p.toSafeInteger=pm,p.toString=se,p.toUpper=dv,p.trim=fv,p.trimEnd=gv,p.trimStart=yv,p.truncate=mv,p.unescape=vv,p.uniqueId=Hv,p.upperCase=wv,p.upperFirst=Yn,p.each=Yc,p.eachRight=Zc,p.first=Wc,eo(p,function(){var e={};return _t(p,function(i,n){oe.call(p.prototype,n)||(e[n]=i)}),e}(),{chain:!1}),p.VERSION=s,st(["bind","bindKey","curry","curryRight","partial","partialRight"],function(e){p[e].placeholder=p}),st(["drop","take"],function(e,i){X.prototype[e]=function(n){n=n===r?1:Re(W(n),0);var c=this.__filtered__&&!i?new X(this):this.clone();return c.__filtered__?c.__takeCount__=Fe(n,c.__takeCount__):c.__views__.push({size:Fe(n,De),type:e+(c.__dir__<0?"Right":"")}),c},X.prototype[e+"Right"]=function(n){return this.reverse()[e](n).reverse()}}),st(["filter","map","takeWhile"],function(e,i){var n=i+1,c=n==E||n==J;X.prototype[e]=function(h){var d=this.clone();return d.__iteratees__.push({iteratee:L(h,3),type:n}),d.__filtered__=d.__filtered__||c,d}}),st(["head","last"],function(e,i){var n="take"+(i?"Right":"");X.prototype[e]=function(){return this[n](1).value()[0]}}),st(["initial","tail"],function(e,i){var n="drop"+(i?"":"Right");X.prototype[e]=function(){return this.__filtered__?new X(this):this[n](1)}}),X.prototype.compact=function(){return this.filter(Ve)},X.prototype.find=function(e){return this.filter(e).head()},X.prototype.findLast=function(e){return this.reverse().find(e)},X.prototype.invokeMap=Q(function(e,i){return typeof e=="function"?new X(this):this.map(function(n){return si(n,e,i)})}),X.prototype.reject=function(e){return this.filter(fs(L(e)))},X.prototype.slice=function(e,i){e=W(e);var n=this;return n.__filtered__&&(e>0||i<0)?new X(n):(e<0?n=n.takeRight(-e):e&&(n=n.drop(e)),i!==r&&(i=W(i),n=i<0?n.dropRight(-i):n.take(i-e)),n)},X.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},X.prototype.toArray=function(){return this.take(De)},_t(X.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 g=this.__wrapped__,y=c?[1]:arguments,v=g instanceof X,S=y[0],O=v||K(g),A=function(Z){var ee=h.apply(p,kt([Z],y));return c&&D?ee[0]:ee};O&&n&&typeof S=="function"&&S.length!=1&&(v=O=!1);var D=this.__chain__,U=!!this.__actions__.length,k=d&&!D,G=v&&!U;if(!d&&O){g=G?g:new X(this);var z=e.apply(g,y);return z.__actions__.push({func:hs,args:[A],thisArg:r}),new ot(z,D)}return k&&G?e.apply(this,y):(z=this.thru(A),k?c?z.value()[0]:z.value():z)})}),st(["pop","push","shift","sort","splice","unshift"],function(e){var i=ji[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(K(d)?d:[],h)}return this[n](function(g){return i.apply(K(g)?g:[],h)})}}),_t(X.prototype,function(e,i){var n=p[i];if(n){var c=n.name+"";oe.call(Pr,c)||(Pr[c]=[]),Pr[c].push({name:i,func:n})}}),Pr[is(r,Y).name]=[{name:"wrapper",func:r}],X.prototype.clone=md,X.prototype.reverse=vd,X.prototype.value=wd,p.prototype.at=Gg,p.prototype.chain=Qg,p.prototype.commit=Yg,p.prototype.next=Zg,p.prototype.plant=ey,p.prototype.reverse=ty,p.prototype.toJSON=p.prototype.valueOf=p.prototype.value=ry,p.prototype.first=p.prototype.head,Yr&&(p.prototype[Yr]=Xg),p},_r=Qp();Xt?((Xt.exports=_r)._=_r,Zs._=_r):Ce._=_r}).call(mi)})(Co,Co.exports);var cI=Object.defineProperty,uI=Object.defineProperties,hI=Object.getOwnPropertyDescriptors,Sh=Object.getOwnPropertySymbols,lI=Object.prototype.hasOwnProperty,pI=Object.prototype.propertyIsEnumerable,Oh=(o,t,r)=>t in o?cI(o,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[t]=r,bs=(o,t)=>{for(var r in t||(t={}))lI.call(t,r)&&Oh(o,r,t[r]);if(Sh)for(var r of Sh(t))pI.call(t,r)&&Oh(o,r,t[r]);return o},dI=(o,t)=>uI(o,hI(t));function Yt(o,t,r){var s;const a=k0(o);return((s=t.rpcMap)==null?void 0:s[a.reference])||`${aI}?chainId=${a.namespace}:${a.reference}&projectId=${r}`}function fr(o){return o.includes(":")?o.split(":")[1]:o}function dl(o){return o.map(t=>`${t.split(":")[0]}:${t.split(":")[1]}`)}function fI(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 gI(o={},t={}){const r=Rh(o),s=Rh(t);return Co.exports.merge(r,s)}function Rh(o){var t,r,s,a;const u={};if(!Dr(o))return u;for(const[l,f]of Object.entries(o)){const w=ko(l)?[l]:f.chains,_=f.methods||[],T=f.events||[],R=f.rpcMap||{},N=vi(l);u[N]=dI(bs(bs({},u[N]),f),{chains:ao(w,(t=u[N])==null?void 0:t.chains),methods:ao(_,(r=u[N])==null?void 0:r.methods),events:ao(T,(s=u[N])==null?void 0:s.events),rpcMap:bs(bs({},R),(a=u[N])==null?void 0:a.rpcMap)})}return u}function yI(o){return o.includes(":")?o.split(":")[2]:o}function mI(o){const t={};for(const[r,s]of Object.entries(o)){const a=s.methods||[],u=s.events||[],l=s.accounts||[],f=ko(r)?[r]:s.chains?s.chains:dl(s.accounts);t[r]={chains:f,methods:a,events:u,accounts:l}}return t}function go(o){return typeof o=="number"?o:o.includes("0x")?parseInt(o,16):o.includes(":")?Number(o.split(":")[1]):Number(o)}const fl={},ye=o=>fl[o],yo=(o,t)=>{fl[o]=t};class vI{constructor(t){this.name="polkadot",this.namespace=t.namespace,this.events=ye("events"),this.client=ye("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(Mt.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=fr(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||Yt(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new Ut(new Zt(s,ye("disableProviderPing")))}}class wI{constructor(t){this.name="eip155",this.namespace=t.namespace,this.events=ye("events"),this.client=ye("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(Mt.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||Yt(`${this.name}:${t}`,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new Ut(new Zt(s,ye("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(fr(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 bI{constructor(t){this.name="solana",this.namespace=t.namespace,this.events=ye("events"),this.client=ye("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(Mt.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=fr(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||Yt(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new Ut(new Zt(s,ye("disableProviderPing")))}}class _I{constructor(t){this.name="cosmos",this.namespace=t.namespace,this.events=ye("events"),this.client=ye("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(Mt.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=fr(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||Yt(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new Ut(new Zt(s,ye("disableProviderPing")))}}class EI{constructor(t){this.name="cip34",this.namespace=t.namespace,this.events=ye("events"),this.client=ye("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(Mt.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=fr(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 Ut(new Zt(s,ye("disableProviderPing")))}}class II{constructor(t){this.name="elrond",this.namespace=t.namespace,this.events=ye("events"),this.client=ye("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(Mt.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=fr(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||Yt(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new Ut(new Zt(s,ye("disableProviderPing")))}}class PI{constructor(t){this.name="multiversx",this.namespace=t.namespace,this.events=ye("events"),this.client=ye("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(Mt.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=fr(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||Yt(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new Ut(new Zt(s,ye("disableProviderPing")))}}class SI{constructor(t){this.name="near",this.namespace=t.namespace,this.events=ye("events"),this.client=ye("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||Yt(`${this.name}:${t}`,this.namespace);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);this.setHttpProvider(t,s)}this.events.emit(Mt.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||Yt(t,this.namespace);return typeof s>"u"?void 0:new Ut(new Zt(s,ye("disableProviderPing")))}}var OI=Object.defineProperty,RI=Object.defineProperties,AI=Object.getOwnPropertyDescriptors,Ah=Object.getOwnPropertySymbols,NI=Object.prototype.hasOwnProperty,TI=Object.prototype.propertyIsEnumerable,Nh=(o,t,r)=>t in o?OI(o,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[t]=r,_s=(o,t)=>{for(var r in t||(t={}))NI.call(t,r)&&Nh(o,r,t[r]);if(Ah)for(var r of Ah(t))TI.call(t,r)&&Nh(o,r,t[r]);return o},mo=(o,t)=>RI(o,AI(t));class Ko{constructor(t){this.events=new H.Ct,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:I.ot(I.k({level:(t==null?void 0:t.logger)||Ih})),this.disableProviderPing=(t==null?void 0:t.disableProviderPing)||!1}static async init(t){const r=new Ko(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:_s({},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,I.formatJsonRpcResult(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:Pe("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=mI(u.namespaces),this.persist("namespaces",this.namespaces))}).catch(u=>{if(u.message!==ll)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 KE.init({logger:this.providerOpts.logger||Ih,relayUrl:this.providerOpts.relayUrl||sI,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=>vi(r)))];yo("client",this.client),yo("events",this.events),yo("disableProviderPing",this.disableProviderPing),t.forEach(r=>{if(!this.session)return;const s=fI(r,this.session),a=dl(s),u=gI(this.namespaces,this.optionalNamespaces),l=mo(_s({},u[r]),{accounts:s,chains:a});switch(r){case"eip155":this.rpcProviders[r]=new wI({namespace:l});break;case"solana":this.rpcProviders[r]=new bI({namespace:l});break;case"cosmos":this.rpcProviders[r]=new _I({namespace:l});break;case"polkadot":this.rpcProviders[r]=new vI({namespace:l});break;case"cip34":this.rpcProviders[r]=new EI({namespace:l});break;case"elrond":this.rpcProviders[r]=new II({namespace:l});break;case"multiversx":this.rpcProviders[r]=new PI({namespace:l});break;case"near":this.rpcProviders[r]=new SI({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(yI))}else if(s.name==="chainChanged"){const a=r.chainId,u=r.event.data,l=vi(a),f=go(a)!==go(u)?`${l}:${go(u)}`:a;this.onChainChanged(f)}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=mo(_s({},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",mo(_s({},Pe("USER_DISCONNECTED")),{data:t.topic}))}),this.on(Mt.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=>vi(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=vi(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(`${Ph}/${t}`,r)}async getFromStore(t){return await this.client.core.storage.getItem(`${Ph}/${t}`)}}const CI=Ko,$I="wc",xI="ethereum_provider",DI=`${$I}@2:${xI}:`,FI="https://rpc.walletconnect.com/v1/",Rs=["eth_sendTransaction","personal_sign"],gl=["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"],As=["chainChanged","accountsChanged"],yl=["chainChanged","accountsChanged","message","disconnect","connect"];var jI=Object.defineProperty,qI=Object.defineProperties,UI=Object.getOwnPropertyDescriptors,Th=Object.getOwnPropertySymbols,MI=Object.prototype.hasOwnProperty,LI=Object.prototype.propertyIsEnumerable,Ch=(o,t,r)=>t in o?jI(o,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[t]=r,bi=(o,t)=>{for(var r in t||(t={}))MI.call(t,r)&&Ch(o,r,t[r]);if(Th)for(var r of Th(t))LI.call(t,r)&&Ch(o,r,t[r]);return o},$h=(o,t)=>qI(o,UI(t));function Ns(o){return Number(o[0].split(":")[1])}function vo(o){return`0x${o.toString(16)}`}function kI(o){const{chains:t,optionalChains:r,methods:s,optionalMethods:a,events:u,optionalEvents:l,rpcMap:f}=o;if(!wo(t))throw new Error("Invalid chains");const w={chains:t,methods:s||Rs,events:u||As,rpcMap:bi({},t.length?{[Ns(t)]:f[Ns(t)]}:{})},_=u==null?void 0:u.filter(M=>!As.includes(M)),T=s==null?void 0:s.filter(M=>!Rs.includes(M));if(!r&&!l&&!a&&!(_!=null&&_.length)&&!(T!=null&&T.length))return{required:t.length?w:void 0};const R=(_==null?void 0:_.length)&&(T==null?void 0:T.length)||!r,N={chains:[...new Set(R?w.chains.concat(r||[]):r)],methods:[...new Set(w.methods.concat(a!=null&&a.length?a:gl))],events:[...new Set(w.events.concat(l!=null&&l.length?l:yl))],rpcMap:f};return{required:t.length?w:void 0,optional:r.length?N:void 0}}class xs{constructor(){this.events=new H.eventsExports.EventEmitter,this.namespace="eip155",this.accounts=[],this.chainId=1,this.STORAGE_KEY=DI,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 xs;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}=kI(this.rpc);try{const a=await new Promise(async(l,f)=>{var w;this.rpc.showQrModal&&((w=this.modal)==null||w.subscribeModal(_=>{!_.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),f(new Error("Connection request reset. Please try again.")))})),await this.signer.connect($h(bi({namespaces:bi({},r&&{[this.namespace]:r})},s&&{optionalNamespaces:{[this.namespace]:s}}),{pairingTopic:t==null?void 0:t.pairingTopic})).then(_=>{l(_)}).catch(_=>{f(new Error(_.message))})});if(!a)return;const u=yw(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",$h(bi({},vw("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 f=a.length?(t==null?void 0:t.methods)||Rs:[],w=a.length?(t==null?void 0:t.events)||As:[],_=(t==null?void 0:t.optionalMethods)||[],T=(t==null?void 0:t.optionalEvents)||[],R=(t==null?void 0:t.rpcMap)||this.buildRpcMap(l,t.projectId),N=(t==null?void 0:t.qrModalOptions)||void 0;return{chains:a==null?void 0:a.map(M=>this.formatChainId(M)),optionalChains:u.map(M=>this.formatChainId(M)),methods:f,events:w,optionalMethods:_,optionalEvents:T,rpcMap:R,showQrModal:!!(t!=null&&t.showQrModal),qrModalOptions:N,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 CI.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 Promise.resolve().then(()=>require("./index-W5vGD3Jp.js")).then(a=>a.index);r=s}catch{throw new Error("To use QR modal, please install @walletconnect/modal package")}if(r)try{this.modal=new r(bi({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&&wo(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&&wo(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])||`${FI}?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 zI=xs;exports.EthereumProvider=zI;exports.OPTIONAL_EVENTS=yl;exports.OPTIONAL_METHODS=gl;exports.REQUIRED_EVENTS=As;exports.REQUIRED_METHODS=Rs;exports.default=xs;
|
|
46
|
+
}`;var G=_u(function(){return ie(d,U+"return "+A).apply(r,g)});if(G.source=A,Wn(G))throw G;return G}function pv(e){return se(e).toLowerCase()}function dv(e){return se(e).toUpperCase()}function fv(e,i,n){if(e=se(e),e&&(n||i===r))return Ta(e);if(!e||!(i=Ye(i)))return e;var c=ft(e),h=ft(i),d=Ca(c,h),g=$a(c,h)+1;return Wt(c,d,g).join("")}function gv(e,i,n){if(e=se(e),e&&(n||i===r))return e.slice(0,Da(e)+1);if(!e||!(i=Ye(i)))return e;var c=ft(e),h=$a(c,ft(i))+1;return Wt(c,0,h).join("")}function yv(e,i,n){if(e=se(e),e&&(n||i===r))return e.replace(Ks,"");if(!e||!(i=Ye(i)))return e;var c=ft(e),h=Ca(c,ft(i));return Wt(c,h).join("")}function mv(e,i){var n=Ds,c=rt;if(be(i)){var h="separator"in i?i.separator:h;n="length"in i?W(i.length):n,c="omission"in i?Ye(i.omission):c}e=se(e);var d=e.length;if(wr(e)){var g=ft(e);d=g.length}if(n>=d)return e;var y=n-br(c);if(y<1)return c;var v=g?Wt(g,0,y).join(""):e.slice(0,y);if(h===r)return v+c;if(g&&(y+=v.length-y),Jn(h)){if(e.slice(y).search(h)){var S,O=v;for(h.global||(h=hn(h.source,se(Zo.exec(h))+"g")),h.lastIndex=0;S=h.exec(O);)var A=S.index;v=v.slice(0,A===r?y:A)}}else if(e.indexOf(Ye(h),y)!=y){var D=v.lastIndexOf(h);D>-1&&(v=v.slice(0,D))}return v+c}function vv(e){return e=se(e),e&&Al.test(e)?e.replace(Go,Kp):e}var wv=Rr(function(e,i,n){return e+(n?" ":"")+i.toUpperCase()}),Yn=Ec("toUpperCase");function bu(e,i,n){return e=se(e),i=n?r:i,i===r?kp(e)?Gp(e):$p(e):e.match(i)||[]}var _u=Q(function(e,i){try{return Ge(e,r,i)}catch(n){return Wn(n)?n:new B(n)}}),bv=Ct(function(e,i){return st(i,function(n){n=It(n),Nt(e,n,Vn(e[n],e))}),e});function _v(e){var i=e==null?0:e.length,n=L();return e=i?ge(e,function(c){if(typeof c[1]!="function")throw new nt(l);return[n(c[0]),c[1]]}):[],Q(function(c){for(var h=-1;++h<i;){var d=e[h];if(Ge(d[0],this,c))return Ge(d[1],this,c)}})}function Ev(e){return Kd(at(e,R))}function Zn(e){return function(){return e}}function Iv(e,i){return e==null||e!==e?i:e}var Pv=Pc(),Sv=Pc(!0);function Ve(e){return e}function Xn(e){return ec(typeof e=="function"?e:at(e,R))}function Ov(e){return rc(at(e,R))}function Rv(e,i){return ic(e,at(i,R))}var Av=Q(function(e,i){return function(n){return si(n,e,i)}}),Nv=Q(function(e,i){return function(n){return si(e,n,i)}});function eo(e,i,n){var c=Ae(i),h=Zi(i,c);n==null&&!(be(i)&&(h.length||!c.length))&&(n=i,i=e,e=this,h=Zi(i,Ae(i)));var d=!(be(n)&&"chain"in n)||!!n.chain,g=xt(e);return st(h,function(y){var v=i[y];e[y]=v,g&&(e.prototype[y]=function(){var S=this.__chain__;if(d||S){var O=e(this.__wrapped__),A=O.__actions__=ze(this.__actions__);return A.push({func:v,args:arguments,thisArg:e}),O.__chain__=S,O}return v.apply(e,kt([this.value()],arguments))})}),e}function Tv(){return Ce._===this&&(Ce._=td),this}function to(){}function Cv(e){return e=W(e),Q(function(i){return sc(i,e)})}var $v=$n(ge),xv=$n(Sa),Dv=$n(rn);function Eu(e){return Mn(e)?sn(It(e)):hf(e)}function Fv(e){return function(i){return e==null?r:sr(e,i)}}var jv=Oc(),qv=Oc(!0);function ro(){return[]}function io(){return!1}function Uv(){return{}}function Mv(){return""}function Lv(){return!0}function kv(e,i){if(e=W(e),e<1||e>ue)return[];var n=De,c=Fe(e,De);i=L(i),e-=De;for(var h=an(c,i);++n<e;)i(n);return h}function zv(e){return K(e)?ge(e,It):Ze(e)?[e]:ze(zc(se(e)))}function Hv(e){var i=++Xp;return se(e)+i}var Bv=ss(function(e,i){return e+i},0),Vv=xn("ceil"),Kv=ss(function(e,i){return e/i},1),Wv=xn("floor");function Jv(e){return e&&e.length?Yi(e,Ve,vn):r}function Gv(e,i){return e&&e.length?Yi(e,L(i,2),vn):r}function Qv(e){return Aa(e,Ve)}function Yv(e,i){return Aa(e,L(i,2))}function Zv(e){return e&&e.length?Yi(e,Ve,En):r}function Xv(e,i){return e&&e.length?Yi(e,L(i,2),En):r}var ew=ss(function(e,i){return e*i},1),tw=xn("round"),rw=ss(function(e,i){return e-i},0);function iw(e){return e&&e.length?on(e,Ve):0}function sw(e,i){return e&&e.length?on(e,L(i,2)):0}return p.after=Oy,p.ary=Xc,p.assign=dm,p.assignIn=du,p.assignInWith=ms,p.assignWith=fm,p.at=gm,p.before=eu,p.bind=Vn,p.bindAll=bv,p.bindKey=tu,p.castArray=Uy,p.chain=Qc,p.chunk=Wf,p.compact=Jf,p.concat=Gf,p.cond=_v,p.conforms=Ev,p.constant=Zn,p.countBy=iy,p.create=ym,p.curry=ru,p.curryRight=iu,p.debounce=su,p.defaults=mm,p.defaultsDeep=vm,p.defer=Ry,p.delay=Ay,p.difference=Qf,p.differenceBy=Yf,p.differenceWith=Zf,p.drop=Xf,p.dropRight=eg,p.dropRightWhile=tg,p.dropWhile=rg,p.fill=ig,p.filter=ny,p.flatMap=cy,p.flatMapDeep=uy,p.flatMapDepth=hy,p.flatten=Kc,p.flattenDeep=sg,p.flattenDepth=ng,p.flip=Ny,p.flow=Pv,p.flowRight=Sv,p.fromPairs=og,p.functions=Sm,p.functionsIn=Om,p.groupBy=ly,p.initial=cg,p.intersection=ug,p.intersectionBy=hg,p.intersectionWith=lg,p.invert=Am,p.invertBy=Nm,p.invokeMap=dy,p.iteratee=Xn,p.keyBy=fy,p.keys=Ae,p.keysIn=Be,p.map=ls,p.mapKeys=Cm,p.mapValues=$m,p.matches=Ov,p.matchesProperty=Rv,p.memoize=ds,p.merge=xm,p.mergeWith=fu,p.method=Av,p.methodOf=Nv,p.mixin=eo,p.negate=fs,p.nthArg=Cv,p.omit=Dm,p.omitBy=Fm,p.once=Ty,p.orderBy=gy,p.over=$v,p.overArgs=Cy,p.overEvery=xv,p.overSome=Dv,p.partial=Kn,p.partialRight=nu,p.partition=yy,p.pick=jm,p.pickBy=gu,p.property=Eu,p.propertyOf=Fv,p.pull=gg,p.pullAll=Jc,p.pullAllBy=yg,p.pullAllWith=mg,p.pullAt=vg,p.range=jv,p.rangeRight=qv,p.rearg=$y,p.reject=wy,p.remove=wg,p.rest=xy,p.reverse=Hn,p.sampleSize=_y,p.set=Um,p.setWith=Mm,p.shuffle=Ey,p.slice=bg,p.sortBy=Sy,p.sortedUniq=Rg,p.sortedUniqBy=Ag,p.split=cv,p.spread=Dy,p.tail=Ng,p.take=Tg,p.takeRight=Cg,p.takeRightWhile=$g,p.takeWhile=xg,p.tap=Jg,p.throttle=Fy,p.thru=hs,p.toArray=hu,p.toPairs=yu,p.toPairsIn=mu,p.toPath=zv,p.toPlainObject=pu,p.transform=Lm,p.unary=jy,p.union=Dg,p.unionBy=Fg,p.unionWith=jg,p.uniq=qg,p.uniqBy=Ug,p.uniqWith=Mg,p.unset=km,p.unzip=Bn,p.unzipWith=Gc,p.update=zm,p.updateWith=Hm,p.values=Tr,p.valuesIn=Bm,p.without=Lg,p.words=bu,p.wrap=qy,p.xor=kg,p.xorBy=zg,p.xorWith=Hg,p.zip=Bg,p.zipObject=Vg,p.zipObjectDeep=Kg,p.zipWith=Wg,p.entries=yu,p.entriesIn=mu,p.extend=du,p.extendWith=ms,eo(p,p),p.add=Bv,p.attempt=_u,p.camelCase=Jm,p.capitalize=vu,p.ceil=Vv,p.clamp=Vm,p.clone=My,p.cloneDeep=ky,p.cloneDeepWith=zy,p.cloneWith=Ly,p.conformsTo=Hy,p.deburr=wu,p.defaultTo=Iv,p.divide=Kv,p.endsWith=Gm,p.eq=yt,p.escape=Qm,p.escapeRegExp=Ym,p.every=sy,p.find=oy,p.findIndex=Bc,p.findKey=wm,p.findLast=ay,p.findLastIndex=Vc,p.findLastKey=bm,p.floor=Wv,p.forEach=Yc,p.forEachRight=Zc,p.forIn=_m,p.forInRight=Em,p.forOwn=Im,p.forOwnRight=Pm,p.get=Gn,p.gt=By,p.gte=Vy,p.has=Rm,p.hasIn=Qn,p.head=Wc,p.identity=Ve,p.includes=py,p.indexOf=ag,p.inRange=Km,p.invoke=Tm,p.isArguments=ar,p.isArray=K,p.isArrayBuffer=Ky,p.isArrayLike=He,p.isArrayLikeObject=Ee,p.isBoolean=Wy,p.isBuffer=Jt,p.isDate=Jy,p.isElement=Gy,p.isEmpty=Qy,p.isEqual=Yy,p.isEqualWith=Zy,p.isError=Wn,p.isFinite=Xy,p.isFunction=xt,p.isInteger=ou,p.isLength=gs,p.isMap=au,p.isMatch=em,p.isMatchWith=tm,p.isNaN=rm,p.isNative=im,p.isNil=nm,p.isNull=sm,p.isNumber=cu,p.isObject=be,p.isObjectLike=_e,p.isPlainObject=hi,p.isRegExp=Jn,p.isSafeInteger=om,p.isSet=uu,p.isString=ys,p.isSymbol=Ze,p.isTypedArray=Nr,p.isUndefined=am,p.isWeakMap=cm,p.isWeakSet=um,p.join=pg,p.kebabCase=Zm,p.last=ut,p.lastIndexOf=dg,p.lowerCase=Xm,p.lowerFirst=ev,p.lt=hm,p.lte=lm,p.max=Jv,p.maxBy=Gv,p.mean=Qv,p.meanBy=Yv,p.min=Zv,p.minBy=Xv,p.stubArray=ro,p.stubFalse=io,p.stubObject=Uv,p.stubString=Mv,p.stubTrue=Lv,p.multiply=ew,p.nth=fg,p.noConflict=Tv,p.noop=to,p.now=ps,p.pad=tv,p.padEnd=rv,p.padStart=iv,p.parseInt=sv,p.random=Wm,p.reduce=my,p.reduceRight=vy,p.repeat=nv,p.replace=ov,p.result=qm,p.round=tw,p.runInContext=m,p.sample=by,p.size=Iy,p.snakeCase=av,p.some=Py,p.sortedIndex=_g,p.sortedIndexBy=Eg,p.sortedIndexOf=Ig,p.sortedLastIndex=Pg,p.sortedLastIndexBy=Sg,p.sortedLastIndexOf=Og,p.startCase=uv,p.startsWith=hv,p.subtract=rw,p.sum=iw,p.sumBy=sw,p.template=lv,p.times=kv,p.toFinite=Dt,p.toInteger=W,p.toLength=lu,p.toLower=pv,p.toNumber=ht,p.toSafeInteger=pm,p.toString=se,p.toUpper=dv,p.trim=fv,p.trimEnd=gv,p.trimStart=yv,p.truncate=mv,p.unescape=vv,p.uniqueId=Hv,p.upperCase=wv,p.upperFirst=Yn,p.each=Yc,p.eachRight=Zc,p.first=Wc,eo(p,function(){var e={};return _t(p,function(i,n){oe.call(p.prototype,n)||(e[n]=i)}),e}(),{chain:!1}),p.VERSION=s,st(["bind","bindKey","curry","curryRight","partial","partialRight"],function(e){p[e].placeholder=p}),st(["drop","take"],function(e,i){X.prototype[e]=function(n){n=n===r?1:Re(W(n),0);var c=this.__filtered__&&!i?new X(this):this.clone();return c.__filtered__?c.__takeCount__=Fe(n,c.__takeCount__):c.__views__.push({size:Fe(n,De),type:e+(c.__dir__<0?"Right":"")}),c},X.prototype[e+"Right"]=function(n){return this.reverse()[e](n).reverse()}}),st(["filter","map","takeWhile"],function(e,i){var n=i+1,c=n==E||n==J;X.prototype[e]=function(h){var d=this.clone();return d.__iteratees__.push({iteratee:L(h,3),type:n}),d.__filtered__=d.__filtered__||c,d}}),st(["head","last"],function(e,i){var n="take"+(i?"Right":"");X.prototype[e]=function(){return this[n](1).value()[0]}}),st(["initial","tail"],function(e,i){var n="drop"+(i?"":"Right");X.prototype[e]=function(){return this.__filtered__?new X(this):this[n](1)}}),X.prototype.compact=function(){return this.filter(Ve)},X.prototype.find=function(e){return this.filter(e).head()},X.prototype.findLast=function(e){return this.reverse().find(e)},X.prototype.invokeMap=Q(function(e,i){return typeof e=="function"?new X(this):this.map(function(n){return si(n,e,i)})}),X.prototype.reject=function(e){return this.filter(fs(L(e)))},X.prototype.slice=function(e,i){e=W(e);var n=this;return n.__filtered__&&(e>0||i<0)?new X(n):(e<0?n=n.takeRight(-e):e&&(n=n.drop(e)),i!==r&&(i=W(i),n=i<0?n.dropRight(-i):n.take(i-e)),n)},X.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},X.prototype.toArray=function(){return this.take(De)},_t(X.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 g=this.__wrapped__,y=c?[1]:arguments,v=g instanceof X,S=y[0],O=v||K(g),A=function(Z){var ee=h.apply(p,kt([Z],y));return c&&D?ee[0]:ee};O&&n&&typeof S=="function"&&S.length!=1&&(v=O=!1);var D=this.__chain__,U=!!this.__actions__.length,k=d&&!D,G=v&&!U;if(!d&&O){g=G?g:new X(this);var z=e.apply(g,y);return z.__actions__.push({func:hs,args:[A],thisArg:r}),new ot(z,D)}return k&&G?e.apply(this,y):(z=this.thru(A),k?c?z.value()[0]:z.value():z)})}),st(["pop","push","shift","sort","splice","unshift"],function(e){var i=ji[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(K(d)?d:[],h)}return this[n](function(g){return i.apply(K(g)?g:[],h)})}}),_t(X.prototype,function(e,i){var n=p[i];if(n){var c=n.name+"";oe.call(Pr,c)||(Pr[c]=[]),Pr[c].push({name:i,func:n})}}),Pr[is(r,Y).name]=[{name:"wrapper",func:r}],X.prototype.clone=md,X.prototype.reverse=vd,X.prototype.value=wd,p.prototype.at=Gg,p.prototype.chain=Qg,p.prototype.commit=Yg,p.prototype.next=Zg,p.prototype.plant=ey,p.prototype.reverse=ty,p.prototype.toJSON=p.prototype.valueOf=p.prototype.value=ry,p.prototype.first=p.prototype.head,Yr&&(p.prototype[Yr]=Xg),p},_r=Qp();Xt?((Xt.exports=_r)._=_r,Zs._=_r):Ce._=_r}).call(mi)})(Co,Co.exports);var cI=Object.defineProperty,uI=Object.defineProperties,hI=Object.getOwnPropertyDescriptors,Sh=Object.getOwnPropertySymbols,lI=Object.prototype.hasOwnProperty,pI=Object.prototype.propertyIsEnumerable,Oh=(o,t,r)=>t in o?cI(o,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[t]=r,bs=(o,t)=>{for(var r in t||(t={}))lI.call(t,r)&&Oh(o,r,t[r]);if(Sh)for(var r of Sh(t))pI.call(t,r)&&Oh(o,r,t[r]);return o},dI=(o,t)=>uI(o,hI(t));function Yt(o,t,r){var s;const a=k0(o);return((s=t.rpcMap)==null?void 0:s[a.reference])||`${aI}?chainId=${a.namespace}:${a.reference}&projectId=${r}`}function fr(o){return o.includes(":")?o.split(":")[1]:o}function dl(o){return o.map(t=>`${t.split(":")[0]}:${t.split(":")[1]}`)}function fI(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 gI(o={},t={}){const r=Rh(o),s=Rh(t);return Co.exports.merge(r,s)}function Rh(o){var t,r,s,a;const u={};if(!Dr(o))return u;for(const[l,f]of Object.entries(o)){const w=ko(l)?[l]:f.chains,_=f.methods||[],T=f.events||[],R=f.rpcMap||{},N=vi(l);u[N]=dI(bs(bs({},u[N]),f),{chains:ao(w,(t=u[N])==null?void 0:t.chains),methods:ao(_,(r=u[N])==null?void 0:r.methods),events:ao(T,(s=u[N])==null?void 0:s.events),rpcMap:bs(bs({},R),(a=u[N])==null?void 0:a.rpcMap)})}return u}function yI(o){return o.includes(":")?o.split(":")[2]:o}function mI(o){const t={};for(const[r,s]of Object.entries(o)){const a=s.methods||[],u=s.events||[],l=s.accounts||[],f=ko(r)?[r]:s.chains?s.chains:dl(s.accounts);t[r]={chains:f,methods:a,events:u,accounts:l}}return t}function go(o){return typeof o=="number"?o:o.includes("0x")?parseInt(o,16):o.includes(":")?Number(o.split(":")[1]):Number(o)}const fl={},ye=o=>fl[o],yo=(o,t)=>{fl[o]=t};class vI{constructor(t){this.name="polkadot",this.namespace=t.namespace,this.events=ye("events"),this.client=ye("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(Mt.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=fr(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||Yt(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new Ut(new Zt(s,ye("disableProviderPing")))}}class wI{constructor(t){this.name="eip155",this.namespace=t.namespace,this.events=ye("events"),this.client=ye("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(Mt.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||Yt(`${this.name}:${t}`,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new Ut(new Zt(s,ye("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(fr(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 bI{constructor(t){this.name="solana",this.namespace=t.namespace,this.events=ye("events"),this.client=ye("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(Mt.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=fr(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||Yt(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new Ut(new Zt(s,ye("disableProviderPing")))}}class _I{constructor(t){this.name="cosmos",this.namespace=t.namespace,this.events=ye("events"),this.client=ye("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(Mt.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=fr(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||Yt(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new Ut(new Zt(s,ye("disableProviderPing")))}}class EI{constructor(t){this.name="cip34",this.namespace=t.namespace,this.events=ye("events"),this.client=ye("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(Mt.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=fr(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 Ut(new Zt(s,ye("disableProviderPing")))}}class II{constructor(t){this.name="elrond",this.namespace=t.namespace,this.events=ye("events"),this.client=ye("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(Mt.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=fr(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||Yt(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new Ut(new Zt(s,ye("disableProviderPing")))}}class PI{constructor(t){this.name="multiversx",this.namespace=t.namespace,this.events=ye("events"),this.client=ye("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(Mt.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=fr(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||Yt(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new Ut(new Zt(s,ye("disableProviderPing")))}}class SI{constructor(t){this.name="near",this.namespace=t.namespace,this.events=ye("events"),this.client=ye("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||Yt(`${this.name}:${t}`,this.namespace);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);this.setHttpProvider(t,s)}this.events.emit(Mt.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||Yt(t,this.namespace);return typeof s>"u"?void 0:new Ut(new Zt(s,ye("disableProviderPing")))}}var OI=Object.defineProperty,RI=Object.defineProperties,AI=Object.getOwnPropertyDescriptors,Ah=Object.getOwnPropertySymbols,NI=Object.prototype.hasOwnProperty,TI=Object.prototype.propertyIsEnumerable,Nh=(o,t,r)=>t in o?OI(o,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[t]=r,_s=(o,t)=>{for(var r in t||(t={}))NI.call(t,r)&&Nh(o,r,t[r]);if(Ah)for(var r of Ah(t))TI.call(t,r)&&Nh(o,r,t[r]);return o},mo=(o,t)=>RI(o,AI(t));class Ko{constructor(t){this.events=new H.Ct,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:I.ot(I.k({level:(t==null?void 0:t.logger)||Ih})),this.disableProviderPing=(t==null?void 0:t.disableProviderPing)||!1}static async init(t){const r=new Ko(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:_s({},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,I.formatJsonRpcResult(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:Pe("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=mI(u.namespaces),this.persist("namespaces",this.namespaces))}).catch(u=>{if(u.message!==ll)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 KE.init({logger:this.providerOpts.logger||Ih,relayUrl:this.providerOpts.relayUrl||sI,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=>vi(r)))];yo("client",this.client),yo("events",this.events),yo("disableProviderPing",this.disableProviderPing),t.forEach(r=>{if(!this.session)return;const s=fI(r,this.session),a=dl(s),u=gI(this.namespaces,this.optionalNamespaces),l=mo(_s({},u[r]),{accounts:s,chains:a});switch(r){case"eip155":this.rpcProviders[r]=new wI({namespace:l});break;case"solana":this.rpcProviders[r]=new bI({namespace:l});break;case"cosmos":this.rpcProviders[r]=new _I({namespace:l});break;case"polkadot":this.rpcProviders[r]=new vI({namespace:l});break;case"cip34":this.rpcProviders[r]=new EI({namespace:l});break;case"elrond":this.rpcProviders[r]=new II({namespace:l});break;case"multiversx":this.rpcProviders[r]=new PI({namespace:l});break;case"near":this.rpcProviders[r]=new SI({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(yI))}else if(s.name==="chainChanged"){const a=r.chainId,u=r.event.data,l=vi(a),f=go(a)!==go(u)?`${l}:${go(u)}`:a;this.onChainChanged(f)}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=mo(_s({},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",mo(_s({},Pe("USER_DISCONNECTED")),{data:t.topic}))}),this.on(Mt.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=>vi(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=vi(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(`${Ph}/${t}`,r)}async getFromStore(t){return await this.client.core.storage.getItem(`${Ph}/${t}`)}}const CI=Ko,$I="wc",xI="ethereum_provider",DI=`${$I}@2:${xI}:`,FI="https://rpc.walletconnect.com/v1/",Rs=["eth_sendTransaction","personal_sign"],gl=["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"],As=["chainChanged","accountsChanged"],yl=["chainChanged","accountsChanged","message","disconnect","connect"];var jI=Object.defineProperty,qI=Object.defineProperties,UI=Object.getOwnPropertyDescriptors,Th=Object.getOwnPropertySymbols,MI=Object.prototype.hasOwnProperty,LI=Object.prototype.propertyIsEnumerable,Ch=(o,t,r)=>t in o?jI(o,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[t]=r,bi=(o,t)=>{for(var r in t||(t={}))MI.call(t,r)&&Ch(o,r,t[r]);if(Th)for(var r of Th(t))LI.call(t,r)&&Ch(o,r,t[r]);return o},$h=(o,t)=>qI(o,UI(t));function Ns(o){return Number(o[0].split(":")[1])}function vo(o){return`0x${o.toString(16)}`}function kI(o){const{chains:t,optionalChains:r,methods:s,optionalMethods:a,events:u,optionalEvents:l,rpcMap:f}=o;if(!wo(t))throw new Error("Invalid chains");const w={chains:t,methods:s||Rs,events:u||As,rpcMap:bi({},t.length?{[Ns(t)]:f[Ns(t)]}:{})},_=u==null?void 0:u.filter(M=>!As.includes(M)),T=s==null?void 0:s.filter(M=>!Rs.includes(M));if(!r&&!l&&!a&&!(_!=null&&_.length)&&!(T!=null&&T.length))return{required:t.length?w:void 0};const R=(_==null?void 0:_.length)&&(T==null?void 0:T.length)||!r,N={chains:[...new Set(R?w.chains.concat(r||[]):r)],methods:[...new Set(w.methods.concat(a!=null&&a.length?a:gl))],events:[...new Set(w.events.concat(l!=null&&l.length?l:yl))],rpcMap:f};return{required:t.length?w:void 0,optional:r.length?N:void 0}}class xs{constructor(){this.events=new H.eventsExports.EventEmitter,this.namespace="eip155",this.accounts=[],this.chainId=1,this.STORAGE_KEY=DI,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 xs;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}=kI(this.rpc);try{const a=await new Promise(async(l,f)=>{var w;this.rpc.showQrModal&&((w=this.modal)==null||w.subscribeModal(_=>{!_.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),f(new Error("Connection request reset. Please try again.")))})),await this.signer.connect($h(bi({namespaces:bi({},r&&{[this.namespace]:r})},s&&{optionalNamespaces:{[this.namespace]:s}}),{pairingTopic:t==null?void 0:t.pairingTopic})).then(_=>{l(_)}).catch(_=>{f(new Error(_.message))})});if(!a)return;const u=yw(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",$h(bi({},vw("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 f=a.length?(t==null?void 0:t.methods)||Rs:[],w=a.length?(t==null?void 0:t.events)||As:[],_=(t==null?void 0:t.optionalMethods)||[],T=(t==null?void 0:t.optionalEvents)||[],R=(t==null?void 0:t.rpcMap)||this.buildRpcMap(l,t.projectId),N=(t==null?void 0:t.qrModalOptions)||void 0;return{chains:a==null?void 0:a.map(M=>this.formatChainId(M)),optionalChains:u.map(M=>this.formatChainId(M)),methods:f,events:w,optionalMethods:_,optionalEvents:T,rpcMap:R,showQrModal:!!(t!=null&&t.showQrModal),qrModalOptions:N,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 CI.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 Promise.resolve().then(()=>require("./index-Cofatf_w.js")).then(a=>a.index);r=s}catch{throw new Error("To use QR modal, please install @walletconnect/modal package")}if(r)try{this.modal=new r(bi({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&&wo(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&&wo(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])||`${FI}?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 zI=xs;exports.EthereumProvider=zI;exports.OPTIONAL_EVENTS=yl;exports.OPTIONAL_METHODS=gl;exports.REQUIRED_EVENTS=As;exports.REQUIRED_METHODS=Rs;exports.default=xs;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { d as te, ab as el, y as It, bP as Bo, o as Nw, g as Tw } from "./index-
|
|
2
|
-
import { c as U, s as Vo, x as tl, r as rl, H as Cw, a as il, q as xs } from "./index-
|
|
3
|
-
import { c as $w, a as xw, g as ku, s as Dw, d as Fw, k as qw, b as jw, I as mr, f as Et, t as dt, e as zu, C as Uw, r as Mw, h as Lr, i as sl, j as Nt, l as js, G as Lw, E as Ge, y as rt, o as Us, m as Ms, n as Hu, p as kw, q as zw, u as Hw, v as Ko, w as Ls, x as Wo, z as er, Y as Bw, A as Vw, B as Bu, D as Kw } from "./browser-
|
|
1
|
+
import { d as te, ab as el, y as It, bP as Bo, o as Nw, g as Tw } from "./index-CdSy2Lfd.mjs";
|
|
2
|
+
import { c as U, s as Vo, x as tl, r as rl, H as Cw, a as il, q as xs } from "./index-Cp5np38p.mjs";
|
|
3
|
+
import { c as $w, a as xw, g as ku, s as Dw, d as Fw, k as qw, b as jw, I as mr, f as Et, t as dt, e as zu, C as Uw, r as Mw, h as Lr, i as sl, j as Nt, l as js, G as Lw, E as Ge, y as rt, o as Us, m as Ms, n as Hu, p as kw, q as zw, u as Hw, v as Ko, w as Ls, x as Wo, z as er, Y as Bw, A as Vw, B as Bu, D as Kw } from "./browser-33Nc32cs.mjs";
|
|
4
4
|
var he = {};
|
|
5
5
|
Object.defineProperty(he, "__esModule", { value: !0 });
|
|
6
6
|
he.getLocalStorage = he.getLocalStorageOrThrow = he.getCrypto = he.getCryptoOrThrow = he.getLocation = he.getLocationOrThrow = he.getNavigator = he.getNavigatorOrThrow = he.getDocument = he.getDocumentOrThrow = he.getFromWindowOrThrow = he.getFromWindow = void 0;
|
|
@@ -8620,7 +8620,7 @@ class ua {
|
|
|
8620
8620
|
if (this.rpc = this.getRpcConfig(t), this.chainId = this.rpc.chains.length ? qs(this.rpc.chains) : qs(this.rpc.optionalChains), this.signer = await wP.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) {
|
|
8621
8621
|
let r;
|
|
8622
8622
|
try {
|
|
8623
|
-
const { WalletConnectModal: s } = await import("./index-
|
|
8623
|
+
const { WalletConnectModal: s } = await import("./index-DGRaAUXo.mjs").then((a) => a.i);
|
|
8624
8624
|
r = s;
|
|
8625
8625
|
} catch {
|
|
8626
8626
|
throw new Error("To use QR modal, please install @walletconnect/modal package");
|
package/lib/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./index-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./index-Tl7zYqHL.js");exports.MAINNET=e.MAINNET;exports.TESTNET=e.TESTNET;exports.dark=e.dark;exports.default=e.WormholeConnect;exports.light=e.light;
|
package/lib/index.mjs
CHANGED