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.0.0-787e037 to 2.0.0-85630cf

3

dist/_types/index.d.ts

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

export { AccountCtrl } from './src/controllers/AccountCtrl';
export { ClientCtrl } from './src/controllers/ClientCtrl';

@@ -9,4 +8,4 @@ export { ConfigCtrl } from './src/controllers/ConfigCtrl';

export { ToastCtrl } from './src/controllers/ToastCtrl';
export type { ConfigCtrlState, DesktopConnectorData, Listing, ListingResponse, RouterView } from './src/types/controllerTypes';
export type { ConfigCtrlState, DesktopConnectorData, InstallConnectorData, Listing, ListingResponse, RouterView, SwitchNetworkData, MobileWallet } from './src/types/controllerTypes';
export { CoreUtil } from './src/utils/CoreUtil';
import './src/utils/PolyfillUtil';
import type { ModalCtrlState } from '../types/controllerTypes';
export interface OpenOptions {
uri?: string;
standaloneChains?: string[];
route?: 'Account' | 'ConnectWallet' | 'Help' | 'SelectNetwork';
}
export declare const ModalCtrl: {
state: ModalCtrlState;
subscribe(callback: (newState: ModalCtrlState) => void): () => void;
open(options?: {
uri: string;
standaloneChains?: string[];
}): void;
open(options?: OpenOptions): Promise<void>;
close(): void;
};
import type { OptionsCtrlState } from '../types/controllerTypes';
export declare const OptionsCtrl: {
state: OptionsCtrlState;
subscribe(callback: (newState: OptionsCtrlState) => void): () => void;
setChains(chains?: OptionsCtrlState['chains']): void;
setStandaloneChains(standaloneChains: OptionsCtrlState['standaloneChains']): void;
setStandaloneUri(standaloneUri: OptionsCtrlState['standaloneUri']): void;
setSelectedChainId(selectedChainId: OptionsCtrlState['selectedChainId']): void;
getSelectedChain(): import("@wagmi/chains").Chain | undefined;
setSelectedChain(selectedChain: OptionsCtrlState['selectedChain']): void;
setIsStandalone(isStandalone: OptionsCtrlState['isStandalone']): void;

@@ -12,2 +14,14 @@ setIsCustomDesktop(isCustomDesktop: OptionsCtrlState['isCustomDesktop']): void;

setIsExplorer(isExplorer: OptionsCtrlState['isExplorer']): void;
getAccount(): void;
setAddress(address: OptionsCtrlState['address']): void;
setIsConnected(isConnected: OptionsCtrlState['isConnected']): void;
setProfileName(profileName: OptionsCtrlState['profileName']): void;
setProfileAvatar(profileAvatar: OptionsCtrlState['profileAvatar']): void;
setProfileLoading(profileLoading: OptionsCtrlState['profileLoading']): void;
setBalanceLoading(balanceLoading: OptionsCtrlState['balanceLoading']): void;
setBalance(balance: OptionsCtrlState['balance']): void;
setIsDataLoaded(isDataLoaded: OptionsCtrlState['isDataLoaded']): void;
setIsUiLoaded(isUiLoaded: OptionsCtrlState['isUiLoaded']): void;
resetProfile(): void;
resetAccount(): void;
};

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

import type { EthereumClient } from '@web3modal/ethereum';
import type { Chain, EthereumClient } from '@web3modal/ethereum';
export interface MobileWallet {

@@ -23,3 +23,5 @@ id: string;

themeBackground?: 'gradient' | 'themeColor';
themeZIndex?: number;
standaloneChains?: string[];
defaultChain?: Chain;
mobileWallets?: MobileWallet[];

@@ -29,4 +31,9 @@ desktopWallets?: DesktopWallet[];

chainImages?: Record<string, string>;
tokenImages?: Record<string, string>;
enableStandaloneMode?: boolean;
enableNetworkView?: boolean;
enableStandaloneMode?: boolean;
explorerAllowList?: string[];
explorerDenyList?: string[];
termsOfServiceUrl?: string;
privacyPolicyUrl?: string;
}

@@ -37,10 +44,22 @@ export interface ModalCtrlState {

export interface OptionsCtrlState {
selectedChainId?: number;
selectedChain?: Chain;
chains?: EthereumClient['chains'];
standaloneChains?: string[];
standaloneUri?: string;
address?: `0x${string}`;
isConnected: boolean;
isStandalone: boolean;
isCustomDesktop: boolean;
isCustomMobile: boolean;
isDataLoaded: boolean;
isUiLoaded: boolean;
isExplorer: boolean;
profileName?: string | null;
profileAvatar?: string | null;
profileLoading?: boolean;
balanceLoading?: boolean;
balance?: {
amount: string;
symbol: string;
};
}

@@ -111,3 +130,3 @@ export interface ExplorerCtrlState {

}
export type RouterView = 'Account' | 'CoinbaseExtensionConnector' | 'CoinbaseMobileConnector' | 'ConnectWallet' | 'DesktopConnector' | 'GetWallet' | 'Help' | 'InjectedConnector' | 'MetaMaskConnector' | 'Qrcode' | 'SelectNetwork' | 'WalletExplorer' | 'WalletFilter';
export type RouterView = 'Account' | 'ConnectWallet' | 'DesktopConnector' | 'GetWallet' | 'Help' | 'InjectedConnector' | 'InstallConnector' | 'Qrcode' | 'SelectNetwork' | 'SwitchNetwork' | 'WalletExplorer' | 'WalletFilter';
export interface DesktopConnectorData {

@@ -120,2 +139,9 @@ name: string;

}
export type SwitchNetworkData = Chain;
export interface InstallConnectorData {
id: string;
name: string;
url: string;
isMobile?: boolean;
}
export interface RouterCtrlState {

@@ -125,3 +151,5 @@ history: RouterView[];

data?: {
DesktopConnector: DesktopConnectorData;
DesktopConnector?: DesktopConnectorData;
SwitchNetwork?: SwitchNetworkData;
InstallConnector?: InstallConnectorData;
};

@@ -133,7 +161,1 @@ }

}
export interface AccountCtrlState {
isConnected: boolean;
address?: string;
balance?: string;
balanceSymbol?: string;
}
export declare const CoreUtil: {
isCoinbaseExtension(): import("@coinbase/wallet-sdk").CoinbaseWalletProvider | undefined;
WALLETCONNECT_DEEPLINK_CHOICE: string;
isMobile(): boolean;
isAndroid(): boolean;
isEmptyObject(value: unknown): boolean;

@@ -11,4 +12,6 @@ isHttpUrl(url: string): boolean;

setWalletConnectDeepLink(href: string, name: string): void;
setWalletConnectAndroidDeepLink(wcUri: string): void;
removeWalletConnectDeepLink(): void;
isNull<T>(value: T | null): value is null;
getWalletConnectVersion(): number;
};

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

import{proxy as r,subscribe as g}from"valtio/vanilla";import{Buffer as U}from"buffer";const l=r({selectedChainId:void 0,chains:void 0,standaloneChains:void 0,standaloneUri:void 0,isStandalone:!1,isCustomDesktop:!1,isCustomMobile:!1,isExplorer:!1}),a={state:l,setChains(e){l.chains=e},setStandaloneChains(e){l.standaloneChains=e},setStandaloneUri(e){l.standaloneUri=e},setSelectedChainId(e){l.selectedChainId=e},setIsStandalone(e){l.isStandalone=e},setIsCustomDesktop(e){l.isCustomDesktop=e},setIsCustomMobile(e){l.isCustomMobile=e},setIsExplorer(e){l.isExplorer=e}},u=r({initialized:!1,ethereumClient:void 0}),S={setEthereumClient(e){!u.initialized&&e&&(u.ethereumClient=e,a.setChains(e.chains),u.initialized=!0)},client(){if(u.ethereumClient)return u.ethereumClient;throw new Error("ClientCtrl has no client set")}},c=r({isConnected:!1,address:void 0,balance:void 0,balanceSymbol:void 0}),M={state:c,subscribe(e){return g(c,()=>e(c))},get(){const e=S.client().getAccount();c.address=e.address,c.isConnected=e.isConnected},setAddress(e){c.address=e},setIsConnected(e){c.isConnected=e}},W="WALLETCONNECT_DEEPLINK_CHOICE",b={isCoinbaseExtension(){return window.coinbaseWalletExtension},isMobile(){return typeof window<"u"?Boolean(window.matchMedia("(pointer:coarse)").matches||/Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent)):!1},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(b.isHttpUrl(e))return this.formatUniversalUrl(e,t,s);const n=e.replaceAll("/","").replaceAll(":","");this.setWalletConnectDeepLink(n,s);const i=encodeURIComponent(t);return`${n}://wc?uri=${i}`},formatUniversalUrl(e,t,s){if(!b.isHttpUrl(e))return this.formatNativeUrl(e,t,s);let n=e;e.endsWith("/")&&(n=e.slice(0,-1)),this.setWalletConnectDeepLink(n,s);const i=encodeURIComponent(t);return`${n}/wc?uri=${i}`},async wait(e){return new Promise(t=>{setTimeout(t,e)})},openHref(e,t="_self"){window.open(e,t,"noreferrer noopener")},setWalletConnectDeepLink(e,t){localStorage.setItem(W,JSON.stringify({href:e,name:t}))},removeWalletConnectDeepLink(){localStorage.removeItem(W)},isNull(e){return e===null}};function j(){return typeof matchMedia<"u"&&matchMedia("(prefers-color-scheme: dark)").matches}const h=r({projectId:void 0,themeMode:j()?"dark":"light",themeColor:"default",themeBackground:b.isMobile()?"themeColor":"gradient",mobileWallets:void 0,desktopWallets:void 0,walletImages:void 0,chainImages:void 0,standaloneChains:void 0,enableStandaloneMode:!1,enableNetworkView:!0}),O={state:h,subscribe(e){return g(h,()=>e(h))},setConfig(e){var t,s,n,i;a.setStandaloneChains(e.standaloneChains),a.setIsStandalone(Boolean((t=e.standaloneChains)==null?void 0:t.length)||Boolean(e.enableStandaloneMode)),a.setIsCustomMobile(Boolean((s=e.mobileWallets)==null?void 0:s.length)),a.setIsCustomDesktop(Boolean((n=e.desktopWallets)==null?void 0:n.length)),a.setIsExplorer(Boolean((i=e.projectId)==null?void 0:i.length)),Object.assign(h,e)},setThemeConfig(e){Object.assign(h,e)}},y="https://explorer-api.walletconnect.com";function k(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 w={async fetchWallets(e,t){const s=k(t),n=`${y}/v3/wallets?projectId=${e}&${s}`;return(await fetch(n)).json()},formatImageUrl(e,t){return`${y}/v2/logo/lg/${t}?projectId=${e}`}},d=r({wallets:{listings:[],total:0,page:1},search:{listings:[],total:0,page:1},previewWallets:[],recomendedWallets:[]});function f(){const{projectId:e}=O.state;if(!e)throw new Error("projectId is required to work with explorer api");return e}const B={state:d,async getPreviewWallets(e){const{listings:t}=await w.fetchWallets(f(),e);return d.previewWallets=Object.values(t),d.previewWallets},async getRecomendedWallets(){const{listings:e}=await w.fetchWallets(f(),{page:1,entries:6});d.recomendedWallets=Object.values(e)},async getPaginatedWallets(e){const{page:t,search:s}=e,{listings:n,total:i}=await w.fetchWallets(f(),e),m=Object.values(n),I=s?"search":"wallets";return d[I]={listings:[...d[I].listings,...m],total:i,page:t??1},{listings:m,total:i}},getImageUrl(e){return w.formatImageUrl(f(),e)},resetSearch(){d.search={listings:[],total:0,page:1}}},o=r({history:["ConnectWallet"],view:"ConnectWallet",data:void 0}),v={state:o,subscribe(e){return g(o,()=>e(o))},push(e,t){e!==o.view&&(o.view=e,t&&(o.data=t),o.history.push(e))},replace(e){o.view=e,o.history=[e]},goBack(){if(o.history.length>1){o.history.pop();const[e]=o.history.slice(-1);o.view=e}}},C=r({open:!1}),x={state:C,subscribe(e){return g(C,()=>e(C))},open(e){var t;const{chains:s}=a.state,{enableNetworkView:n}=O.state,i=s?.length&&s.length>1,{isConnected:m}=S.client().getAccount();m?v.replace("Account"):i&&n?v.replace("SelectNetwork"):v.replace("ConnectWallet"),typeof e?.uri=="string"&&a.setStandaloneUri(e.uri),(t=e?.standaloneChains)!=null&&t.length&&a.setStandaloneChains(e.standaloneChains),C.open=!0},close(){C.open=!1}},p=r({open:!1,message:"",variant:"success"}),N={state:p,subscribe(e){return g(p,()=>e(p))},openToast(e,t){p.open=!0,p.message=e,p.variant=t},closeToast(){p.open=!1}};typeof window<"u"&&(window.Buffer||(window.Buffer=U),window.global||(window.global=window),window.process||(window.process={env:{}}));export{M as AccountCtrl,S as ClientCtrl,O as ConfigCtrl,b as CoreUtil,B as ExplorerCtrl,x as ModalCtrl,a as OptionsCtrl,v as RouterCtrl,N as ToastCtrl};
import{proxy as p,subscribe as f}from"valtio/vanilla";import{Buffer as O}from"buffer";const n=p({selectedChain:void 0,chains:void 0,standaloneChains:void 0,standaloneUri:void 0,address:void 0,profileName:void 0,profileAvatar:void 0,profileLoading:!1,balanceLoading:!1,balance:void 0,isConnected:!1,isStandalone:!1,isCustomDesktop:!1,isCustomMobile:!1,isExplorer:!1,isDataLoaded:!1,isUiLoaded:!1}),a={state:n,subscribe(e){return f(n,()=>e(n))},setChains(e){n.chains=e},setStandaloneChains(e){n.standaloneChains=e},setStandaloneUri(e){n.standaloneUri=e},getSelectedChain(){const e=I.client().getNetwork().chain;return e&&(n.selectedChain=e),n.selectedChain},setSelectedChain(e){n.selectedChain=e},setIsStandalone(e){n.isStandalone=e},setIsCustomDesktop(e){n.isCustomDesktop=e},setIsCustomMobile(e){n.isCustomMobile=e},setIsExplorer(e){n.isExplorer=e},getAccount(){const e=I.client().getAccount();n.address=e.address,n.isConnected=e.isConnected},setAddress(e){n.address=e},setIsConnected(e){n.isConnected=e},setProfileName(e){n.profileName=e},setProfileAvatar(e){n.profileAvatar=e},setProfileLoading(e){n.profileLoading=e},setBalanceLoading(e){n.balanceLoading=e},setBalance(e){n.balance=e},setIsDataLoaded(e){n.isDataLoaded=e},setIsUiLoaded(e){n.isUiLoaded=e},resetProfile(){n.profileName=void 0,n.profileAvatar=void 0,n.balance=void 0},resetAccount(){n.address=void 0,a.resetProfile()}},h=p({initialized:!1,ethereumClient:void 0}),I={setEthereumClient(e){!h.initialized&&e&&(h.ethereumClient=e,a.setChains(e.chains),h.initialized=!0)},client(){if(h.ethereumClient)return h.ethereumClient;throw new Error("ClientCtrl has no client set")}},c={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 c.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(c.isHttpUrl(e))return this.formatUniversalUrl(e,t,s);let o=e;o.includes("://")||(o=e.replaceAll("/","").replaceAll(":",""),o=`${o}://`),this.setWalletConnectDeepLink(o,s);const l=encodeURIComponent(t);return`${o}wc?uri=${l}`},formatUniversalUrl(e,t,s){if(!c.isHttpUrl(e))return this.formatNativeUrl(e,t,s);let o=e;e.endsWith("/")&&(o=e.slice(0,-1)),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="_self"){window.open(e,t,"noreferrer noopener")},setWalletConnectDeepLink(e,t){localStorage.setItem(c.WALLETCONNECT_DEEPLINK_CHOICE,JSON.stringify({href:e,name:t}))},setWalletConnectAndroidDeepLink(e){const[t]=e.split("?");localStorage.setItem(c.WALLETCONNECT_DEEPLINK_CHOICE,JSON.stringify({href:t,name:"Android"}))},removeWalletConnectDeepLink(){localStorage.removeItem(c.WALLETCONNECT_DEEPLINK_CHOICE)},isNull(e){return e===null},getWalletConnectVersion(){const{isStandalone:e}=a.state;let t=1;return e||(t=I.client().walletConnectVersion),t}};function S(){return typeof matchMedia<"u"&&matchMedia("(prefers-color-scheme: dark)").matches}const g=p({projectId:void 0,themeMode:S()?"dark":"light",themeColor:"default",themeBackground:c.isMobile()?"themeColor":"gradient",themeZIndex:89,mobileWallets:void 0,desktopWallets:void 0,walletImages:void 0,chainImages:void 0,tokenImages:void 0,standaloneChains:void 0,enableStandaloneMode:!1,enableNetworkView:!1,defaultChain:void 0,explorerAllowList:void 0,explorerDenyList:void 0,termsOfServiceUrl:void 0,privacyPolicyUrl:void 0}),E={state:g,subscribe(e){return f(g,()=>e(g))},setConfig(e){var t,s,o,l;if(a.setStandaloneChains(e.standaloneChains),a.setIsStandalone(Boolean((t=e.standaloneChains)==null?void 0:t.length)||Boolean(e.enableStandaloneMode)),a.setIsCustomMobile(Boolean((s=e.mobileWallets)==null?void 0:s.length)),a.setIsCustomDesktop(Boolean((o=e.desktopWallets)==null?void 0:o.length)),a.setIsExplorer(Boolean((l=e.projectId)==null?void 0:l.length)),e.defaultChain)a.setSelectedChain(e.defaultChain);else if(!a.state.isStandalone){const u=I.client().getDefaultChain();a.setSelectedChain(u)}Object.assign(g,e)},setThemeConfig(e){Object.assign(g,e)}},L="https://explorer-api.walletconnect.com";function y(e){const t=Object.fromEntries(Object.entries(e).filter(([s,o])=>typeof o<"u"&&o!==null&&o!=="").map(([s,o])=>[s,o.toString()]));return new URLSearchParams(t).toString()}const w={async fetchWallets(e,t){const s=y(t),o=`${L}/v3/wallets?projectId=${e}&${s}`;return(await fetch(o)).json()},formatImageUrl(e,t){return`${L}/v3/logo/lg/${t}?projectId=${e}`}},r=p({wallets:{listings:[],total:0,page:1},search:{listings:[],total:0,page:1},previewWallets:[],recomendedWallets:[]});function b(){const{projectId:e}=E.state;if(!e)throw new Error("projectId is required to work with explorer api");return e}const A={state:r,async getPreviewWallets(e){const{listings:t}=await w.fetchWallets(b(),e);return r.previewWallets=Object.values(t),r.previewWallets},async getRecomendedWallets(){const{listings:e}=await w.fetchWallets(b(),{page:1,entries:6});r.recomendedWallets=Object.values(e)},async getPaginatedWallets(e){const{page:t,search:s}=e,{listings:o,total:l}=await w.fetchWallets(b(),e),u=Object.values(o),v=s?"search":"wallets";return r[v]={listings:[...r[v].listings,...u],total:l,page:t??1},{listings:u,total:l}},getImageUrl(e){return w.formatImageUrl(b(),e)},resetSearch(){r.search={listings:[],total:0,page:1}}},i=p({history:["ConnectWallet"],view:"ConnectWallet",data:void 0}),m={state:i,subscribe(e){return f(i,()=>e(i))},push(e,t){e!==i.view&&(i.view=e,t&&(i.data=t),i.history.push(e))},replace(e){i.view=e,i.history=[e]},goBack(){if(i.history.length>1){i.history.pop();const[e]=i.history.slice(-1);i.view=e}}},C=p({open:!1}),k={state:C,subscribe(e){return f(C,()=>e(C))},async open(e){return new Promise(t=>{const{isConnected:s,isStandalone:o,isUiLoaded:l,isDataLoaded:u}=a.state,{enableNetworkView:v}=E.state;if(o?(a.setStandaloneUri(e?.uri),a.setStandaloneChains(e?.standaloneChains),m.replace("ConnectWallet")):e!=null&&e.route?m.replace(e.route):s?m.replace("Account"):v?m.replace("SelectNetwork"):m.replace("ConnectWallet"),l&&u)C.open=!0,t();else{const W=setInterval(()=>{a.state.isUiLoaded&&a.state.isDataLoaded&&(clearInterval(W),C.open=!0,t())},200)}})},close(){C.open=!1}},d=p({open:!1,message:"",variant:"success"}),P={state:d,subscribe(e){return f(d,()=>e(d))},openToast(e,t){d.open=!0,d.message=e,d.variant=t},closeToast(){d.open=!1}};typeof window<"u"&&(window.Buffer||(window.Buffer=O),window.global||(window.global=window),window.process||(window.process={env:{}}));export{I as ClientCtrl,E as ConfigCtrl,c as CoreUtil,A as ExplorerCtrl,k as ModalCtrl,a as OptionsCtrl,m as RouterCtrl,P as ToastCtrl};
//# sourceMappingURL=index.js.map
{
"name": "@web3modal/core",
"version": "2.0.0-787e037",
"version": "2.0.0-85630cf",
"main": "dist/index.js",

@@ -20,6 +20,6 @@ "type": "module",

"buffer": "6.0.3",
"valtio": "1.7.6"
"valtio": "1.9.0"
},
"devDependencies": {
"@web3modal/ethereum": "2.0.0-787e037"
"@web3modal/ethereum": "2.0.0-85630cf"
},

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

@@ -12,3 +12,3 @@ ### 📚 [Documentation](https://docs.walletconnect.com/2.0/introduction/web3modal/about)

<p align="center">
<img src="./.github/assets/header.png" alt="" border="0">
<img src="./.github/assets/header.jpg" alt="" border="0">
</p>

@@ -15,0 +15,0 @@

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