Socket
Socket
Sign inDemoInstall

@web3modal/core

Package Overview
Dependencies
Maintainers
4
Versions
374
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@web3modal/core - npm Package Compare versions

Comparing version 2.2.0-17f140d to 2.2.0-afa987d

2

dist/index.js

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

import{proxy as d,subscribe as h}from"valtio/vanilla";import{Buffer as S}from"buffer";const o=d({selectedChain:void 0,chains:void 0,standaloneChains:void 0,standaloneUri:void 0,isStandalone:!1,isCustomDesktop:!1,isCustomMobile:!1,isDataLoaded:!1,isUiLoaded:!1,walletConnectVersion:1}),i={state:o,subscribe(e){return h(o,()=>e(o))},setChains(e){o.chains=e},setStandaloneChains(e){o.standaloneChains=e},setStandaloneUri(e){o.standaloneUri=e},getSelectedChain(){const e=C.client().getNetwork().chain;return e&&(o.selectedChain=e),o.selectedChain},setSelectedChain(e){o.selectedChain=e},setIsStandalone(e){o.isStandalone=e},setIsCustomDesktop(e){o.isCustomDesktop=e},setIsCustomMobile(e){o.isCustomMobile=e},setIsDataLoaded(e){o.isDataLoaded=e},setIsUiLoaded(e){o.isUiLoaded=e},setWalletConnectVersion(e){o.walletConnectVersion=e}},g=d({initialized:!1,ethereumClient:void 0}),C={setEthereumClient(e){!g.initialized&&e&&(g.ethereumClient=e,i.setChains(e.chains),g.initialized=!0)},client(){if(g.ethereumClient)return g.ethereumClient;throw new Error("ClientCtrl has no client set")}},a=d({address:void 0,profileName:void 0,profileAvatar:void 0,profileLoading:!1,balanceLoading:!1,balance:void 0,isConnected:!1}),N={state:a,subscribe(e){return h(a,()=>e(a))},getAccount(){const e=C.client().getAccount();a.address=e.address,a.isConnected=e.isConnected},async fetchProfile(e,t){try{a.profileLoading=!0;const s=t??a.address,{id:n}=C.client().getDefaultChain();if(s&&n===1){const[l,c]=await Promise.all([C.client().fetchEnsName({address:s,chainId:1}),C.client().fetchEnsAvatar({address:s,chainId:1})]);c&&await e(c),a.profileName=l,a.profileAvatar=c}}finally{a.profileLoading=!1}},async fetchBalance(e){try{a.balanceLoading=!0;const t=e??a.address;if(t){const s=await C.client().fetchBalance({address:t});a.balance={amount:s.formatted,symbol:s.symbol}}}finally{a.balanceLoading=!1}},setAddress(e){a.address=e},setIsConnected(e){a.isConnected=e},resetBalance(){a.balance=void 0},resetAccount(){a.address=void 0,a.isConnected=!1,a.profileName=void 0,a.profileAvatar=void 0,a.balance=void 0}},b=d({projectId:"",mobileWallets:void 0,desktopWallets:void 0,walletImages:void 0,chainImages:void 0,tokenImages:void 0,standaloneChains:void 0,enableStandaloneMode:!1,enableNetworkView:!1,enableAccountView:!0,enableExplorer:!0,defaultChain:void 0,explorerAllowList:void 0,explorerDenyList:void 0,termsOfServiceUrl:void 0,privacyPolicyUrl:void 0}),W={state:b,subscribe(e){return h(b,()=>e(b))},setConfig(e){var t,s,n,l;if(i.setStandaloneChains(e.standaloneChains),i.setIsStandalone(Boolean((t=e.standaloneChains)==null?void 0:t.length)||Boolean(e.enableStandaloneMode)),i.setIsCustomMobile(Boolean((s=e.mobileWallets)==null?void 0:s.length)),i.setIsCustomDesktop(Boolean((n=e.desktopWallets)==null?void 0:n.length)),i.setWalletConnectVersion((l=e.walletConnectVersion)!=null?l:1),e.defaultChain)i.setSelectedChain(e.defaultChain);else if(!i.state.isStandalone){const c=C.client().getDefaultChain();i.setSelectedChain(c)}Object.assign(b,e)}},E="https://explorer-api.walletconnect.com";function U(e){const t=Object.fromEntries(Object.entries(e).filter(([s,n])=>typeof n<"u"&&n!==null&&n!=="").map(([s,n])=>[s,n.toString()]));return new URLSearchParams(t).toString()}const L={async fetchWallets(e,t){const s=U(t),n=`${E}/v3/wallets?projectId=${e}&${s}`;return(await fetch(n)).json()},formatImageUrl(e,t){return`${E}/v3/logo/lg/${t}?projectId=${e}`}},u=d({wallets:{listings:[],total:0,page:1},search:{listings:[],total:0,page:1},previewWallets:[],recomendedWallets:[]});function I(){const{projectId:e}=W.state;if(!e)throw new Error("projectId is required to work with explorer api");return e}const P={state:u,async getPreviewWallets(e){const{listings:t}=await L.fetchWallets(I(),e);return u.previewWallets=Object.values(t),u.previewWallets},async getRecomendedWallets(){const{listings:e}=await L.fetchWallets(I(),{page:1,entries:6});u.recomendedWallets=Object.values(e)},async getPaginatedWallets(e){const{page:t,search:s}=e,{listings:n,total:l}=await L.fetchWallets(I(),e),c=Object.values(n),v=s?"search":"wallets";return u[v]={listings:[...u[v].listings,...c],total:l,page:t??1},{listings:c,total:l}},getImageUrl(e){return L.formatImageUrl(I(),e)},resetSearch(){u.search={listings:[],total:0,page:1}}},r=d({history:["ConnectWallet"],view:"ConnectWallet",data:void 0}),w={state:r,subscribe(e){return h(r,()=>e(r))},push(e,t){e!==r.view&&(r.view=e,t&&(r.data=t),r.history.push(e))},replace(e){r.view=e,r.history=[e]},goBack(){if(r.history.length>1){r.history.pop();const[e]=r.history.slice(-1);r.view=e}}},f=d({open:!1}),j={state:f,subscribe(e){return h(f,()=>e(f))},async open(e){return new Promise(t=>{const{isStandalone:s,isUiLoaded:n,isDataLoaded:l}=i.state,{isConnected:c}=N.state,{enableNetworkView:v}=W.state;if(s?(i.setStandaloneUri(e?.uri),i.setStandaloneChains(e?.standaloneChains),w.replace("ConnectWallet")):e!=null&&e.route?w.replace(e.route):c?w.replace("Account"):v?w.replace("SelectNetwork"):w.replace("ConnectWallet"),n&&l)f.open=!0,t();else{const O=setInterval(()=>{i.state.isUiLoaded&&i.state.isDataLoaded&&(clearInterval(O),f.open=!0,t())},200)}})},close(){f.open=!1}};function A(){return typeof matchMedia<"u"&&matchMedia("(prefers-color-scheme: dark)").matches}const y=d({themeMode:A()?"dark":"light"}),$={state:y,subscribe(e){return h(y,()=>e(y))},setThemeConfig(e){Object.assign(y,e)}},p=d({open:!1,message:"",variant:"success"}),T={state:p,subscribe(e){return h(p,()=>e(p))},openToast(e,t){p.open=!0,p.message=e,p.variant=t},closeToast(){p.open=!1}},m={WALLETCONNECT_DEEPLINK_CHOICE:"WALLETCONNECT_DEEPLINK_CHOICE",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 m.isMobile()&&navigator.userAgent.toLowerCase().includes("android")},isEmptyObject(e){return Object.getPrototypeOf(e)===Object.prototype&&Object.getOwnPropertyNames(e).length===0&&Object.getOwnPropertySymbols(e).length===0},isHttpUrl(e){return e.startsWith("http://")||e.startsWith("https://")},formatNativeUrl(e,t,s){if(m.isHttpUrl(e))return this.formatUniversalUrl(e,t,s);let n=e;n.includes("://")||(n=e.replaceAll("/","").replaceAll(":",""),n=`${n}://`),this.setWalletConnectDeepLink(n,s);const l=encodeURIComponent(t);return`${n}wc?uri=${l}`},formatUniversalUrl(e,t,s){if(!m.isHttpUrl(e))return this.formatNativeUrl(e,t,s);let n=e;e.endsWith("/")&&(n=e.slice(0,-1)),this.setWalletConnectDeepLink(n,s);const l=encodeURIComponent(t);return`${n}/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){localStorage.setItem(m.WALLETCONNECT_DEEPLINK_CHOICE,JSON.stringify({href:e,name:t}))},setWalletConnectAndroidDeepLink(e){const[t]=e.split("?");localStorage.setItem(m.WALLETCONNECT_DEEPLINK_CHOICE,JSON.stringify({href:t,name:"Android"}))},removeWalletConnectDeepLink(){localStorage.removeItem(m.WALLETCONNECT_DEEPLINK_CHOICE)},isNull(e){return e===null}};typeof window<"u"&&(window.Buffer||(window.Buffer=S),window.global||(window.global=window),window.process||(window.process={env:{}}));export{N as AccountCtrl,C as ClientCtrl,W as ConfigCtrl,m as CoreUtil,P as ExplorerCtrl,j as ModalCtrl,i as OptionsCtrl,w as RouterCtrl,$ as ThemeCtrl,T as ToastCtrl};
import{proxy as d,subscribe as h}from"valtio/vanilla";import{Buffer as S}from"buffer";const o=d({selectedChain:void 0,chains:void 0,standaloneChains:void 0,standaloneUri:void 0,isStandalone:!1,isCustomDesktop:!1,isCustomMobile:!1,isDataLoaded:!1,isUiLoaded:!1,walletConnectVersion:1}),i={state:o,subscribe(e){return h(o,()=>e(o))},setChains(e){o.chains=e},setStandaloneChains(e){o.standaloneChains=e},setStandaloneUri(e){o.standaloneUri=e},getSelectedChain(){const e=C.client().getNetwork().chain;return e&&(o.selectedChain=e),o.selectedChain},setSelectedChain(e){o.selectedChain=e},setIsStandalone(e){o.isStandalone=e},setIsCustomDesktop(e){o.isCustomDesktop=e},setIsCustomMobile(e){o.isCustomMobile=e},setIsDataLoaded(e){o.isDataLoaded=e},setIsUiLoaded(e){o.isUiLoaded=e},setWalletConnectVersion(e){o.walletConnectVersion=e}},g=d({initialized:!1,ethereumClient:void 0}),C={setEthereumClient(e){!g.initialized&&e&&(g.ethereumClient=e,i.setChains(e.chains),g.initialized=!0)},client(){if(g.ethereumClient)return g.ethereumClient;throw new Error("ClientCtrl has no client set")}},a=d({address:void 0,profileName:void 0,profileAvatar:void 0,profileLoading:!1,balanceLoading:!1,balance:void 0,isConnected:!1}),N={state:a,subscribe(e){return h(a,()=>e(a))},getAccount(){const e=C.client().getAccount();a.address=e.address,a.isConnected=e.isConnected},async fetchProfile(e,t){try{a.profileLoading=!0;const s=t??a.address,{id:n}=C.client().getDefaultChain();if(s&&n===1){const[l,c]=await Promise.all([C.client().fetchEnsName({address:s,chainId:1}),C.client().fetchEnsAvatar({address:s,chainId:1})]);c&&await e(c),a.profileName=l,a.profileAvatar=c}}finally{a.profileLoading=!1}},async fetchBalance(e){try{a.balanceLoading=!0;const t=e??a.address;if(t){const s=await C.client().fetchBalance({address:t});a.balance={amount:s.formatted,symbol:s.symbol}}}finally{a.balanceLoading=!1}},setAddress(e){a.address=e},setIsConnected(e){a.isConnected=e},resetBalance(){a.balance=void 0},resetAccount(){a.address=void 0,a.isConnected=!1,a.profileName=void 0,a.profileAvatar=void 0,a.balance=void 0}},b=d({projectId:"",mobileWallets:void 0,desktopWallets:void 0,walletImages:void 0,chainImages:void 0,tokenImages:void 0,standaloneChains:void 0,enableStandaloneMode:!1,enableNetworkView:!1,enableAccountView:!0,enableExplorer:!0,defaultChain:void 0,explorerAllowList:void 0,explorerDenyList:void 0,termsOfServiceUrl:void 0,privacyPolicyUrl:void 0}),W={state:b,subscribe(e){return h(b,()=>e(b))},setConfig(e){var t,s,n,l;if(i.setStandaloneChains(e.standaloneChains),i.setIsStandalone(!!((t=e.standaloneChains)!=null&&t.length)||!!e.enableStandaloneMode),i.setIsCustomMobile(!!((s=e.mobileWallets)!=null&&s.length)),i.setIsCustomDesktop(!!((n=e.desktopWallets)!=null&&n.length)),i.setWalletConnectVersion((l=e.walletConnectVersion)!=null?l:1),e.defaultChain)i.setSelectedChain(e.defaultChain);else if(!i.state.isStandalone){const c=C.client().getDefaultChain();i.setSelectedChain(c)}Object.assign(b,e)}},E="https://explorer-api.walletconnect.com";function U(e){const t=Object.fromEntries(Object.entries(e).filter(([s,n])=>typeof n<"u"&&n!==null&&n!=="").map(([s,n])=>[s,n.toString()]));return new URLSearchParams(t).toString()}const L={async fetchWallets(e,t){const s=U(t),n=`${E}/v3/wallets?projectId=${e}&${s}`;return(await fetch(n)).json()},formatImageUrl(e,t){return`${E}/v3/logo/lg/${t}?projectId=${e}`}},u=d({wallets:{listings:[],total:0,page:1},search:{listings:[],total:0,page:1},previewWallets:[],recomendedWallets:[]});function I(){const{projectId:e}=W.state;if(!e)throw new Error("projectId is required to work with explorer api");return e}const P={state:u,async getPreviewWallets(e){const{listings:t}=await L.fetchWallets(I(),e);return u.previewWallets=Object.values(t),u.previewWallets},async getRecomendedWallets(){const{listings:e}=await L.fetchWallets(I(),{page:1,entries:6});u.recomendedWallets=Object.values(e)},async getPaginatedWallets(e){const{page:t,search:s}=e,{listings:n,total:l}=await L.fetchWallets(I(),e),c=Object.values(n),v=s?"search":"wallets";return u[v]={listings:[...u[v].listings,...c],total:l,page:t??1},{listings:c,total:l}},getImageUrl(e){return L.formatImageUrl(I(),e)},resetSearch(){u.search={listings:[],total:0,page:1}}},r=d({history:["ConnectWallet"],view:"ConnectWallet",data:void 0}),w={state:r,subscribe(e){return h(r,()=>e(r))},push(e,t){e!==r.view&&(r.view=e,t&&(r.data=t),r.history.push(e))},replace(e){r.view=e,r.history=[e]},goBack(){if(r.history.length>1){r.history.pop();const[e]=r.history.slice(-1);r.view=e}}},f=d({open:!1}),j={state:f,subscribe(e){return h(f,()=>e(f))},async open(e){return new Promise(t=>{const{isStandalone:s,isUiLoaded:n,isDataLoaded:l}=i.state,{isConnected:c}=N.state,{enableNetworkView:v}=W.state;if(s?(i.setStandaloneUri(e?.uri),i.setStandaloneChains(e?.standaloneChains),w.replace("ConnectWallet")):e!=null&&e.route?w.replace(e.route):c?w.replace("Account"):v?w.replace("SelectNetwork"):w.replace("ConnectWallet"),n&&l)f.open=!0,t();else{const O=setInterval(()=>{i.state.isUiLoaded&&i.state.isDataLoaded&&(clearInterval(O),f.open=!0,t())},200)}})},close(){f.open=!1}};function A(){return typeof matchMedia<"u"&&matchMedia("(prefers-color-scheme: dark)").matches}const y=d({themeMode:A()?"dark":"light"}),$={state:y,subscribe(e){return h(y,()=>e(y))},setThemeConfig(e){Object.assign(y,e)}},p=d({open:!1,message:"",variant:"success"}),T={state:p,subscribe(e){return h(p,()=>e(p))},openToast(e,t){p.open=!0,p.message=e,p.variant=t},closeToast(){p.open=!1}},m={WALLETCONNECT_DEEPLINK_CHOICE:"WALLETCONNECT_DEEPLINK_CHOICE",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 m.isMobile()&&navigator.userAgent.toLowerCase().includes("android")},isEmptyObject(e){return Object.getPrototypeOf(e)===Object.prototype&&Object.getOwnPropertyNames(e).length===0&&Object.getOwnPropertySymbols(e).length===0},isHttpUrl(e){return e.startsWith("http://")||e.startsWith("https://")},formatNativeUrl(e,t,s){if(m.isHttpUrl(e))return this.formatUniversalUrl(e,t,s);let n=e;n.includes("://")||(n=e.replaceAll("/","").replaceAll(":",""),n=`${n}://`),this.setWalletConnectDeepLink(n,s);const l=encodeURIComponent(t);return`${n}wc?uri=${l}`},formatUniversalUrl(e,t,s){if(!m.isHttpUrl(e))return this.formatNativeUrl(e,t,s);let n=e;e.endsWith("/")&&(n=e.slice(0,-1)),this.setWalletConnectDeepLink(n,s);const l=encodeURIComponent(t);return`${n}/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){localStorage.setItem(m.WALLETCONNECT_DEEPLINK_CHOICE,JSON.stringify({href:e,name:t}))},setWalletConnectAndroidDeepLink(e){const[t]=e.split("?");localStorage.setItem(m.WALLETCONNECT_DEEPLINK_CHOICE,JSON.stringify({href:t,name:"Android"}))},removeWalletConnectDeepLink(){localStorage.removeItem(m.WALLETCONNECT_DEEPLINK_CHOICE)},isNull(e){return e===null}};typeof window<"u"&&(window.Buffer||(window.Buffer=S),window.global||(window.global=window),window.process||(window.process={env:{}}));export{N as AccountCtrl,C as ClientCtrl,W as ConfigCtrl,m as CoreUtil,P as ExplorerCtrl,j as ModalCtrl,i as OptionsCtrl,w as RouterCtrl,$ as ThemeCtrl,T as ToastCtrl};
//# sourceMappingURL=index.js.map
{
"name": "@web3modal/core",
"version": "2.2.0-17f140d",
"version": "2.2.0-afa987d",
"main": "dist/index.js",

@@ -23,3 +23,3 @@ "type": "module",

"devDependencies": {
"@web3modal/ethereum": "2.2.0-17f140d"
"@web3modal/ethereum": "2.2.0-afa987d"
},

@@ -26,0 +26,0 @@ "keywords": [

Sorry, the diff of this file is not supported yet

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