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-d873f5c to 2.0.0-d8cdbe6

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

4

dist/_types/index.d.ts

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

export { ToastCtrl } from './src/controllers/ToastCtrl';
export type { ConfigCtrlState, DesktopConnectorData, Listing, ListingResponse, RouterView } from './src/types/controllerTypes';
export { CoreHelpers } from './src/utils/CoreHelpers';
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): 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,12 @@ 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;
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,6 +44,8 @@ export interface ModalCtrlState {

export interface OptionsCtrlState {
selectedChainId?: number;
selectedChain?: Chain;
chains?: EthereumClient['chains'];
standaloneChains?: string[];
standaloneUri?: string;
address?: `0x${string}`;
isConnected: boolean;
isStandalone: boolean;

@@ -46,2 +55,10 @@ isCustomDesktop: boolean;

isExplorer: boolean;
profileName?: string | null;
profileAvatar?: string | null;
profileLoading?: boolean;
balanceLoading?: boolean;
balance?: {
amount: string;
symbol: string;
};
}

@@ -112,3 +129,3 @@ export interface ExplorerCtrlState {

}
export type RouterView = '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 {

@@ -121,2 +138,9 @@ name: string;

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

@@ -126,3 +150,5 @@ history: RouterView[];

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

@@ -129,0 +155,0 @@ }

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

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

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

"buffer": "6.0.3",
"valtio": "1.7.6"
"valtio": "1.8.0"
},
"devDependencies": {
"@web3modal/ethereum": "2.0.0-d873f5c"
"@web3modal/ethereum": "2.0.0-d8cdbe6"
},

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