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.3.0-d60e267 to 2.3.0-e8cbe91

dist/_types/src/controllers/WcConnectionCtrl.d.ts

1

dist/_types/index.d.ts

@@ -10,4 +10,5 @@ export { AccountCtrl } from './src/controllers/AccountCtrl';

export { ToastCtrl } from './src/controllers/ToastCtrl';
export { WcConnectionCtrl } from './src/controllers/WcConnectionCtrl';
export type { ConfigCtrlState, Listing, ListingResponse, MobileWallet, RouterView, SwitchNetworkData, ThemeCtrlState, WalletData } from './src/types/controllerTypes';
export { CoreUtil } from './src/utils/CoreUtil';
import './src/utils/PolyfillUtil';

@@ -218,1 +218,5 @@ import type { Chain, EthereumClient } from '@web3modal/ethereum';

}
export interface WcConnectionCtrlState {
pairingUri: string;
pairingError: boolean;
}

1

dist/_types/src/utils/CoreUtil.d.ts

@@ -14,3 +14,2 @@ export declare const CoreUtil: {

setWalletConnectAndroidDeepLink(wcUri: string): void;
removeWalletConnectDeepLink(): void;
setWeb3ModalVersionInStorage(): void;

@@ -17,0 +16,0 @@ getWalletRouterData(): import("../..").WalletData;

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

import{proxy as h,subscribe as v}from"valtio/vanilla";import{Buffer as U}from"buffer";let y;const p={ethereumClient:void 0,setEthereumClient(e){y=e},client(){if(y)return y;throw new Error("ClientCtrl has no client set")}},i=h({history:["ConnectWallet"],view:"ConnectWallet",data:void 0}),w={state:i,subscribe(e){return v(i,()=>e(i))},push(e,t){e!==i.view&&(i.view=e,t&&(i.data=t),i.history.push(e))},reset(e){i.view=e,i.history=[e]},replace(e){i.history.length>1&&(i.history[i.history.length-1]=e,i.view=e)},goBack(){if(i.history.length>1){i.history.pop();const[e]=i.history.slice(-1);i.view=e}},setData(e){i.data=e}},d={WALLETCONNECT_DEEPLINK_CHOICE:"WALLETCONNECT_DEEPLINK_CHOICE",W3M_VERSION:"W3M_VERSION",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 d.isMobile()&&navigator.userAgent.toLowerCase().includes("android")},isIos(){const e=navigator.userAgent.toLowerCase();return d.isMobile()&&(e.includes("iphone")||e.includes("ipad"))},isHttpUrl(e){return e.startsWith("http://")||e.startsWith("https://")},formatNativeUrl(e,t,s){if(d.isHttpUrl(e))return this.formatUniversalUrl(e,t,s);let n=e;n.includes("://")||(n=e.replaceAll("/","").replaceAll(":",""),n=`${n}://`),this.setWalletConnectDeepLink(n,s);const o=encodeURIComponent(t);return`${n}wc?uri=${o}`},formatUniversalUrl(e,t,s){if(!d.isHttpUrl(e))return this.formatNativeUrl(e,t,s);let n=e;e.endsWith("/")&&(n=e.slice(0,-1)),this.setWalletConnectDeepLink(n,s);const o=encodeURIComponent(t);return`${n}/wc?uri=${o}`},async wait(e){return new Promise(t=>{setTimeout(t,e)})},openHref(e,t){window.open(e,t,"noreferrer noopener")},setWalletConnectDeepLink(e,t){localStorage.setItem(d.WALLETCONNECT_DEEPLINK_CHOICE,JSON.stringify({href:e,name:t}))},setWalletConnectAndroidDeepLink(e){const[t]=e.split("?");localStorage.setItem(d.WALLETCONNECT_DEEPLINK_CHOICE,JSON.stringify({href:t,name:"Android"}))},removeWalletConnectDeepLink(){localStorage.removeItem(d.WALLETCONNECT_DEEPLINK_CHOICE)},setWeb3ModalVersionInStorage(){typeof localStorage<"u"&&localStorage.setItem(d.W3M_VERSION,"2.3.0-d60e267")},getWalletRouterData(){var e;const t=(e=w.state.data)==null?void 0:e.Wallet;if(!t)throw new Error('Missing "Wallet" view data');return t},getSwitchNetworkRouterData(){var e;const t=(e=w.state.data)==null?void 0:e.SwitchNetwork;if(!t)throw new Error('Missing "SwitchNetwork" view data');return t}},r=h({selectedChain:void 0,chains:void 0,standaloneChains:void 0,standaloneUri:void 0,isStandalone:!1,isCustomDesktop:!1,isCustomMobile:!1,isDataLoaded:!1,isUiLoaded:!1,isInjectedMobile:!1,walletConnectVersion:1}),l={state:r,subscribe(e){return v(r,()=>e(r))},setChains(e){r.chains=e},setStandaloneChains(e){r.standaloneChains=e},setStandaloneUri(e){r.standaloneUri=e},getSelectedChain(){const e=p.client().getNetwork().chain;return e&&(r.selectedChain=e),r.selectedChain},setSelectedChain(e){r.selectedChain=e},setIsStandalone(e){r.isStandalone=e},setIsCustomDesktop(e){r.isCustomDesktop=e},setIsCustomMobile(e){r.isCustomMobile=e},setIsDataLoaded(e){r.isDataLoaded=e},setIsUiLoaded(e){r.isUiLoaded=e},setWalletConnectVersion(e){r.walletConnectVersion=e},setIsInjectedMobile(e){r.isInjectedMobile=e}},L=h({projectId:"",mobileWallets:void 0,desktopWallets:void 0,walletImages:void 0,chainImages:void 0,tokenImages:void 0,tokenContracts: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}),I={state:L,subscribe(e){return v(L,()=>e(L))},setConfig(e){var t,s,n,o;l.setStandaloneChains(e.standaloneChains),l.setIsStandalone(!!((t=e.standaloneChains)!=null&&t.length)||!!e.enableStandaloneMode),l.setIsCustomMobile(!!((s=e.mobileWallets)!=null&&s.length)),l.setIsCustomDesktop(!!((n=e.desktopWallets)!=null&&n.length)),l.setWalletConnectVersion((o=e.walletConnectVersion)!=null?o:1),l.state.isStandalone||(l.setChains(p.client().chains),l.setIsInjectedMobile(d.isMobile()&&p.client().isInjectedProviderInstalled())),e.defaultChain&&l.setSelectedChain(e.defaultChain),d.setWeb3ModalVersionInStorage(),Object.assign(L,e)}},a=h({address:void 0,profileName:void 0,profileAvatar:void 0,profileLoading:!1,balanceLoading:!1,balance:void 0,isConnected:!1}),A={state:a,subscribe(e){return v(a,()=>e(a))},getAccount(){const e=p.client().getAccount();a.address=e.address,a.isConnected=e.isConnected},async fetchProfile(e,t){var s;try{a.profileLoading=!0;const n=t??a.address,o=(s=l.state.chains)==null?void 0:s.find(c=>c.id===1);if(n&&o){const[c,u]=await Promise.all([p.client().fetchEnsName({address:n,chainId:1}),p.client().fetchEnsAvatar({address:n,chainId:1})]);u&&await e(u),a.profileName=c,a.profileAvatar=u}}finally{a.profileLoading=!1}},async fetchBalance(e){try{const{chain:t}=p.client().getNetwork(),{tokenContracts:s}=I.state;let n;t&&s&&(n=s[t.id]),a.balanceLoading=!0;const o=e??a.address;if(o){const c=await p.client().fetchBalance({address:o,token:n});a.balance={amount:c.formatted,symbol:c.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}},E="https://explorer-api.walletconnect.com";async function W(e,t){const s=new URL(e,E);return s.searchParams.append("projectId",I.state.projectId),Object.entries(t).forEach(([n,o])=>{o&&s.searchParams.append(n,String(o))}),(await fetch(s)).json()}const C={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)},getWalletImageUrl(e){return`${E}/w3m/v1/getWalletImage/${e}?projectId=${I.state.projectId}`},getAssetImageUrl(e){return`${E}/w3m/v1/getAssetImage/${e}?projectId=${I.state.projectId}`}},S=d.isMobile(),g=h({wallets:{listings:[],total:0,page:1},injectedWallets:[],search:{listings:[],total:0,page:1},recomendedWallets:[]}),_={state:g,async getRecomendedWallets(e){const{listings:t}=S?await C.getMobileListings(e):await C.getDesktopListings(e);return g.recomendedWallets=Object.values(t),g.recomendedWallets},async getWallets(e){const{page:t,search:s}=e,{listings:n,total:o}=S?await C.getMobileListings(e):await C.getDesktopListings(e),c=Object.values(n),u=s?"search":"wallets";return g[u]={listings:[...g[u].listings,...c],total:o,page:t??1},{listings:c,total:o}},async getInjectedWallets(){const{listings:e}=await C.getInjectedListings({}),t=Object.values(e);return g.injectedWallets=t,g.injectedWallets},getWalletImageUrl(e){return C.getWalletImageUrl(e)},getAssetImageUrl(e){return C.getAssetImageUrl(e)},resetSearch(){g.search={listings:[],total:0,page:1}}},f=h({open:!1}),R={state:f,subscribe(e){return v(f,()=>e(f))},async open(e){return new Promise(t=>{const{isStandalone:s,isUiLoaded:n,isDataLoaded:o}=l.state,{isConnected:c}=A.state,{enableNetworkView:u}=I.state;if(s?(l.setStandaloneUri(e?.uri),l.setStandaloneChains(e?.standaloneChains),w.reset("ConnectWallet")):e!=null&&e.route?w.reset(e.route):c?w.reset("Account"):u?w.reset("SelectNetwork"):w.reset("ConnectWallet"),n&&o)f.open=!0,t();else{const k=setInterval(()=>{l.state.isUiLoaded&&l.state.isDataLoaded&&(clearInterval(k),f.open=!0,t())},200)}})},close(){f.open=!1}};var O=Object.defineProperty,M=Object.getOwnPropertySymbols,j=Object.prototype.hasOwnProperty,D=Object.prototype.propertyIsEnumerable,N=(e,t,s)=>t in e?O(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,P=(e,t)=>{for(var s in t||(t={}))j.call(t,s)&&N(e,s,t[s]);if(M)for(var s of M(t))D.call(t,s)&&N(e,s,t[s]);return e};function $(){return typeof matchMedia<"u"&&matchMedia("(prefers-color-scheme: dark)").matches}const b=h({themeMode:$()?"dark":"light"}),B={state:b,subscribe(e){return v(b,()=>e(b))},setThemeConfig(e){const{themeMode:t,themeVariables:s}=e;t&&(b.themeMode=t),s&&(b.themeVariables=P({},s))}},m=h({open:!1,message:"",variant:"success"}),H={state:m,subscribe(e){return v(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=U),window.global||(window.global=window),window.process||(window.process={env:{}}));export{A as AccountCtrl,p as ClientCtrl,I as ConfigCtrl,d as CoreUtil,_ as ExplorerCtrl,R as ModalCtrl,l as OptionsCtrl,w as RouterCtrl,B as ThemeCtrl,H as ToastCtrl};
import{proxy as u,subscribe as C}from"valtio/vanilla";import{Buffer as P}from"buffer";let E;const h={ethereumClient:void 0,setEthereumClient(e){E=e},client(){if(E)return E;throw new Error("ClientCtrl has no client set")}},i=u({history:["ConnectWallet"],view:"ConnectWallet",data:void 0}),v={state:i,subscribe(e){return C(i,()=>e(i))},push(e,t){e!==i.view&&(i.view=e,t&&(i.data=t),i.history.push(e))},reset(e){i.view=e,i.history=[e]},replace(e){i.history.length>1&&(i.history[i.history.length-1]=e,i.view=e)},goBack(){if(i.history.length>1){i.history.pop();const[e]=i.history.slice(-1);i.view=e}},setData(e){i.data=e}},g={WALLETCONNECT_DEEPLINK_CHOICE:"WALLETCONNECT_DEEPLINK_CHOICE",W3M_VERSION:"W3M_VERSION",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 g.isMobile()&&navigator.userAgent.toLowerCase().includes("android")},isIos(){const e=navigator.userAgent.toLowerCase();return g.isMobile()&&(e.includes("iphone")||e.includes("ipad"))},isHttpUrl(e){return e.startsWith("http://")||e.startsWith("https://")},formatNativeUrl(e,t,n){if(g.isHttpUrl(e))return this.formatUniversalUrl(e,t,n);let s=e;s.includes("://")||(s=e.replaceAll("/","").replaceAll(":",""),s=`${s}://`),this.setWalletConnectDeepLink(s,n);const o=encodeURIComponent(t);return`${s}wc?uri=${o}`},formatUniversalUrl(e,t,n){if(!g.isHttpUrl(e))return this.formatNativeUrl(e,t,n);let s=e;e.endsWith("/")&&(s=e.slice(0,-1)),this.setWalletConnectDeepLink(s,n);const o=encodeURIComponent(t);return`${s}/wc?uri=${o}`},async wait(e){return new Promise(t=>{setTimeout(t,e)})},openHref(e,t){window.open(e,t,"noreferrer noopener")},setWalletConnectDeepLink(e,t){localStorage.setItem(g.WALLETCONNECT_DEEPLINK_CHOICE,JSON.stringify({href:e,name:t}))},setWalletConnectAndroidDeepLink(e){const[t]=e.split("?");localStorage.setItem(g.WALLETCONNECT_DEEPLINK_CHOICE,JSON.stringify({href:t,name:"Android"}))},setWeb3ModalVersionInStorage(){typeof localStorage<"u"&&localStorage.setItem(g.W3M_VERSION,"2.3.0-e8cbe91")},getWalletRouterData(){var e;const t=(e=v.state.data)==null?void 0:e.Wallet;if(!t)throw new Error('Missing "Wallet" view data');return t},getSwitchNetworkRouterData(){var e;const t=(e=v.state.data)==null?void 0:e.SwitchNetwork;if(!t)throw new Error('Missing "SwitchNetwork" view data');return t}},r=u({selectedChain:void 0,chains:void 0,standaloneChains:void 0,standaloneUri:void 0,isStandalone:!1,isCustomDesktop:!1,isCustomMobile:!1,isDataLoaded:!1,isUiLoaded:!1,isInjectedMobile:!1,walletConnectVersion:1}),l={state:r,subscribe(e){return C(r,()=>e(r))},setChains(e){r.chains=e},setStandaloneChains(e){r.standaloneChains=e},setStandaloneUri(e){r.standaloneUri=e},getSelectedChain(){const e=h.client().getNetwork().chain;return e&&(r.selectedChain=e),r.selectedChain},setSelectedChain(e){r.selectedChain=e},setIsStandalone(e){r.isStandalone=e},setIsCustomDesktop(e){r.isCustomDesktop=e},setIsCustomMobile(e){r.isCustomMobile=e},setIsDataLoaded(e){r.isDataLoaded=e},setIsUiLoaded(e){r.isUiLoaded=e},setWalletConnectVersion(e){r.walletConnectVersion=e},setIsInjectedMobile(e){r.isInjectedMobile=e}},y=u({projectId:"",mobileWallets:void 0,desktopWallets:void 0,walletImages:void 0,chainImages:void 0,tokenImages:void 0,tokenContracts: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}),L={state:y,subscribe(e){return C(y,()=>e(y))},setConfig(e){var t,n,s,o;l.setStandaloneChains(e.standaloneChains),l.setIsStandalone(!!((t=e.standaloneChains)!=null&&t.length)||!!e.enableStandaloneMode),l.setIsCustomMobile(!!((n=e.mobileWallets)!=null&&n.length)),l.setIsCustomDesktop(!!((s=e.desktopWallets)!=null&&s.length)),l.setWalletConnectVersion((o=e.walletConnectVersion)!=null?o:1),l.state.isStandalone||(l.setChains(h.client().chains),l.setIsInjectedMobile(g.isMobile()&&h.client().isInjectedProviderInstalled())),e.defaultChain&&l.setSelectedChain(e.defaultChain),g.setWeb3ModalVersionInStorage(),Object.assign(y,e)}},a=u({address:void 0,profileName:void 0,profileAvatar:void 0,profileLoading:!1,balanceLoading:!1,balance:void 0,isConnected:!1}),$={state:a,subscribe(e){return C(a,()=>e(a))},getAccount(){const e=h.client().getAccount();a.address=e.address,a.isConnected=e.isConnected},async fetchProfile(e,t){var n;try{a.profileLoading=!0;const s=t??a.address,o=(n=l.state.chains)==null?void 0:n.find(c=>c.id===1);if(s&&o){const[c,d]=await Promise.all([h.client().fetchEnsName({address:s,chainId:1}),h.client().fetchEnsAvatar({address:s,chainId:1})]);d&&await e(d),a.profileName=c,a.profileAvatar=d}}finally{a.profileLoading=!1}},async fetchBalance(e){try{const{chain:t}=h.client().getNetwork(),{tokenContracts:n}=L.state;let s;t&&n&&(s=n[t.id]),a.balanceLoading=!0;const o=e??a.address;if(o){const c=await h.client().fetchBalance({address:o,token:s});a.balance={amount:c.formatted,symbol:c.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}},U="https://explorer-api.walletconnect.com";async function S(e,t){const n=new URL(e,U);return n.searchParams.append("projectId",L.state.projectId),Object.entries(t).forEach(([s,o])=>{o&&n.searchParams.append(s,String(o))}),(await fetch(n)).json()}const w={async getDesktopListings(e){return S("/w3m/v1/getDesktopListings",e)},async getMobileListings(e){return S("/w3m/v1/getMobileListings",e)},async getInjectedListings(e){return S("/w3m/v1/getInjectedListings",e)},getWalletImageUrl(e){return`${U}/w3m/v1/getWalletImage/${e}?projectId=${L.state.projectId}`},getAssetImageUrl(e){return`${U}/w3m/v1/getAssetImage/${e}?projectId=${L.state.projectId}`}},M=g.isMobile(),p=u({wallets:{listings:[],total:0,page:1},injectedWallets:[],search:{listings:[],total:0,page:1},recomendedWallets:[]}),K={state:p,async getRecomendedWallets(e){const{listings:t}=M?await w.getMobileListings(e):await w.getDesktopListings(e);return p.recomendedWallets=Object.values(t),p.recomendedWallets},async getWallets(e){const{page:t,search:n}=e,{listings:s,total:o}=M?await w.getMobileListings(e):await w.getDesktopListings(e),c=Object.values(s),d=n?"search":"wallets";return p[d]={listings:[...p[d].listings,...c],total:o,page:t??1},{listings:c,total:o}},async getInjectedWallets(){const{listings:e}=await w.getInjectedListings({}),t=Object.values(e);return p.injectedWallets=t,p.injectedWallets},getWalletImageUrl(e){return w.getWalletImageUrl(e)},getAssetImageUrl(e){return w.getAssetImageUrl(e)},resetSearch(){p.search={listings:[],total:0,page:1}}},f=u({pairingUri:"",pairingError:!1}),N={state:f,subscribe(e){return C(f,()=>e(f))},setPairingUri(e){f.pairingUri=e},setPairingError(e){f.pairingError=e}},b=u({open:!1}),J={state:b,subscribe(e){return C(b,()=>e(b))},async open(e){return new Promise(t=>{const{isStandalone:n,isUiLoaded:s,isDataLoaded:o}=l.state,{pairingUri:c}=N.state,{isConnected:d}=$.state,{enableNetworkView:A}=L.state;if(n?(l.setStandaloneUri(e?.uri),l.setStandaloneChains(e?.standaloneChains),v.reset("ConnectWallet")):e!=null&&e.route?v.reset(e.route):d?v.reset("Account"):A?v.reset("SelectNetwork"):v.reset("ConnectWallet"),s&&o&&(n||c||d))b.open=!0,t();else{const O=setInterval(()=>{const W=l.state,D=N.state;W.isUiLoaded&&W.isDataLoaded&&(W.isStandalone||D.pairingUri||d)&&(clearInterval(O),b.open=!0,t())},200)}})},close(){b.open=!1}};var V=Object.defineProperty,k=Object.getOwnPropertySymbols,T=Object.prototype.hasOwnProperty,_=Object.prototype.propertyIsEnumerable,j=(e,t,n)=>t in e?V(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,R=(e,t)=>{for(var n in t||(t={}))T.call(t,n)&&j(e,n,t[n]);if(k)for(var n of k(t))_.call(t,n)&&j(e,n,t[n]);return e};function B(){return typeof matchMedia<"u"&&matchMedia("(prefers-color-scheme: dark)").matches}const I=u({themeMode:B()?"dark":"light"}),q={state:I,subscribe(e){return C(I,()=>e(I))},setThemeConfig(e){const{themeMode:t,themeVariables:n}=e;t&&(I.themeMode=t),n&&(I.themeVariables=R({},n))}},m=u({open:!1,message:"",variant:"success"}),z={state:m,subscribe(e){return C(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=P),window.global||(window.global=window),window.process||(window.process={env:{}}));export{$ as AccountCtrl,h as ClientCtrl,L as ConfigCtrl,g as CoreUtil,K as ExplorerCtrl,J as ModalCtrl,l as OptionsCtrl,v as RouterCtrl,q as ThemeCtrl,z as ToastCtrl,N as WcConnectionCtrl};
//# sourceMappingURL=index.js.map
{
"name": "@web3modal/core",
"version": "2.3.0-d60e267",
"version": "2.3.0-e8cbe91",
"main": "dist/index.js",

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

"devDependencies": {
"@web3modal/ethereum": "2.3.0-d60e267"
"@web3modal/ethereum": "2.3.0-e8cbe91"
},

@@ -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