1732.eecc7b4d2903533a.js 9.3 KB

1
  1. "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1732],{76698:(e,t,s)=>{s.d(t,{Ao:()=>l,D8:()=>S,IN:()=>m,dC:()=>K,jL:()=>n,lH:()=>V,mb:()=>g,pV:()=>N,vZ:()=>c});var i=s(2614),o=s(41562).Buffer;let a=(0,i.BX)({history:["ConnectWallet"],view:"ConnectWallet",data:void 0}),n={state:a,subscribe:e=>(0,i.B1)(a,()=>e(a)),push(e,t){e!==a.view&&(a.view=e,t&&(a.data=t),a.history.push(e))},reset(e){a.view=e,a.history=[e]},replace(e){a.history.length>1&&(a.history[a.history.length-1]=e,a.view=e)},goBack(){if(a.history.length>1){a.history.pop();let[e]=a.history.slice(-1);a.view=e}},setData(e){a.data=e}},l={WALLETCONNECT_DEEPLINK_CHOICE:"WALLETCONNECT_DEEPLINK_CHOICE",WCM_VERSION:"WCM_VERSION",RECOMMENDED_WALLET_AMOUNT:9,isMobile:()=>"undefined"!=typeof window&&!!(window.matchMedia("(pointer:coarse)").matches||/Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent)),isAndroid:()=>l.isMobile()&&navigator.userAgent.toLowerCase().includes("android"),isIos(){let e=navigator.userAgent.toLowerCase();return l.isMobile()&&(e.includes("iphone")||e.includes("ipad"))},isHttpUrl:e=>e.startsWith("http://")||e.startsWith("https://"),isArray:e=>Array.isArray(e)&&e.length>0,isTelegram:()=>"undefined"!=typeof window&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto),formatNativeUrl(e,t,s){if(l.isHttpUrl(e))return this.formatUniversalUrl(e,t,s);let i=e;i.includes("://")||(i=e.replaceAll("/","").replaceAll(":",""),i=`${i}://`),i.endsWith("/")||(i=`${i}/`),this.setWalletConnectDeepLink(i,s);let o=encodeURIComponent(t);return`${i}wc?uri=${o}`},formatUniversalUrl(e,t,s){if(!l.isHttpUrl(e))return this.formatNativeUrl(e,t,s);let i=e;if(i.startsWith("https://t.me")){let e=o.from(t).toString("base64").replace(/[=]/g,"");i.endsWith("/")&&(i=i.slice(0,-1)),this.setWalletConnectDeepLink(i,s);let a=new URL(i);return a.searchParams.set("startapp",e),a.toString()}i.endsWith("/")||(i=`${i}/`),this.setWalletConnectDeepLink(i,s);let a=encodeURIComponent(t);return`${i}wc?uri=${a}`},wait:async e=>new Promise(t=>{setTimeout(t,e)}),openHref(e,t){let s=this.isTelegram()?"_blank":t;window.open(e,s,"noreferrer noopener")},setWalletConnectDeepLink(e,t){try{localStorage.setItem(l.WALLETCONNECT_DEEPLINK_CHOICE,JSON.stringify({href:e,name:t}))}catch(e){console.info("Unable to set WalletConnect deep link")}},setWalletConnectAndroidDeepLink(e){try{let[t]=e.split("?");localStorage.setItem(l.WALLETCONNECT_DEEPLINK_CHOICE,JSON.stringify({href:t,name:"Android"}))}catch(e){console.info("Unable to set WalletConnect android deep link")}},removeWalletConnectDeepLink(){try{localStorage.removeItem(l.WALLETCONNECT_DEEPLINK_CHOICE)}catch(e){console.info("Unable to remove WalletConnect deep link")}},setModalVersionInStorage(){try{"undefined"!=typeof localStorage&&localStorage.setItem(l.WCM_VERSION,"2.7.0")}catch(e){console.info("Unable to set Web3Modal version in storage")}},getWalletRouterData(){var e;let t=null==(e=n.state.data)?void 0:e.Wallet;if(!t)throw Error('Missing "Wallet" view data');return t}},r="undefined"!=typeof location&&(location.hostname.includes("localhost")||location.protocol.includes("https")),d=(0,i.BX)({enabled:r,userSessionId:"",events:[],connectedWalletId:void 0}),c={state:d,subscribe:e=>(0,i.B1)(d.events,()=>e((0,i.P9)(d.events[d.events.length-1]))),initialize(){d.enabled&&void 0!==(null==crypto?void 0:crypto.randomUUID)&&(d.userSessionId=crypto.randomUUID())},setConnectedWalletId(e){d.connectedWalletId=e},click(e){if(d.enabled){let t={type:"CLICK",name:e.name,userSessionId:d.userSessionId,timestamp:Date.now(),data:e};d.events.push(t)}},track(e){if(d.enabled){let t={type:"TRACK",name:e.name,userSessionId:d.userSessionId,timestamp:Date.now(),data:e};d.events.push(t)}},view(e){if(d.enabled){let t={type:"VIEW",name:e.name,userSessionId:d.userSessionId,timestamp:Date.now(),data:e};d.events.push(t)}}},p=(0,i.BX)({chains:void 0,walletConnectUri:void 0,isAuth:!1,isCustomDesktop:!1,isCustomMobile:!1,isDataLoaded:!1,isUiLoaded:!1}),m={state:p,subscribe:e=>(0,i.B1)(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}},u=(0,i.BX)({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}),g={state:u,subscribe:e=>(0,i.B1)(u,()=>e(u)),setConfig(e){var t,s;c.initialize(),m.setChains(e.chains),m.setIsAuth(!!e.enableAuthMode),m.setIsCustomMobile(!!(null==(t=e.mobileWallets)?void 0:t.length)),m.setIsCustomDesktop(!!(null==(s=e.desktopWallets)?void 0:s.length)),l.setModalVersionInStorage(),Object.assign(u,e)}};var h=Object.defineProperty,b=Object.getOwnPropertySymbols,v=Object.prototype.hasOwnProperty,I=Object.prototype.propertyIsEnumerable,f=(e,t,s)=>t in e?h(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,w=(e,t)=>{for(var s in t||(t={}))v.call(t,s)&&f(e,s,t[s]);if(b)for(var s of b(t))I.call(t,s)&&f(e,s,t[s]);return e};let y="https://explorer-api.walletconnect.com",C="js-2.7.0";async function W(e,t){let s=w({sdkType:"wcm",sdkVersion:C},t),i=new URL(e,y);return i.searchParams.append("projectId",g.state.projectId),Object.entries(s).forEach(([e,t])=>{t&&i.searchParams.append(e,String(t))}),(await fetch(i)).json()}let L={getDesktopListings:async e=>W("/w3m/v1/getDesktopListings",e),getMobileListings:async e=>W("/w3m/v1/getMobileListings",e),getAllListings:async e=>W("/w3m/v1/getAllListings",e),getWalletImageUrl:e=>`${y}/w3m/v1/getWalletImage/${e}?projectId=${g.state.projectId}&sdkType=wcm&sdkVersion=${C}`,getAssetImageUrl:e=>`${y}/w3m/v1/getAssetImage/${e}?projectId=${g.state.projectId}&sdkType=wcm&sdkVersion=${C}`};var E=Object.defineProperty,O=Object.getOwnPropertySymbols,A=Object.prototype.hasOwnProperty,U=Object.prototype.propertyIsEnumerable,k=(e,t,s)=>t in e?E(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,D=(e,t)=>{for(var s in t||(t={}))A.call(t,s)&&k(e,s,t[s]);if(O)for(var s of O(t))U.call(t,s)&&k(e,s,t[s]);return e};let M=l.isMobile(),j=(0,i.BX)({wallets:{listings:[],total:0,page:1},search:{listings:[],total:0,page:1},recomendedWallets:[]}),N={state:j,async getRecomendedWallets(){let{explorerRecommendedWalletIds:e,explorerExcludedWalletIds:t}=g.state;if("NONE"===e||"ALL"===t&&!e)return j.recomendedWallets;if(l.isArray(e)){let t=e.join(","),{listings:s}=await L.getAllListings({recommendedIds:t}),i=Object.values(s);i.sort((t,s)=>e.indexOf(t.id)-e.indexOf(s.id)),j.recomendedWallets=i}else{let{chains:e,isAuth:s}=m.state,i=null==e?void 0:e.join(","),o=l.isArray(t),a={page:1,sdks:s?"auth_v1":void 0,entries:l.RECOMMENDED_WALLET_AMOUNT,chains:i,version:2,excludedIds:o?t.join(","):void 0},{listings:n}=M?await L.getMobileListings(a):await L.getDesktopListings(a);j.recomendedWallets=Object.values(n)}return j.recomendedWallets},async getWallets(e){let t=D({},e),{explorerRecommendedWalletIds:s,explorerExcludedWalletIds:i}=g.state,{recomendedWallets:o}=j;if("ALL"===i)return j.wallets;o.length?t.excludedIds=o.map(e=>e.id).join(","):l.isArray(s)&&(t.excludedIds=s.join(",")),l.isArray(i)&&(t.excludedIds=[t.excludedIds,i].filter(Boolean).join(",")),m.state.isAuth&&(t.sdks="auth_v1");let{page:a,search:n}=e,{listings:r,total:d}=M?await L.getMobileListings(t):await L.getDesktopListings(t),c=Object.values(r),p=n?"search":"wallets";return j[p]={listings:[...j[p].listings,...c],total:d,page:null!=a?a:1},{listings:c,total:d}},getWalletImageUrl:e=>L.getWalletImageUrl(e),getAssetImageUrl:e=>L.getAssetImageUrl(e),resetSearch(){j.search={listings:[],total:0,page:1}}},T=(0,i.BX)({open:!1}),S={state:T,subscribe:e=>(0,i.B1)(T,()=>e(T)),open:async e=>new Promise(t=>{let{isUiLoaded:s,isDataLoaded:i}=m.state;if(l.removeWalletConnectDeepLink(),m.setWalletConnectUri(null==e?void 0:e.uri),m.setChains(null==e?void 0:e.chains),n.reset("ConnectWallet"),s&&i)T.open=!0,t();else{let e=setInterval(()=>{let s=m.state;s.isUiLoaded&&s.isDataLoaded&&(clearInterval(e),T.open=!0,t())},200)}}),close(){T.open=!1}};var P=Object.defineProperty,_=Object.getOwnPropertySymbols,B=Object.prototype.hasOwnProperty,$=Object.prototype.propertyIsEnumerable,x=(e,t,s)=>t in e?P(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,R=(e,t)=>{for(var s in t||(t={}))B.call(t,s)&&x(e,s,t[s]);if(_)for(var s of _(t))$.call(t,s)&&x(e,s,t[s]);return e};let H=(0,i.BX)({themeMode:"undefined"!=typeof matchMedia&&matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}),V={state:H,subscribe:e=>(0,i.B1)(H,()=>e(H)),setThemeConfig(e){let{themeMode:t,themeVariables:s}=e;t&&(H.themeMode=t),s&&(H.themeVariables=R({},s))}},X=(0,i.BX)({open:!1,message:"",variant:"success"}),K={state:X,subscribe:e=>(0,i.B1)(X,()=>e(X)),openToast(e,t){X.open=!0,X.message=e,X.variant=t},closeToast(){X.open=!1}}},91732:(e,t,s)=>{s.d(t,{WalletConnectModal:()=>o});var i=s(76698);class o{constructor(e){this.openModal=i.D8.open,this.closeModal=i.D8.close,this.subscribeModal=i.D8.subscribe,this.setTheme=i.lH.setThemeConfig,i.lH.setThemeConfig(e),i.mb.setConfig(e),this.initUi()}async initUi(){if("undefined"!=typeof window){await s.e(4948).then(s.bind(s,64948));let e=document.createElement("wcm-modal");document.body.insertAdjacentElement("beforeend",e),i.IN.setIsUiLoaded(!0)}}}}}]);