Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@walletconnect/modal-core

Package Overview
Dependencies
Maintainers
10
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@walletconnect/modal-core - npm Package Compare versions

Comparing version 2.5.0-f0d3ee1 to 2.5.0

2

dist/index.js

@@ -1,1 +0,1 @@

import{proxy as p,subscribe as h,snapshot as k}from"valtio/vanilla";import{Buffer as x}from"buffer";const n=p({history:["ConnectWallet"],view:"ConnectWallet",data:void 0}),N={state:n,subscribe(e){return h(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}},i={WALLETCONNECT_DEEPLINK_CHOICE:"WALLETCONNECT_DEEPLINK_CHOICE",WCM_VERSION:"WCM_VERSION",RECOMMENDED_WALLET_AMOUNT:9,isMobile(){return typeof window<"u"?Boolean(window.matchMedia("(pointer:coarse)").matches||/Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent)):!1},isAndroid(){return i.isMobile()&&navigator.userAgent.toLowerCase().includes("android")},isIos(){const e=navigator.userAgent.toLowerCase();return i.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(i.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 r=encodeURIComponent(t);return`${o}wc?uri=${r}`},formatUniversalUrl(e,t,s){if(!i.isHttpUrl(e))return this.formatNativeUrl(e,t,s);let o=e;o.endsWith("/")||(o=`${o}/`),this.setWalletConnectDeepLink(o,s);const r=encodeURIComponent(t);return`${o}wc?uri=${r}`},async wait(e){return new Promise(t=>{setTimeout(t,e)})},openHref(e,t){window.open(e,t,"noreferrer noopener")},setWalletConnectDeepLink(e,t){localStorage.setItem(i.WALLETCONNECT_DEEPLINK_CHOICE,JSON.stringify({href:e,name:t}))},setWalletConnectAndroidDeepLink(e){const[t]=e.split("?");localStorage.setItem(i.WALLETCONNECT_DEEPLINK_CHOICE,JSON.stringify({href:t,name:"Android"}))},removeWalletConnectDeepLink(){localStorage.removeItem(i.WALLETCONNECT_DEEPLINK_CHOICE)},setModalVersionInStorage(){typeof localStorage<"u"&&localStorage.setItem(i.WCM_VERSION,"2.5.0-0d56da4")},getWalletRouterData(){var e;const t=(e=N.state.data)==null?void 0:e.Wallet;if(!t)throw new Error('Missing "Wallet" view data');return t}},T=typeof location<"u"&&(location.hostname.includes("localhost")||location.protocol.includes("https")),a=p({enabled:T,userSessionId:"",events:[],connectedWalletId:void 0}),$={state:a,subscribe(e){return h(a.events,()=>e(k(a.events[a.events.length-1])))},initialize(){a.enabled&&typeof crypto<"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)}}},l=p({chains:void 0,walletConnectUri:void 0,isAuth:!1,isCustomDesktop:!1,isCustomMobile:!1,isDataLoaded:!1,isUiLoaded:!1}),c={state:l,subscribe(e){return h(l,()=>e(l))},setChains(e){l.chains=e},setWalletConnectUri(e){l.walletConnectUri=e},setIsCustomDesktop(e){l.isCustomDesktop=e},setIsCustomMobile(e){l.isCustomMobile=e},setIsDataLoaded(e){l.isDataLoaded=e},setIsUiLoaded(e){l.isUiLoaded=e},setIsAuth(e){l.isAuth=e}},y=p({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}),C={state:y,subscribe(e){return h(y,()=>e(y))},setConfig(e){var t,s;$.initialize(),c.setChains(e.chains),c.setIsAuth(Boolean(e.enableAuthMode)),c.setIsCustomMobile(Boolean((t=e.mobileWallets)==null?void 0:t.length)),c.setIsCustomDesktop(Boolean((s=e.desktopWallets)==null?void 0:s.length)),i.setModalVersionInStorage(),Object.assign(y,e)}},W="https://explorer-api.walletconnect.com";async function L(e,t){const s=new URL(e,W);return s.searchParams.append("projectId",C.state.projectId),Object.entries(t).forEach(([o,r])=>{r&&s.searchParams.append(o,String(r))}),(await fetch(s)).json()}const g={async getDesktopListings(e){return L("/w3m/v1/getDesktopListings",e)},async getMobileListings(e){return L("/w3m/v1/getMobileListings",e)},async getInjectedListings(e){return L("/w3m/v1/getInjectedListings",e)},async getAllListings(e){return L("/w3m/v1/getAllListings",e)},getWalletImageUrl(e){return`${W}/w3m/v1/getWalletImage/${e}?projectId=${C.state.projectId}`},getAssetImageUrl(e){return`${W}/w3m/v1/getAssetImage/${e}?projectId=${C.state.projectId}`}};var P=Object.defineProperty,O=Object.getOwnPropertySymbols,_=Object.prototype.hasOwnProperty,R=Object.prototype.propertyIsEnumerable,U=(e,t,s)=>t in e?P(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,B=(e,t)=>{for(var s in t||(t={}))_.call(t,s)&&U(e,s,t[s]);if(O)for(var s of O(t))R.call(t,s)&&U(e,s,t[s]);return e};const M=i.isMobile(),d=p({wallets:{listings:[],total:0,page:1},search:{listings:[],total:0,page:1},recomendedWallets:[]}),G={state:d,async getRecomendedWallets(){const{explorerRecommendedWalletIds:e,explorerExcludedWalletIds:t}=C.state;if(e==="NONE"||t==="ALL"&&!e)return d.recomendedWallets;if(i.isArray(e)){const s={recommendedIds:e.join(",")},{listings:o}=await g.getAllListings(s),r=Object.values(o);r.sort((u,v)=>{const w=e.indexOf(u.id),f=e.indexOf(v.id);return w-f}),d.recomendedWallets=r}else{const{chains:s,isAuth:o}=c.state,r=s?.join(","),u=i.isArray(t),v={page:1,sdks:o?"auth_v1":void 0,entries:i.RECOMMENDED_WALLET_AMOUNT,chains:r,version:2,excludedIds:u?t.join(","):void 0},{listings:w}=M?await g.getMobileListings(v):await g.getDesktopListings(v);d.recomendedWallets=Object.values(w)}return d.recomendedWallets},async getWallets(e){const t=B({},e),{explorerRecommendedWalletIds:s,explorerExcludedWalletIds:o}=C.state,{recomendedWallets:r}=d;if(o==="ALL")return d.wallets;t.search||(r.length?t.excludedIds=r.map(S=>S.id).join(","):i.isArray(s)&&(t.excludedIds=s.join(","))),i.isArray(o)&&(t.excludedIds=[t.excludedIds,o].filter(Boolean).join(",")),c.state.isAuth&&(t.sdks="auth_v1");const{page:u,search:v}=e,{listings:w,total:f}=M?await g.getMobileListings(t):await g.getDesktopListings(t),E=Object.values(w),A=v?"search":"wallets";return d[A]={listings:[...d[A].listings,...E],total:f,page:u??1},{listings:E,total:f}},getWalletImageUrl(e){return g.getWalletImageUrl(e)},getAssetImageUrl(e){return g.getAssetImageUrl(e)},resetSearch(){d.search={listings:[],total:0,page:1}}},I=p({open:!1}),Q={state:I,subscribe(e){return h(I,()=>e(I))},async open(e){return new Promise(t=>{const{isUiLoaded:s,isDataLoaded:o}=c.state;if(c.setWalletConnectUri(e?.uri),c.setChains(e?.chains),N.reset("ConnectWallet"),s&&o)I.open=!0,t();else{const r=setInterval(()=>{const u=c.state;u.isUiLoaded&&u.isDataLoaded&&(clearInterval(r),I.open=!0,t())},200)}})},close(){I.open=!1}};var H=Object.defineProperty,D=Object.getOwnPropertySymbols,V=Object.prototype.hasOwnProperty,K=Object.prototype.propertyIsEnumerable,j=(e,t,s)=>t in e?H(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,z=(e,t)=>{for(var s in t||(t={}))V.call(t,s)&&j(e,s,t[s]);if(D)for(var s of D(t))K.call(t,s)&&j(e,s,t[s]);return e};function J(){return typeof matchMedia<"u"&&matchMedia("(prefers-color-scheme: dark)").matches}const b=p({themeMode:J()?"dark":"light"}),X={state:b,subscribe(e){return h(b,()=>e(b))},setThemeConfig(e){const{themeMode:t,themeVariables:s}=e;t&&(b.themeMode=t),s&&(b.themeVariables=z({},s))}},m=p({open:!1,message:"",variant:"success"}),Y={state:m,subscribe(e){return h(m,()=>e(m))},openToast(e,t){m.open=!0,m.message=e,m.variant=t},closeToast(){m.open=!1}};typeof window<"u"&&(window.Buffer||(window.Buffer=x),window.global||(window.global=window),window.process||(window.process={env:{}}),window.global||(window.global=window));export{C as ConfigCtrl,i as CoreUtil,$ as EventsCtrl,G as ExplorerCtrl,Q as ModalCtrl,c as OptionsCtrl,N as RouterCtrl,X as ThemeCtrl,Y as ToastCtrl};
import{proxy as p,subscribe as h,snapshot as k}from"valtio/vanilla";import{Buffer as x}from"buffer";const n=p({history:["ConnectWallet"],view:"ConnectWallet",data:void 0}),N={state:n,subscribe(e){return h(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}},i={WALLETCONNECT_DEEPLINK_CHOICE:"WALLETCONNECT_DEEPLINK_CHOICE",WCM_VERSION:"WCM_VERSION",RECOMMENDED_WALLET_AMOUNT:9,isMobile(){return typeof window<"u"?Boolean(window.matchMedia("(pointer:coarse)").matches||/Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent)):!1},isAndroid(){return i.isMobile()&&navigator.userAgent.toLowerCase().includes("android")},isIos(){const e=navigator.userAgent.toLowerCase();return i.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(i.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 r=encodeURIComponent(t);return`${o}wc?uri=${r}`},formatUniversalUrl(e,t,s){if(!i.isHttpUrl(e))return this.formatNativeUrl(e,t,s);let o=e;o.endsWith("/")||(o=`${o}/`),this.setWalletConnectDeepLink(o,s);const r=encodeURIComponent(t);return`${o}wc?uri=${r}`},async wait(e){return new Promise(t=>{setTimeout(t,e)})},openHref(e,t){window.open(e,t,"noreferrer noopener")},setWalletConnectDeepLink(e,t){localStorage.setItem(i.WALLETCONNECT_DEEPLINK_CHOICE,JSON.stringify({href:e,name:t}))},setWalletConnectAndroidDeepLink(e){const[t]=e.split("?");localStorage.setItem(i.WALLETCONNECT_DEEPLINK_CHOICE,JSON.stringify({href:t,name:"Android"}))},removeWalletConnectDeepLink(){localStorage.removeItem(i.WALLETCONNECT_DEEPLINK_CHOICE)},setModalVersionInStorage(){typeof localStorage<"u"&&localStorage.setItem(i.WCM_VERSION,"2.5.0-f0d3ee1")},getWalletRouterData(){var e;const t=(e=N.state.data)==null?void 0:e.Wallet;if(!t)throw new Error('Missing "Wallet" view data');return t}},T=typeof location<"u"&&(location.hostname.includes("localhost")||location.protocol.includes("https")),a=p({enabled:T,userSessionId:"",events:[],connectedWalletId:void 0}),$={state:a,subscribe(e){return h(a.events,()=>e(k(a.events[a.events.length-1])))},initialize(){a.enabled&&typeof crypto<"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)}}},l=p({chains:void 0,walletConnectUri:void 0,isAuth:!1,isCustomDesktop:!1,isCustomMobile:!1,isDataLoaded:!1,isUiLoaded:!1}),c={state:l,subscribe(e){return h(l,()=>e(l))},setChains(e){l.chains=e},setWalletConnectUri(e){l.walletConnectUri=e},setIsCustomDesktop(e){l.isCustomDesktop=e},setIsCustomMobile(e){l.isCustomMobile=e},setIsDataLoaded(e){l.isDataLoaded=e},setIsUiLoaded(e){l.isUiLoaded=e},setIsAuth(e){l.isAuth=e}},y=p({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}),C={state:y,subscribe(e){return h(y,()=>e(y))},setConfig(e){var t,s;$.initialize(),c.setChains(e.chains),c.setIsAuth(Boolean(e.enableAuthMode)),c.setIsCustomMobile(Boolean((t=e.mobileWallets)==null?void 0:t.length)),c.setIsCustomDesktop(Boolean((s=e.desktopWallets)==null?void 0:s.length)),i.setModalVersionInStorage(),Object.assign(y,e)}},W="https://explorer-api.walletconnect.com";async function L(e,t){const s=new URL(e,W);return s.searchParams.append("projectId",C.state.projectId),Object.entries(t).forEach(([o,r])=>{r&&s.searchParams.append(o,String(r))}),(await fetch(s)).json()}const g={async getDesktopListings(e){return L("/w3m/v1/getDesktopListings",e)},async getMobileListings(e){return L("/w3m/v1/getMobileListings",e)},async getInjectedListings(e){return L("/w3m/v1/getInjectedListings",e)},async getAllListings(e){return L("/w3m/v1/getAllListings",e)},getWalletImageUrl(e){return`${W}/w3m/v1/getWalletImage/${e}?projectId=${C.state.projectId}`},getAssetImageUrl(e){return`${W}/w3m/v1/getAssetImage/${e}?projectId=${C.state.projectId}`}};var P=Object.defineProperty,O=Object.getOwnPropertySymbols,_=Object.prototype.hasOwnProperty,R=Object.prototype.propertyIsEnumerable,U=(e,t,s)=>t in e?P(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,B=(e,t)=>{for(var s in t||(t={}))_.call(t,s)&&U(e,s,t[s]);if(O)for(var s of O(t))R.call(t,s)&&U(e,s,t[s]);return e};const M=i.isMobile(),d=p({wallets:{listings:[],total:0,page:1},search:{listings:[],total:0,page:1},recomendedWallets:[]}),G={state:d,async getRecomendedWallets(){const{explorerRecommendedWalletIds:e,explorerExcludedWalletIds:t}=C.state;if(e==="NONE"||t==="ALL"&&!e)return d.recomendedWallets;if(i.isArray(e)){const s={recommendedIds:e.join(",")},{listings:o}=await g.getAllListings(s),r=Object.values(o);r.sort((u,v)=>{const w=e.indexOf(u.id),f=e.indexOf(v.id);return w-f}),d.recomendedWallets=r}else{const{chains:s,isAuth:o}=c.state,r=s?.join(","),u=i.isArray(t),v={page:1,sdks:o?"auth_v1":void 0,entries:i.RECOMMENDED_WALLET_AMOUNT,chains:r,version:2,excludedIds:u?t.join(","):void 0},{listings:w}=M?await g.getMobileListings(v):await g.getDesktopListings(v);d.recomendedWallets=Object.values(w)}return d.recomendedWallets},async getWallets(e){const t=B({},e),{explorerRecommendedWalletIds:s,explorerExcludedWalletIds:o}=C.state,{recomendedWallets:r}=d;if(o==="ALL")return d.wallets;t.search||(r.length?t.excludedIds=r.map(S=>S.id).join(","):i.isArray(s)&&(t.excludedIds=s.join(","))),i.isArray(o)&&(t.excludedIds=[t.excludedIds,o].filter(Boolean).join(",")),c.state.isAuth&&(t.sdks="auth_v1");const{page:u,search:v}=e,{listings:w,total:f}=M?await g.getMobileListings(t):await g.getDesktopListings(t),E=Object.values(w),A=v?"search":"wallets";return d[A]={listings:[...d[A].listings,...E],total:f,page:u??1},{listings:E,total:f}},getWalletImageUrl(e){return g.getWalletImageUrl(e)},getAssetImageUrl(e){return g.getAssetImageUrl(e)},resetSearch(){d.search={listings:[],total:0,page:1}}},I=p({open:!1}),Q={state:I,subscribe(e){return h(I,()=>e(I))},async open(e){return new Promise(t=>{const{isUiLoaded:s,isDataLoaded:o}=c.state;if(c.setWalletConnectUri(e?.uri),c.setChains(e?.chains),N.reset("ConnectWallet"),s&&o)I.open=!0,t();else{const r=setInterval(()=>{const u=c.state;u.isUiLoaded&&u.isDataLoaded&&(clearInterval(r),I.open=!0,t())},200)}})},close(){I.open=!1}};var H=Object.defineProperty,D=Object.getOwnPropertySymbols,V=Object.prototype.hasOwnProperty,K=Object.prototype.propertyIsEnumerable,j=(e,t,s)=>t in e?H(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,z=(e,t)=>{for(var s in t||(t={}))V.call(t,s)&&j(e,s,t[s]);if(D)for(var s of D(t))K.call(t,s)&&j(e,s,t[s]);return e};function J(){return typeof matchMedia<"u"&&matchMedia("(prefers-color-scheme: dark)").matches}const b=p({themeMode:J()?"dark":"light"}),X={state:b,subscribe(e){return h(b,()=>e(b))},setThemeConfig(e){const{themeMode:t,themeVariables:s}=e;t&&(b.themeMode=t),s&&(b.themeVariables=z({},s))}},m=p({open:!1,message:"",variant:"success"}),Y={state:m,subscribe(e){return h(m,()=>e(m))},openToast(e,t){m.open=!0,m.message=e,m.variant=t},closeToast(){m.open=!1}};typeof window<"u"&&(window.Buffer||(window.Buffer=x),window.global||(window.global=window),window.process||(window.process={env:{}}),window.global||(window.global=window));export{C as ConfigCtrl,i as CoreUtil,$ as EventsCtrl,G as ExplorerCtrl,Q as ModalCtrl,c as OptionsCtrl,N as RouterCtrl,X as ThemeCtrl,Y as ToastCtrl};
{
"name": "@walletconnect/modal-core",
"version": "2.5.0-f0d3ee1",
"version": "2.5.0",
"main": "dist/index.js",

@@ -5,0 +5,0 @@ "type": "module",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc