@wormhole-foundation/wormhole-connect 0.3.22-beta.6-development → 0.3.23-beta.0-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-kFE7Egv7.js → ccip-BOQxYwA4.js} +1 -1
- package/dist/assets/cosmos-DpJHRy9R.js +38 -0
- package/dist/assets/{cosmwasm-K-vi4me_.js → cosmwasm-Dngp91th.js} +3 -3
- package/dist/assets/{ens-validation.es6-BaHGKtnQ.js → ens-validation.es6-DY5iRcEw.js} +1 -1
- package/dist/assets/{evm-DyQ3Up1i.js → evm-CXBiqSp9.js} +26 -26
- package/dist/assets/{index-Dqd4pSig.js → index-BhecnthD.js} +1 -1
- package/dist/assets/{index-EkdPNlSn.js → index-BphOrDO3.js} +1 -1
- package/dist/assets/index-BqmJ5ps2.js +3 -0
- package/dist/assets/{index-6ERMnMWg.js → index-CX56YBaw.js} +1 -1
- package/dist/assets/{index-Ci7BRqEw.js → index-DBB96cBs.js} +2 -2
- package/dist/assets/{index-BC4s7rDX.js → index-DwWFp7_d.js} +1 -1
- package/dist/assets/{index.es-BnzPN21S.js → index.es-BWLyUn8A.js} +2 -2
- package/dist/assets/{solana-D0TX7DHf.js → solana-C3hk0iY4.js} +2 -2
- package/dist/assets/{solanaEmbed.esm-CBOtlgbY.js → solanaEmbed.esm-Bzvc2Yau.js} +1 -1
- package/dist/assets/{unsignedTransaction-CWlZwFZw.js → unsignedTransaction-DhgJ038I.js} +1 -1
- package/dist/main.js +9 -9
- package/dist/src/utils/wallet/evm.d.ts.map +1 -1
- package/lib/{algorand-DjUTtqxk.mjs → algorand-kK-8oojN.mjs} +4 -4
- package/lib/{algorand-BgVfTPrs.js → algorand-mZNvVCps.js} +1 -1
- package/lib/{aptos-xxNUHC8o.mjs → aptos-C8ttM75J.mjs} +4 -4
- package/lib/{aptos-JOeRwo7r.js → aptos-CfDDJUg1.js} +2 -2
- package/lib/{aptos-CVVZJ32U.js → aptos-Dct_m6Gg.js} +1 -1
- package/lib/{aptos-BmyHkXb6.mjs → aptos-DgRBytsM.mjs} +1 -1
- package/lib/{browser-B_2ji4LP.mjs → browser-Bf0arMap.mjs} +2 -2
- package/lib/{browser-EzqecQNA.js → browser-DVTB-WO0.js} +1 -1
- package/lib/{browser-ponyfill-yx2re7P5.mjs → browser-ponyfill-BBGnYIgf.mjs} +1 -1
- package/lib/{browser-ponyfill-DH_DuJjr.js → browser-ponyfill-CtGm2L9z.js} +1 -1
- package/lib/{ccip-B2atrHiU.js → ccip-BQ7Z_goB.js} +1 -1
- package/lib/{ccip-JjlhOiF-.mjs → ccip-DzflCjUZ.mjs} +1 -1
- package/lib/{chain-BE2gm6l5.mjs → chain-D1Ms6bPc.mjs} +1 -1
- package/lib/{chain-Ck_2P-B0.js → chain-HMnpkrbl.js} +1 -1
- package/lib/{cosmos-BqA6T2gQ.mjs → cosmos-BIzn30Lo.mjs} +6 -6
- package/lib/cosmos-DFeWBfwa.js +38 -0
- package/lib/{cosmwasm-dpMbVaHd.mjs → cosmwasm-CYZkMUNw.mjs} +6 -6
- package/lib/{cosmwasm-D8-LmG14.js → cosmwasm-Cw-jZjyR.js} +2 -2
- package/lib/{create-CONoHCNu.js → create-BjUw-7kj.js} +1 -1
- package/lib/{create-NSzn0Mjd.mjs → create-D7KM2TbJ.mjs} +1 -1
- package/lib/{ens-validation.es6-DQMHfHaf.js → ens-validation.es6-CSendvHo.js} +1 -1
- package/lib/{ens-validation.es6-SwNVNlnL.mjs → ens-validation.es6-CtTsD9-1.mjs} +2 -2
- package/lib/{evm-BzbkH6iw.mjs → evm-2ARfiEbk.mjs} +6 -6
- package/lib/{evm-DQDZ6407.js → evm-CyCIXNVR.js} +22 -22
- package/lib/{evm-D7ExbjR0.mjs → evm-WeYh1CwH.mjs} +1588 -1596
- package/lib/{evm-CNyEgAvC.js → evm-vq8ExBtp.js} +2 -2
- package/lib/{index-BRY7PwCe.mjs → index-4Diyx7dk.mjs} +3 -3
- package/lib/{index-CHDQPgcS.mjs → index-6g1GFCCq.mjs} +2 -2
- package/lib/{index-Dz2gv_XI.mjs → index-9ZdnzH2d.mjs} +5 -5
- package/lib/{index-DzX0K2kv.js → index-B1oIabF3.js} +1 -1
- package/lib/{index-BiJV97Xz.js → index-B3xO-Vlp.js} +1 -1
- package/lib/{index-BG34ZjNr.mjs → index-B4Wo5ciI.mjs} +4 -4
- package/lib/{index-NS46gHyL.js → index-B9iI7y0N.js} +1 -1
- package/lib/{index-uwGV-Vn3.js → index-BC9O3q0O.js} +1 -1
- package/lib/{index-eFtXd025.mjs → index-BFLX4WxO.mjs} +4 -4
- package/lib/{index-gM7Zj76T.js → index-BPsT8R1K.js} +1 -1
- package/lib/{index-7ZAqkUlU.mjs → index-BSAsS8RD.mjs} +1 -1
- package/lib/{index-CD_ekrEI.mjs → index-BYDoWQJF.mjs} +4 -4
- package/lib/{index-XH2z1iXX.mjs → index-BaO4Z093.mjs} +3 -3
- package/lib/{index-Bd6oWjRV.mjs → index-BeO_qTcl.mjs} +2 -2
- package/lib/{index-wj32vNhH.js → index-BhOoVwl8.js} +1 -1
- package/lib/{index-DvQrjwKV.mjs → index-BtObdPhn.mjs} +4 -4
- package/lib/{index-DW-MTqZy.mjs → index-BzX2BW_O.mjs} +4 -4
- package/lib/{index-BgYENi3t.js → index-C2c8vR42.js} +1 -1
- package/lib/{index-6ZiA60gP.js → index-C2oD47lT.js} +1 -1
- package/lib/{index-DQR7qDM7.mjs → index-C6mDtHMX.mjs} +86 -88
- package/lib/{index-hyVeTz05.js → index-C9SlTWZB.js} +1 -1
- package/lib/{index-BYInpg-j.js → index-CHc9Fnxq.js} +1 -1
- package/lib/{index-Dh1gwYHK.js → index-CIbWgDdT.js} +1 -1
- package/lib/{index-ClJ9xKH_.js → index-CJWNAIq4.js} +1 -1
- package/lib/{index-SL51oRv6.mjs → index-CK0z65I9.mjs} +4 -4
- package/lib/{index-BNxdQt8p.js → index-CMB6PdWJ.js} +1 -1
- package/lib/{index-BozvRZRr.mjs → index-CMxa7eqf.mjs} +5 -5
- package/lib/{index-CeTuOmVc.mjs → index-CNSXR9tB.mjs} +5 -5
- package/lib/{index-BCRhQQj3.mjs → index-CV1VV-zJ.mjs} +3 -3
- package/lib/{index-B3EOWCDT.js → index-CxrhBQyI.js} +1 -1
- package/lib/{index-BS-5mncz.mjs → index-CyGeUScn.mjs} +5 -5
- package/lib/index-D5ZI8OQ5.js +3 -0
- package/lib/{index-DsuNqUD-.mjs → index-DAY2C3ja.mjs} +4 -4
- package/lib/{index-Ci2ZLtDV.js → index-DHPvJyI7.js} +1 -1
- package/lib/{index-THgGZbp0.js → index-DMbFl-Wn.js} +1 -1
- package/lib/{index-DkLEkXih.mjs → index-DVFnDDyZ.mjs} +4 -4
- package/lib/{index-DuiRxqsN.js → index-DjAqAqeU.js} +1 -1
- package/lib/{index-9m7TBK6v.mjs → index-EqiiaA9-.mjs} +4 -4
- package/lib/{index-BRSYiZGo.js → index-GooDQIzI.js} +1 -1
- package/lib/{index-BtH96J3O.mjs → index-IQlvm76i.mjs} +72 -72
- package/lib/{index-iNOxku8i.js → index-Jgr_mZ4Y.js} +1 -1
- package/lib/{index-D4hS9TeC.js → index-L9bSVF77.js} +1 -1
- package/lib/{index-Rl2MOwgU.mjs → index-f8fcieOQ.mjs} +4 -4
- package/lib/{index-C7tR7eyI.js → index-k5MpmioF.js} +1 -1
- package/lib/{index-_YUXIUK8.js → index-nxd7L_DD.js} +1 -1
- package/lib/{index-GGqf7rB-.mjs → index-qsqnFs3a.mjs} +2 -2
- package/lib/{index-Dh6Zmu7D.js → index-rtZ91I3M.js} +8 -8
- package/lib/{index-Fv3-CE1p.mjs → index-yG0Rs8Eb.mjs} +2 -2
- package/lib/{index.es-CKpdDKzf.mjs → index.es-CEImaU7l.mjs} +5 -5
- package/lib/{index.es-Bj1J4jCu.js → index.es-gwZvea5f.js} +2 -2
- package/lib/index.js +1 -1
- package/lib/index.mjs +1 -1
- package/lib/{libsodium-wrappers-Dta7f8ar.js → libsodium-wrappers-Bez_KKB1.js} +1 -1
- package/lib/{libsodium-wrappers-B_H4aRTY.mjs → libsodium-wrappers-Cz0uCBox.mjs} +1 -1
- package/lib/{sei-UDsMKtbc.mjs → sei-BYR1KxHW.mjs} +2 -2
- package/lib/{sei-DGdkVzbE.js → sei-BrTMqCke.js} +1 -1
- package/lib/{solana-CkviJVw5.js → solana-0RqhvUa1.js} +1 -1
- package/lib/{solana-DPaJOryR.mjs → solana-BLtdLKKq.mjs} +3 -3
- package/lib/{solana-C9YVHn-W.mjs → solana-CRbkLsWk.mjs} +6 -6
- package/lib/{solana-BZhGAwx6.js → solana-D3NR_tHO.js} +2 -2
- package/lib/{solanaEmbed.esm-DnssMltk.mjs → solanaEmbed.esm-CaR2Md_k.mjs} +2 -2
- package/lib/{solanaEmbed.esm-C0UDKbGU.js → solanaEmbed.esm-E-eNJK6U.js} +1 -1
- package/lib/src/utils/wallet/evm.d.ts.map +1 -1
- package/lib/{sui-8btJKilJ.mjs → sui-BZ_uS8zP.mjs} +1 -1
- package/lib/{sui-c83-J_ow.js → sui-CErMMm5A.js} +2 -2
- package/lib/{sui-CUfyUGKk.mjs → sui-DeoYmh3N.mjs} +4 -4
- package/lib/{sui-6-wJdSqv.js → sui-T81Wy4dP.js} +1 -1
- package/lib/{unsignedTransaction-CWjweDuU.js → unsignedTransaction-DCa77QzH.js} +1 -1
- package/lib/{unsignedTransaction-C293HA6V.mjs → unsignedTransaction-DJSAg3zT.mjs} +2 -2
- package/package.json +1 -1
- package/dist/assets/cosmos-BUbSl2Zd.js +0 -38
- package/dist/assets/index-5a-xin_S.js +0 -3
- package/lib/cosmos-arjQyma2.js +0 -38
- package/lib/index-CgyVAtoK.js +0 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { P as e, T as f, A as c } from "./solana-
|
|
2
|
-
import { aJ as O, aK as s, cO as o, cM as d, aM as A, cN as p } from "./index-
|
|
1
|
+
import { P as e, T as f, A as c } from "./solana-CRbkLsWk.mjs";
|
|
2
|
+
import { aJ as O, aK as s, cO as o, cM as d, aM as A, cN as p } from "./index-C6mDtHMX.mjs";
|
|
3
3
|
class m extends Error {
|
|
4
4
|
constructor(r) {
|
|
5
5
|
super(r);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ac as Mh, y as gt, d as ee, cq as To } from "./index-
|
|
2
|
-
import { c as F, s as xo, x as Lh, r as kh, H as Ew, a as zh, q as Ss } from "./index-
|
|
3
|
-
import { I as lr, f as ft, t as nt, c as Nu, C as Iw, r as Pw, a as Dr, g as Hh, i as bt, b as Cs, G as Sw, E as ke, y as Qe, o as $s, k as As, h as Ow, d as Cu, e as Rw, s as Nw, j as Cw, l as Do, m as Ts, n as Fo, p as Wt, Y as $w, q as Aw, u as $u, v as Tw } from "./browser-
|
|
4
|
-
import { o as Au } from "./browser-ponyfill-
|
|
1
|
+
import { ac as Mh, y as gt, d as ee, cq as To } from "./index-C6mDtHMX.mjs";
|
|
2
|
+
import { c as F, s as xo, x as Lh, r as kh, H as Ew, a as zh, q as Ss } from "./index-BSAsS8RD.mjs";
|
|
3
|
+
import { I as lr, f as ft, t as nt, c as Nu, C as Iw, r as Pw, a as Dr, g as Hh, i as bt, b as Cs, G as Sw, E as ke, y as Qe, o as $s, k as As, h as Ow, d as Cu, e as Rw, s as Nw, j as Cw, l as Do, m as Ts, n as Fo, p as Wt, Y as $w, q as Aw, u as $u, v as Tw } from "./browser-Bf0arMap.mjs";
|
|
4
|
+
import { o as Au } from "./browser-ponyfill-BBGnYIgf.mjs";
|
|
5
5
|
var se = {};
|
|
6
6
|
Object.defineProperty(se, "__esModule", { value: !0 });
|
|
7
7
|
se.getLocalStorage = se.getLocalStorageOrThrow = se.getCrypto = se.getCryptoOrThrow = se.getLocation = se.getLocationOrThrow = se.getNavigator = se.getNavigatorOrThrow = se.getDocument = se.getDocumentOrThrow = se.getFromWindowOrThrow = se.getFromWindow = void 0;
|
|
@@ -8194,7 +8194,7 @@ class Qo {
|
|
|
8194
8194
|
if (this.rpc = this.getRpcConfig(t), this.chainId = this.rpc.chains.length ? Ns(this.rpc.chains) : Ns(this.rpc.optionalChains), this.signer = await QI.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) {
|
|
8195
8195
|
let r;
|
|
8196
8196
|
try {
|
|
8197
|
-
const { WalletConnectModal: s } = await import("./index-
|
|
8197
|
+
const { WalletConnectModal: s } = await import("./index-BeO_qTcl.mjs").then((a) => a.i);
|
|
8198
8198
|
r = s;
|
|
8199
8199
|
} catch {
|
|
8200
8200
|
throw new Error("To use QR modal, please install @walletconnect/modal package");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=require("./index-rtZ91I3M.js"),T=require("./index-GooDQIzI.js"),I=require("./browser-DVTB-WO0.js"),lu=require("./browser-ponyfill-CtGm2L9z.js");var ne={};Object.defineProperty(ne,"__esModule",{value:!0});ne.getLocalStorage=ne.getLocalStorageOrThrow=ne.getCrypto=ne.getCryptoOrThrow=ne.getLocation=ne.getLocationOrThrow=ne.getNavigator=ne.getNavigatorOrThrow=ne.getDocument=ne.getDocumentOrThrow=ne.getFromWindowOrThrow=ne.getFromWindow=void 0;function nr(o){let t;return typeof window<"u"&&typeof window[o]<"u"&&(t=window[o]),t}ne.getFromWindow=nr;function Cr(o){const t=nr(o);if(!t)throw new Error(`${o} is not defined in Window`);return t}ne.getFromWindowOrThrow=Cr;function Xm(){return Cr("document")}ne.getDocumentOrThrow=Xm;function ew(){return nr("document")}ne.getDocument=ew;function tw(){return Cr("navigator")}ne.getNavigatorOrThrow=tw;function rw(){return nr("navigator")}ne.getNavigator=rw;function iw(){return Cr("location")}ne.getLocationOrThrow=iw;function sw(){return nr("location")}ne.getLocation=sw;function nw(){return Cr("crypto")}ne.getCryptoOrThrow=nw;function ow(){return nr("crypto")}ne.getCrypto=ow;function aw(){return Cr("localStorage")}ne.getLocalStorageOrThrow=aw;function cw(){return nr("localStorage")}ne.getLocalStorage=cw;var _o={};Object.defineProperty(_o,"__esModule",{value:!0});_o.getWindowMetadata=void 0;const pu=ne;function uw(){let o,t;try{o=pu.getDocumentOrThrow(),t=pu.getLocationOrThrow()}catch{return null}function r(){const O=o.getElementsByTagName("link"),N=[];for(let q=0;q<O.length;q++){const D=O[q],K=D.getAttribute("rel");if(K&&K.toLowerCase().indexOf("icon")>-1){const F=D.getAttribute("href");if(F)if(F.toLowerCase().indexOf("https:")===-1&&F.toLowerCase().indexOf("http:")===-1&&F.indexOf("//")!==0){let G=t.protocol+"//"+t.host;if(F.indexOf("/")===0)G+=F;else{const de=t.pathname.split("/");de.pop();const Z=de.join("/");G+=Z+"/"+F}N.push(G)}else if(F.indexOf("//")===0){const G=t.protocol+F;N.push(G)}else N.push(F)}}return N}function s(...O){const N=o.getElementsByTagName("meta");for(let q=0;q<N.length;q++){const D=N[q],K=["itemprop","property","name"].map(F=>D.getAttribute(F)).filter(F=>F?O.includes(F):!1);if(K.length&&K){const F=D.getAttribute("content");if(F)return F}}return""}function a(){let O=s("name","og:site_name","og:title","twitter:title");return O||(O=o.title),O}function u(){return s("description","og:description","twitter:description","keywords")}const l=a(),g=u(),w=t.origin,b=r();return{description:g,url:w,icons:b,name:l}}_o.getWindowMetadata=uw;function hw(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 lw={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 pw(o,t){const{message:r,code:s}=lw[o];return{message:r,code:s}}function ao(o,t){return!!Array.isArray(o)}var $r={};/*! *****************************************************************************
|
|
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 += '`),Y&&(R+=`' +
|
|
|
43
43
|
function print() { __p += __j.call(arguments, '') }
|
|
44
44
|
`:`;
|
|
45
45
|
`)+R+`return __p
|
|
46
|
-
}`;var B=cu(function(){return ee(d,j+"return "+R).apply(r,f)});if(B.source=R,qn(B))throw B;return B}function om(e){return te(e).toLowerCase()}function am(e){return te(e).toUpperCase()}function cm(e,i,n){if(e=te(e),e&&(n||i===r))return va(e);if(!e||!(i=Ve(i)))return e;var c=ot(e),h=ot(i),d=ma(c,h),f=wa(c,h)+1;return Lt(c,d,f).join("")}function um(e,i,n){if(e=te(e),e&&(n||i===r))return e.slice(0,ba(e)+1);if(!e||!(i=Ve(i)))return e;var c=ot(e),h=wa(c,ot(i))+1;return Lt(c,0,h).join("")}function hm(e,i,n){if(e=te(e),e&&(n||i===r))return e.replace(js,"");if(!e||!(i=Ve(i)))return e;var c=ot(e),h=ma(c,ot(i));return Lt(c,h).join("")}function lm(e,i){var n=il,c=sl;if(le(i)){var h="separator"in i?i.separator:h;n="length"in i?V(i.length):n,c="omission"in i?Ve(i.omission):c}e=te(e);var d=e.length;if(dr(e)){var f=ot(e);d=f.length}if(n>=d)return e;var y=n-fr(c);if(y<1)return c;var m=f?Lt(f,0,y).join(""):e.slice(0,y);if(h===r)return m+c;if(f&&(y+=m.length-y),Un(h)){if(e.slice(y).search(h)){var P,S=m;for(h.global||(h=Xs(h.source,te(Mo.exec(h))+"g")),h.lastIndex=0;P=h.exec(S);)var R=P.index;m=m.slice(0,R===r?y:R)}}else if(e.indexOf(Ve(h),y)!=y){var A=m.lastIndexOf(h);A>-1&&(m=m.slice(0,A))}return m+c}function pm(e){return e=te(e),e&&El.test(e)?e.replace(jo,Lp):e}var dm=br(function(e,i,n){return e+(n?" ":"")+i.toUpperCase()}),kn=uc("toUpperCase");function au(e,i,n){return e=te(e),i=n?r:i,i===r?Fp(e)?Hp(e):Op(e):e.match(i)||[]}var cu=W(function(e,i){try{return ze(e,r,i)}catch(n){return qn(n)?n:new z(n)}}),fm=Et(function(e,i){return Qe(i,function(n){n=gt(n),_t(e,n,Fn(e[n],e))}),e});function gm(e){var i=e==null?0:e.length,n=U();return e=i?ue(e,function(c){if(typeof c[1]!="function")throw new Ye(l);return[n(c[0]),c[1]]}):[],W(function(c){for(var h=-1;++h<i;){var d=e[h];if(ze(d[0],this,c))return ze(d[1],this,c)}})}function ym(e){return Ld(Xe(e,O))}function zn(e){return function(){return e}}function vm(e,i){return e==null||e!==e?i:e}var mm=lc(),wm=lc(!0);function Ue(e){return e}function Hn(e){return ka(typeof e=="function"?e:Xe(e,O))}function _m(e){return Ha(Xe(e,O))}function bm(e,i){return Va(e,Xe(i,O))}var Em=W(function(e,i){return function(n){return Qr(n,e,i)}}),Im=W(function(e,i){return function(n){return Qr(e,n,i)}});function Vn(e,i,n){var c=be(i),h=Bi(i,c);n==null&&!(le(i)&&(h.length||!c.length))&&(n=i,i=e,e=this,h=Bi(i,be(i)));var d=!(le(n)&&"chain"in n)||!!n.chain,f=Pt(e);return Qe(h,function(y){var m=i[y];e[y]=m,f&&(e.prototype[y]=function(){var P=this.__chain__;if(d||P){var S=e(this.__wrapped__),R=S.__actions__=Fe(this.__actions__);return R.push({func:m,args:arguments,thisArg:e}),S.__chain__=P,S}return m.apply(e,Dt([this.value()],arguments))})}),e}function Pm(){return Ie._===this&&(Ie._=Gp),this}function Bn(){}function Sm(e){return e=V(e),W(function(i){return Ba(i,e)})}var Om=En(ue),Rm=En(pa),Nm=En(Ks);function uu(e){return Cn(e)?Ws(gt(e)):sf(e)}function Cm(e){return function(i){return e==null?r:Zt(e,i)}}var $m=dc(),Am=dc(!0);function Kn(){return[]}function Wn(){return!1}function Tm(){return{}}function xm(){return""}function Dm(){return!0}function Fm(e,i){if(e=V(e),e<1||e>Tt)return[];var n=pt,c=Oe(e,pt);i=U(i),e-=pt;for(var h=Qs(c,i);++n<e;)i(n);return h}function jm(e){return H(e)?ue(e,gt):Be(e)?[e]:Fe(Cc(te(e)))}function qm(e){var i=++Wp;return te(e)+i}var Um=Yi(function(e,i){return e+i},0),Mm=In("ceil"),Lm=Yi(function(e,i){return e/i},1),km=In("floor");function zm(e){return e&&e.length?Vi(e,Ue,cn):r}function Hm(e,i){return e&&e.length?Vi(e,U(i,2),cn):r}function Vm(e){return ga(e,Ue)}function Bm(e,i){return ga(e,U(i,2))}function Km(e){return e&&e.length?Vi(e,Ue,pn):r}function Wm(e,i){return e&&e.length?Vi(e,U(i,2),pn):r}var Jm=Yi(function(e,i){return e*i},1),Gm=In("round"),Qm=Yi(function(e,i){return e-i},0);function Ym(e){return e&&e.length?Gs(e,Ue):0}function Zm(e,i){return e&&e.length?Gs(e,U(i,2)):0}return p.after=_y,p.ary=Lc,p.assign=av,p.assignIn=eu,p.assignInWith=hs,p.assignWith=cv,p.at=uv,p.before=kc,p.bind=Fn,p.bindAll=fm,p.bindKey=zc,p.castArray=Ty,p.chain=qc,p.chunk=kf,p.compact=zf,p.concat=Hf,p.cond=gm,p.conforms=ym,p.constant=zn,p.countBy=Yg,p.create=hv,p.curry=Hc,p.curryRight=Vc,p.debounce=Bc,p.defaults=lv,p.defaultsDeep=pv,p.defer=by,p.delay=Ey,p.difference=Vf,p.differenceBy=Bf,p.differenceWith=Kf,p.drop=Wf,p.dropRight=Jf,p.dropRightWhile=Gf,p.dropWhile=Qf,p.fill=Yf,p.filter=Xg,p.flatMap=ry,p.flatMapDeep=iy,p.flatMapDepth=sy,p.flatten=xc,p.flattenDeep=Zf,p.flattenDepth=Xf,p.flip=Iy,p.flow=mm,p.flowRight=wm,p.fromPairs=eg,p.functions=wv,p.functionsIn=_v,p.groupBy=ny,p.initial=rg,p.intersection=ig,p.intersectionBy=sg,p.intersectionWith=ng,p.invert=Ev,p.invertBy=Iv,p.invokeMap=ay,p.iteratee=Hn,p.keyBy=cy,p.keys=be,p.keysIn=qe,p.map=ss,p.mapKeys=Sv,p.mapValues=Ov,p.matches=_m,p.matchesProperty=bm,p.memoize=os,p.merge=Rv,p.mergeWith=tu,p.method=Em,p.methodOf=Im,p.mixin=Vn,p.negate=as,p.nthArg=Sm,p.omit=Nv,p.omitBy=Cv,p.once=Py,p.orderBy=uy,p.over=Om,p.overArgs=Sy,p.overEvery=Rm,p.overSome=Nm,p.partial=jn,p.partialRight=Kc,p.partition=hy,p.pick=$v,p.pickBy=ru,p.property=uu,p.propertyOf=Cm,p.pull=ug,p.pullAll=Fc,p.pullAllBy=hg,p.pullAllWith=lg,p.pullAt=pg,p.range=$m,p.rangeRight=Am,p.rearg=Oy,p.reject=dy,p.remove=dg,p.rest=Ry,p.reverse=xn,p.sampleSize=gy,p.set=Tv,p.setWith=xv,p.shuffle=yy,p.slice=fg,p.sortBy=wy,p.sortedUniq=bg,p.sortedUniqBy=Eg,p.split=rm,p.spread=Ny,p.tail=Ig,p.take=Pg,p.takeRight=Sg,p.takeRightWhile=Og,p.takeWhile=Rg,p.tap=zg,p.throttle=Cy,p.thru=is,p.toArray=Yc,p.toPairs=iu,p.toPairsIn=su,p.toPath=jm,p.toPlainObject=Xc,p.transform=Dv,p.unary=$y,p.union=Ng,p.unionBy=Cg,p.unionWith=$g,p.uniq=Ag,p.uniqBy=Tg,p.uniqWith=xg,p.unset=Fv,p.unzip=Dn,p.unzipWith=jc,p.update=jv,p.updateWith=qv,p.values=Pr,p.valuesIn=Uv,p.without=Dg,p.words=au,p.wrap=Ay,p.xor=Fg,p.xorBy=jg,p.xorWith=qg,p.zip=Ug,p.zipObject=Mg,p.zipObjectDeep=Lg,p.zipWith=kg,p.entries=iu,p.entriesIn=su,p.extend=eu,p.extendWith=hs,Vn(p,p),p.add=Um,p.attempt=cu,p.camelCase=zv,p.capitalize=nu,p.ceil=Mm,p.clamp=Mv,p.clone=xy,p.cloneDeep=Fy,p.cloneDeepWith=jy,p.cloneWith=Dy,p.conformsTo=qy,p.deburr=ou,p.defaultTo=vm,p.divide=Lm,p.endsWith=Hv,p.eq=ct,p.escape=Vv,p.escapeRegExp=Bv,p.every=Zg,p.find=ey,p.findIndex=Ac,p.findKey=dv,p.findLast=ty,p.findLastIndex=Tc,p.findLastKey=fv,p.floor=km,p.forEach=Uc,p.forEachRight=Mc,p.forIn=gv,p.forInRight=yv,p.forOwn=vv,p.forOwnRight=mv,p.get=Mn,p.gt=Uy,p.gte=My,p.has=bv,p.hasIn=Ln,p.head=Dc,p.identity=Ue,p.includes=oy,p.indexOf=tg,p.inRange=Lv,p.invoke=Pv,p.isArguments=tr,p.isArray=H,p.isArrayBuffer=Ly,p.isArrayLike=je,p.isArrayLikeObject=ge,p.isBoolean=ky,p.isBuffer=kt,p.isDate=zy,p.isElement=Hy,p.isEmpty=Vy,p.isEqual=By,p.isEqualWith=Ky,p.isError=qn,p.isFinite=Wy,p.isFunction=Pt,p.isInteger=Wc,p.isLength=cs,p.isMap=Jc,p.isMatch=Jy,p.isMatchWith=Gy,p.isNaN=Qy,p.isNative=Yy,p.isNil=Xy,p.isNull=Zy,p.isNumber=Gc,p.isObject=le,p.isObjectLike=pe,p.isPlainObject=ri,p.isRegExp=Un,p.isSafeInteger=ev,p.isSet=Qc,p.isString=us,p.isSymbol=Be,p.isTypedArray=Ir,p.isUndefined=tv,p.isWeakMap=rv,p.isWeakSet=iv,p.join=og,p.kebabCase=Kv,p.last=tt,p.lastIndexOf=ag,p.lowerCase=Wv,p.lowerFirst=Jv,p.lt=sv,p.lte=nv,p.max=zm,p.maxBy=Hm,p.mean=Vm,p.meanBy=Bm,p.min=Km,p.minBy=Wm,p.stubArray=Kn,p.stubFalse=Wn,p.stubObject=Tm,p.stubString=xm,p.stubTrue=Dm,p.multiply=Jm,p.nth=cg,p.noConflict=Pm,p.noop=Bn,p.now=ns,p.pad=Gv,p.padEnd=Qv,p.padStart=Yv,p.parseInt=Zv,p.random=kv,p.reduce=ly,p.reduceRight=py,p.repeat=Xv,p.replace=em,p.result=Av,p.round=Gm,p.runInContext=v,p.sample=fy,p.size=vy,p.snakeCase=tm,p.some=my,p.sortedIndex=gg,p.sortedIndexBy=yg,p.sortedIndexOf=vg,p.sortedLastIndex=mg,p.sortedLastIndexBy=wg,p.sortedLastIndexOf=_g,p.startCase=im,p.startsWith=sm,p.subtract=Qm,p.sum=Ym,p.sumBy=Zm,p.template=nm,p.times=Fm,p.toFinite=St,p.toInteger=V,p.toLength=Zc,p.toLower=om,p.toNumber=rt,p.toSafeInteger=ov,p.toString=te,p.toUpper=am,p.trim=cm,p.trimEnd=um,p.trimStart=hm,p.truncate=lm,p.unescape=pm,p.uniqueId=qm,p.upperCase=dm,p.upperFirst=kn,p.each=Uc,p.eachRight=Mc,p.first=Dc,Vn(p,function(){var e={};return dt(p,function(i,n){re.call(p.prototype,n)||(e[n]=i)}),e}(),{chain:!1}),p.VERSION=s,Qe(["bind","bindKey","curry","curryRight","partial","partialRight"],function(e){p[e].placeholder=p}),Qe(["drop","take"],function(e,i){Q.prototype[e]=function(n){n=n===r?1:_e(V(n),0);var c=this.__filtered__&&!i?new Q(this):this.clone();return c.__filtered__?c.__takeCount__=Oe(n,c.__takeCount__):c.__views__.push({size:Oe(n,pt),type:e+(c.__dir__<0?"Right":"")}),c},Q.prototype[e+"Right"]=function(n){return this.reverse()[e](n).reverse()}}),Qe(["filter","map","takeWhile"],function(e,i){var n=i+1,c=n==xo||n==cl;Q.prototype[e]=function(h){var d=this.clone();return d.__iteratees__.push({iteratee:U(h,3),type:n}),d.__filtered__=d.__filtered__||c,d}}),Qe(["head","last"],function(e,i){var n="take"+(i?"Right":"");Q.prototype[e]=function(){return this[n](1).value()[0]}}),Qe(["initial","tail"],function(e,i){var n="drop"+(i?"":"Right");Q.prototype[e]=function(){return this.__filtered__?new Q(this):this[n](1)}}),Q.prototype.compact=function(){return this.filter(Ue)},Q.prototype.find=function(e){return this.filter(e).head()},Q.prototype.findLast=function(e){return this.reverse().find(e)},Q.prototype.invokeMap=W(function(e,i){return typeof e=="function"?new Q(this):this.map(function(n){return Qr(n,e,i)})}),Q.prototype.reject=function(e){return this.filter(as(U(e)))},Q.prototype.slice=function(e,i){e=V(e);var n=this;return n.__filtered__&&(e>0||i<0)?new Q(n):(e<0?n=n.takeRight(-e):e&&(n=n.drop(e)),i!==r&&(i=V(i),n=i<0?n.dropRight(-i):n.take(i-e)),n)},Q.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},Q.prototype.toArray=function(){return this.take(pt)},dt(Q.prototype,function(e,i){var n=/^(?:filter|find|map|reject)|While$/.test(i),c=/^(?:head|last)$/.test(i),h=p[c?"take"+(i=="last"?"Right":""):i],d=c||/^find/.test(i);h&&(p.prototype[i]=function(){var f=this.__wrapped__,y=c?[1]:arguments,m=f instanceof Q,P=y[0],S=m||H(f),R=function(J){var Y=h.apply(p,Dt([J],y));return c&&A?Y[0]:Y};S&&n&&typeof P=="function"&&P.length!=1&&(m=S=!1);var A=this.__chain__,j=!!this.__actions__.length,M=d&&!A,B=m&&!j;if(!d&&S){f=B?f:new Q(this);var L=e.apply(f,y);return L.__actions__.push({func:is,args:[R],thisArg:r}),new Ze(L,A)}return M&&B?e.apply(this,y):(L=this.thru(R),M?c?L.value()[0]:L.value():L)})}),Qe(["pop","push","shift","sort","splice","unshift"],function(e){var i=Ci[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(H(d)?d:[],h)}return this[n](function(f){return i.apply(H(f)?f:[],h)})}}),dt(Q.prototype,function(e,i){var n=p[i];if(n){var c=n.name+"";re.call(mr,c)||(mr[c]=[]),mr[c].push({name:i,func:n})}}),mr[Qi(r,G).name]=[{name:"wrapper",func:r}],Q.prototype.clone=ld,Q.prototype.reverse=pd,Q.prototype.value=dd,p.prototype.at=Hg,p.prototype.chain=Vg,p.prototype.commit=Bg,p.prototype.next=Kg,p.prototype.plant=Jg,p.prototype.reverse=Gg,p.prototype.toJSON=p.prototype.valueOf=p.prototype.value=Qg,p.prototype.first=p.prototype.head,Hr&&(p.prototype[Hr]=Wg),p},gr=Vp();Wt?((Wt.exports=gr)._=gr,zs._=gr):Ie._=gr}).call(ui)})(wo,wo.exports);var KE=Object.defineProperty,WE=Object.defineProperties,JE=Object.getOwnPropertyDescriptors,lh=Object.getOwnPropertySymbols,GE=Object.prototype.hasOwnProperty,QE=Object.prototype.propertyIsEnumerable,ph=(o,t,r)=>t in o?KE(o,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[t]=r,ds=(o,t)=>{for(var r in t||(t={}))GE.call(t,r)&&ph(o,r,t[r]);if(lh)for(var r of lh(t))QE.call(t,r)&&ph(o,r,t[r]);return o},YE=(o,t)=>WE(o,JE(t));function Vt(o,t,r){var s;const a=O0(o);return((s=t.rpcMap)==null?void 0:s[a.reference])||`${BE}?chainId=${a.namespace}:${a.reference}&projectId=${r}`}function cr(o){return o.includes(":")?o.split(":")[1]:o}function Xh(o){return o.map(t=>`${t.split(":")[0]}:${t.split(":")[1]}`)}function ZE(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 XE(o={},t={}){const r=dh(o),s=dh(t);return wo.exports.merge(r,s)}function dh(o){var t,r,s,a;const u={};if(!Nr(o))return u;for(const[l,g]of Object.entries(o)){const w=Ro(l)?[l]:g.chains,b=g.methods||[],C=g.events||[],O=g.rpcMap||{},N=hi(l);u[N]=YE(ds(ds({},u[N]),g),{chains:Qn(w,(t=u[N])==null?void 0:t.chains),methods:Qn(b,(r=u[N])==null?void 0:r.methods),events:Qn(C,(s=u[N])==null?void 0:s.events),rpcMap:ds(ds({},O),(a=u[N])==null?void 0:a.rpcMap)})}return u}function eI(o){return o.includes(":")?o.split(":")[2]:o}function tI(o){const t={};for(const[r,s]of Object.entries(o)){const a=s.methods||[],u=s.events||[],l=s.accounts||[],g=Ro(r)?[r]:s.chains?s.chains:Xh(s.accounts);t[r]={chains:g,methods:a,events:u,accounts:l}}return t}function io(o){return typeof o=="number"?o:o.includes("0x")?parseInt(o,16):o.includes(":")?Number(o.split(":")[1]):Number(o)}const el={},he=o=>el[o],so=(o,t)=>{el[o]=t};class rI{constructor(t){this.name="polkadot",this.namespace=t.namespace,this.events=he("events"),this.client=he("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($t.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=cr(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||Vt(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new Ct(new Bt(s,he("disableProviderPing")))}}class iI{constructor(t){this.name="eip155",this.namespace=t.namespace,this.events=he("events"),this.client=he("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($t.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||Vt(`${this.name}:${t}`,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new Ct(new Bt(s,he("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(cr(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 sI{constructor(t){this.name="solana",this.namespace=t.namespace,this.events=he("events"),this.client=he("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($t.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=cr(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||Vt(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new Ct(new Bt(s,he("disableProviderPing")))}}class nI{constructor(t){this.name="cosmos",this.namespace=t.namespace,this.events=he("events"),this.client=he("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($t.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=cr(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||Vt(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new Ct(new Bt(s,he("disableProviderPing")))}}class oI{constructor(t){this.name="cip34",this.namespace=t.namespace,this.events=he("events"),this.client=he("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($t.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=cr(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 Ct(new Bt(s,he("disableProviderPing")))}}class aI{constructor(t){this.name="elrond",this.namespace=t.namespace,this.events=he("events"),this.client=he("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($t.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=cr(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||Vt(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new Ct(new Bt(s,he("disableProviderPing")))}}class cI{constructor(t){this.name="multiversx",this.namespace=t.namespace,this.events=he("events"),this.client=he("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($t.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=cr(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||Vt(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new Ct(new Bt(s,he("disableProviderPing")))}}class uI{constructor(t){this.name="near",this.namespace=t.namespace,this.events=he("events"),this.client=he("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||Vt(`${this.name}:${t}`,this.namespace);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);this.setHttpProvider(t,s)}this.events.emit($t.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||Vt(t,this.namespace);return typeof s>"u"?void 0:new Ct(new Bt(s,he("disableProviderPing")))}}var hI=Object.defineProperty,lI=Object.defineProperties,pI=Object.getOwnPropertyDescriptors,fh=Object.getOwnPropertySymbols,dI=Object.prototype.hasOwnProperty,fI=Object.prototype.propertyIsEnumerable,gh=(o,t,r)=>t in o?hI(o,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[t]=r,fs=(o,t)=>{for(var r in t||(t={}))dI.call(t,r)&&gh(o,r,t[r]);if(fh)for(var r of fh(t))fI.call(t,r)&&gh(o,r,t[r]);return o},no=(o,t)=>lI(o,pI(t));class To{constructor(t){this.events=new k.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)||uh})),this.disableProviderPing=(t==null?void 0:t.disableProviderPing)||!1}static async init(t){const r=new To(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:fs({},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:ve("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=tI(u.namespaces),this.persist("namespaces",this.namespaces))}).catch(u=>{if(u.message!==Yh)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(sr(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 AE.init({logger:this.providerOpts.logger||uh,relayUrl:this.providerOpts.relayUrl||zE,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=>hi(r)))];so("client",this.client),so("events",this.events),so("disableProviderPing",this.disableProviderPing),t.forEach(r=>{if(!this.session)return;const s=ZE(r,this.session),a=Xh(s),u=XE(this.namespaces,this.optionalNamespaces),l=no(fs({},u[r]),{accounts:s,chains:a});switch(r){case"eip155":this.rpcProviders[r]=new iI({namespace:l});break;case"solana":this.rpcProviders[r]=new sI({namespace:l});break;case"cosmos":this.rpcProviders[r]=new nI({namespace:l});break;case"polkadot":this.rpcProviders[r]=new rI({namespace:l});break;case"cip34":this.rpcProviders[r]=new oI({namespace:l});break;case"elrond":this.rpcProviders[r]=new aI({namespace:l});break;case"multiversx":this.rpcProviders[r]=new cI({namespace:l});break;case"near":this.rpcProviders[r]=new uI({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&&sr(a)&&this.events.emit("accountsChanged",a.map(eI))}else if(s.name==="chainChanged"){const a=r.chainId,u=r.event.data,l=hi(a),g=io(a)!==io(u)?`${l}:${io(u)}`:a;this.onChainChanged(g)}else this.events.emit(s.name,s.data);this.events.emit("session_event",t)}),this.client.on("session_update",({topic:t,params:r})=>{var s;const{namespaces:a}=r,u=(s=this.client)==null?void 0:s.session.get(t);this.session=no(fs({},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",no(fs({},ve("USER_DISCONNECTED")),{data:t.topic}))}),this.on($t.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=>hi(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=hi(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(`${hh}/${t}`,r)}async getFromStore(t){return await this.client.core.storage.getItem(`${hh}/${t}`)}}const gI=To,yI="wc",vI="ethereum_provider",mI=`${yI}@2:${vI}:`,wI="https://rpc.walletconnect.com/v1/",ws=["eth_sendTransaction","personal_sign"],tl=["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"],_s=["chainChanged","accountsChanged"],rl=["chainChanged","accountsChanged","message","disconnect","connect"];var _I=Object.defineProperty,bI=Object.defineProperties,EI=Object.getOwnPropertyDescriptors,yh=Object.getOwnPropertySymbols,II=Object.prototype.hasOwnProperty,PI=Object.prototype.propertyIsEnumerable,vh=(o,t,r)=>t in o?_I(o,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[t]=r,pi=(o,t)=>{for(var r in t||(t={}))II.call(t,r)&&vh(o,r,t[r]);if(yh)for(var r of yh(t))PI.call(t,r)&&vh(o,r,t[r]);return o},mh=(o,t)=>bI(o,EI(t));function bs(o){return Number(o[0].split(":")[1])}function oo(o){return`0x${o.toString(16)}`}function SI(o){const{chains:t,optionalChains:r,methods:s,optionalMethods:a,events:u,optionalEvents:l,rpcMap:g}=o;if(!ao(t))throw new Error("Invalid chains");const w={chains:t,methods:s||ws,events:u||_s,rpcMap:pi({},t.length?{[bs(t)]:g[bs(t)]}:{})},b=u==null?void 0:u.filter(q=>!_s.includes(q)),C=s==null?void 0:s.filter(q=>!ws.includes(q));if(!r&&!l&&!a&&!(b!=null&&b.length)&&!(C!=null&&C.length))return{required:t.length?w:void 0};const O=(b==null?void 0:b.length)&&(C==null?void 0:C.length)||!r,N={chains:[...new Set(O?w.chains.concat(r||[]):r)],methods:[...new Set(w.methods.concat(a!=null&&a.length?a:tl))],events:[...new Set(w.events.concat(l!=null&&l.length?l:rl))],rpcMap:g};return{required:t.length?w:void 0,optional:r.length?N:void 0}}class Ss{constructor(){this.events=new k.eventsExports.EventEmitter,this.namespace="eip155",this.accounts=[],this.chainId=1,this.STORAGE_KEY=mI,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 Ss;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}=SI(this.rpc);try{const a=await new Promise(async(l,g)=>{var w;this.rpc.showQrModal&&((w=this.modal)==null||w.subscribeModal(b=>{!b.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),g(new Error("Connection request reset. Please try again.")))})),await this.signer.connect(mh(pi({namespaces:pi({},r&&{[this.namespace]:r})},s&&{optionalNamespaces:{[this.namespace]:s}}),{pairingTopic:t==null?void 0:t.pairingTopic})).then(b=>{l(b)}).catch(b=>{g(new Error(b.message))})});if(!a)return;const u=hw(a.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:u),this.setAccounts(u),this.events.emit("connect",{chainId:oo(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",oo(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",mh(pi({},pw("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",oo(this.chainId)),this.persist())}setChainId(t){if(this.isCompatibleChainId(t)){const r=this.parseChainId(t);this.chainId=r,this.switchEthereumChain(r)}}parseAccountId(t){const[r,s,a]=t.split(":");return{chainId:`${r}:${s}`,address:a}}setAccounts(t){this.accounts=t.filter(r=>this.parseChainId(this.parseAccountId(r).chainId)===this.chainId).map(r=>this.parseAccountId(r).address),this.events.emit("accountsChanged",this.accounts)}getRpcConfig(t){var r,s;const a=(r=t==null?void 0:t.chains)!=null?r:[],u=(s=t==null?void 0:t.optionalChains)!=null?s:[],l=a.concat(u);if(!l.length)throw new Error("No chains specified in either `chains` or `optionalChains`");const g=a.length?(t==null?void 0:t.methods)||ws:[],w=a.length?(t==null?void 0:t.events)||_s:[],b=(t==null?void 0:t.optionalMethods)||[],C=(t==null?void 0:t.optionalEvents)||[],O=(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(q=>this.formatChainId(q)),optionalChains:u.map(q=>this.formatChainId(q)),methods:g,events:w,optionalMethods:b,optionalEvents:C,rpcMap:O,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?bs(this.rpc.chains):bs(this.rpc.optionalChains),this.signer=await gI.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-6ZiA60gP.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(pi({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&&ao(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&&ao(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])||`${wI}?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 OI=Ss;exports.EthereumProvider=OI;exports.OPTIONAL_EVENTS=rl;exports.OPTIONAL_METHODS=tl;exports.REQUIRED_EVENTS=_s;exports.REQUIRED_METHODS=ws;exports.default=Ss;
|
|
46
|
+
}`;var B=cu(function(){return ee(d,j+"return "+R).apply(r,f)});if(B.source=R,qn(B))throw B;return B}function om(e){return te(e).toLowerCase()}function am(e){return te(e).toUpperCase()}function cm(e,i,n){if(e=te(e),e&&(n||i===r))return va(e);if(!e||!(i=Ve(i)))return e;var c=ot(e),h=ot(i),d=ma(c,h),f=wa(c,h)+1;return Lt(c,d,f).join("")}function um(e,i,n){if(e=te(e),e&&(n||i===r))return e.slice(0,ba(e)+1);if(!e||!(i=Ve(i)))return e;var c=ot(e),h=wa(c,ot(i))+1;return Lt(c,0,h).join("")}function hm(e,i,n){if(e=te(e),e&&(n||i===r))return e.replace(js,"");if(!e||!(i=Ve(i)))return e;var c=ot(e),h=ma(c,ot(i));return Lt(c,h).join("")}function lm(e,i){var n=il,c=sl;if(le(i)){var h="separator"in i?i.separator:h;n="length"in i?V(i.length):n,c="omission"in i?Ve(i.omission):c}e=te(e);var d=e.length;if(dr(e)){var f=ot(e);d=f.length}if(n>=d)return e;var y=n-fr(c);if(y<1)return c;var m=f?Lt(f,0,y).join(""):e.slice(0,y);if(h===r)return m+c;if(f&&(y+=m.length-y),Un(h)){if(e.slice(y).search(h)){var P,S=m;for(h.global||(h=Xs(h.source,te(Mo.exec(h))+"g")),h.lastIndex=0;P=h.exec(S);)var R=P.index;m=m.slice(0,R===r?y:R)}}else if(e.indexOf(Ve(h),y)!=y){var A=m.lastIndexOf(h);A>-1&&(m=m.slice(0,A))}return m+c}function pm(e){return e=te(e),e&&El.test(e)?e.replace(jo,Lp):e}var dm=br(function(e,i,n){return e+(n?" ":"")+i.toUpperCase()}),kn=uc("toUpperCase");function au(e,i,n){return e=te(e),i=n?r:i,i===r?Fp(e)?Hp(e):Op(e):e.match(i)||[]}var cu=W(function(e,i){try{return ze(e,r,i)}catch(n){return qn(n)?n:new z(n)}}),fm=Et(function(e,i){return Qe(i,function(n){n=gt(n),_t(e,n,Fn(e[n],e))}),e});function gm(e){var i=e==null?0:e.length,n=U();return e=i?ue(e,function(c){if(typeof c[1]!="function")throw new Ye(l);return[n(c[0]),c[1]]}):[],W(function(c){for(var h=-1;++h<i;){var d=e[h];if(ze(d[0],this,c))return ze(d[1],this,c)}})}function ym(e){return Ld(Xe(e,O))}function zn(e){return function(){return e}}function vm(e,i){return e==null||e!==e?i:e}var mm=lc(),wm=lc(!0);function Ue(e){return e}function Hn(e){return ka(typeof e=="function"?e:Xe(e,O))}function _m(e){return Ha(Xe(e,O))}function bm(e,i){return Va(e,Xe(i,O))}var Em=W(function(e,i){return function(n){return Qr(n,e,i)}}),Im=W(function(e,i){return function(n){return Qr(e,n,i)}});function Vn(e,i,n){var c=be(i),h=Bi(i,c);n==null&&!(le(i)&&(h.length||!c.length))&&(n=i,i=e,e=this,h=Bi(i,be(i)));var d=!(le(n)&&"chain"in n)||!!n.chain,f=Pt(e);return Qe(h,function(y){var m=i[y];e[y]=m,f&&(e.prototype[y]=function(){var P=this.__chain__;if(d||P){var S=e(this.__wrapped__),R=S.__actions__=Fe(this.__actions__);return R.push({func:m,args:arguments,thisArg:e}),S.__chain__=P,S}return m.apply(e,Dt([this.value()],arguments))})}),e}function Pm(){return Ie._===this&&(Ie._=Gp),this}function Bn(){}function Sm(e){return e=V(e),W(function(i){return Ba(i,e)})}var Om=En(ue),Rm=En(pa),Nm=En(Ks);function uu(e){return Cn(e)?Ws(gt(e)):sf(e)}function Cm(e){return function(i){return e==null?r:Zt(e,i)}}var $m=dc(),Am=dc(!0);function Kn(){return[]}function Wn(){return!1}function Tm(){return{}}function xm(){return""}function Dm(){return!0}function Fm(e,i){if(e=V(e),e<1||e>Tt)return[];var n=pt,c=Oe(e,pt);i=U(i),e-=pt;for(var h=Qs(c,i);++n<e;)i(n);return h}function jm(e){return H(e)?ue(e,gt):Be(e)?[e]:Fe(Cc(te(e)))}function qm(e){var i=++Wp;return te(e)+i}var Um=Yi(function(e,i){return e+i},0),Mm=In("ceil"),Lm=Yi(function(e,i){return e/i},1),km=In("floor");function zm(e){return e&&e.length?Vi(e,Ue,cn):r}function Hm(e,i){return e&&e.length?Vi(e,U(i,2),cn):r}function Vm(e){return ga(e,Ue)}function Bm(e,i){return ga(e,U(i,2))}function Km(e){return e&&e.length?Vi(e,Ue,pn):r}function Wm(e,i){return e&&e.length?Vi(e,U(i,2),pn):r}var Jm=Yi(function(e,i){return e*i},1),Gm=In("round"),Qm=Yi(function(e,i){return e-i},0);function Ym(e){return e&&e.length?Gs(e,Ue):0}function Zm(e,i){return e&&e.length?Gs(e,U(i,2)):0}return p.after=_y,p.ary=Lc,p.assign=av,p.assignIn=eu,p.assignInWith=hs,p.assignWith=cv,p.at=uv,p.before=kc,p.bind=Fn,p.bindAll=fm,p.bindKey=zc,p.castArray=Ty,p.chain=qc,p.chunk=kf,p.compact=zf,p.concat=Hf,p.cond=gm,p.conforms=ym,p.constant=zn,p.countBy=Yg,p.create=hv,p.curry=Hc,p.curryRight=Vc,p.debounce=Bc,p.defaults=lv,p.defaultsDeep=pv,p.defer=by,p.delay=Ey,p.difference=Vf,p.differenceBy=Bf,p.differenceWith=Kf,p.drop=Wf,p.dropRight=Jf,p.dropRightWhile=Gf,p.dropWhile=Qf,p.fill=Yf,p.filter=Xg,p.flatMap=ry,p.flatMapDeep=iy,p.flatMapDepth=sy,p.flatten=xc,p.flattenDeep=Zf,p.flattenDepth=Xf,p.flip=Iy,p.flow=mm,p.flowRight=wm,p.fromPairs=eg,p.functions=wv,p.functionsIn=_v,p.groupBy=ny,p.initial=rg,p.intersection=ig,p.intersectionBy=sg,p.intersectionWith=ng,p.invert=Ev,p.invertBy=Iv,p.invokeMap=ay,p.iteratee=Hn,p.keyBy=cy,p.keys=be,p.keysIn=qe,p.map=ss,p.mapKeys=Sv,p.mapValues=Ov,p.matches=_m,p.matchesProperty=bm,p.memoize=os,p.merge=Rv,p.mergeWith=tu,p.method=Em,p.methodOf=Im,p.mixin=Vn,p.negate=as,p.nthArg=Sm,p.omit=Nv,p.omitBy=Cv,p.once=Py,p.orderBy=uy,p.over=Om,p.overArgs=Sy,p.overEvery=Rm,p.overSome=Nm,p.partial=jn,p.partialRight=Kc,p.partition=hy,p.pick=$v,p.pickBy=ru,p.property=uu,p.propertyOf=Cm,p.pull=ug,p.pullAll=Fc,p.pullAllBy=hg,p.pullAllWith=lg,p.pullAt=pg,p.range=$m,p.rangeRight=Am,p.rearg=Oy,p.reject=dy,p.remove=dg,p.rest=Ry,p.reverse=xn,p.sampleSize=gy,p.set=Tv,p.setWith=xv,p.shuffle=yy,p.slice=fg,p.sortBy=wy,p.sortedUniq=bg,p.sortedUniqBy=Eg,p.split=rm,p.spread=Ny,p.tail=Ig,p.take=Pg,p.takeRight=Sg,p.takeRightWhile=Og,p.takeWhile=Rg,p.tap=zg,p.throttle=Cy,p.thru=is,p.toArray=Yc,p.toPairs=iu,p.toPairsIn=su,p.toPath=jm,p.toPlainObject=Xc,p.transform=Dv,p.unary=$y,p.union=Ng,p.unionBy=Cg,p.unionWith=$g,p.uniq=Ag,p.uniqBy=Tg,p.uniqWith=xg,p.unset=Fv,p.unzip=Dn,p.unzipWith=jc,p.update=jv,p.updateWith=qv,p.values=Pr,p.valuesIn=Uv,p.without=Dg,p.words=au,p.wrap=Ay,p.xor=Fg,p.xorBy=jg,p.xorWith=qg,p.zip=Ug,p.zipObject=Mg,p.zipObjectDeep=Lg,p.zipWith=kg,p.entries=iu,p.entriesIn=su,p.extend=eu,p.extendWith=hs,Vn(p,p),p.add=Um,p.attempt=cu,p.camelCase=zv,p.capitalize=nu,p.ceil=Mm,p.clamp=Mv,p.clone=xy,p.cloneDeep=Fy,p.cloneDeepWith=jy,p.cloneWith=Dy,p.conformsTo=qy,p.deburr=ou,p.defaultTo=vm,p.divide=Lm,p.endsWith=Hv,p.eq=ct,p.escape=Vv,p.escapeRegExp=Bv,p.every=Zg,p.find=ey,p.findIndex=Ac,p.findKey=dv,p.findLast=ty,p.findLastIndex=Tc,p.findLastKey=fv,p.floor=km,p.forEach=Uc,p.forEachRight=Mc,p.forIn=gv,p.forInRight=yv,p.forOwn=vv,p.forOwnRight=mv,p.get=Mn,p.gt=Uy,p.gte=My,p.has=bv,p.hasIn=Ln,p.head=Dc,p.identity=Ue,p.includes=oy,p.indexOf=tg,p.inRange=Lv,p.invoke=Pv,p.isArguments=tr,p.isArray=H,p.isArrayBuffer=Ly,p.isArrayLike=je,p.isArrayLikeObject=ge,p.isBoolean=ky,p.isBuffer=kt,p.isDate=zy,p.isElement=Hy,p.isEmpty=Vy,p.isEqual=By,p.isEqualWith=Ky,p.isError=qn,p.isFinite=Wy,p.isFunction=Pt,p.isInteger=Wc,p.isLength=cs,p.isMap=Jc,p.isMatch=Jy,p.isMatchWith=Gy,p.isNaN=Qy,p.isNative=Yy,p.isNil=Xy,p.isNull=Zy,p.isNumber=Gc,p.isObject=le,p.isObjectLike=pe,p.isPlainObject=ri,p.isRegExp=Un,p.isSafeInteger=ev,p.isSet=Qc,p.isString=us,p.isSymbol=Be,p.isTypedArray=Ir,p.isUndefined=tv,p.isWeakMap=rv,p.isWeakSet=iv,p.join=og,p.kebabCase=Kv,p.last=tt,p.lastIndexOf=ag,p.lowerCase=Wv,p.lowerFirst=Jv,p.lt=sv,p.lte=nv,p.max=zm,p.maxBy=Hm,p.mean=Vm,p.meanBy=Bm,p.min=Km,p.minBy=Wm,p.stubArray=Kn,p.stubFalse=Wn,p.stubObject=Tm,p.stubString=xm,p.stubTrue=Dm,p.multiply=Jm,p.nth=cg,p.noConflict=Pm,p.noop=Bn,p.now=ns,p.pad=Gv,p.padEnd=Qv,p.padStart=Yv,p.parseInt=Zv,p.random=kv,p.reduce=ly,p.reduceRight=py,p.repeat=Xv,p.replace=em,p.result=Av,p.round=Gm,p.runInContext=v,p.sample=fy,p.size=vy,p.snakeCase=tm,p.some=my,p.sortedIndex=gg,p.sortedIndexBy=yg,p.sortedIndexOf=vg,p.sortedLastIndex=mg,p.sortedLastIndexBy=wg,p.sortedLastIndexOf=_g,p.startCase=im,p.startsWith=sm,p.subtract=Qm,p.sum=Ym,p.sumBy=Zm,p.template=nm,p.times=Fm,p.toFinite=St,p.toInteger=V,p.toLength=Zc,p.toLower=om,p.toNumber=rt,p.toSafeInteger=ov,p.toString=te,p.toUpper=am,p.trim=cm,p.trimEnd=um,p.trimStart=hm,p.truncate=lm,p.unescape=pm,p.uniqueId=qm,p.upperCase=dm,p.upperFirst=kn,p.each=Uc,p.eachRight=Mc,p.first=Dc,Vn(p,function(){var e={};return dt(p,function(i,n){re.call(p.prototype,n)||(e[n]=i)}),e}(),{chain:!1}),p.VERSION=s,Qe(["bind","bindKey","curry","curryRight","partial","partialRight"],function(e){p[e].placeholder=p}),Qe(["drop","take"],function(e,i){Q.prototype[e]=function(n){n=n===r?1:_e(V(n),0);var c=this.__filtered__&&!i?new Q(this):this.clone();return c.__filtered__?c.__takeCount__=Oe(n,c.__takeCount__):c.__views__.push({size:Oe(n,pt),type:e+(c.__dir__<0?"Right":"")}),c},Q.prototype[e+"Right"]=function(n){return this.reverse()[e](n).reverse()}}),Qe(["filter","map","takeWhile"],function(e,i){var n=i+1,c=n==xo||n==cl;Q.prototype[e]=function(h){var d=this.clone();return d.__iteratees__.push({iteratee:U(h,3),type:n}),d.__filtered__=d.__filtered__||c,d}}),Qe(["head","last"],function(e,i){var n="take"+(i?"Right":"");Q.prototype[e]=function(){return this[n](1).value()[0]}}),Qe(["initial","tail"],function(e,i){var n="drop"+(i?"":"Right");Q.prototype[e]=function(){return this.__filtered__?new Q(this):this[n](1)}}),Q.prototype.compact=function(){return this.filter(Ue)},Q.prototype.find=function(e){return this.filter(e).head()},Q.prototype.findLast=function(e){return this.reverse().find(e)},Q.prototype.invokeMap=W(function(e,i){return typeof e=="function"?new Q(this):this.map(function(n){return Qr(n,e,i)})}),Q.prototype.reject=function(e){return this.filter(as(U(e)))},Q.prototype.slice=function(e,i){e=V(e);var n=this;return n.__filtered__&&(e>0||i<0)?new Q(n):(e<0?n=n.takeRight(-e):e&&(n=n.drop(e)),i!==r&&(i=V(i),n=i<0?n.dropRight(-i):n.take(i-e)),n)},Q.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},Q.prototype.toArray=function(){return this.take(pt)},dt(Q.prototype,function(e,i){var n=/^(?:filter|find|map|reject)|While$/.test(i),c=/^(?:head|last)$/.test(i),h=p[c?"take"+(i=="last"?"Right":""):i],d=c||/^find/.test(i);h&&(p.prototype[i]=function(){var f=this.__wrapped__,y=c?[1]:arguments,m=f instanceof Q,P=y[0],S=m||H(f),R=function(J){var Y=h.apply(p,Dt([J],y));return c&&A?Y[0]:Y};S&&n&&typeof P=="function"&&P.length!=1&&(m=S=!1);var A=this.__chain__,j=!!this.__actions__.length,M=d&&!A,B=m&&!j;if(!d&&S){f=B?f:new Q(this);var L=e.apply(f,y);return L.__actions__.push({func:is,args:[R],thisArg:r}),new Ze(L,A)}return M&&B?e.apply(this,y):(L=this.thru(R),M?c?L.value()[0]:L.value():L)})}),Qe(["pop","push","shift","sort","splice","unshift"],function(e){var i=Ci[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(H(d)?d:[],h)}return this[n](function(f){return i.apply(H(f)?f:[],h)})}}),dt(Q.prototype,function(e,i){var n=p[i];if(n){var c=n.name+"";re.call(mr,c)||(mr[c]=[]),mr[c].push({name:i,func:n})}}),mr[Qi(r,G).name]=[{name:"wrapper",func:r}],Q.prototype.clone=ld,Q.prototype.reverse=pd,Q.prototype.value=dd,p.prototype.at=Hg,p.prototype.chain=Vg,p.prototype.commit=Bg,p.prototype.next=Kg,p.prototype.plant=Jg,p.prototype.reverse=Gg,p.prototype.toJSON=p.prototype.valueOf=p.prototype.value=Qg,p.prototype.first=p.prototype.head,Hr&&(p.prototype[Hr]=Wg),p},gr=Vp();Wt?((Wt.exports=gr)._=gr,zs._=gr):Ie._=gr}).call(ui)})(wo,wo.exports);var KE=Object.defineProperty,WE=Object.defineProperties,JE=Object.getOwnPropertyDescriptors,lh=Object.getOwnPropertySymbols,GE=Object.prototype.hasOwnProperty,QE=Object.prototype.propertyIsEnumerable,ph=(o,t,r)=>t in o?KE(o,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[t]=r,ds=(o,t)=>{for(var r in t||(t={}))GE.call(t,r)&&ph(o,r,t[r]);if(lh)for(var r of lh(t))QE.call(t,r)&&ph(o,r,t[r]);return o},YE=(o,t)=>WE(o,JE(t));function Vt(o,t,r){var s;const a=O0(o);return((s=t.rpcMap)==null?void 0:s[a.reference])||`${BE}?chainId=${a.namespace}:${a.reference}&projectId=${r}`}function cr(o){return o.includes(":")?o.split(":")[1]:o}function Xh(o){return o.map(t=>`${t.split(":")[0]}:${t.split(":")[1]}`)}function ZE(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 XE(o={},t={}){const r=dh(o),s=dh(t);return wo.exports.merge(r,s)}function dh(o){var t,r,s,a;const u={};if(!Nr(o))return u;for(const[l,g]of Object.entries(o)){const w=Ro(l)?[l]:g.chains,b=g.methods||[],C=g.events||[],O=g.rpcMap||{},N=hi(l);u[N]=YE(ds(ds({},u[N]),g),{chains:Qn(w,(t=u[N])==null?void 0:t.chains),methods:Qn(b,(r=u[N])==null?void 0:r.methods),events:Qn(C,(s=u[N])==null?void 0:s.events),rpcMap:ds(ds({},O),(a=u[N])==null?void 0:a.rpcMap)})}return u}function eI(o){return o.includes(":")?o.split(":")[2]:o}function tI(o){const t={};for(const[r,s]of Object.entries(o)){const a=s.methods||[],u=s.events||[],l=s.accounts||[],g=Ro(r)?[r]:s.chains?s.chains:Xh(s.accounts);t[r]={chains:g,methods:a,events:u,accounts:l}}return t}function io(o){return typeof o=="number"?o:o.includes("0x")?parseInt(o,16):o.includes(":")?Number(o.split(":")[1]):Number(o)}const el={},he=o=>el[o],so=(o,t)=>{el[o]=t};class rI{constructor(t){this.name="polkadot",this.namespace=t.namespace,this.events=he("events"),this.client=he("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($t.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=cr(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||Vt(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new Ct(new Bt(s,he("disableProviderPing")))}}class iI{constructor(t){this.name="eip155",this.namespace=t.namespace,this.events=he("events"),this.client=he("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($t.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||Vt(`${this.name}:${t}`,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new Ct(new Bt(s,he("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(cr(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 sI{constructor(t){this.name="solana",this.namespace=t.namespace,this.events=he("events"),this.client=he("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($t.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=cr(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||Vt(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new Ct(new Bt(s,he("disableProviderPing")))}}class nI{constructor(t){this.name="cosmos",this.namespace=t.namespace,this.events=he("events"),this.client=he("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($t.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=cr(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||Vt(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new Ct(new Bt(s,he("disableProviderPing")))}}class oI{constructor(t){this.name="cip34",this.namespace=t.namespace,this.events=he("events"),this.client=he("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($t.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=cr(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 Ct(new Bt(s,he("disableProviderPing")))}}class aI{constructor(t){this.name="elrond",this.namespace=t.namespace,this.events=he("events"),this.client=he("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($t.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=cr(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||Vt(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new Ct(new Bt(s,he("disableProviderPing")))}}class cI{constructor(t){this.name="multiversx",this.namespace=t.namespace,this.events=he("events"),this.client=he("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($t.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=cr(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||Vt(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new Ct(new Bt(s,he("disableProviderPing")))}}class uI{constructor(t){this.name="near",this.namespace=t.namespace,this.events=he("events"),this.client=he("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||Vt(`${this.name}:${t}`,this.namespace);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);this.setHttpProvider(t,s)}this.events.emit($t.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||Vt(t,this.namespace);return typeof s>"u"?void 0:new Ct(new Bt(s,he("disableProviderPing")))}}var hI=Object.defineProperty,lI=Object.defineProperties,pI=Object.getOwnPropertyDescriptors,fh=Object.getOwnPropertySymbols,dI=Object.prototype.hasOwnProperty,fI=Object.prototype.propertyIsEnumerable,gh=(o,t,r)=>t in o?hI(o,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[t]=r,fs=(o,t)=>{for(var r in t||(t={}))dI.call(t,r)&&gh(o,r,t[r]);if(fh)for(var r of fh(t))fI.call(t,r)&&gh(o,r,t[r]);return o},no=(o,t)=>lI(o,pI(t));class To{constructor(t){this.events=new k.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)||uh})),this.disableProviderPing=(t==null?void 0:t.disableProviderPing)||!1}static async init(t){const r=new To(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:fs({},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:ve("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=tI(u.namespaces),this.persist("namespaces",this.namespaces))}).catch(u=>{if(u.message!==Yh)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(sr(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 AE.init({logger:this.providerOpts.logger||uh,relayUrl:this.providerOpts.relayUrl||zE,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=>hi(r)))];so("client",this.client),so("events",this.events),so("disableProviderPing",this.disableProviderPing),t.forEach(r=>{if(!this.session)return;const s=ZE(r,this.session),a=Xh(s),u=XE(this.namespaces,this.optionalNamespaces),l=no(fs({},u[r]),{accounts:s,chains:a});switch(r){case"eip155":this.rpcProviders[r]=new iI({namespace:l});break;case"solana":this.rpcProviders[r]=new sI({namespace:l});break;case"cosmos":this.rpcProviders[r]=new nI({namespace:l});break;case"polkadot":this.rpcProviders[r]=new rI({namespace:l});break;case"cip34":this.rpcProviders[r]=new oI({namespace:l});break;case"elrond":this.rpcProviders[r]=new aI({namespace:l});break;case"multiversx":this.rpcProviders[r]=new cI({namespace:l});break;case"near":this.rpcProviders[r]=new uI({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&&sr(a)&&this.events.emit("accountsChanged",a.map(eI))}else if(s.name==="chainChanged"){const a=r.chainId,u=r.event.data,l=hi(a),g=io(a)!==io(u)?`${l}:${io(u)}`:a;this.onChainChanged(g)}else this.events.emit(s.name,s.data);this.events.emit("session_event",t)}),this.client.on("session_update",({topic:t,params:r})=>{var s;const{namespaces:a}=r,u=(s=this.client)==null?void 0:s.session.get(t);this.session=no(fs({},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",no(fs({},ve("USER_DISCONNECTED")),{data:t.topic}))}),this.on($t.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=>hi(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=hi(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(`${hh}/${t}`,r)}async getFromStore(t){return await this.client.core.storage.getItem(`${hh}/${t}`)}}const gI=To,yI="wc",vI="ethereum_provider",mI=`${yI}@2:${vI}:`,wI="https://rpc.walletconnect.com/v1/",ws=["eth_sendTransaction","personal_sign"],tl=["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"],_s=["chainChanged","accountsChanged"],rl=["chainChanged","accountsChanged","message","disconnect","connect"];var _I=Object.defineProperty,bI=Object.defineProperties,EI=Object.getOwnPropertyDescriptors,yh=Object.getOwnPropertySymbols,II=Object.prototype.hasOwnProperty,PI=Object.prototype.propertyIsEnumerable,vh=(o,t,r)=>t in o?_I(o,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[t]=r,pi=(o,t)=>{for(var r in t||(t={}))II.call(t,r)&&vh(o,r,t[r]);if(yh)for(var r of yh(t))PI.call(t,r)&&vh(o,r,t[r]);return o},mh=(o,t)=>bI(o,EI(t));function bs(o){return Number(o[0].split(":")[1])}function oo(o){return`0x${o.toString(16)}`}function SI(o){const{chains:t,optionalChains:r,methods:s,optionalMethods:a,events:u,optionalEvents:l,rpcMap:g}=o;if(!ao(t))throw new Error("Invalid chains");const w={chains:t,methods:s||ws,events:u||_s,rpcMap:pi({},t.length?{[bs(t)]:g[bs(t)]}:{})},b=u==null?void 0:u.filter(q=>!_s.includes(q)),C=s==null?void 0:s.filter(q=>!ws.includes(q));if(!r&&!l&&!a&&!(b!=null&&b.length)&&!(C!=null&&C.length))return{required:t.length?w:void 0};const O=(b==null?void 0:b.length)&&(C==null?void 0:C.length)||!r,N={chains:[...new Set(O?w.chains.concat(r||[]):r)],methods:[...new Set(w.methods.concat(a!=null&&a.length?a:tl))],events:[...new Set(w.events.concat(l!=null&&l.length?l:rl))],rpcMap:g};return{required:t.length?w:void 0,optional:r.length?N:void 0}}class Ss{constructor(){this.events=new k.eventsExports.EventEmitter,this.namespace="eip155",this.accounts=[],this.chainId=1,this.STORAGE_KEY=mI,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 Ss;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}=SI(this.rpc);try{const a=await new Promise(async(l,g)=>{var w;this.rpc.showQrModal&&((w=this.modal)==null||w.subscribeModal(b=>{!b.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),g(new Error("Connection request reset. Please try again.")))})),await this.signer.connect(mh(pi({namespaces:pi({},r&&{[this.namespace]:r})},s&&{optionalNamespaces:{[this.namespace]:s}}),{pairingTopic:t==null?void 0:t.pairingTopic})).then(b=>{l(b)}).catch(b=>{g(new Error(b.message))})});if(!a)return;const u=hw(a.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:u),this.setAccounts(u),this.events.emit("connect",{chainId:oo(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",oo(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",mh(pi({},pw("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",oo(this.chainId)),this.persist())}setChainId(t){if(this.isCompatibleChainId(t)){const r=this.parseChainId(t);this.chainId=r,this.switchEthereumChain(r)}}parseAccountId(t){const[r,s,a]=t.split(":");return{chainId:`${r}:${s}`,address:a}}setAccounts(t){this.accounts=t.filter(r=>this.parseChainId(this.parseAccountId(r).chainId)===this.chainId).map(r=>this.parseAccountId(r).address),this.events.emit("accountsChanged",this.accounts)}getRpcConfig(t){var r,s;const a=(r=t==null?void 0:t.chains)!=null?r:[],u=(s=t==null?void 0:t.optionalChains)!=null?s:[],l=a.concat(u);if(!l.length)throw new Error("No chains specified in either `chains` or `optionalChains`");const g=a.length?(t==null?void 0:t.methods)||ws:[],w=a.length?(t==null?void 0:t.events)||_s:[],b=(t==null?void 0:t.optionalMethods)||[],C=(t==null?void 0:t.optionalEvents)||[],O=(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(q=>this.formatChainId(q)),optionalChains:u.map(q=>this.formatChainId(q)),methods:g,events:w,optionalMethods:b,optionalEvents:C,rpcMap:O,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?bs(this.rpc.chains):bs(this.rpc.optionalChains),this.signer=await gI.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-C2oD47lT.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(pi({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&&ao(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&&ao(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])||`${wI}?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 OI=Ss;exports.EthereumProvider=OI;exports.OPTIONAL_EVENTS=rl;exports.OPTIONAL_METHODS=tl;exports.REQUIRED_EVENTS=_s;exports.REQUIRED_METHODS=ws;exports.default=Ss;
|
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-rtZ91I3M.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