@reown/appkit-cdn 0.0.3 → 0.0.4
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/{W3MFrameProviderSingleton-BpWUndnw.cjs → W3MFrameProviderSingleton-BPW-iicw.cjs} +24 -24
- package/dist/{W3MFrameProviderSingleton-CuVI_88U.js → W3MFrameProviderSingleton-C0cnhaTp.js} +171 -172
- package/dist/ethers.cjs +1 -1
- package/dist/ethers.js +986 -897
- package/dist/{hooks.module-BmccViTi.cjs → hooks.module-CznhRnD8.cjs} +1 -1
- package/dist/{hooks.module-C2zxEs4Z.js → hooks.module-DDA9XQhP.js} +1 -1
- package/dist/{index-e2XnZub2.cjs → index-BLj7JLFx.cjs} +1 -1
- package/dist/{index-CytFwM4F.cjs → index-BUi5SfXe.cjs} +1 -1
- package/dist/{index--u0BBJui.js → index-BfndvsxR.js} +2 -2
- package/dist/{index-DIBheNE_.js → index-BjDQZhCC.js} +2 -2
- package/dist/{index-DxKsnlAL.cjs → index-CGVAZ4op.cjs} +1 -1
- package/dist/{index-DTZ3zFoi.js → index-CJlx78Gf.js} +2 -2
- package/dist/{index-B5dlb2GK.cjs → index-D4J5pbXW.cjs} +1 -1
- package/dist/{index-BGcCLdgU.js → index-DBXYKiLS.js} +2 -2
- package/dist/{index-Cbfs_-YJ.js → index-DDxg-CnX.js} +2 -2
- package/dist/{index-CjczsdX0.js → index-DEDntV4l.js} +2 -2
- package/dist/{index-CEbNT_sk.cjs → index-DJZpgYw1.cjs} +1 -1
- package/dist/{index-DoNvH4sY.cjs → index-DUA8iuT-.cjs} +1 -1
- package/dist/{index-_fb0kPJf.js → index-DzzvtAEu.js} +1 -1
- package/dist/{index-BzzLy8QO.js → index-Ij2u7oAT.js} +2 -2
- package/dist/{index-BgSdiVHK.cjs → index-JwYoIh-Y.cjs} +1 -1
- package/dist/{index-qHZ88Aei.cjs → index-mtzTuPjF.cjs} +1 -1
- package/dist/{index.es-Dzy36BN7.js → index.es-CMbAWbN4.js} +2 -2
- package/dist/{index.es-wptiKBWB.cjs → index.es-oLid2UZg.cjs} +2 -2
- package/dist/{metamask-sdk-vSsaK2qA.js → metamask-sdk-8Alxi0fO.js} +1 -1
- package/dist/{metamask-sdk-CH4ak2WC.cjs → metamask-sdk-CMhxptNL.cjs} +1 -1
- package/dist/{native-DZv9b0EL.js → native-B_ZKbAy2.js} +1 -1
- package/dist/{native-DUnMHCku.cjs → native-CoR5CkbH.cjs} +1 -1
- package/dist/{w3m-modal-pgEnMCmq.cjs → w3m-modal-CiBinOIk.cjs} +3 -3
- package/dist/{w3m-modal-Cb8iN1Y9.js → w3m-modal-zyJFtzIf.js} +5 -5
- package/dist/{wagmi-Cz2I9r-O.cjs → wagmi-BL69ctC0.cjs} +11 -11
- package/dist/{wagmi-Dnkdlm7T.js → wagmi-BPQ-82KE.js} +532 -429
- package/dist/wagmi.cjs +1 -1
- package/dist/wagmi.js +2 -2
- package/package.json +5 -5
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { k as m } from "./W3MFrameProviderSingleton-
|
|
2
|
-
import { e as P, h as We, a as Ve } from "./wagmi-
|
|
1
|
+
import { k as m } from "./W3MFrameProviderSingleton-C0cnhaTp.js";
|
|
2
|
+
import { e as P, h as We, a as Ve } from "./wagmi-BPQ-82KE.js";
|
|
3
3
|
const qe = () => "9.1.0", ke = (e) => e.toString(16).padStart(2, "0"), Fe = (e) => {
|
|
4
4
|
const n = new Uint8Array(e / 2);
|
|
5
5
|
return window.crypto.getRandomValues(n), Array.from(n, ke).join("");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const i=require("./W3MFrameProviderSingleton-
|
|
1
|
+
"use strict";const i=require("./W3MFrameProviderSingleton-BPW-iicw.cjs"),n=i.proxy({history:["ConnectWallet"],view:"ConnectWallet",data:void 0}),U={state:n,subscribe(e){return i.subscribe(n,()=>e(n))},push(e,t){e!==n.view&&(n.view=e,t&&(n.data=t),n.history.push(e))},reset(e){n.view=e,n.history=[e]},replace(e){n.history.length>1&&(n.history[n.history.length-1]=e,n.view=e)},goBack(){if(n.history.length>1){n.history.pop();const[e]=n.history.slice(-1);n.view=e}},setData(e){n.data=e}},r={WALLETCONNECT_DEEPLINK_CHOICE:"WALLETCONNECT_DEEPLINK_CHOICE",WCM_VERSION:"WCM_VERSION",RECOMMENDED_WALLET_AMOUNT:9,isMobile(){return typeof window<"u"?!!(window.matchMedia("(pointer:coarse)").matches||/Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent)):!1},isAndroid(){return r.isMobile()&&navigator.userAgent.toLowerCase().includes("android")},isIos(){const e=navigator.userAgent.toLowerCase();return r.isMobile()&&(e.includes("iphone")||e.includes("ipad"))},isHttpUrl(e){return e.startsWith("http://")||e.startsWith("https://")},isArray(e){return Array.isArray(e)&&e.length>0},formatNativeUrl(e,t,s){if(r.isHttpUrl(e))return this.formatUniversalUrl(e,t,s);let o=e;o.includes("://")||(o=e.replaceAll("/","").replaceAll(":",""),o=`${o}://`),o.endsWith("/")||(o=`${o}/`),this.setWalletConnectDeepLink(o,s);const l=encodeURIComponent(t);return`${o}wc?uri=${l}`},formatUniversalUrl(e,t,s){if(!r.isHttpUrl(e))return this.formatNativeUrl(e,t,s);let o=e;o.endsWith("/")||(o=`${o}/`),this.setWalletConnectDeepLink(o,s);const l=encodeURIComponent(t);return`${o}wc?uri=${l}`},async wait(e){return new Promise(t=>{setTimeout(t,e)})},openHref(e,t){window.open(e,t,"noreferrer noopener")},setWalletConnectDeepLink(e,t){try{localStorage.setItem(r.WALLETCONNECT_DEEPLINK_CHOICE,JSON.stringify({href:e,name:t}))}catch{console.info("Unable to set WalletConnect deep link")}},setWalletConnectAndroidDeepLink(e){try{const[t]=e.split("?");localStorage.setItem(r.WALLETCONNECT_DEEPLINK_CHOICE,JSON.stringify({href:t,name:"Android"}))}catch{console.info("Unable to set WalletConnect android deep link")}},removeWalletConnectDeepLink(){try{localStorage.removeItem(r.WALLETCONNECT_DEEPLINK_CHOICE)}catch{console.info("Unable to remove WalletConnect deep link")}},setModalVersionInStorage(){try{typeof localStorage<"u"&&localStorage.setItem(r.WCM_VERSION,"2.6.2")}catch{console.info("Unable to set Web3Modal version in storage")}},getWalletRouterData(){var e;const t=(e=U.state.data)==null?void 0:e.Wallet;if(!t)throw new Error('Missing "Wallet" view data');return t}},R=typeof location<"u"&&(location.hostname.includes("localhost")||location.protocol.includes("https")),a=i.proxy({enabled:R,userSessionId:"",events:[],connectedWalletId:void 0}),_={state:a,subscribe(e){return i.subscribe(a.events,()=>e(i.snapshot(a.events[a.events.length-1])))},initialize(){a.enabled&&typeof(crypto==null?void 0:crypto.randomUUID)<"u"&&(a.userSessionId=crypto.randomUUID())},setConnectedWalletId(e){a.connectedWalletId=e},click(e){if(a.enabled){const t={type:"CLICK",name:e.name,userSessionId:a.userSessionId,timestamp:Date.now(),data:e};a.events.push(t)}},track(e){if(a.enabled){const t={type:"TRACK",name:e.name,userSessionId:a.userSessionId,timestamp:Date.now(),data:e};a.events.push(t)}},view(e){if(a.enabled){const t={type:"VIEW",name:e.name,userSessionId:a.userSessionId,timestamp:Date.now(),data:e};a.events.push(t)}}},p=i.proxy({chains:void 0,walletConnectUri:void 0,isAuth:!1,isCustomDesktop:!1,isCustomMobile:!1,isDataLoaded:!1,isUiLoaded:!1}),c={state:p,subscribe(e){return i.subscribe(p,()=>e(p))},setChains(e){p.chains=e},setWalletConnectUri(e){p.walletConnectUri=e},setIsCustomDesktop(e){p.isCustomDesktop=e},setIsCustomMobile(e){p.isCustomMobile=e},setIsDataLoaded(e){p.isDataLoaded=e},setIsUiLoaded(e){p.isUiLoaded=e},setIsAuth(e){p.isAuth=e}},C=i.proxy({projectId:"",mobileWallets:void 0,desktopWallets:void 0,walletImages:void 0,chains:void 0,enableAuthMode:!1,enableExplorer:!0,explorerExcludedWalletIds:void 0,explorerRecommendedWalletIds:void 0,termsOfServiceUrl:void 0,privacyPolicyUrl:void 0}),b={state:C,subscribe(e){return i.subscribe(C,()=>e(C))},setConfig(e){var t,s;_.initialize(),c.setChains(e.chains),c.setIsAuth(!!e.enableAuthMode),c.setIsCustomMobile(!!((t=e.mobileWallets)!=null&&t.length)),c.setIsCustomDesktop(!!((s=e.desktopWallets)!=null&&s.length)),r.setModalVersionInStorage(),Object.assign(C,e)}};var V=Object.defineProperty,D=Object.getOwnPropertySymbols,H=Object.prototype.hasOwnProperty,B=Object.prototype.propertyIsEnumerable,k=(e,t,s)=>t in e?V(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,K=(e,t)=>{for(var s in t||(t={}))H.call(t,s)&&k(e,s,t[s]);if(D)for(var s of D(t))B.call(t,s)&&k(e,s,t[s]);return e};const L="https://explorer-api.walletconnect.com",O="wcm",E="js-2.6.2";async function w(e,t){const s=K({sdkType:O,sdkVersion:E},t),o=new URL(e,L);return o.searchParams.append("projectId",b.state.projectId),Object.entries(s).forEach(([l,d])=>{d&&o.searchParams.append(l,String(d))}),(await fetch(o)).json()}const m={async getDesktopListings(e){return w("/w3m/v1/getDesktopListings",e)},async getMobileListings(e){return w("/w3m/v1/getMobileListings",e)},async getInjectedListings(e){return w("/w3m/v1/getInjectedListings",e)},async getAllListings(e){return w("/w3m/v1/getAllListings",e)},getWalletImageUrl(e){return`${L}/w3m/v1/getWalletImage/${e}?projectId=${b.state.projectId}&sdkType=${O}&sdkVersion=${E}`},getAssetImageUrl(e){return`${L}/w3m/v1/getAssetImage/${e}?projectId=${b.state.projectId}&sdkType=${O}&sdkVersion=${E}`}};var z=Object.defineProperty,S=Object.getOwnPropertySymbols,q=Object.prototype.hasOwnProperty,J=Object.prototype.propertyIsEnumerable,N=(e,t,s)=>t in e?z(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,F=(e,t)=>{for(var s in t||(t={}))q.call(t,s)&&N(e,s,t[s]);if(S)for(var s of S(t))J.call(t,s)&&N(e,s,t[s]);return e};const x=r.isMobile(),u=i.proxy({wallets:{listings:[],total:0,page:1},search:{listings:[],total:0,page:1},recomendedWallets:[]}),G={state:u,async getRecomendedWallets(){const{explorerRecommendedWalletIds:e,explorerExcludedWalletIds:t}=b.state;if(e==="NONE"||t==="ALL"&&!e)return u.recomendedWallets;if(r.isArray(e)){const s={recommendedIds:e.join(",")},{listings:o}=await m.getAllListings(s),l=Object.values(o);l.sort((d,h)=>{const v=e.indexOf(d.id),f=e.indexOf(h.id);return v-f}),u.recomendedWallets=l}else{const{chains:s,isAuth:o}=c.state,l=s==null?void 0:s.join(","),d=r.isArray(t),h={page:1,sdks:o?"auth_v1":void 0,entries:r.RECOMMENDED_WALLET_AMOUNT,chains:l,version:2,excludedIds:d?t.join(","):void 0},{listings:v}=x?await m.getMobileListings(h):await m.getDesktopListings(h);u.recomendedWallets=Object.values(v)}return u.recomendedWallets},async getWallets(e){const t=F({},e),{explorerRecommendedWalletIds:s,explorerExcludedWalletIds:o}=b.state,{recomendedWallets:l}=u;if(o==="ALL")return u.wallets;l.length?t.excludedIds=l.map($=>$.id).join(","):r.isArray(s)&&(t.excludedIds=s.join(",")),r.isArray(o)&&(t.excludedIds=[t.excludedIds,o].filter(Boolean).join(",")),c.state.isAuth&&(t.sdks="auth_v1");const{page:d,search:h}=e,{listings:v,total:f}=x?await m.getMobileListings(t):await m.getDesktopListings(t),M=Object.values(v),j=h?"search":"wallets";return u[j]={listings:[...u[j].listings,...M],total:f,page:d??1},{listings:M,total:f}},getWalletImageUrl(e){return m.getWalletImageUrl(e)},getAssetImageUrl(e){return m.getAssetImageUrl(e)},resetSearch(){u.search={listings:[],total:0,page:1}}},y=i.proxy({open:!1}),W={state:y,subscribe(e){return i.subscribe(y,()=>e(y))},async open(e){return new Promise(t=>{const{isUiLoaded:s,isDataLoaded:o}=c.state;if(r.removeWalletConnectDeepLink(),c.setWalletConnectUri(e==null?void 0:e.uri),c.setChains(e==null?void 0:e.chains),U.reset("ConnectWallet"),s&&o)y.open=!0,t();else{const l=setInterval(()=>{const d=c.state;d.isUiLoaded&&d.isDataLoaded&&(clearInterval(l),y.open=!0,t())},200)}})},close(){y.open=!1}};var Q=Object.defineProperty,T=Object.getOwnPropertySymbols,X=Object.prototype.hasOwnProperty,Y=Object.prototype.propertyIsEnumerable,P=(e,t,s)=>t in e?Q(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,Z=(e,t)=>{for(var s in t||(t={}))X.call(t,s)&&P(e,s,t[s]);if(T)for(var s of T(t))Y.call(t,s)&&P(e,s,t[s]);return e};function ee(){return typeof matchMedia<"u"&&matchMedia("(prefers-color-scheme: dark)").matches}const I=i.proxy({themeMode:ee()?"dark":"light"}),A={state:I,subscribe(e){return i.subscribe(I,()=>e(I))},setThemeConfig(e){const{themeMode:t,themeVariables:s}=e;t&&(I.themeMode=t),s&&(I.themeVariables=Z({},s))}},g=i.proxy({open:!1,message:"",variant:"success"}),te={state:g,subscribe(e){return i.subscribe(g,()=>e(g))},openToast(e,t){g.open=!0,g.message=e,g.variant=t},closeToast(){g.open=!1}};class se{constructor(t){this.openModal=W.open,this.closeModal=W.close,this.subscribeModal=W.subscribe,this.setTheme=A.setThemeConfig,A.setThemeConfig(t),b.setConfig(t),this.initUi()}async initUi(){if(typeof window<"u"){await Promise.resolve().then(()=>require("./index-mtzTuPjF.cjs"));const t=document.createElement("wcm-modal");document.body.insertAdjacentElement("beforeend",t),c.setIsUiLoaded(!0)}}}const oe=Object.freeze(Object.defineProperty({__proto__:null,WalletConnectModal:se},Symbol.toStringTag,{value:"Module"}));exports.R=_;exports.T=U;exports.a=r;exports.index=oe;exports.ne=A;exports.oe=te;exports.p=c;exports.se=W;exports.te=G;exports.y=b;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { B as f, s as rn, k as L, l as sn, b7 as an } from "./W3MFrameProviderSingleton-
|
|
2
|
-
import { j as on, r as _t, a as Et, b as cn } from "./hooks.module-
|
|
1
|
+
import { B as f, s as rn, k as L, l as sn, b7 as an } from "./W3MFrameProviderSingleton-C0cnhaTp.js";
|
|
2
|
+
import { j as on, r as _t, a as Et, b as cn } from "./hooks.module-DDA9XQhP.js";
|
|
3
3
|
var St = {}, ne = {}, be = {};
|
|
4
4
|
Object.defineProperty(be, "__esModule", { value: !0 });
|
|
5
5
|
be.walletLogo = void 0;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { p as u, o as h, bX as R } from "./W3MFrameProviderSingleton-
|
|
1
|
+
import { p as u, o as h, bX as R } from "./W3MFrameProviderSingleton-C0cnhaTp.js";
|
|
2
2
|
const n = u({ history: ["ConnectWallet"], view: "ConnectWallet", data: void 0 }), x = { state: n, subscribe(e) {
|
|
3
3
|
return h(n, () => e(n));
|
|
4
4
|
}, push(e, t) {
|
|
@@ -230,7 +230,7 @@ class se {
|
|
|
230
230
|
}
|
|
231
231
|
async initUi() {
|
|
232
232
|
if (typeof window < "u") {
|
|
233
|
-
await import("./index-
|
|
233
|
+
await import("./index-Ij2u7oAT.js");
|
|
234
234
|
const t = document.createElement("wcm-modal");
|
|
235
235
|
document.body.insertAdjacentElement("beforeend", t), c.setIsUiLoaded(!0);
|
|
236
236
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { k as I, b8 as Rr, B, s as Ba, b9 as Bi, ba as Di, bb as Qe, l as Da, b7 as Ha } from "./W3MFrameProviderSingleton-
|
|
2
|
-
import { a as ce, b as Ir, r as Dt, j as Ua } from "./hooks.module-
|
|
1
|
+
import { k as I, b8 as Rr, B, s as Ba, b9 as Bi, ba as Di, bb as Qe, l as Da, b7 as Ha } from "./W3MFrameProviderSingleton-C0cnhaTp.js";
|
|
2
|
+
import { a as ce, b as Ir, r as Dt, j as Ua } from "./hooks.module-DDA9XQhP.js";
|
|
3
3
|
var Hi = {}, Ft = {}, Ar = {};
|
|
4
4
|
Object.defineProperty(Ar, "__esModule", { value: !0 });
|
|
5
5
|
Ar.walletLogo = void 0;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./W3MFrameProviderSingleton-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./W3MFrameProviderSingleton-BPW-iicw.cjs"),t=e.Oe`<svg class="input_mask" width="328" height="100" viewBox="0 0 328 100" fill="none">
|
|
2
2
|
<mask id="path-1-inside-1_18299_4189">
|
|
3
3
|
<path
|
|
4
4
|
class="input_mask__border"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const p=require("./W3MFrameProviderSingleton-
|
|
1
|
+
"use strict";const p=require("./W3MFrameProviderSingleton-BPW-iicw.cjs");function _(n,a){for(var i=0;i<a.length;i++){const e=a[i];if(typeof e!="string"&&!Array.isArray(e)){for(const s in e)if(s!=="default"&&!(s in n)){const o=Object.getOwnPropertyDescriptor(e,s);o&&Object.defineProperty(n,s,o.get?o:{enumerable:!0,get:()=>e[s]})}}}return Object.freeze(Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}))}var l={},g={},f={};Object.defineProperty(f,"__esModule",{value:!0});f.getLowerCase=void 0;function w(n){return n&&n.toLowerCase()}f.getLowerCase=w;Object.defineProperty(g,"__esModule",{value:!0});g.SafeAppProvider=void 0;const m=p.eventsExports,u=f;class k extends m.EventEmitter{constructor(a,i){super(),this.submittedTxs=new Map,this.safe=a,this.sdk=i}async connect(){this.emit("connect",{chainId:this.chainId})}async disconnect(){}get chainId(){return this.safe.chainId}async request(a){const{method:i,params:e=[]}=a;switch(i){case"eth_accounts":return[this.safe.safeAddress];case"net_version":case"eth_chainId":return`0x${this.chainId.toString(16)}`;case"personal_sign":{const[t,r]=e;if(this.safe.safeAddress.toLowerCase()!==r.toLowerCase())throw new Error("The address or message hash is invalid");const h=await this.sdk.txs.signMessage(t);return("signature"in h?h.signature:void 0)||"0x"}case"eth_sign":{const[t,r]=e;if(this.safe.safeAddress.toLowerCase()!==t.toLowerCase()||!r.startsWith("0x"))throw new Error("The address or message hash is invalid");const h=await this.sdk.txs.signMessage(r);return("signature"in h?h.signature:void 0)||"0x"}case"eth_signTypedData":case"eth_signTypedData_v4":{const[t,r]=e,h=typeof r=="string"?JSON.parse(r):r;if(this.safe.safeAddress.toLowerCase()!==t.toLowerCase())throw new Error("The address is invalid");const c=await this.sdk.txs.signTypedMessage(h);return("signature"in c?c.signature:void 0)||"0x"}case"eth_sendTransaction":const s={...e[0],value:e[0].value||"0",data:e[0].data||"0x"};typeof s.gas=="string"&&s.gas.startsWith("0x")&&(s.gas=parseInt(s.gas,16));const o=await this.sdk.txs.send({txs:[s],params:{safeTxGas:s.gas}});return this.submittedTxs.set(o.safeTxHash,{from:this.safe.safeAddress,hash:o.safeTxHash,gas:0,gasPrice:"0x00",nonce:0,input:s.data,value:s.value,to:s.to,blockHash:null,blockNumber:null,transactionIndex:null}),o.safeTxHash;case"eth_blockNumber":return(await this.sdk.eth.getBlockByNumber(["latest"])).number;case"eth_getBalance":return this.sdk.eth.getBalance([(0,u.getLowerCase)(e[0]),e[1]]);case"eth_getCode":return this.sdk.eth.getCode([(0,u.getLowerCase)(e[0]),e[1]]);case"eth_getTransactionCount":return this.sdk.eth.getTransactionCount([(0,u.getLowerCase)(e[0]),e[1]]);case"eth_getStorageAt":return this.sdk.eth.getStorageAt([(0,u.getLowerCase)(e[0]),e[1],e[2]]);case"eth_getBlockByNumber":return this.sdk.eth.getBlockByNumber([e[0],e[1]]);case"eth_getBlockByHash":return this.sdk.eth.getBlockByHash([e[0],e[1]]);case"eth_getTransactionByHash":let d=e[0];try{d=(await this.sdk.txs.getBySafeTxHash(d)).txHash||d}catch{}return this.submittedTxs.has(d)?this.submittedTxs.get(d):this.sdk.eth.getTransactionByHash([d]).then(t=>(t&&(t.hash=e[0]),t));case"eth_getTransactionReceipt":{let t=e[0];try{t=(await this.sdk.txs.getBySafeTxHash(t)).txHash||t}catch{}return this.sdk.eth.getTransactionReceipt([t]).then(r=>(r&&(r.transactionHash=e[0]),r))}case"eth_estimateGas":return this.sdk.eth.getEstimateGas(e[0]);case"eth_call":return this.sdk.eth.call([e[0],e[1]]);case"eth_getLogs":return this.sdk.eth.getPastLogs([e[0]]);case"eth_gasPrice":return this.sdk.eth.getGasPrice();case"wallet_getPermissions":return this.sdk.wallet.getPermissions();case"wallet_requestPermissions":return this.sdk.wallet.requestPermissions(e[0]);case"safe_setSettings":return this.sdk.eth.setSafeSettings([e[0]]);default:throw Error(`"${a.method}" not implemented`)}}send(a,i){a||i("Undefined request"),this.request(a).then(e=>i(null,{jsonrpc:"2.0",id:a.id,result:e})).catch(e=>i(e,null))}}g.SafeAppProvider=k;(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.SafeAppProvider=void 0;var a=g;Object.defineProperty(n,"SafeAppProvider",{enumerable:!0,get:function(){return a.SafeAppProvider}})})(l);const y=_({__proto__:null},[l]);exports.index=y;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as fe, s as Ke, T as E, o as Q, R as Ho, a as g, t as P, p as H, y as ae } from "./index-
|
|
2
|
-
import { bb as Bo, F as R, bY as Zo } from "./W3MFrameProviderSingleton-
|
|
1
|
+
import { n as fe, s as Ke, T as E, o as Q, R as Ho, a as g, t as P, p as H, y as ae } from "./index-DDxg-CnX.js";
|
|
2
|
+
import { bb as Bo, F as R, bY as Zo } from "./W3MFrameProviderSingleton-C0cnhaTp.js";
|
|
3
3
|
/**
|
|
4
4
|
* @license
|
|
5
5
|
* Copyright 2019 Google LLC
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./W3MFrameProviderSingleton-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./W3MFrameProviderSingleton-BPW-iicw.cjs"),o=n.proxy({status:"uninitialized"}),u={state:o,subscribeKey(t,e){return n.subscribeKey(o,t,e)},subscribe(t){return n.subscribe(o,()=>t(o))},_getClient(){if(!o._client)throw new Error("SIWEController client not set");return o._client},async getNonce(t){const i=await this._getClient().getNonce(t);return this.setNonce(i),i},async getSession(){try{const e=await this._getClient().getSession();return e&&(this.setSession(e),this.setStatus("success")),e}catch{return}},createMessage(t){const i=this._getClient().createMessage(t);return this.setMessage(i),i},async verifyMessage(t){return await this._getClient().verifyMessage(t)},async signIn(){return await this._getClient().signIn()},async signOut(){var e;const t=this._getClient();await t.signOut(),this.setStatus("ready"),this.setSession(void 0),(e=t.onSignOut)==null||e.call(t)},onSignIn(t){var i;const e=this._getClient();(i=e.onSignIn)==null||i.call(e,t)},onSignOut(){var e;const t=this._getClient();(e=t.onSignOut)==null||e.call(t)},setSIWEClient(t){o._client=n.ref(t),o.status="ready",n.OptionsController.setIsSiweEnabled(t.options.enabled)},setNonce(t){o.nonce=t},setStatus(t){o.status=t,n.AccountController.setSiweStatus(t)},setMessage(t){o.message=t},setSession(t){o.session=t,o.status=t?"success":"ready"}},d=n.i`
|
|
2
2
|
:host {
|
|
3
3
|
display: flex;
|
|
4
4
|
justify-content: center;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./index-D4J5pbXW.cjs"),O=require("./W3MFrameProviderSingleton-BPW-iicw.cjs");/**
|
|
2
2
|
* @license
|
|
3
3
|
* Copyright 2019 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { bb as Ns, j as be, bd as yb, be as tt, bf as Th, bg as xa, bh as Wr, bi as qr, bj as Wp, B as Os, bk as Zp, bl as Xp, bm as wb, bn as td, bo as Ef, bp as vh, bq as ba, br as bb, bs as _b, bt as Ab, bu as Eb, bv as dn, bw as Ib, bx as tr, by as _r, b9 as gs, bz as Na, bA as Sb, bB as Pb, bC as Mb, bD as If, bE as Cb, bF as xb, bG as Nb, bH as Rb, bI as an, bJ as Fh, bK as ti, bL as Ob, bM as Dh, bN as qh, bO as Ra, bP as kh, bQ as ed, bR as Vi, bS as gi, bT as ro, bU as lo, bV as en, bW as Mi } from "./W3MFrameProviderSingleton-
|
|
1
|
+
import { bb as Ns, j as be, bd as yb, be as tt, bf as Th, bg as xa, bh as Wr, bi as qr, bj as Wp, B as Os, bk as Zp, bl as Xp, bm as wb, bn as td, bo as Ef, bp as vh, bq as ba, br as bb, bs as _b, bt as Ab, bu as Eb, bv as dn, bw as Ib, bx as tr, by as _r, b9 as gs, bz as Na, bA as Sb, bB as Pb, bC as Mb, bD as If, bE as Cb, bF as xb, bG as Nb, bH as Rb, bI as an, bJ as Fh, bK as ti, bL as Ob, bM as Dh, bN as qh, bO as Ra, bP as kh, bQ as ed, bR as Vi, bS as gi, bT as ro, bU as lo, bV as en, bW as Mi } from "./W3MFrameProviderSingleton-C0cnhaTp.js";
|
|
2
2
|
const Tb = ":";
|
|
3
3
|
function io(i) {
|
|
4
4
|
const [t, e] = i.split(Tb);
|
|
@@ -11628,7 +11628,7 @@ class Xh {
|
|
|
11628
11628
|
if (this.rpc = this.getRpcConfig(t), this.chainId = this.rpc.chains.length ? Ca(this.rpc.chains) : Ca(this.rpc.optionalChains), this.signer = await o4.init({ projectId: this.rpc.projectId, metadata: this.rpc.metadata, disableProviderPing: t.disableProviderPing, relayUrl: t.relayUrl, storageOptions: t.storageOptions, customStoragePrefix: t.customStoragePrefix, telemetryEnabled: t.telemetryEnabled }), this.registerEventListeners(), await this.loadPersistedSession(), this.rpc.showQrModal) {
|
|
11629
11629
|
let e;
|
|
11630
11630
|
try {
|
|
11631
|
-
const { WalletConnectModal: s } = await import("./index-
|
|
11631
|
+
const { WalletConnectModal: s } = await import("./index-DDxg-CnX.js").then((o) => o.i);
|
|
11632
11632
|
e = s;
|
|
11633
11633
|
} catch {
|
|
11634
11634
|
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 A=require("./W3MFrameProviderSingleton-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const A=require("./W3MFrameProviderSingleton-BPW-iicw.cjs"),Uw=":";function $n(i){const[t,e]=i.split(Uw);return{namespace:t,reference:e}}function Gl(i,t=[]){const e=[];return Object.keys(i).forEach(s=>{if(t.length&&!t.includes(s))return;const o=i[s];e.push(...o.accounts)}),e}function Ap(i,t){return i.includes(":")?[i]:t.chains||[]}var $w=Object.defineProperty,Yl=Object.getOwnPropertySymbols,zw=Object.prototype.hasOwnProperty,Lw=Object.prototype.propertyIsEnumerable,Wl=(i,t,e)=>t in i?$w(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,Zl=(i,t)=>{for(var e in t||(t={}))zw.call(t,e)&&Wl(i,e,t[e]);if(Yl)for(var e of Yl(t))Lw.call(t,e)&&Wl(i,e,t[e]);return i};const Kw="ReactNative",mr={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},Hw="js";function Hn(){return typeof A.process$1<"u"&&typeof A.process$1.versions<"u"&&typeof A.process$1.versions.node<"u"}function Gn(){return!A.getDocument_1()&&!!A.getNavigator_1()&&navigator.product===Kw}function Yn(){return!Hn()&&!!A.getNavigator_1()&&!!A.getDocument_1()}function Wn(){return Gn()?mr.reactNative:Hn()?mr.node:Yn()?mr.browser:mr.unknown}function Vw(){var i;try{return Gn()&&typeof A.global<"u"&&typeof(A.global==null?void 0:A.global.Application)<"u"?(i=A.global.Application)==null?void 0:i.applicationId:void 0}catch{return}}function Jw(i,t){let e=A.queryString.parse(i);return e=Zl(Zl({},e),t),i=A.queryString.stringify(e),i}function Qw(){return A.getWindowMetadata_1()||{name:"",description:"",url:"",icons:[""]}}function Gw(){if(Wn()===mr.reactNative&&typeof A.global<"u"&&typeof(A.global==null?void 0:A.global.Platform)<"u"){const{OS:e,Version:s}=A.global.Platform;return[e,s].join("-")}const i=A.detect();if(i===null)return"unknown";const t=i.os?i.os.replace(" ","").toLowerCase():"unknown";return i.type==="browser"?[t,i.name,i.version].join("-"):[t,i.version].join("-")}function Yw(){var i;const t=Wn();return t===mr.browser?[t,((i=A.getLocation_1())==null?void 0:i.host)||"unknown"].join(":"):t}function Ww(i,t,e){const s=Gw(),o=Yw();return[[i,t].join("-"),[Hw,e].join("-"),s,o].join("/")}function Zw({protocol:i,version:t,relayUrl:e,sdkVersion:s,auth:o,projectId:a,useOnCloseEvent:h,bundleId:p}){const v=e.split("?"),y=Ww(i,t,s),M={auth:o,ua:y,projectId:a,useOnCloseEvent:h||void 0,origin:p||void 0},P=Jw(v[1]||"",M);return v[0]+"?"+P}function ws(i,t){return i.filter(e=>t.includes(e)).length===i.length}function Ep(i){return Object.fromEntries(i.entries())}function Ip(i){return new Map(Object.entries(i))}function ys(i=A.cjs.FIVE_MINUTES,t){const e=A.cjs.toMiliseconds(i||A.cjs.FIVE_MINUTES);let s,o,a;return{resolve:h=>{a&&s&&(clearTimeout(a),s(h))},reject:h=>{a&&o&&(clearTimeout(a),o(h))},done:()=>new Promise((h,p)=>{a=setTimeout(()=>{p(new Error(t))},e),s=h,o=p})}}function Qs(i,t,e){return new Promise(async(s,o)=>{const a=setTimeout(()=>o(new Error(e)),t);try{const h=await i;s(h)}catch(h){o(h)}clearTimeout(a)})}function Sp(i,t){if(typeof t=="string"&&t.startsWith(`${i}:`))return t;if(i.toLowerCase()==="topic"){if(typeof t!="string")throw new Error('Value must be "string" for expirer target type: topic');return`topic:${t}`}else if(i.toLowerCase()==="id"){if(typeof t!="number")throw new Error('Value must be "number" for expirer target type: id');return`id:${t}`}throw new Error(`Unknown expirer target type: ${i}`)}function Xw(i){return Sp("topic",i)}function tb(i){return Sp("id",i)}function Pp(i){const[t,e]=i.split(":"),s={id:void 0,topic:void 0};if(t==="topic"&&typeof e=="string")s.topic=e;else if(t==="id"&&Number.isInteger(Number(e)))s.id=Number(e);else throw new Error(`Invalid target, expected id:number or topic:string, got ${t}:${e}`);return s}function Ue(i,t){return A.cjs.fromMiliseconds(Date.now()+A.cjs.toMiliseconds(i))}function rs(i){return Date.now()>=A.cjs.toMiliseconds(i)}function It(i,t){return`${i}${t?`:${t}`:""}`}function Yo(i=[],t=[]){return[...new Set([...i,...t])]}async function eb({id:i,topic:t,wcDeepLink:e}){var s;try{if(!e)return;const o=typeof e=="string"?JSON.parse(e):e;let a=o==null?void 0:o.href;if(typeof a!="string")return;a.endsWith("/")&&(a=a.slice(0,-1));const h=`${a}/wc?requestId=${i}&sessionTopic=${t}`,p=Wn();if(p===mr.browser){if(!((s=A.getDocument_1())!=null&&s.hasFocus())){console.warn("Document does not have focus, skipping deeplink.");return}h.startsWith("https://")||h.startsWith("http://")?window.open(h,"_blank","noreferrer noopener"):window.open(h,"_self","noreferrer noopener")}else p===mr.reactNative&&typeof(A.global==null?void 0:A.global.Linking)<"u"&&await A.global.Linking.openURL(h)}catch(o){console.error(o)}}async function rb(i,t){try{return await i.getItem(t)||(Yn()?localStorage.getItem(t):void 0)}catch(e){console.error(e)}}function ib(){return typeof crypto<"u"&&crypto!=null&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,i=>{const t=Math.random()*16|0;return(i==="x"?t:t&3|8).toString(16)})}var Mp=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof A.global<"u"?A.global:typeof self<"u"?self:{};function sb(i){var t=i.default;if(typeof t=="function"){var e=function(){return t.apply(this,arguments)};e.prototype=t.prototype}else e={};return Object.defineProperty(e,"__esModule",{value:!0}),Object.keys(i).forEach(function(s){var o=Object.getOwnPropertyDescriptor(i,s);Object.defineProperty(e,s,o.get?o:{enumerable:!0,get:function(){return i[s]}})}),e}var Cp={exports:{}};/**
|
|
2
2
|
* [js-sha3]{@link https://github.com/emn178/js-sha3}
|
|
3
3
|
*
|
|
4
4
|
* @version 0.8.0
|
|
@@ -40,4 +40,4 @@ __p += '`),Rt&&(J+=`' +
|
|
|
40
40
|
function print() { __p += __j.call(arguments, '') }
|
|
41
41
|
`:`;
|
|
42
42
|
`)+J+`return __p
|
|
43
|
-
}`;var _t=Vl(function(){return qt(_,nt+"return "+J).apply(e,x)});if(_t.source=J,mc(_t))throw _t;return _t}function Jy(r){return jt(r).toLowerCase()}function Qy(r){return jt(r).toUpperCase()}function Gy(r,n,c){if(r=jt(r),r&&(c||n===e))return eu(r);if(!r||!(n=fr(n)))return r;var l=kr(r),g=kr(n),_=ru(l,g),x=iu(l,g)+1;return Xi(l,_,x).join("")}function Yy(r,n,c){if(r=jt(r),r&&(c||n===e))return r.slice(0,nu(r)+1);if(!r||!(n=fr(n)))return r;var l=kr(r),g=iu(l,kr(n))+1;return Xi(l,0,g).join("")}function Wy(r,n,c){if(r=jt(r),r&&(c||n===e))return r.replace(Jt,"");if(!r||!(n=fr(n)))return r;var l=kr(r),g=ru(l,kr(n));return Xi(l,g).join("")}function Zy(r,n){var c=Te,l=Ct;if(be(n)){var g="separator"in n?n.separator:g;c="length"in n?bt(n.length):c,l="omission"in n?fr(n.omission):l}r=jt(r);var _=r.length;if(Ns(r)){var x=kr(r);_=x.length}if(c>=_)return r;var R=c-Os(l);if(R<1)return l;var F=x?Xi(x,0,R).join(""):r.slice(0,R);if(g===e)return F+l;if(x&&(R+=F.length-R),vc(g)){if(r.slice(R).search(g)){var z,L=F;for(g.global||(g=Ta(g.source,jt(Zt.exec(g))+"g")),g.lastIndex=0;z=g.exec(L);)var J=z.index;F=F.slice(0,J===e?R:J)}}else if(r.indexOf(fr(g),R)!=R){var Z=F.lastIndexOf(g);Z>-1&&(F=F.slice(0,Z))}return F+l}function Xy(r){return r=jt(r),r&&se.test(r)?r.replace(Yt,C0):r}var tw=js(function(r,n,c){return r+(c?" ":"")+n.toUpperCase()}),bc=Ju("toUpperCase");function Hl(r,n,c){return r=jt(r),n=c?e:n,n===e?E0(r)?N0(r):d0(r):r.match(n)||[]}var Vl=At(function(r,n){try{return ur(r,e,n)}catch(c){return mc(c)?c:new vt(c)}}),ew=Oi(function(r,n){return br(n,function(c){c=oi(c),Ri(r,c,dc(r[c],r))}),r});function rw(r){var n=r==null?0:r.length,c=ft();return r=n?we(r,function(l){if(typeof l[1]!="function")throw new _r(h);return[c(l[0]),l[1]]}):[],At(function(l){for(var g=-1;++g<n;){var _=r[g];if(ur(_[0],this,l))return ur(_[1],this,l)}})}function iw(r){return Cg(Er(r,P))}function _c(r){return function(){return r}}function sw(r,n){return r==null||r!==r?n:r}var nw=Gu(),ow=Gu(!0);function rr(r){return r}function Ac(r){return Su(typeof r=="function"?r:Er(r,P))}function aw(r){return Mu(Er(r,P))}function cw(r,n){return Cu(r,Er(n,P))}var hw=At(function(r,n){return function(c){return An(c,r,n)}}),uw=At(function(r,n){return function(c){return An(r,c,n)}});function Ec(r,n,c){var l=Fe(n),g=Ao(n,l);c==null&&!(be(n)&&(g.length||!l.length))&&(c=n,n=r,r=this,g=Ao(n,Fe(n)));var _=!(be(c)&&"chain"in c)||!!c.chain,x=Fi(r);return br(g,function(R){var F=n[R];r[R]=F,x&&(r.prototype[R]=function(){var z=this.__chain__;if(_||z){var L=r(this.__wrapped__),J=L.__actions__=Xe(this.__actions__);return J.push({func:F,args:arguments,thisArg:r}),L.__chain__=z,L}return F.apply(r,Ji([this.value()],arguments))})}),r}function lw(){return qe._===this&&(qe._=k0),this}function Ic(){}function fw(r){return r=bt(r),At(function(n){return xu(n,r)})}var pw=ec(we),dw=ec(Yh),gw=ec(Pa);function Jl(r){return cc(r)?Ma(oi(r)):Hg(r)}function mw(r){return function(n){return r==null?e:ls(r,n)}}var vw=Wu(),yw=Wu(!0);function Sc(){return[]}function Pc(){return!1}function ww(){return{}}function bw(){return""}function _w(){return!0}function Aw(r,n){if(r=bt(r),r<1||r>N)return[];var c=f,l=Le(r,f);n=ft(n),r-=f;for(var g=Ra(l,n);++c<r;)n(c);return g}function Ew(r){return yt(r)?we(r,oi):pr(r)?[r]:Xe(pl(jt(r)))}function Iw(r){var n=++D0;return jt(r)+n}var Sw=Co(function(r,n){return r+n},0),Pw=rc("ceil"),Mw=Co(function(r,n){return r/n},1),Cw=rc("floor");function xw(r){return r&&r.length?_o(r,rr,$a):e}function Rw(r,n){return r&&r.length?_o(r,ft(n,2),$a):e}function Nw(r){return Xh(r,rr)}function Ow(r,n){return Xh(r,ft(n,2))}function Tw(r){return r&&r.length?_o(r,rr,Ha):e}function Fw(r,n){return r&&r.length?_o(r,ft(n,2),Ha):e}var Dw=Co(function(r,n){return r*n},1),qw=rc("round"),kw=Co(function(r,n){return r-n},0);function Bw(r){return r&&r.length?xa(r,rr):0}function jw(r,n){return r&&r.length?xa(r,ft(n,2)):0}return w.after=av,w.ary=Il,w.assign=Qv,w.assignIn=Bl,w.assignInWith=$o,w.assignWith=Gv,w.at=Yv,w.before=Sl,w.bind=dc,w.bindAll=ew,w.bindKey=Pl,w.castArray=wv,w.chain=_l,w.chunk=C1,w.compact=x1,w.concat=R1,w.cond=rw,w.conforms=iw,w.constant=_c,w.countBy=Bm,w.create=Wv,w.curry=Ml,w.curryRight=Cl,w.debounce=xl,w.defaults=Zv,w.defaultsDeep=Xv,w.defer=cv,w.delay=hv,w.difference=N1,w.differenceBy=O1,w.differenceWith=T1,w.drop=F1,w.dropRight=D1,w.dropRightWhile=q1,w.dropWhile=k1,w.fill=B1,w.filter=Um,w.flatMap=Lm,w.flatMapDeep=Km,w.flatMapDepth=Hm,w.flatten=vl,w.flattenDeep=j1,w.flattenDepth=U1,w.flip=uv,w.flow=nw,w.flowRight=ow,w.fromPairs=$1,w.functions=oy,w.functionsIn=ay,w.groupBy=Vm,w.initial=L1,w.intersection=K1,w.intersectionBy=H1,w.intersectionWith=V1,w.invert=hy,w.invertBy=uy,w.invokeMap=Qm,w.iteratee=Ac,w.keyBy=Gm,w.keys=Fe,w.keysIn=er,w.map=Do,w.mapKeys=fy,w.mapValues=py,w.matches=aw,w.matchesProperty=cw,w.memoize=ko,w.merge=dy,w.mergeWith=jl,w.method=hw,w.methodOf=uw,w.mixin=Ec,w.negate=Bo,w.nthArg=fw,w.omit=gy,w.omitBy=my,w.once=lv,w.orderBy=Ym,w.over=pw,w.overArgs=fv,w.overEvery=dw,w.overSome=gw,w.partial=gc,w.partialRight=Rl,w.partition=Wm,w.pick=vy,w.pickBy=Ul,w.property=Jl,w.propertyOf=mw,w.pull=Y1,w.pullAll=wl,w.pullAllBy=W1,w.pullAllWith=Z1,w.pullAt=X1,w.range=vw,w.rangeRight=yw,w.rearg=pv,w.reject=tv,w.remove=tm,w.rest=dv,w.reverse=fc,w.sampleSize=rv,w.set=wy,w.setWith=by,w.shuffle=iv,w.slice=em,w.sortBy=ov,w.sortedUniq=cm,w.sortedUniqBy=hm,w.split=Ly,w.spread=gv,w.tail=um,w.take=lm,w.takeRight=fm,w.takeRightWhile=pm,w.takeWhile=dm,w.tap=xm,w.throttle=mv,w.thru=Fo,w.toArray=Dl,w.toPairs=$l,w.toPairsIn=zl,w.toPath=Ew,w.toPlainObject=kl,w.transform=_y,w.unary=vv,w.union=gm,w.unionBy=mm,w.unionWith=vm,w.uniq=ym,w.uniqBy=wm,w.uniqWith=bm,w.unset=Ay,w.unzip=pc,w.unzipWith=bl,w.update=Ey,w.updateWith=Iy,w.values=zs,w.valuesIn=Sy,w.without=_m,w.words=Hl,w.wrap=yv,w.xor=Am,w.xorBy=Em,w.xorWith=Im,w.zip=Sm,w.zipObject=Pm,w.zipObjectDeep=Mm,w.zipWith=Cm,w.entries=$l,w.entriesIn=zl,w.extend=Bl,w.extendWith=$o,Ec(w,w),w.add=Sw,w.attempt=Vl,w.camelCase=xy,w.capitalize=Ll,w.ceil=Pw,w.clamp=Py,w.clone=bv,w.cloneDeep=Av,w.cloneDeepWith=Ev,w.cloneWith=_v,w.conformsTo=Iv,w.deburr=Kl,w.defaultTo=sw,w.divide=Mw,w.endsWith=Ry,w.eq=jr,w.escape=Ny,w.escapeRegExp=Oy,w.every=jm,w.find=$m,w.findIndex=gl,w.findKey=ty,w.findLast=zm,w.findLastIndex=ml,w.findLastKey=ey,w.floor=Cw,w.forEach=Al,w.forEachRight=El,w.forIn=ry,w.forInRight=iy,w.forOwn=sy,w.forOwnRight=ny,w.get=yc,w.gt=Sv,w.gte=Pv,w.has=cy,w.hasIn=wc,w.head=yl,w.identity=rr,w.includes=Jm,w.indexOf=z1,w.inRange=My,w.invoke=ly,w.isArguments=ds,w.isArray=yt,w.isArrayBuffer=Mv,w.isArrayLike=tr,w.isArrayLikeObject=Ee,w.isBoolean=Cv,w.isBuffer=ts,w.isDate=xv,w.isElement=Rv,w.isEmpty=Nv,w.isEqual=Ov,w.isEqualWith=Tv,w.isError=mc,w.isFinite=Fv,w.isFunction=Fi,w.isInteger=Nl,w.isLength=jo,w.isMap=Ol,w.isMatch=Dv,w.isMatchWith=qv,w.isNaN=kv,w.isNative=Bv,w.isNil=Uv,w.isNull=jv,w.isNumber=Tl,w.isObject=be,w.isObjectLike=_e,w.isPlainObject=Cn,w.isRegExp=vc,w.isSafeInteger=$v,w.isSet=Fl,w.isString=Uo,w.isSymbol=pr,w.isTypedArray=$s,w.isUndefined=zv,w.isWeakMap=Lv,w.isWeakSet=Kv,w.join=J1,w.kebabCase=Ty,w.last=Sr,w.lastIndexOf=Q1,w.lowerCase=Fy,w.lowerFirst=Dy,w.lt=Hv,w.lte=Vv,w.max=xw,w.maxBy=Rw,w.mean=Nw,w.meanBy=Ow,w.min=Tw,w.minBy=Fw,w.stubArray=Sc,w.stubFalse=Pc,w.stubObject=ww,w.stubString=bw,w.stubTrue=_w,w.multiply=Dw,w.nth=G1,w.noConflict=lw,w.noop=Ic,w.now=qo,w.pad=qy,w.padEnd=ky,w.padStart=By,w.parseInt=jy,w.random=Cy,w.reduce=Zm,w.reduceRight=Xm,w.repeat=Uy,w.replace=$y,w.result=yy,w.round=qw,w.runInContext=O,w.sample=ev,w.size=sv,w.snakeCase=zy,w.some=nv,w.sortedIndex=rm,w.sortedIndexBy=im,w.sortedIndexOf=sm,w.sortedLastIndex=nm,w.sortedLastIndexBy=om,w.sortedLastIndexOf=am,w.startCase=Ky,w.startsWith=Hy,w.subtract=kw,w.sum=Bw,w.sumBy=jw,w.template=Vy,w.times=Aw,w.toFinite=Di,w.toInteger=bt,w.toLength=ql,w.toLower=Jy,w.toNumber=Pr,w.toSafeInteger=Jv,w.toString=jt,w.toUpper=Qy,w.trim=Gy,w.trimEnd=Yy,w.trimStart=Wy,w.truncate=Zy,w.unescape=Xy,w.uniqueId=Iw,w.upperCase=tw,w.upperFirst=bc,w.each=Al,w.eachRight=El,w.first=yl,Ec(w,function(){var r={};return si(w,function(n,c){Qt.call(w.prototype,c)||(r[c]=n)}),r}(),{chain:!1}),w.VERSION=s,br(["bind","bindKey","curry","curryRight","partial","partialRight"],function(r){w[r].placeholder=w}),br(["drop","take"],function(r,n){St.prototype[r]=function(c){c=c===e?1:Re(bt(c),0);var l=this.__filtered__&&!n?new St(this):this.clone();return l.__filtered__?l.__takeCount__=Le(c,l.__takeCount__):l.__views__.push({size:Le(c,f),type:r+(l.__dir__<0?"Right":"")}),l},St.prototype[r+"Right"]=function(c){return this.reverse()[r](c).reverse()}}),br(["filter","map","takeWhile"],function(r,n){var c=n+1,l=c==d||c==I;St.prototype[r]=function(g){var _=this.clone();return _.__iteratees__.push({iteratee:ft(g,3),type:c}),_.__filtered__=_.__filtered__||l,_}}),br(["head","last"],function(r,n){var c="take"+(n?"Right":"");St.prototype[r]=function(){return this[c](1).value()[0]}}),br(["initial","tail"],function(r,n){var c="drop"+(n?"":"Right");St.prototype[r]=function(){return this.__filtered__?new St(this):this[c](1)}}),St.prototype.compact=function(){return this.filter(rr)},St.prototype.find=function(r){return this.filter(r).head()},St.prototype.findLast=function(r){return this.reverse().find(r)},St.prototype.invokeMap=At(function(r,n){return typeof r=="function"?new St(this):this.map(function(c){return An(c,r,n)})}),St.prototype.reject=function(r){return this.filter(Bo(ft(r)))},St.prototype.slice=function(r,n){r=bt(r);var c=this;return c.__filtered__&&(r>0||n<0)?new St(c):(r<0?c=c.takeRight(-r):r&&(c=c.drop(r)),n!==e&&(n=bt(n),c=n<0?c.dropRight(-n):c.take(n-r)),c)},St.prototype.takeRightWhile=function(r){return this.reverse().takeWhile(r).reverse()},St.prototype.toArray=function(){return this.take(f)},si(St.prototype,function(r,n){var c=/^(?:filter|find|map|reject)|While$/.test(n),l=/^(?:head|last)$/.test(n),g=w[l?"take"+(n=="last"?"Right":""):n],_=l||/^find/.test(n);g&&(w.prototype[n]=function(){var x=this.__wrapped__,R=l?[1]:arguments,F=x instanceof St,z=R[0],L=F||yt(x),J=function(Et){var Rt=g.apply(w,Ji([Et],R));return l&&Z?Rt[0]:Rt};L&&c&&typeof z=="function"&&z.length!=1&&(F=L=!1);var Z=this.__chain__,nt=!!this.__actions__.length,pt=_&&!Z,_t=F&&!nt;if(!_&&L){x=_t?x:new St(this);var dt=r.apply(x,R);return dt.__actions__.push({func:Fo,args:[J],thisArg:e}),new Ar(dt,Z)}return pt&&_t?r.apply(this,R):(dt=this.thru(J),pt?l?dt.value()[0]:dt.value():dt)})}),br(["pop","push","shift","sort","splice","unshift"],function(r){var n=no[r],c=/^(?:push|sort|unshift)$/.test(r)?"tap":"thru",l=/^(?:pop|shift)$/.test(r);w.prototype[r]=function(){var g=arguments;if(l&&!this.__chain__){var _=this.value();return n.apply(yt(_)?_:[],g)}return this[c](function(x){return n.apply(yt(x)?x:[],g)})}}),si(St.prototype,function(r,n){var c=w[n];if(c){var l=c.name+"";Qt.call(qs,l)||(qs[l]=[]),qs[l].push({name:n,func:c})}}),qs[Mo(e,Q).name]=[{name:"wrapper",func:e}],St.prototype.clone=X0,St.prototype.reverse=tg,St.prototype.value=eg,w.prototype.at=Rm,w.prototype.chain=Nm,w.prototype.commit=Om,w.prototype.next=Tm,w.prototype.plant=Dm,w.prototype.reverse=qm,w.prototype.toJSON=w.prototype.valueOf=w.prototype.value=km,w.prototype.first=w.prototype.head,gn&&(w.prototype[gn]=Fm),w},Ts=O0();os?((os.exports=Ts)._=Ts,Aa._=Ts):qe._=Ts}).call(kn)})(lh,lh.exports);var jI=Object.defineProperty,UI=Object.defineProperties,$I=Object.getOwnPropertyDescriptors,up=Object.getOwnPropertySymbols,zI=Object.prototype.hasOwnProperty,LI=Object.prototype.propertyIsEnumerable,lp=(i,t,e)=>t in i?jI(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,Jo=(i,t)=>{for(var e in t||(t={}))zI.call(t,e)&&lp(i,e,t[e]);if(up)for(var e of up(t))LI.call(t,e)&&lp(i,e,t[e]);return i},KI=(i,t)=>UI(i,$I(t));function Qr(i,t,e){var s;const o=$n(i);return((s=t.rpcMap)==null?void 0:s[o.reference])||`${BI}?chainId=${o.namespace}:${o.reference}&projectId=${e}`}function Ss(i){return i.includes(":")?i.split(":")[1]:i}function qd(i){return i.map(t=>`${t.split(":")[0]}:${t.split(":")[1]}`)}function HI(i,t){const e=Object.keys(t.namespaces).filter(o=>o.includes(i));if(!e.length)return[];const s=[];return e.forEach(o=>{const a=t.namespaces[o].accounts;s.push(...a)}),s}function Qc(i={},t={}){const e=fp(i),s=fp(t);return lh.exports.merge(e,s)}function fp(i){var t,e,s,o;const a={};if(!Qn(i))return a;for(const[h,p]of Object.entries(i)){const v=bh(h)?[h]:p.chains,y=p.methods||[],M=p.events||[],P=p.rpcMap||{},T=Un(h);a[T]=KI(Jo(Jo({},a[T]),p),{chains:Yo(v,(t=a[T])==null?void 0:t.chains),methods:Yo(y,(e=a[T])==null?void 0:e.methods),events:Yo(M,(s=a[T])==null?void 0:s.events),rpcMap:Jo(Jo({},P),(o=a[T])==null?void 0:o.rpcMap)})}return a}function VI(i){return i.includes(":")?i.split(":")[2]:i}function pp(i){const t={};for(const[e,s]of Object.entries(i)){const o=s.methods||[],a=s.events||[],h=s.accounts||[],p=bh(e)?[e]:s.chains?s.chains:qd(s.accounts);t[e]={chains:p,methods:o,events:a,accounts:h}}return t}function Gc(i){return typeof i=="number"?i:i.includes("0x")?parseInt(i,16):(i=i.includes(":")?i.split(":")[1]:i,isNaN(Number(i))?i:Number(i))}const kd={},Ut=i=>kd[i],Yc=(i,t)=>{kd[i]=t};class JI{constructor(t){this.name="polkadot",this.namespace=t.namespace,this.events=Ut("events"),this.client=Ut("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){this.httpProviders[t]||this.setHttpProvider(t,e),this.chainId=t,this.events.emit(Gr.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`)}getAccounts(){const t=this.namespace.accounts;return t?t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2])||[]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{var s;const o=Ss(e);t[o]=this.createHttpProvider(o,(s=this.namespace.rpcMap)==null?void 0:s[e])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const s=this.createHttpProvider(t,e);s&&(this.httpProviders[t]=s)}createHttpProvider(t,e){const s=e||Qr(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new A.o(new A.f$1(s,Ut("disableProviderPing")))}}var QI=Object.defineProperty,GI=Object.defineProperties,YI=Object.getOwnPropertyDescriptors,dp=Object.getOwnPropertySymbols,WI=Object.prototype.hasOwnProperty,ZI=Object.prototype.propertyIsEnumerable,gp=(i,t,e)=>t in i?QI(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,mp=(i,t)=>{for(var e in t||(t={}))WI.call(t,e)&&gp(i,e,t[e]);if(dp)for(var e of dp(t))ZI.call(t,e)&&gp(i,e,t[e]);return i},vp=(i,t)=>GI(i,YI(t));class XI{constructor(t){this.name="eip155",this.namespace=t.namespace,this.events=Ut("events"),this.client=Ut("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());case"wallet_getCapabilities":return await this.getCapabilities(t)}return this.namespace.methods.includes(t.request.method)?await this.client.request(t):this.getHttpProvider().request(t.request)}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}setDefaultChain(t,e){this.httpProviders[t]||this.setHttpProvider(parseInt(t),e),this.chainId=parseInt(t),this.events.emit(Gr.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId.toString();if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}createHttpProvider(t,e){const s=e||Qr(`${this.name}:${t}`,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new A.o(new A.f$1(s,Ut("disableProviderPing")))}setHttpProvider(t,e){const s=this.createHttpProvider(t,e);s&&(this.httpProviders[t]=s)}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{var s;const o=parseInt(Ss(e));t[o]=this.createHttpProvider(o,(s=this.namespace.rpcMap)==null?void 0:s[e])}),t}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}getHttpProvider(){const t=this.chainId,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}async handleSwitchChain(t){var e,s;let o=t.request.params?(e=t.request.params[0])==null?void 0:e.chainId:"0x0";o=o.startsWith("0x")?o:`0x${o}`;const a=parseInt(o,16);if(this.isChainApproved(a))this.setDefaultChain(`${a}`);else if(this.namespace.methods.includes("wallet_switchEthereumChain"))await this.client.request({topic:t.topic,request:{method:t.request.method,params:[{chainId:o}]},chainId:(s=this.namespace.chains)==null?void 0:s[0]}),this.setDefaultChain(`${a}`);else throw new Error(`Failed to switch to chain 'eip155:${a}'. The chain is not approved or the wallet does not support 'wallet_switchEthereumChain' method.`);return null}isChainApproved(t){return this.namespace.chains.includes(`${this.name}:${t}`)}async getCapabilities(t){var e,s,o;const a=(s=(e=t.request)==null?void 0:e.params)==null?void 0:s[0];if(!a)throw new Error("Missing address parameter in `wallet_getCapabilities` request");const h=this.client.session.get(t.topic),p=((o=h==null?void 0:h.sessionProperties)==null?void 0:o.capabilities)||{};if(p!=null&&p[a])return p==null?void 0:p[a];const v=await this.client.request(t);try{await this.client.session.update(t.topic,{sessionProperties:vp(mp({},h.sessionProperties||{}),{capabilities:vp(mp({},p||{}),{[a]:v})})})}catch(y){console.warn("Failed to update session with capabilities",y)}return v}}class t8{constructor(t){this.name="solana",this.namespace=t.namespace,this.events=Ut("events"),this.client=Ut("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){this.httpProviders[t]||this.setHttpProvider(t,e),this.chainId=t,this.events.emit(Gr.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{var s;const o=Ss(e);t[o]=this.createHttpProvider(o,(s=this.namespace.rpcMap)==null?void 0:s[e])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const s=this.createHttpProvider(t,e);s&&(this.httpProviders[t]=s)}createHttpProvider(t,e){const s=e||Qr(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new A.o(new A.f$1(s,Ut("disableProviderPing")))}}class e8{constructor(t){this.name="cosmos",this.namespace=t.namespace,this.events=Ut("events"),this.client=Ut("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){this.httpProviders[t]||this.setHttpProvider(t,e),this.chainId=t,this.events.emit(Gr.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{var s;const o=Ss(e);t[o]=this.createHttpProvider(o,(s=this.namespace.rpcMap)==null?void 0:s[e])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const s=this.createHttpProvider(t,e);s&&(this.httpProviders[t]=s)}createHttpProvider(t,e){const s=e||Qr(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new A.o(new A.f$1(s,Ut("disableProviderPing")))}}class r8{constructor(t){this.name="algorand",this.namespace=t.namespace,this.events=Ut("events"),this.client=Ut("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){if(!this.httpProviders[t]){const s=e||Qr(`${this.name}:${t}`,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);this.setHttpProvider(t,s)}this.chainId=t,this.events.emit(Gr.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{var s;t[e]=this.createHttpProvider(e,(s=this.namespace.rpcMap)==null?void 0:s[e])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const s=this.createHttpProvider(t,e);s&&(this.httpProviders[t]=s)}createHttpProvider(t,e){const s=e||Qr(t,this.namespace,this.client.core.projectId);return typeof s>"u"?void 0:new A.o(new A.f$1(s,Ut("disableProviderPing")))}}class i8{constructor(t){this.name="cip34",this.namespace=t.namespace,this.events=Ut("events"),this.client=Ut("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){this.httpProviders[t]||this.setHttpProvider(t,e),this.chainId=t,this.events.emit(Gr.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{const s=this.getCardanoRPCUrl(e),o=Ss(e);t[o]=this.createHttpProvider(o,s)}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}getCardanoRPCUrl(t){const e=this.namespace.rpcMap;if(e)return e[t]}setHttpProvider(t,e){const s=this.createHttpProvider(t,e);s&&(this.httpProviders[t]=s)}createHttpProvider(t,e){const s=e||this.getCardanoRPCUrl(t);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new A.o(new A.f$1(s,Ut("disableProviderPing")))}}class s8{constructor(t){this.name="elrond",this.namespace=t.namespace,this.events=Ut("events"),this.client=Ut("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){this.httpProviders[t]||this.setHttpProvider(t,e),this.chainId=t,this.events.emit(Gr.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{var s;const o=Ss(e);t[o]=this.createHttpProvider(o,(s=this.namespace.rpcMap)==null?void 0:s[e])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const s=this.createHttpProvider(t,e);s&&(this.httpProviders[t]=s)}createHttpProvider(t,e){const s=e||Qr(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new A.o(new A.f$1(s,Ut("disableProviderPing")))}}class n8{constructor(t){this.name="multiversx",this.namespace=t.namespace,this.events=Ut("events"),this.client=Ut("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){this.httpProviders[t]||this.setHttpProvider(t,e),this.chainId=t,this.events.emit(Gr.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{var s;const o=Ss(e);t[o]=this.createHttpProvider(o,(s=this.namespace.rpcMap)==null?void 0:s[e])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const s=this.createHttpProvider(t,e);s&&(this.httpProviders[t]=s)}createHttpProvider(t,e){const s=e||Qr(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new A.o(new A.f$1(s,Ut("disableProviderPing")))}}class o8{constructor(t){this.name="near",this.namespace=t.namespace,this.events=Ut("events"),this.client=Ut("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){if(this.chainId=t,!this.httpProviders[t]){const s=e||Qr(`${this.name}:${t}`,this.namespace);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);this.setHttpProvider(t,s)}this.events.emit(Gr.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const t=this.namespace.accounts;return t?t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2])||[]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{var s;t[e]=this.createHttpProvider(e,(s=this.namespace.rpcMap)==null?void 0:s[e])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const s=this.createHttpProvider(t,e);s&&(this.httpProviders[t]=s)}createHttpProvider(t,e){const s=e||Qr(t,this.namespace);return typeof s>"u"?void 0:new A.o(new A.f$1(s,Ut("disableProviderPing")))}}class a8{constructor(t){this.name=Hs,this.namespace=t.namespace,this.events=Ut("events"),this.client=Ut("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace.chains=[...new Set((this.namespace.chains||[]).concat(t.chains||[]))],this.namespace.accounts=[...new Set((this.namespace.accounts||[]).concat(t.accounts||[]))],this.namespace.methods=[...new Set((this.namespace.methods||[]).concat(t.methods||[]))],this.namespace.events=[...new Set((this.namespace.events||[]).concat(t.events||[]))],this.httpProviders=this.createHttpProviders()}requestAccounts(){return this.getAccounts()}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider(t.chainId).request(t.request)}setDefaultChain(t,e){this.httpProviders[t]||this.setHttpProvider(t,e),this.chainId=t,this.events.emit(Gr.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){var t,e;const s={};return(e=(t=this.namespace)==null?void 0:t.accounts)==null||e.forEach(o=>{const a=$n(o);s[`${a.namespace}:${a.reference}`]=this.createHttpProvider(o)}),s}getHttpProvider(t){const e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const s=this.createHttpProvider(t,e);s&&(this.httpProviders[t]=s)}createHttpProvider(t,e){const s=e||Qr(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new A.o(new A.f$1(s,Ut("disableProviderPing")))}}var c8=Object.defineProperty,h8=Object.defineProperties,u8=Object.getOwnPropertyDescriptors,yp=Object.getOwnPropertySymbols,l8=Object.prototype.hasOwnProperty,f8=Object.prototype.propertyIsEnumerable,wp=(i,t,e)=>t in i?c8(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,Qo=(i,t)=>{for(var e in t||(t={}))l8.call(t,e)&&wp(i,e,t[e]);if(yp)for(var e of yp(t))f8.call(t,e)&&wp(i,e,t[e]);return i},Wc=(i,t)=>h8(i,u8(t));class Ph{constructor(t){this.events=new A.Gg,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:A.Wg(A.k({level:(t==null?void 0:t.logger)||cp})),this.disableProviderPing=(t==null?void 0:t.disableProviderPing)||!1}static async init(t){const e=new Ph(t);return await e.initialize(),e}async request(t,e,s){const[o,a]=this.validateChain(e);if(!this.session)throw new Error("Please call connect() before request()");return await this.getProvider(o).request({request:Qo({},t),chainId:`${o}:${a}`,topic:this.session.topic,expiry:s})}sendAsync(t,e,s,o){const a=new Date().getTime();this.request(t,s,o).then(h=>e(null,A.formatJsonRpcResult(a,h))).catch(h=>e(h,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:Gt("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)}async authenticate(t){if(!this.client)throw new Error("Sign Client not initialized");this.setNamespaces(t),await this.cleanupPendingPairings();const{uri:e,response:s}=await this.client.authenticate(t);e&&(this.uri=e,this.events.emit("display_uri",e));const o=await s();if(this.session=o.session,this.session){const a=pp(this.session.namespaces);this.namespaces=Qc(this.namespaces,a),this.persist("namespaces",this.namespaces),this.onConnect()}return o}on(t,e){this.events.on(t,e)}once(t,e){this.events.once(t,e)}removeListener(t,e){this.events.removeListener(t,e)}off(t,e){this.events.off(t,e)}get isWalletConnect(){return!0}async pair(t){this.shouldAbortPairingAttempt=!1;let e=0;do{if(this.shouldAbortPairingAttempt)throw new Error("Pairing aborted");if(e>=this.maxPairingAttempts)throw new Error("Max auto pairing attempts reached");const{uri:s,approval:o}=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 o().then(a=>{this.session=a;const h=pp(a.namespaces);this.namespaces=Qc(this.namespaces,h),this.persist("namespaces",this.namespaces)}).catch(a=>{if(a.message!==Dd)throw a;e++})}while(!this.session);return this.onConnect(),this.session}setDefaultChain(t,e){try{if(!this.session)return;const[s,o]=this.validateChain(t),a=this.getProvider(s);a.name===Hs?a.setDefaultChain(`${s}:${o}`,e):a.setDefaultChain(o,e)}catch(s){if(!/Please call connect/.test(s.message))throw s}}async cleanupPendingPairings(t={}){this.logger.info("Cleaning up inactive pairings...");const e=this.client.pairing.getAll();if(yi(e)){for(const s of e)t.deletePairings?this.client.core.expirer.set(s.topic,0):await this.client.core.relayer.subscriber.unsubscribe(s.topic);this.logger.info(`Inactive pairings cleared: ${e.length}`)}}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 Sh.init({core:this.providerOpts.core,logger:this.providerOpts.logger||cp,relayUrl:this.providerOpts.relayUrl||DI,projectId:this.providerOpts.projectId,metadata:this.providerOpts.metadata,storageOptions:this.providerOpts.storageOptions,storage:this.providerOpts.storage,name:this.providerOpts.name,customStoragePrefix:this.providerOpts.customStoragePrefix,telemetryEnabled:this.providerOpts.telemetryEnabled}),this.logger.trace("SignClient Initialized")}createProviders(){if(!this.client)throw new Error("Sign Client not initialized");if(!this.session)throw new Error("Session not initialized. Please call connect() before enable()");const t=[...new Set(Object.keys(this.session.namespaces).map(e=>Un(e)))];Yc("client",this.client),Yc("events",this.events),Yc("disableProviderPing",this.disableProviderPing),t.forEach(e=>{if(!this.session)return;const s=HI(e,this.session),o=qd(s),a=Qc(this.namespaces,this.optionalNamespaces),h=Wc(Qo({},a[e]),{accounts:s,chains:o});switch(e){case"eip155":this.rpcProviders[e]=new XI({namespace:h});break;case"algorand":this.rpcProviders[e]=new r8({namespace:h});break;case"solana":this.rpcProviders[e]=new t8({namespace:h});break;case"cosmos":this.rpcProviders[e]=new e8({namespace:h});break;case"polkadot":this.rpcProviders[e]=new JI({namespace:h});break;case"cip34":this.rpcProviders[e]=new i8({namespace:h});break;case"elrond":this.rpcProviders[e]=new s8({namespace:h});break;case"multiversx":this.rpcProviders[e]=new n8({namespace:h});break;case"near":this.rpcProviders[e]=new o8({namespace:h});break;default:this.rpcProviders[Hs]?this.rpcProviders[Hs].updateNamespace(h):this.rpcProviders[Hs]=new a8({namespace:h})}})}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:e}=t,{event:s}=e;if(s.name==="accountsChanged"){const o=s.data;o&&yi(o)&&this.events.emit("accountsChanged",o.map(VI))}else if(s.name==="chainChanged"){const o=e.chainId,a=e.event.data,h=Un(o),p=Gc(o)!==Gc(a)?`${h}:${Gc(a)}`:o;this.onChainChanged(p)}else this.events.emit(s.name,s.data);this.events.emit("session_event",t)}),this.client.on("session_update",({topic:t,params:e})=>{var s;const{namespaces:o}=e,a=(s=this.client)==null?void 0:s.session.get(t);this.session=Wc(Qo({},a),{namespaces:o}),this.onSessionUpdate(),this.events.emit("session_update",{topic:t,params:e})}),this.client.on("session_delete",async t=>{await this.cleanup(),this.events.emit("session_delete",t),this.events.emit("disconnect",Wc(Qo({},Gt("USER_DISCONNECTED")),{data:t.topic}))}),this.on(Gr.DEFAULT_CHAIN_CHANGED,t=>{this.onChainChanged(t,!0)})}getProvider(t){return this.rpcProviders[t]||this.rpcProviders[Hs]}onSessionUpdate(){Object.keys(this.rpcProviders).forEach(t=>{var e;this.getProvider(t).updateNamespace((e=this.session)==null?void 0:e.namespaces[t])})}setNamespaces(t){const{namespaces:e,optionalNamespaces:s,sessionProperties:o}=t;e&&Object.keys(e).length&&(this.namespaces=e),s&&Object.keys(s).length&&(this.optionalNamespaces=s),this.sessionProperties=o,this.persist("namespaces",e),this.persist("optionalNamespaces",s)}validateChain(t){const[e,s]=(t==null?void 0:t.split(":"))||["",""];if(!this.namespaces||!Object.keys(this.namespaces).length)return[e,s];if(e&&!Object.keys(this.namespaces||{}).map(h=>Un(h)).includes(e))throw new Error(`Namespace '${e}' is not configured. Please call connect() first with namespace config.`);if(e&&s)return[e,s];const o=Un(Object.keys(this.namespaces)[0]),a=this.rpcProviders[o].getDefaultChain();return[o,a]}async requestAccounts(){const[t]=this.validateChain();return await this.getProvider(t).requestAccounts()}onChainChanged(t,e=!1){if(!this.namespaces)return;const[s,o]=this.validateChain(t);o&&(e||this.getProvider(s).setDefaultChain(o),this.namespaces[s]?this.namespaces[s].defaultChain=o:this.namespaces[`${s}:${o}`]?this.namespaces[`${s}:${o}`].defaultChain=o:this.namespaces[`${s}:${o}`]={defaultChain:o},this.persist("namespaces",this.namespaces),this.events.emit("chainChanged",o))}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,e){this.client.core.storage.setItem(`${hp}/${t}`,e)}async getFromStore(t){return await this.client.core.storage.getItem(`${hp}/${t}`)}}const p8=Ph,d8="wc",g8="ethereum_provider",m8=`${d8}@2:${g8}:`,v8="https://rpc.walletconnect.com/v1/",ua=["eth_sendTransaction","personal_sign"],Bd=["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","wallet_sendCalls","wallet_getCapabilities","wallet_getCallsStatus","wallet_showCallsStatus"],la=["chainChanged","accountsChanged"],jd=["chainChanged","accountsChanged","message","disconnect","connect"];var y8=Object.defineProperty,w8=Object.defineProperties,b8=Object.getOwnPropertyDescriptors,bp=Object.getOwnPropertySymbols,_8=Object.prototype.hasOwnProperty,A8=Object.prototype.propertyIsEnumerable,_p=(i,t,e)=>t in i?y8(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,Vs=(i,t)=>{for(var e in t||(t={}))_8.call(t,e)&&_p(i,e,t[e]);if(bp)for(var e of bp(t))A8.call(t,e)&&_p(i,e,t[e]);return i},Zc=(i,t)=>w8(i,b8(t));function fa(i){return Number(i[0].split(":")[1])}function Go(i){return`0x${i.toString(16)}`}function E8(i){const{chains:t,optionalChains:e,methods:s,optionalMethods:o,events:a,optionalEvents:h,rpcMap:p}=i;if(!yi(t))throw new Error("Invalid chains");const v={chains:t,methods:s||ua,events:a||la,rpcMap:Vs({},t.length?{[fa(t)]:p[fa(t)]}:{})},y=a==null?void 0:a.filter(D=>!la.includes(D)),M=s==null?void 0:s.filter(D=>!ua.includes(D));if(!e&&!h&&!o&&!(y!=null&&y.length)&&!(M!=null&&M.length))return{required:t.length?v:void 0};const P=(y==null?void 0:y.length)&&(M==null?void 0:M.length)||!e,T={chains:[...new Set(P?v.chains.concat(e||[]):e)],methods:[...new Set(v.methods.concat(o!=null&&o.length?o:Bd))],events:[...new Set(v.events.concat(h!=null&&h.length?h:jd))],rpcMap:p};return{required:t.length?v:void 0,optional:e.length?T:void 0}}class ma{constructor(){this.events=new A.eventsExports.EventEmitter,this.namespace="eip155",this.accounts=[],this.chainId=1,this.STORAGE_KEY=m8,this.on=(t,e)=>(this.events.on(t,e),this),this.once=(t,e)=>(this.events.once(t,e),this),this.removeListener=(t,e)=>(this.events.removeListener(t,e),this),this.off=(t,e)=>(this.events.off(t,e),this),this.parseAccount=t=>this.isCompatibleChainId(t)?this.parseAccountId(t).address:t,this.signer={},this.rpc={}}static async init(t){const e=new ma;return await e.initialize(t),e}async request(t,e){return await this.signer.request(t,this.formatChainId(this.chainId),e)}sendAsync(t,e,s){this.signer.sendAsync(t,e,this.formatChainId(this.chainId),s)}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:e,optional:s}=E8(this.rpc);try{const o=await new Promise(async(h,p)=>{var v;this.rpc.showQrModal&&((v=this.modal)==null||v.subscribeModal(y=>{!y.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),p(new Error("Connection request reset. Please try again.")))})),await this.signer.connect(Zc(Vs({namespaces:Vs({},e&&{[this.namespace]:e})},s&&{optionalNamespaces:{[this.namespace]:s}}),{pairingTopic:t==null?void 0:t.pairingTopic})).then(y=>{h(y)}).catch(y=>{p(new Error(y.message))})});if(!o)return;const a=Gl(o.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:a),this.setAccounts(a),this.events.emit("connect",{chainId:Go(this.chainId)})}catch(o){throw this.signer.logger.error(o),o}finally{this.modal&&this.modal.closeModal()}}async authenticate(t){if(!this.signer.client)throw new Error("Provider not initialized. Call init() first");this.loadConnectOpts({chains:t==null?void 0:t.chains});try{const e=await new Promise(async(o,a)=>{var h;this.rpc.showQrModal&&((h=this.modal)==null||h.subscribeModal(p=>{!p.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),a(new Error("Connection request reset. Please try again.")))})),await this.signer.authenticate(Zc(Vs({},t),{chains:this.rpc.chains})).then(p=>{o(p)}).catch(p=>{a(new Error(p.message))})}),s=e.session;if(s){const o=Gl(s.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:o),this.setAccounts(o),this.events.emit("connect",{chainId:Go(this.chainId)})}return e}catch(e){throw this.signer.logger.error(e),e}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:e}=t,{event:s}=e;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 e=parseInt(t);this.chainId=e,this.events.emit("chainChanged",Go(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",Zc(Vs({},Gt("USER_DISCONNECTED")),{data:t.topic,name:"USER_DISCONNECTED"}))}),this.signer.on("display_uri",t=>{var e,s;this.rpc.showQrModal&&((e=this.modal)==null||e.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 e=t.filter(s=>this.isCompatibleChainId(s)).map(s=>this.parseChainId(s));e.length&&(this.chainId=e[0],this.events.emit("chainChanged",Go(this.chainId)),this.persist())}setChainId(t){if(this.isCompatibleChainId(t)){const e=this.parseChainId(t);this.chainId=e,this.switchEthereumChain(e)}}parseAccountId(t){const[e,s,o]=t.split(":");return{chainId:`${e}:${s}`,address:o}}setAccounts(t){this.accounts=t.filter(e=>this.parseChainId(this.parseAccountId(e).chainId)===this.chainId).map(e=>this.parseAccountId(e).address),this.events.emit("accountsChanged",this.accounts)}getRpcConfig(t){var e,s;const o=(e=t==null?void 0:t.chains)!=null?e:[],a=(s=t==null?void 0:t.optionalChains)!=null?s:[],h=o.concat(a);if(!h.length)throw new Error("No chains specified in either `chains` or `optionalChains`");const p=o.length?(t==null?void 0:t.methods)||ua:[],v=o.length?(t==null?void 0:t.events)||la:[],y=(t==null?void 0:t.optionalMethods)||[],M=(t==null?void 0:t.optionalEvents)||[],P=(t==null?void 0:t.rpcMap)||this.buildRpcMap(h,t.projectId),T=(t==null?void 0:t.qrModalOptions)||void 0;return{chains:o==null?void 0:o.map(D=>this.formatChainId(D)),optionalChains:a.map(D=>this.formatChainId(D)),methods:p,events:v,optionalMethods:y,optionalEvents:M,rpcMap:P,showQrModal:!!(t!=null&&t.showQrModal),qrModalOptions:T,projectId:t.projectId,metadata:t.metadata}}buildRpcMap(t,e){const s={};return t.forEach(o=>{s[o]=this.getRpcUrl(o,e)}),s}async initialize(t){if(this.rpc=this.getRpcConfig(t),this.chainId=this.rpc.chains.length?fa(this.rpc.chains):fa(this.rpc.optionalChains),this.signer=await p8.init({projectId:this.rpc.projectId,metadata:this.rpc.metadata,disableProviderPing:t.disableProviderPing,relayUrl:t.relayUrl,storageOptions:t.storageOptions,customStoragePrefix:t.customStoragePrefix,telemetryEnabled:t.telemetryEnabled}),this.registerEventListeners(),await this.loadPersistedSession(),this.rpc.showQrModal){let e;try{const{WalletConnectModal:s}=await Promise.resolve().then(()=>require("./index-B5dlb2GK.cjs")).then(o=>o.index);e=s}catch{throw new Error("To use QR modal, please install @walletconnect/modal package")}if(e)try{this.modal=new e(Vs({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:e,optionalChains:s,rpcMap:o}=t;e&&yi(e)&&(this.rpc.chains=e.map(a=>this.formatChainId(a)),e.forEach(a=>{this.rpc.rpcMap[a]=(o==null?void 0:o[a])||this.getRpcUrl(a)})),s&&yi(s)&&(this.rpc.optionalChains=[],this.rpc.optionalChains=s==null?void 0:s.map(a=>this.formatChainId(a)),s.forEach(a=>{this.rpc.rpcMap[a]=(o==null?void 0:o[a])||this.getRpcUrl(a)}))}getRpcUrl(t,e){var s;return((s=this.rpc.rpcMap)==null?void 0:s[t])||`${v8}?chainId=eip155:${t}&projectId=${e||this.rpc.projectId}`}async loadPersistedSession(){if(this.session)try{const t=await this.signer.client.core.storage.getItem(`${this.STORAGE_KEY}/chainId`),e=this.session.namespaces[`${this.namespace}:${t}`]?this.session.namespaces[`${this.namespace}:${t}`]:this.session.namespaces[this.namespace];this.setChainIds(t?[this.formatChainId(t)]:e==null?void 0:e.accounts),this.setAccounts(e==null?void 0:e.accounts)}catch(t){this.signer.logger.error("Failed to load persisted session, clearing state..."),this.signer.logger.error(t),await this.disconnect().catch(e=>this.signer.logger.warn(e))}}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(e=>this.parseAccount(e))}}const I8=ma;exports.EthereumProvider=I8;exports.OPTIONAL_EVENTS=jd;exports.OPTIONAL_METHODS=Bd;exports.REQUIRED_EVENTS=la;exports.REQUIRED_METHODS=ua;exports.default=ma;
|
|
43
|
+
}`;var _t=Vl(function(){return qt(_,nt+"return "+J).apply(e,x)});if(_t.source=J,mc(_t))throw _t;return _t}function Jy(r){return jt(r).toLowerCase()}function Qy(r){return jt(r).toUpperCase()}function Gy(r,n,c){if(r=jt(r),r&&(c||n===e))return eu(r);if(!r||!(n=fr(n)))return r;var l=kr(r),g=kr(n),_=ru(l,g),x=iu(l,g)+1;return Xi(l,_,x).join("")}function Yy(r,n,c){if(r=jt(r),r&&(c||n===e))return r.slice(0,nu(r)+1);if(!r||!(n=fr(n)))return r;var l=kr(r),g=iu(l,kr(n))+1;return Xi(l,0,g).join("")}function Wy(r,n,c){if(r=jt(r),r&&(c||n===e))return r.replace(Jt,"");if(!r||!(n=fr(n)))return r;var l=kr(r),g=ru(l,kr(n));return Xi(l,g).join("")}function Zy(r,n){var c=Te,l=Ct;if(be(n)){var g="separator"in n?n.separator:g;c="length"in n?bt(n.length):c,l="omission"in n?fr(n.omission):l}r=jt(r);var _=r.length;if(Ns(r)){var x=kr(r);_=x.length}if(c>=_)return r;var R=c-Os(l);if(R<1)return l;var F=x?Xi(x,0,R).join(""):r.slice(0,R);if(g===e)return F+l;if(x&&(R+=F.length-R),vc(g)){if(r.slice(R).search(g)){var z,L=F;for(g.global||(g=Ta(g.source,jt(Zt.exec(g))+"g")),g.lastIndex=0;z=g.exec(L);)var J=z.index;F=F.slice(0,J===e?R:J)}}else if(r.indexOf(fr(g),R)!=R){var Z=F.lastIndexOf(g);Z>-1&&(F=F.slice(0,Z))}return F+l}function Xy(r){return r=jt(r),r&&se.test(r)?r.replace(Yt,C0):r}var tw=js(function(r,n,c){return r+(c?" ":"")+n.toUpperCase()}),bc=Ju("toUpperCase");function Hl(r,n,c){return r=jt(r),n=c?e:n,n===e?E0(r)?N0(r):d0(r):r.match(n)||[]}var Vl=At(function(r,n){try{return ur(r,e,n)}catch(c){return mc(c)?c:new vt(c)}}),ew=Oi(function(r,n){return br(n,function(c){c=oi(c),Ri(r,c,dc(r[c],r))}),r});function rw(r){var n=r==null?0:r.length,c=ft();return r=n?we(r,function(l){if(typeof l[1]!="function")throw new _r(h);return[c(l[0]),l[1]]}):[],At(function(l){for(var g=-1;++g<n;){var _=r[g];if(ur(_[0],this,l))return ur(_[1],this,l)}})}function iw(r){return Cg(Er(r,P))}function _c(r){return function(){return r}}function sw(r,n){return r==null||r!==r?n:r}var nw=Gu(),ow=Gu(!0);function rr(r){return r}function Ac(r){return Su(typeof r=="function"?r:Er(r,P))}function aw(r){return Mu(Er(r,P))}function cw(r,n){return Cu(r,Er(n,P))}var hw=At(function(r,n){return function(c){return An(c,r,n)}}),uw=At(function(r,n){return function(c){return An(r,c,n)}});function Ec(r,n,c){var l=Fe(n),g=Ao(n,l);c==null&&!(be(n)&&(g.length||!l.length))&&(c=n,n=r,r=this,g=Ao(n,Fe(n)));var _=!(be(c)&&"chain"in c)||!!c.chain,x=Fi(r);return br(g,function(R){var F=n[R];r[R]=F,x&&(r.prototype[R]=function(){var z=this.__chain__;if(_||z){var L=r(this.__wrapped__),J=L.__actions__=Xe(this.__actions__);return J.push({func:F,args:arguments,thisArg:r}),L.__chain__=z,L}return F.apply(r,Ji([this.value()],arguments))})}),r}function lw(){return qe._===this&&(qe._=k0),this}function Ic(){}function fw(r){return r=bt(r),At(function(n){return xu(n,r)})}var pw=ec(we),dw=ec(Yh),gw=ec(Pa);function Jl(r){return cc(r)?Ma(oi(r)):Hg(r)}function mw(r){return function(n){return r==null?e:ls(r,n)}}var vw=Wu(),yw=Wu(!0);function Sc(){return[]}function Pc(){return!1}function ww(){return{}}function bw(){return""}function _w(){return!0}function Aw(r,n){if(r=bt(r),r<1||r>N)return[];var c=f,l=Le(r,f);n=ft(n),r-=f;for(var g=Ra(l,n);++c<r;)n(c);return g}function Ew(r){return yt(r)?we(r,oi):pr(r)?[r]:Xe(pl(jt(r)))}function Iw(r){var n=++D0;return jt(r)+n}var Sw=Co(function(r,n){return r+n},0),Pw=rc("ceil"),Mw=Co(function(r,n){return r/n},1),Cw=rc("floor");function xw(r){return r&&r.length?_o(r,rr,$a):e}function Rw(r,n){return r&&r.length?_o(r,ft(n,2),$a):e}function Nw(r){return Xh(r,rr)}function Ow(r,n){return Xh(r,ft(n,2))}function Tw(r){return r&&r.length?_o(r,rr,Ha):e}function Fw(r,n){return r&&r.length?_o(r,ft(n,2),Ha):e}var Dw=Co(function(r,n){return r*n},1),qw=rc("round"),kw=Co(function(r,n){return r-n},0);function Bw(r){return r&&r.length?xa(r,rr):0}function jw(r,n){return r&&r.length?xa(r,ft(n,2)):0}return w.after=av,w.ary=Il,w.assign=Qv,w.assignIn=Bl,w.assignInWith=$o,w.assignWith=Gv,w.at=Yv,w.before=Sl,w.bind=dc,w.bindAll=ew,w.bindKey=Pl,w.castArray=wv,w.chain=_l,w.chunk=C1,w.compact=x1,w.concat=R1,w.cond=rw,w.conforms=iw,w.constant=_c,w.countBy=Bm,w.create=Wv,w.curry=Ml,w.curryRight=Cl,w.debounce=xl,w.defaults=Zv,w.defaultsDeep=Xv,w.defer=cv,w.delay=hv,w.difference=N1,w.differenceBy=O1,w.differenceWith=T1,w.drop=F1,w.dropRight=D1,w.dropRightWhile=q1,w.dropWhile=k1,w.fill=B1,w.filter=Um,w.flatMap=Lm,w.flatMapDeep=Km,w.flatMapDepth=Hm,w.flatten=vl,w.flattenDeep=j1,w.flattenDepth=U1,w.flip=uv,w.flow=nw,w.flowRight=ow,w.fromPairs=$1,w.functions=oy,w.functionsIn=ay,w.groupBy=Vm,w.initial=L1,w.intersection=K1,w.intersectionBy=H1,w.intersectionWith=V1,w.invert=hy,w.invertBy=uy,w.invokeMap=Qm,w.iteratee=Ac,w.keyBy=Gm,w.keys=Fe,w.keysIn=er,w.map=Do,w.mapKeys=fy,w.mapValues=py,w.matches=aw,w.matchesProperty=cw,w.memoize=ko,w.merge=dy,w.mergeWith=jl,w.method=hw,w.methodOf=uw,w.mixin=Ec,w.negate=Bo,w.nthArg=fw,w.omit=gy,w.omitBy=my,w.once=lv,w.orderBy=Ym,w.over=pw,w.overArgs=fv,w.overEvery=dw,w.overSome=gw,w.partial=gc,w.partialRight=Rl,w.partition=Wm,w.pick=vy,w.pickBy=Ul,w.property=Jl,w.propertyOf=mw,w.pull=Y1,w.pullAll=wl,w.pullAllBy=W1,w.pullAllWith=Z1,w.pullAt=X1,w.range=vw,w.rangeRight=yw,w.rearg=pv,w.reject=tv,w.remove=tm,w.rest=dv,w.reverse=fc,w.sampleSize=rv,w.set=wy,w.setWith=by,w.shuffle=iv,w.slice=em,w.sortBy=ov,w.sortedUniq=cm,w.sortedUniqBy=hm,w.split=Ly,w.spread=gv,w.tail=um,w.take=lm,w.takeRight=fm,w.takeRightWhile=pm,w.takeWhile=dm,w.tap=xm,w.throttle=mv,w.thru=Fo,w.toArray=Dl,w.toPairs=$l,w.toPairsIn=zl,w.toPath=Ew,w.toPlainObject=kl,w.transform=_y,w.unary=vv,w.union=gm,w.unionBy=mm,w.unionWith=vm,w.uniq=ym,w.uniqBy=wm,w.uniqWith=bm,w.unset=Ay,w.unzip=pc,w.unzipWith=bl,w.update=Ey,w.updateWith=Iy,w.values=zs,w.valuesIn=Sy,w.without=_m,w.words=Hl,w.wrap=yv,w.xor=Am,w.xorBy=Em,w.xorWith=Im,w.zip=Sm,w.zipObject=Pm,w.zipObjectDeep=Mm,w.zipWith=Cm,w.entries=$l,w.entriesIn=zl,w.extend=Bl,w.extendWith=$o,Ec(w,w),w.add=Sw,w.attempt=Vl,w.camelCase=xy,w.capitalize=Ll,w.ceil=Pw,w.clamp=Py,w.clone=bv,w.cloneDeep=Av,w.cloneDeepWith=Ev,w.cloneWith=_v,w.conformsTo=Iv,w.deburr=Kl,w.defaultTo=sw,w.divide=Mw,w.endsWith=Ry,w.eq=jr,w.escape=Ny,w.escapeRegExp=Oy,w.every=jm,w.find=$m,w.findIndex=gl,w.findKey=ty,w.findLast=zm,w.findLastIndex=ml,w.findLastKey=ey,w.floor=Cw,w.forEach=Al,w.forEachRight=El,w.forIn=ry,w.forInRight=iy,w.forOwn=sy,w.forOwnRight=ny,w.get=yc,w.gt=Sv,w.gte=Pv,w.has=cy,w.hasIn=wc,w.head=yl,w.identity=rr,w.includes=Jm,w.indexOf=z1,w.inRange=My,w.invoke=ly,w.isArguments=ds,w.isArray=yt,w.isArrayBuffer=Mv,w.isArrayLike=tr,w.isArrayLikeObject=Ee,w.isBoolean=Cv,w.isBuffer=ts,w.isDate=xv,w.isElement=Rv,w.isEmpty=Nv,w.isEqual=Ov,w.isEqualWith=Tv,w.isError=mc,w.isFinite=Fv,w.isFunction=Fi,w.isInteger=Nl,w.isLength=jo,w.isMap=Ol,w.isMatch=Dv,w.isMatchWith=qv,w.isNaN=kv,w.isNative=Bv,w.isNil=Uv,w.isNull=jv,w.isNumber=Tl,w.isObject=be,w.isObjectLike=_e,w.isPlainObject=Cn,w.isRegExp=vc,w.isSafeInteger=$v,w.isSet=Fl,w.isString=Uo,w.isSymbol=pr,w.isTypedArray=$s,w.isUndefined=zv,w.isWeakMap=Lv,w.isWeakSet=Kv,w.join=J1,w.kebabCase=Ty,w.last=Sr,w.lastIndexOf=Q1,w.lowerCase=Fy,w.lowerFirst=Dy,w.lt=Hv,w.lte=Vv,w.max=xw,w.maxBy=Rw,w.mean=Nw,w.meanBy=Ow,w.min=Tw,w.minBy=Fw,w.stubArray=Sc,w.stubFalse=Pc,w.stubObject=ww,w.stubString=bw,w.stubTrue=_w,w.multiply=Dw,w.nth=G1,w.noConflict=lw,w.noop=Ic,w.now=qo,w.pad=qy,w.padEnd=ky,w.padStart=By,w.parseInt=jy,w.random=Cy,w.reduce=Zm,w.reduceRight=Xm,w.repeat=Uy,w.replace=$y,w.result=yy,w.round=qw,w.runInContext=O,w.sample=ev,w.size=sv,w.snakeCase=zy,w.some=nv,w.sortedIndex=rm,w.sortedIndexBy=im,w.sortedIndexOf=sm,w.sortedLastIndex=nm,w.sortedLastIndexBy=om,w.sortedLastIndexOf=am,w.startCase=Ky,w.startsWith=Hy,w.subtract=kw,w.sum=Bw,w.sumBy=jw,w.template=Vy,w.times=Aw,w.toFinite=Di,w.toInteger=bt,w.toLength=ql,w.toLower=Jy,w.toNumber=Pr,w.toSafeInteger=Jv,w.toString=jt,w.toUpper=Qy,w.trim=Gy,w.trimEnd=Yy,w.trimStart=Wy,w.truncate=Zy,w.unescape=Xy,w.uniqueId=Iw,w.upperCase=tw,w.upperFirst=bc,w.each=Al,w.eachRight=El,w.first=yl,Ec(w,function(){var r={};return si(w,function(n,c){Qt.call(w.prototype,c)||(r[c]=n)}),r}(),{chain:!1}),w.VERSION=s,br(["bind","bindKey","curry","curryRight","partial","partialRight"],function(r){w[r].placeholder=w}),br(["drop","take"],function(r,n){St.prototype[r]=function(c){c=c===e?1:Re(bt(c),0);var l=this.__filtered__&&!n?new St(this):this.clone();return l.__filtered__?l.__takeCount__=Le(c,l.__takeCount__):l.__views__.push({size:Le(c,f),type:r+(l.__dir__<0?"Right":"")}),l},St.prototype[r+"Right"]=function(c){return this.reverse()[r](c).reverse()}}),br(["filter","map","takeWhile"],function(r,n){var c=n+1,l=c==d||c==I;St.prototype[r]=function(g){var _=this.clone();return _.__iteratees__.push({iteratee:ft(g,3),type:c}),_.__filtered__=_.__filtered__||l,_}}),br(["head","last"],function(r,n){var c="take"+(n?"Right":"");St.prototype[r]=function(){return this[c](1).value()[0]}}),br(["initial","tail"],function(r,n){var c="drop"+(n?"":"Right");St.prototype[r]=function(){return this.__filtered__?new St(this):this[c](1)}}),St.prototype.compact=function(){return this.filter(rr)},St.prototype.find=function(r){return this.filter(r).head()},St.prototype.findLast=function(r){return this.reverse().find(r)},St.prototype.invokeMap=At(function(r,n){return typeof r=="function"?new St(this):this.map(function(c){return An(c,r,n)})}),St.prototype.reject=function(r){return this.filter(Bo(ft(r)))},St.prototype.slice=function(r,n){r=bt(r);var c=this;return c.__filtered__&&(r>0||n<0)?new St(c):(r<0?c=c.takeRight(-r):r&&(c=c.drop(r)),n!==e&&(n=bt(n),c=n<0?c.dropRight(-n):c.take(n-r)),c)},St.prototype.takeRightWhile=function(r){return this.reverse().takeWhile(r).reverse()},St.prototype.toArray=function(){return this.take(f)},si(St.prototype,function(r,n){var c=/^(?:filter|find|map|reject)|While$/.test(n),l=/^(?:head|last)$/.test(n),g=w[l?"take"+(n=="last"?"Right":""):n],_=l||/^find/.test(n);g&&(w.prototype[n]=function(){var x=this.__wrapped__,R=l?[1]:arguments,F=x instanceof St,z=R[0],L=F||yt(x),J=function(Et){var Rt=g.apply(w,Ji([Et],R));return l&&Z?Rt[0]:Rt};L&&c&&typeof z=="function"&&z.length!=1&&(F=L=!1);var Z=this.__chain__,nt=!!this.__actions__.length,pt=_&&!Z,_t=F&&!nt;if(!_&&L){x=_t?x:new St(this);var dt=r.apply(x,R);return dt.__actions__.push({func:Fo,args:[J],thisArg:e}),new Ar(dt,Z)}return pt&&_t?r.apply(this,R):(dt=this.thru(J),pt?l?dt.value()[0]:dt.value():dt)})}),br(["pop","push","shift","sort","splice","unshift"],function(r){var n=no[r],c=/^(?:push|sort|unshift)$/.test(r)?"tap":"thru",l=/^(?:pop|shift)$/.test(r);w.prototype[r]=function(){var g=arguments;if(l&&!this.__chain__){var _=this.value();return n.apply(yt(_)?_:[],g)}return this[c](function(x){return n.apply(yt(x)?x:[],g)})}}),si(St.prototype,function(r,n){var c=w[n];if(c){var l=c.name+"";Qt.call(qs,l)||(qs[l]=[]),qs[l].push({name:n,func:c})}}),qs[Mo(e,Q).name]=[{name:"wrapper",func:e}],St.prototype.clone=X0,St.prototype.reverse=tg,St.prototype.value=eg,w.prototype.at=Rm,w.prototype.chain=Nm,w.prototype.commit=Om,w.prototype.next=Tm,w.prototype.plant=Dm,w.prototype.reverse=qm,w.prototype.toJSON=w.prototype.valueOf=w.prototype.value=km,w.prototype.first=w.prototype.head,gn&&(w.prototype[gn]=Fm),w},Ts=O0();os?((os.exports=Ts)._=Ts,Aa._=Ts):qe._=Ts}).call(kn)})(lh,lh.exports);var jI=Object.defineProperty,UI=Object.defineProperties,$I=Object.getOwnPropertyDescriptors,up=Object.getOwnPropertySymbols,zI=Object.prototype.hasOwnProperty,LI=Object.prototype.propertyIsEnumerable,lp=(i,t,e)=>t in i?jI(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,Jo=(i,t)=>{for(var e in t||(t={}))zI.call(t,e)&&lp(i,e,t[e]);if(up)for(var e of up(t))LI.call(t,e)&&lp(i,e,t[e]);return i},KI=(i,t)=>UI(i,$I(t));function Qr(i,t,e){var s;const o=$n(i);return((s=t.rpcMap)==null?void 0:s[o.reference])||`${BI}?chainId=${o.namespace}:${o.reference}&projectId=${e}`}function Ss(i){return i.includes(":")?i.split(":")[1]:i}function qd(i){return i.map(t=>`${t.split(":")[0]}:${t.split(":")[1]}`)}function HI(i,t){const e=Object.keys(t.namespaces).filter(o=>o.includes(i));if(!e.length)return[];const s=[];return e.forEach(o=>{const a=t.namespaces[o].accounts;s.push(...a)}),s}function Qc(i={},t={}){const e=fp(i),s=fp(t);return lh.exports.merge(e,s)}function fp(i){var t,e,s,o;const a={};if(!Qn(i))return a;for(const[h,p]of Object.entries(i)){const v=bh(h)?[h]:p.chains,y=p.methods||[],M=p.events||[],P=p.rpcMap||{},T=Un(h);a[T]=KI(Jo(Jo({},a[T]),p),{chains:Yo(v,(t=a[T])==null?void 0:t.chains),methods:Yo(y,(e=a[T])==null?void 0:e.methods),events:Yo(M,(s=a[T])==null?void 0:s.events),rpcMap:Jo(Jo({},P),(o=a[T])==null?void 0:o.rpcMap)})}return a}function VI(i){return i.includes(":")?i.split(":")[2]:i}function pp(i){const t={};for(const[e,s]of Object.entries(i)){const o=s.methods||[],a=s.events||[],h=s.accounts||[],p=bh(e)?[e]:s.chains?s.chains:qd(s.accounts);t[e]={chains:p,methods:o,events:a,accounts:h}}return t}function Gc(i){return typeof i=="number"?i:i.includes("0x")?parseInt(i,16):(i=i.includes(":")?i.split(":")[1]:i,isNaN(Number(i))?i:Number(i))}const kd={},Ut=i=>kd[i],Yc=(i,t)=>{kd[i]=t};class JI{constructor(t){this.name="polkadot",this.namespace=t.namespace,this.events=Ut("events"),this.client=Ut("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){this.httpProviders[t]||this.setHttpProvider(t,e),this.chainId=t,this.events.emit(Gr.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`)}getAccounts(){const t=this.namespace.accounts;return t?t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2])||[]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{var s;const o=Ss(e);t[o]=this.createHttpProvider(o,(s=this.namespace.rpcMap)==null?void 0:s[e])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const s=this.createHttpProvider(t,e);s&&(this.httpProviders[t]=s)}createHttpProvider(t,e){const s=e||Qr(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new A.o(new A.f$1(s,Ut("disableProviderPing")))}}var QI=Object.defineProperty,GI=Object.defineProperties,YI=Object.getOwnPropertyDescriptors,dp=Object.getOwnPropertySymbols,WI=Object.prototype.hasOwnProperty,ZI=Object.prototype.propertyIsEnumerable,gp=(i,t,e)=>t in i?QI(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,mp=(i,t)=>{for(var e in t||(t={}))WI.call(t,e)&&gp(i,e,t[e]);if(dp)for(var e of dp(t))ZI.call(t,e)&&gp(i,e,t[e]);return i},vp=(i,t)=>GI(i,YI(t));class XI{constructor(t){this.name="eip155",this.namespace=t.namespace,this.events=Ut("events"),this.client=Ut("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());case"wallet_getCapabilities":return await this.getCapabilities(t)}return this.namespace.methods.includes(t.request.method)?await this.client.request(t):this.getHttpProvider().request(t.request)}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}setDefaultChain(t,e){this.httpProviders[t]||this.setHttpProvider(parseInt(t),e),this.chainId=parseInt(t),this.events.emit(Gr.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId.toString();if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}createHttpProvider(t,e){const s=e||Qr(`${this.name}:${t}`,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new A.o(new A.f$1(s,Ut("disableProviderPing")))}setHttpProvider(t,e){const s=this.createHttpProvider(t,e);s&&(this.httpProviders[t]=s)}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{var s;const o=parseInt(Ss(e));t[o]=this.createHttpProvider(o,(s=this.namespace.rpcMap)==null?void 0:s[e])}),t}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}getHttpProvider(){const t=this.chainId,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}async handleSwitchChain(t){var e,s;let o=t.request.params?(e=t.request.params[0])==null?void 0:e.chainId:"0x0";o=o.startsWith("0x")?o:`0x${o}`;const a=parseInt(o,16);if(this.isChainApproved(a))this.setDefaultChain(`${a}`);else if(this.namespace.methods.includes("wallet_switchEthereumChain"))await this.client.request({topic:t.topic,request:{method:t.request.method,params:[{chainId:o}]},chainId:(s=this.namespace.chains)==null?void 0:s[0]}),this.setDefaultChain(`${a}`);else throw new Error(`Failed to switch to chain 'eip155:${a}'. The chain is not approved or the wallet does not support 'wallet_switchEthereumChain' method.`);return null}isChainApproved(t){return this.namespace.chains.includes(`${this.name}:${t}`)}async getCapabilities(t){var e,s,o;const a=(s=(e=t.request)==null?void 0:e.params)==null?void 0:s[0];if(!a)throw new Error("Missing address parameter in `wallet_getCapabilities` request");const h=this.client.session.get(t.topic),p=((o=h==null?void 0:h.sessionProperties)==null?void 0:o.capabilities)||{};if(p!=null&&p[a])return p==null?void 0:p[a];const v=await this.client.request(t);try{await this.client.session.update(t.topic,{sessionProperties:vp(mp({},h.sessionProperties||{}),{capabilities:vp(mp({},p||{}),{[a]:v})})})}catch(y){console.warn("Failed to update session with capabilities",y)}return v}}class t8{constructor(t){this.name="solana",this.namespace=t.namespace,this.events=Ut("events"),this.client=Ut("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){this.httpProviders[t]||this.setHttpProvider(t,e),this.chainId=t,this.events.emit(Gr.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{var s;const o=Ss(e);t[o]=this.createHttpProvider(o,(s=this.namespace.rpcMap)==null?void 0:s[e])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const s=this.createHttpProvider(t,e);s&&(this.httpProviders[t]=s)}createHttpProvider(t,e){const s=e||Qr(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new A.o(new A.f$1(s,Ut("disableProviderPing")))}}class e8{constructor(t){this.name="cosmos",this.namespace=t.namespace,this.events=Ut("events"),this.client=Ut("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){this.httpProviders[t]||this.setHttpProvider(t,e),this.chainId=t,this.events.emit(Gr.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{var s;const o=Ss(e);t[o]=this.createHttpProvider(o,(s=this.namespace.rpcMap)==null?void 0:s[e])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const s=this.createHttpProvider(t,e);s&&(this.httpProviders[t]=s)}createHttpProvider(t,e){const s=e||Qr(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new A.o(new A.f$1(s,Ut("disableProviderPing")))}}class r8{constructor(t){this.name="algorand",this.namespace=t.namespace,this.events=Ut("events"),this.client=Ut("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){if(!this.httpProviders[t]){const s=e||Qr(`${this.name}:${t}`,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);this.setHttpProvider(t,s)}this.chainId=t,this.events.emit(Gr.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{var s;t[e]=this.createHttpProvider(e,(s=this.namespace.rpcMap)==null?void 0:s[e])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const s=this.createHttpProvider(t,e);s&&(this.httpProviders[t]=s)}createHttpProvider(t,e){const s=e||Qr(t,this.namespace,this.client.core.projectId);return typeof s>"u"?void 0:new A.o(new A.f$1(s,Ut("disableProviderPing")))}}class i8{constructor(t){this.name="cip34",this.namespace=t.namespace,this.events=Ut("events"),this.client=Ut("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){this.httpProviders[t]||this.setHttpProvider(t,e),this.chainId=t,this.events.emit(Gr.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{const s=this.getCardanoRPCUrl(e),o=Ss(e);t[o]=this.createHttpProvider(o,s)}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}getCardanoRPCUrl(t){const e=this.namespace.rpcMap;if(e)return e[t]}setHttpProvider(t,e){const s=this.createHttpProvider(t,e);s&&(this.httpProviders[t]=s)}createHttpProvider(t,e){const s=e||this.getCardanoRPCUrl(t);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new A.o(new A.f$1(s,Ut("disableProviderPing")))}}class s8{constructor(t){this.name="elrond",this.namespace=t.namespace,this.events=Ut("events"),this.client=Ut("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){this.httpProviders[t]||this.setHttpProvider(t,e),this.chainId=t,this.events.emit(Gr.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{var s;const o=Ss(e);t[o]=this.createHttpProvider(o,(s=this.namespace.rpcMap)==null?void 0:s[e])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const s=this.createHttpProvider(t,e);s&&(this.httpProviders[t]=s)}createHttpProvider(t,e){const s=e||Qr(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new A.o(new A.f$1(s,Ut("disableProviderPing")))}}class n8{constructor(t){this.name="multiversx",this.namespace=t.namespace,this.events=Ut("events"),this.client=Ut("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){this.httpProviders[t]||this.setHttpProvider(t,e),this.chainId=t,this.events.emit(Gr.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{var s;const o=Ss(e);t[o]=this.createHttpProvider(o,(s=this.namespace.rpcMap)==null?void 0:s[e])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const s=this.createHttpProvider(t,e);s&&(this.httpProviders[t]=s)}createHttpProvider(t,e){const s=e||Qr(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new A.o(new A.f$1(s,Ut("disableProviderPing")))}}class o8{constructor(t){this.name="near",this.namespace=t.namespace,this.events=Ut("events"),this.client=Ut("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){if(this.chainId=t,!this.httpProviders[t]){const s=e||Qr(`${this.name}:${t}`,this.namespace);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);this.setHttpProvider(t,s)}this.events.emit(Gr.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const t=this.namespace.accounts;return t?t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2])||[]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{var s;t[e]=this.createHttpProvider(e,(s=this.namespace.rpcMap)==null?void 0:s[e])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const s=this.createHttpProvider(t,e);s&&(this.httpProviders[t]=s)}createHttpProvider(t,e){const s=e||Qr(t,this.namespace);return typeof s>"u"?void 0:new A.o(new A.f$1(s,Ut("disableProviderPing")))}}class a8{constructor(t){this.name=Hs,this.namespace=t.namespace,this.events=Ut("events"),this.client=Ut("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace.chains=[...new Set((this.namespace.chains||[]).concat(t.chains||[]))],this.namespace.accounts=[...new Set((this.namespace.accounts||[]).concat(t.accounts||[]))],this.namespace.methods=[...new Set((this.namespace.methods||[]).concat(t.methods||[]))],this.namespace.events=[...new Set((this.namespace.events||[]).concat(t.events||[]))],this.httpProviders=this.createHttpProviders()}requestAccounts(){return this.getAccounts()}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider(t.chainId).request(t.request)}setDefaultChain(t,e){this.httpProviders[t]||this.setHttpProvider(t,e),this.chainId=t,this.events.emit(Gr.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){var t,e;const s={};return(e=(t=this.namespace)==null?void 0:t.accounts)==null||e.forEach(o=>{const a=$n(o);s[`${a.namespace}:${a.reference}`]=this.createHttpProvider(o)}),s}getHttpProvider(t){const e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const s=this.createHttpProvider(t,e);s&&(this.httpProviders[t]=s)}createHttpProvider(t,e){const s=e||Qr(t,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${t}`);return new A.o(new A.f$1(s,Ut("disableProviderPing")))}}var c8=Object.defineProperty,h8=Object.defineProperties,u8=Object.getOwnPropertyDescriptors,yp=Object.getOwnPropertySymbols,l8=Object.prototype.hasOwnProperty,f8=Object.prototype.propertyIsEnumerable,wp=(i,t,e)=>t in i?c8(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,Qo=(i,t)=>{for(var e in t||(t={}))l8.call(t,e)&&wp(i,e,t[e]);if(yp)for(var e of yp(t))f8.call(t,e)&&wp(i,e,t[e]);return i},Wc=(i,t)=>h8(i,u8(t));class Ph{constructor(t){this.events=new A.Gg,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:A.Wg(A.k({level:(t==null?void 0:t.logger)||cp})),this.disableProviderPing=(t==null?void 0:t.disableProviderPing)||!1}static async init(t){const e=new Ph(t);return await e.initialize(),e}async request(t,e,s){const[o,a]=this.validateChain(e);if(!this.session)throw new Error("Please call connect() before request()");return await this.getProvider(o).request({request:Qo({},t),chainId:`${o}:${a}`,topic:this.session.topic,expiry:s})}sendAsync(t,e,s,o){const a=new Date().getTime();this.request(t,s,o).then(h=>e(null,A.formatJsonRpcResult(a,h))).catch(h=>e(h,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:Gt("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)}async authenticate(t){if(!this.client)throw new Error("Sign Client not initialized");this.setNamespaces(t),await this.cleanupPendingPairings();const{uri:e,response:s}=await this.client.authenticate(t);e&&(this.uri=e,this.events.emit("display_uri",e));const o=await s();if(this.session=o.session,this.session){const a=pp(this.session.namespaces);this.namespaces=Qc(this.namespaces,a),this.persist("namespaces",this.namespaces),this.onConnect()}return o}on(t,e){this.events.on(t,e)}once(t,e){this.events.once(t,e)}removeListener(t,e){this.events.removeListener(t,e)}off(t,e){this.events.off(t,e)}get isWalletConnect(){return!0}async pair(t){this.shouldAbortPairingAttempt=!1;let e=0;do{if(this.shouldAbortPairingAttempt)throw new Error("Pairing aborted");if(e>=this.maxPairingAttempts)throw new Error("Max auto pairing attempts reached");const{uri:s,approval:o}=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 o().then(a=>{this.session=a;const h=pp(a.namespaces);this.namespaces=Qc(this.namespaces,h),this.persist("namespaces",this.namespaces)}).catch(a=>{if(a.message!==Dd)throw a;e++})}while(!this.session);return this.onConnect(),this.session}setDefaultChain(t,e){try{if(!this.session)return;const[s,o]=this.validateChain(t),a=this.getProvider(s);a.name===Hs?a.setDefaultChain(`${s}:${o}`,e):a.setDefaultChain(o,e)}catch(s){if(!/Please call connect/.test(s.message))throw s}}async cleanupPendingPairings(t={}){this.logger.info("Cleaning up inactive pairings...");const e=this.client.pairing.getAll();if(yi(e)){for(const s of e)t.deletePairings?this.client.core.expirer.set(s.topic,0):await this.client.core.relayer.subscriber.unsubscribe(s.topic);this.logger.info(`Inactive pairings cleared: ${e.length}`)}}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 Sh.init({core:this.providerOpts.core,logger:this.providerOpts.logger||cp,relayUrl:this.providerOpts.relayUrl||DI,projectId:this.providerOpts.projectId,metadata:this.providerOpts.metadata,storageOptions:this.providerOpts.storageOptions,storage:this.providerOpts.storage,name:this.providerOpts.name,customStoragePrefix:this.providerOpts.customStoragePrefix,telemetryEnabled:this.providerOpts.telemetryEnabled}),this.logger.trace("SignClient Initialized")}createProviders(){if(!this.client)throw new Error("Sign Client not initialized");if(!this.session)throw new Error("Session not initialized. Please call connect() before enable()");const t=[...new Set(Object.keys(this.session.namespaces).map(e=>Un(e)))];Yc("client",this.client),Yc("events",this.events),Yc("disableProviderPing",this.disableProviderPing),t.forEach(e=>{if(!this.session)return;const s=HI(e,this.session),o=qd(s),a=Qc(this.namespaces,this.optionalNamespaces),h=Wc(Qo({},a[e]),{accounts:s,chains:o});switch(e){case"eip155":this.rpcProviders[e]=new XI({namespace:h});break;case"algorand":this.rpcProviders[e]=new r8({namespace:h});break;case"solana":this.rpcProviders[e]=new t8({namespace:h});break;case"cosmos":this.rpcProviders[e]=new e8({namespace:h});break;case"polkadot":this.rpcProviders[e]=new JI({namespace:h});break;case"cip34":this.rpcProviders[e]=new i8({namespace:h});break;case"elrond":this.rpcProviders[e]=new s8({namespace:h});break;case"multiversx":this.rpcProviders[e]=new n8({namespace:h});break;case"near":this.rpcProviders[e]=new o8({namespace:h});break;default:this.rpcProviders[Hs]?this.rpcProviders[Hs].updateNamespace(h):this.rpcProviders[Hs]=new a8({namespace:h})}})}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:e}=t,{event:s}=e;if(s.name==="accountsChanged"){const o=s.data;o&&yi(o)&&this.events.emit("accountsChanged",o.map(VI))}else if(s.name==="chainChanged"){const o=e.chainId,a=e.event.data,h=Un(o),p=Gc(o)!==Gc(a)?`${h}:${Gc(a)}`:o;this.onChainChanged(p)}else this.events.emit(s.name,s.data);this.events.emit("session_event",t)}),this.client.on("session_update",({topic:t,params:e})=>{var s;const{namespaces:o}=e,a=(s=this.client)==null?void 0:s.session.get(t);this.session=Wc(Qo({},a),{namespaces:o}),this.onSessionUpdate(),this.events.emit("session_update",{topic:t,params:e})}),this.client.on("session_delete",async t=>{await this.cleanup(),this.events.emit("session_delete",t),this.events.emit("disconnect",Wc(Qo({},Gt("USER_DISCONNECTED")),{data:t.topic}))}),this.on(Gr.DEFAULT_CHAIN_CHANGED,t=>{this.onChainChanged(t,!0)})}getProvider(t){return this.rpcProviders[t]||this.rpcProviders[Hs]}onSessionUpdate(){Object.keys(this.rpcProviders).forEach(t=>{var e;this.getProvider(t).updateNamespace((e=this.session)==null?void 0:e.namespaces[t])})}setNamespaces(t){const{namespaces:e,optionalNamespaces:s,sessionProperties:o}=t;e&&Object.keys(e).length&&(this.namespaces=e),s&&Object.keys(s).length&&(this.optionalNamespaces=s),this.sessionProperties=o,this.persist("namespaces",e),this.persist("optionalNamespaces",s)}validateChain(t){const[e,s]=(t==null?void 0:t.split(":"))||["",""];if(!this.namespaces||!Object.keys(this.namespaces).length)return[e,s];if(e&&!Object.keys(this.namespaces||{}).map(h=>Un(h)).includes(e))throw new Error(`Namespace '${e}' is not configured. Please call connect() first with namespace config.`);if(e&&s)return[e,s];const o=Un(Object.keys(this.namespaces)[0]),a=this.rpcProviders[o].getDefaultChain();return[o,a]}async requestAccounts(){const[t]=this.validateChain();return await this.getProvider(t).requestAccounts()}onChainChanged(t,e=!1){if(!this.namespaces)return;const[s,o]=this.validateChain(t);o&&(e||this.getProvider(s).setDefaultChain(o),this.namespaces[s]?this.namespaces[s].defaultChain=o:this.namespaces[`${s}:${o}`]?this.namespaces[`${s}:${o}`].defaultChain=o:this.namespaces[`${s}:${o}`]={defaultChain:o},this.persist("namespaces",this.namespaces),this.events.emit("chainChanged",o))}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,e){this.client.core.storage.setItem(`${hp}/${t}`,e)}async getFromStore(t){return await this.client.core.storage.getItem(`${hp}/${t}`)}}const p8=Ph,d8="wc",g8="ethereum_provider",m8=`${d8}@2:${g8}:`,v8="https://rpc.walletconnect.com/v1/",ua=["eth_sendTransaction","personal_sign"],Bd=["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","wallet_sendCalls","wallet_getCapabilities","wallet_getCallsStatus","wallet_showCallsStatus"],la=["chainChanged","accountsChanged"],jd=["chainChanged","accountsChanged","message","disconnect","connect"];var y8=Object.defineProperty,w8=Object.defineProperties,b8=Object.getOwnPropertyDescriptors,bp=Object.getOwnPropertySymbols,_8=Object.prototype.hasOwnProperty,A8=Object.prototype.propertyIsEnumerable,_p=(i,t,e)=>t in i?y8(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,Vs=(i,t)=>{for(var e in t||(t={}))_8.call(t,e)&&_p(i,e,t[e]);if(bp)for(var e of bp(t))A8.call(t,e)&&_p(i,e,t[e]);return i},Zc=(i,t)=>w8(i,b8(t));function fa(i){return Number(i[0].split(":")[1])}function Go(i){return`0x${i.toString(16)}`}function E8(i){const{chains:t,optionalChains:e,methods:s,optionalMethods:o,events:a,optionalEvents:h,rpcMap:p}=i;if(!yi(t))throw new Error("Invalid chains");const v={chains:t,methods:s||ua,events:a||la,rpcMap:Vs({},t.length?{[fa(t)]:p[fa(t)]}:{})},y=a==null?void 0:a.filter(D=>!la.includes(D)),M=s==null?void 0:s.filter(D=>!ua.includes(D));if(!e&&!h&&!o&&!(y!=null&&y.length)&&!(M!=null&&M.length))return{required:t.length?v:void 0};const P=(y==null?void 0:y.length)&&(M==null?void 0:M.length)||!e,T={chains:[...new Set(P?v.chains.concat(e||[]):e)],methods:[...new Set(v.methods.concat(o!=null&&o.length?o:Bd))],events:[...new Set(v.events.concat(h!=null&&h.length?h:jd))],rpcMap:p};return{required:t.length?v:void 0,optional:e.length?T:void 0}}class ma{constructor(){this.events=new A.eventsExports.EventEmitter,this.namespace="eip155",this.accounts=[],this.chainId=1,this.STORAGE_KEY=m8,this.on=(t,e)=>(this.events.on(t,e),this),this.once=(t,e)=>(this.events.once(t,e),this),this.removeListener=(t,e)=>(this.events.removeListener(t,e),this),this.off=(t,e)=>(this.events.off(t,e),this),this.parseAccount=t=>this.isCompatibleChainId(t)?this.parseAccountId(t).address:t,this.signer={},this.rpc={}}static async init(t){const e=new ma;return await e.initialize(t),e}async request(t,e){return await this.signer.request(t,this.formatChainId(this.chainId),e)}sendAsync(t,e,s){this.signer.sendAsync(t,e,this.formatChainId(this.chainId),s)}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:e,optional:s}=E8(this.rpc);try{const o=await new Promise(async(h,p)=>{var v;this.rpc.showQrModal&&((v=this.modal)==null||v.subscribeModal(y=>{!y.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),p(new Error("Connection request reset. Please try again.")))})),await this.signer.connect(Zc(Vs({namespaces:Vs({},e&&{[this.namespace]:e})},s&&{optionalNamespaces:{[this.namespace]:s}}),{pairingTopic:t==null?void 0:t.pairingTopic})).then(y=>{h(y)}).catch(y=>{p(new Error(y.message))})});if(!o)return;const a=Gl(o.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:a),this.setAccounts(a),this.events.emit("connect",{chainId:Go(this.chainId)})}catch(o){throw this.signer.logger.error(o),o}finally{this.modal&&this.modal.closeModal()}}async authenticate(t){if(!this.signer.client)throw new Error("Provider not initialized. Call init() first");this.loadConnectOpts({chains:t==null?void 0:t.chains});try{const e=await new Promise(async(o,a)=>{var h;this.rpc.showQrModal&&((h=this.modal)==null||h.subscribeModal(p=>{!p.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),a(new Error("Connection request reset. Please try again.")))})),await this.signer.authenticate(Zc(Vs({},t),{chains:this.rpc.chains})).then(p=>{o(p)}).catch(p=>{a(new Error(p.message))})}),s=e.session;if(s){const o=Gl(s.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:o),this.setAccounts(o),this.events.emit("connect",{chainId:Go(this.chainId)})}return e}catch(e){throw this.signer.logger.error(e),e}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:e}=t,{event:s}=e;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 e=parseInt(t);this.chainId=e,this.events.emit("chainChanged",Go(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",Zc(Vs({},Gt("USER_DISCONNECTED")),{data:t.topic,name:"USER_DISCONNECTED"}))}),this.signer.on("display_uri",t=>{var e,s;this.rpc.showQrModal&&((e=this.modal)==null||e.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 e=t.filter(s=>this.isCompatibleChainId(s)).map(s=>this.parseChainId(s));e.length&&(this.chainId=e[0],this.events.emit("chainChanged",Go(this.chainId)),this.persist())}setChainId(t){if(this.isCompatibleChainId(t)){const e=this.parseChainId(t);this.chainId=e,this.switchEthereumChain(e)}}parseAccountId(t){const[e,s,o]=t.split(":");return{chainId:`${e}:${s}`,address:o}}setAccounts(t){this.accounts=t.filter(e=>this.parseChainId(this.parseAccountId(e).chainId)===this.chainId).map(e=>this.parseAccountId(e).address),this.events.emit("accountsChanged",this.accounts)}getRpcConfig(t){var e,s;const o=(e=t==null?void 0:t.chains)!=null?e:[],a=(s=t==null?void 0:t.optionalChains)!=null?s:[],h=o.concat(a);if(!h.length)throw new Error("No chains specified in either `chains` or `optionalChains`");const p=o.length?(t==null?void 0:t.methods)||ua:[],v=o.length?(t==null?void 0:t.events)||la:[],y=(t==null?void 0:t.optionalMethods)||[],M=(t==null?void 0:t.optionalEvents)||[],P=(t==null?void 0:t.rpcMap)||this.buildRpcMap(h,t.projectId),T=(t==null?void 0:t.qrModalOptions)||void 0;return{chains:o==null?void 0:o.map(D=>this.formatChainId(D)),optionalChains:a.map(D=>this.formatChainId(D)),methods:p,events:v,optionalMethods:y,optionalEvents:M,rpcMap:P,showQrModal:!!(t!=null&&t.showQrModal),qrModalOptions:T,projectId:t.projectId,metadata:t.metadata}}buildRpcMap(t,e){const s={};return t.forEach(o=>{s[o]=this.getRpcUrl(o,e)}),s}async initialize(t){if(this.rpc=this.getRpcConfig(t),this.chainId=this.rpc.chains.length?fa(this.rpc.chains):fa(this.rpc.optionalChains),this.signer=await p8.init({projectId:this.rpc.projectId,metadata:this.rpc.metadata,disableProviderPing:t.disableProviderPing,relayUrl:t.relayUrl,storageOptions:t.storageOptions,customStoragePrefix:t.customStoragePrefix,telemetryEnabled:t.telemetryEnabled}),this.registerEventListeners(),await this.loadPersistedSession(),this.rpc.showQrModal){let e;try{const{WalletConnectModal:s}=await Promise.resolve().then(()=>require("./index-D4J5pbXW.cjs")).then(o=>o.index);e=s}catch{throw new Error("To use QR modal, please install @walletconnect/modal package")}if(e)try{this.modal=new e(Vs({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:e,optionalChains:s,rpcMap:o}=t;e&&yi(e)&&(this.rpc.chains=e.map(a=>this.formatChainId(a)),e.forEach(a=>{this.rpc.rpcMap[a]=(o==null?void 0:o[a])||this.getRpcUrl(a)})),s&&yi(s)&&(this.rpc.optionalChains=[],this.rpc.optionalChains=s==null?void 0:s.map(a=>this.formatChainId(a)),s.forEach(a=>{this.rpc.rpcMap[a]=(o==null?void 0:o[a])||this.getRpcUrl(a)}))}getRpcUrl(t,e){var s;return((s=this.rpc.rpcMap)==null?void 0:s[t])||`${v8}?chainId=eip155:${t}&projectId=${e||this.rpc.projectId}`}async loadPersistedSession(){if(this.session)try{const t=await this.signer.client.core.storage.getItem(`${this.STORAGE_KEY}/chainId`),e=this.session.namespaces[`${this.namespace}:${t}`]?this.session.namespaces[`${this.namespace}:${t}`]:this.session.namespaces[this.namespace];this.setChainIds(t?[this.formatChainId(t)]:e==null?void 0:e.accounts),this.setAccounts(e==null?void 0:e.accounts)}catch(t){this.signer.logger.error("Failed to load persisted session, clearing state..."),this.signer.logger.error(t),await this.disconnect().catch(e=>this.signer.logger.warn(e))}}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(e=>this.parseAccount(e))}}const I8=ma;exports.EthereumProvider=I8;exports.OPTIONAL_EVENTS=jd;exports.OPTIONAL_METHODS=Bd;exports.REQUIRED_EVENTS=la;exports.REQUIRED_METHODS=ua;exports.default=ma;
|