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

@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-6ce38ab to 2.0.0-787e037

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

16

dist/_types/index.d.ts

@@ -1,13 +0,11 @@

export { AccountCtrl, initialAccountlState } from './src/controllers/AccountCtrl';
export { AccountCtrl } from './src/controllers/AccountCtrl';
export { ClientCtrl } from './src/controllers/ClientCtrl';
export { ConfigCtrl } from './src/controllers/ConfigCtrl';
export { ConnectModalCtrl } from './src/controllers/ConnectModalCtrl';
export { ExplorerCtrl } from './src/controllers/ExplorerCtrl';
export { ModalToastCtrl } from './src/controllers/ModalToastCtrl';
export { ModalCtrl } from './src/controllers/ModalCtrl';
export { OptionsCtrl } from './src/controllers/OptionsCtrl';
export { RouterCtrl } from './src/controllers/RouterCtrl';
export { CoreHelpers } from './src/utils/CoreHelpers';
export { getExplorerApi } from './src/utils/ExplorerApi';
export type { Account } from './types/accountTypes';
export type { ConfigOptions } from './types/configTypes';
export type { Listing } from './types/explorerTypes';
export type { RouterView } from './types/routerTypes';
export { ToastCtrl } from './src/controllers/ToastCtrl';
export type { ConfigCtrlState, DesktopConnectorData, Listing, ListingResponse, RouterView } from './src/types/controllerTypes';
export { CoreUtil } from './src/utils/CoreUtil';
import './src/utils/PolyfillUtil';

@@ -1,16 +0,8 @@

import type { Account } from '../../types/accountTypes';
export declare const initialAccountlState: {
connected: boolean;
chainSupported: boolean;
address: string;
chainId: string;
connector: string;
};
import type { AccountCtrlState } from '../types/controllerTypes';
export declare const AccountCtrl: {
state: Account;
subscribe(callback: (newState: Account) => void): () => void;
setAccount(account: Omit<Account, 'connected'>): void;
setAddress(address: Account['address']): void;
setChain(chainId: Account['chainId'], chainSupported: Account['chainSupported']): void;
resetAccount(): void;
state: AccountCtrlState;
subscribe(callback: (newState: AccountCtrlState) => void): () => void;
get(): void;
setAddress(address: AccountCtrlState['address']): void;
setIsConnected(isConnected: AccountCtrlState['isConnected']): void;
};

@@ -1,41 +0,5 @@

import type { EthereumClient, Web3ModalEthereum } from '@web3modal/ethereum';
export interface State {
ethereum?: typeof Web3ModalEthereum;
}
import type { ClientCtrlState } from '../types/controllerTypes';
export declare const ClientCtrl: {
ethereum(): {
walletConnectRpc({ projectId }: import("@web3modal/ethereum/dist/_types/types/apiTypes").GetWalletConnectProviderOpts): import("@wagmi/core").ChainProviderFn<import("@ethersproject/providers").JsonRpcProvider, import("@ethersproject/providers").WebSocketProvider, import("@wagmi/core").Chain>;
defaultConnectors({ appName, chains }: import("@web3modal/ethereum/dist/_types/types/apiTypes").GetDefaultConnectorsOpts): (import("@wagmi/core/connectors/walletConnect").WalletConnectConnector | import("@wagmi/core").InjectedConnector | import("@wagmi/core/connectors/coinbaseWallet").CoinbaseWalletConnector)[];
createClient(wagmiClient: EthereumClient): any;
getDefaultConnectorChainId(connector: import("@wagmi/core").Connector<any, any, any>): number;
getConnectorById(id: "coinbaseWallet" | "injected" | "metaMask" | "walletConnect"): import("@wagmi/core").Connector<any, any, any>;
disconnect(): Promise<void>;
connectWalletConnect(onUri: (uri: string) => void): Promise<import("@wagmi/core").ConnectResult<import("@wagmi/core").Provider>>;
connectLinking(onUri: (uri: string) => void): Promise<import("@wagmi/core").ConnectResult<import("@wagmi/core").Provider>>;
connectCoinbaseMobile(onUri?: ((uri: string) => void) | undefined): Promise<import("@wagmi/core").ConnectResult<import("@wagmi/core").Provider>>;
connectCoinbaseExtension(): Promise<import("@wagmi/core").ConnectResult<import("@wagmi/core").Provider>>;
connectMetaMask(): Promise<import("@wagmi/core").ConnectResult<import("@wagmi/core").Provider>>;
connectInjected(): Promise<import("@wagmi/core").ConnectResult<import("@wagmi/core").Provider>>;
switchChain(chainId: string): Promise<string>;
signTypedData({ value, domain, types }: import("@web3modal/ethereum").SignTypedDataOpts): Promise<string>;
signMessage(message: string): Promise<string>;
fetchBalance(opts: import("@web3modal/ethereum").GetBalanceOpts): Promise<string>;
fetchSigner(): Promise<import("@wagmi/core").FetchSignerResult<import("ethers").Signer>>;
getNetwork(): import("@wagmi/core").GetNetworkResult;
getContract({ addressOrName, contractInterface, signerOrProvider }: import("@web3modal/ethereum").GetContractOpts): import("ethers").Contract;
getToken({ address, chainId, formatUnits }: import("@web3modal/ethereum").GetTokenOpts): Promise<import("@wagmi/core").FetchTokenResult>;
readContract(opts: import("@web3modal/ethereum").ContractOpts): Promise<import("@ethersproject/abi").Result>;
writeContract(opts: import("@web3modal/ethereum").WriteContractOpts): Promise<import("@wagmi/core").SendTransactionResult>;
prepareWriteContract(opts: import("@web3modal/ethereum").PrepareWriteContractOpts): Promise<import("@wagmi/core").PrepareWriteContractResult<import("ethers").Signer>>;
watchReadContract(opts: import("@web3modal/ethereum").WatchReadContractOpts): void;
fetchEnsAddress(opts: import("@web3modal/ethereum").FetchEnsAddressOpts): Promise<string | undefined>;
fetchEnsAvatar(opts: import("@web3modal/ethereum").FetchEnsAvatarOpts): Promise<string | undefined>;
fetchEnsName(opts: import("@web3modal/ethereum").FetchEnsNameOpts): Promise<string | undefined>;
fetchEnsResolver(opts: import("@web3modal/ethereum").FetchEnsAddressOpts): Promise<import("@wagmi/core").FetchEnsResolverResult>;
fetchTransaction(opts: import("@web3modal/ethereum").FetchTransactionOpts): Promise<import("@ethersproject/abstract-provider").TransactionResponse>;
prepareSendTransaction(opts: import("@web3modal/ethereum").PrepareSendTransactionOpts): Promise<import("@wagmi/core").PrepareSendTransactionResult>;
sendTransaction(opts: import("@web3modal/ethereum").PrepareSendTransactionOpts): Promise<import("@wagmi/core").SendTransactionResult>;
waitForTransaction(opts: import("@web3modal/ethereum").WaitForTransactionOpts): Promise<import("@ethersproject/abstract-provider").TransactionReceipt>;
};
setEthereumClient(ethereumClient: EthereumClient): Promise<void>;
setEthereumClient(ethereumClient: ClientCtrlState['ethereumClient']): void;
client(): import("@web3modal/ethereum").EthereumClient;
};

@@ -1,9 +0,7 @@

import type { ConfigOptions } from '../../types/configTypes';
export interface State extends ConfigOptions {
configured: boolean;
}
import type { ConfigCtrlState } from '../types/controllerTypes';
export declare const ConfigCtrl: {
state: State;
subscribe(callback: (newState: State) => void): () => void;
setConfig(config: ConfigOptions): void;
state: ConfigCtrlState;
subscribe(callback: (newState: ConfigCtrlState) => void): () => void;
setConfig(config: ConfigCtrlState): void;
setThemeConfig(theme: Pick<ConfigCtrlState, 'themeBackground' | 'themeColor' | 'themeMode'>): void;
};

@@ -1,16 +0,12 @@

import type { Listing, ListingResponse, PageParams } from '../../types/explorerTypes';
export interface State {
search: string;
page: number;
wallets: ListingResponse;
previewWallets: Listing[];
}
import type { ExplorerCtrlState, PageParams } from '../types/controllerTypes';
export declare const ExplorerCtrl: {
state: State;
subscribe(callback: (newState: State) => void): () => void;
getPreviewWallets(): Promise<Listing[]>;
state: ExplorerCtrlState;
getPreviewWallets(params: PageParams): Promise<import("../types/controllerTypes").Listing[]>;
getRecomendedWallets(): Promise<void>;
getPaginatedWallets(params: PageParams): Promise<{
listings: Listing[];
listings: import("../types/controllerTypes").Listing[];
total: number;
}>;
getImageUrl(imageId: string): string;
resetSearch(): void;
};

@@ -1,12 +0,8 @@

import type { RouterView } from '../../types/routerTypes';
export interface State {
history: RouterView[];
view: RouterView;
}
import type { RouterCtrlState } from '../types/controllerTypes';
export declare const RouterCtrl: {
state: State;
subscribe(callback: (newState: State) => void): () => void;
push(view: State['view']): void;
replace(view: State['view']): void;
state: RouterCtrlState;
subscribe(callback: (newState: RouterCtrlState) => void): () => void;
push(view: RouterCtrlState['view'], data?: RouterCtrlState['data']): void;
replace(view: RouterCtrlState['view']): void;
goBack(): void;
};

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

import{Buffer as C}from"buffer";import{proxy as a,subscribe as l}from"valtio/vanilla";const g={connected:!1,chainSupported:!1,address:"",chainId:"",connector:""},i=a(g),O={state:i,subscribe(e){return l(i,()=>e(i))},setAccount(e){Object.assign(i,e),i.connected=!0},setAddress(e){i.address=e},setChain(e,t){i.chainId=e,i.chainSupported=t},resetAccount(){Object.assign(i,g)}},w=a({ethereum:void 0}),$={ethereum(){if(!w.ethereum)throw new Error("Ethereum client was not provided");return w.ethereum},async setEthereumClient(e){const{Web3ModalEthereum:t}=await import("@web3modal/ethereum");w.ethereum=t.createClient(e)}};function b(){return typeof matchMedia<"u"&&matchMedia("(prefers-color-scheme: dark)").matches}const u=a({configured:!1,projectId:"",theme:b()?"dark":"light",accentColor:"default"}),E={state:u,subscribe(e){return l(u,()=>e(u))},setConfig(e){if(!e.projectId)throw new Error("Web3Modal requires projectId that can be obtained at cloud.walletconnect.com");Object.assign(u,e),u.configured=!0}},p=a({open:!1}),A={state:p,subscribe(e){return l(p,()=>e(p))},openModal(){p.open=!0},closeModal(){p.open=!1}};function v(){return{url:"https://explorer-api.walletconnect.com",projectId:E.state.projectId}}function y(e){const t=Object.fromEntries(Object.entries(e).map(([s,n])=>[s,n.toString()]));return new URLSearchParams(t).toString()}function W(e){const{url:t,projectId:s}=v();return`${t}/v3/wallets?projectId=${s}&${y(e)}`}async function f(e){return(await fetch(W(e))).json()}const r=a({search:"",page:1,wallets:{listings:[],total:0},previewWallets:[]}),L={state:r,subscribe(e){return l(r,()=>e(r))},async getPreviewWallets(){const{listings:e}=await f({page:1,entries:10,version:1});return r.previewWallets=Object.values(e),r.previewWallets},async getPaginatedWallets(e){const{listings:t,total:s}=await f(e),n=Object.values(t);r.wallets={listings:[...r.wallets.listings,...n],total:s};const{page:d,search:h}=e;return typeof d<"u"&&r.page!==d&&(r.page=d),typeof h<"u"&&r.search!==h&&(r.search=h),{listings:n,total:s}}},c=a({open:!1,message:""}),M={state:c,subscribe(e){return l(c,()=>e(c))},openToast(e){c.open=!0,c.message=e},closeToast(){c.open=!1}},o=a({history:["ConnectWallet"],view:"ConnectWallet"}),S={state:o,subscribe(e){return l(o,()=>e(o))},push(e){o.view=e,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}}},m="WALLETCONNECT_DEEPLINK_CHOICE",P={isCoinbaseExtension(){return window.coinbaseWalletExtension},isMobile(){return Boolean(window.matchMedia("(pointer:coarse)").matches||/Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent))},formatNativeUrl(e,t,s){const n=e.replaceAll("/","").replaceAll(":","");return this.setWalletConnectDeepLink(n,s),`${n}://wc?uri=${t}`},formatUniversalUrl(e,t,s){let n=e;return e.endsWith("/")&&(n=e.slice(0,-1)),this.setWalletConnectDeepLink(n,s),`${n}/wc?uri=${t}`},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(m,JSON.stringify({href:e,name:t}))},removeWalletConnectDeepLink(){localStorage.removeItem(m)}};typeof window<"u"&&!window.Buffer&&(window.Buffer=C);export{O as AccountCtrl,$ as ClientCtrl,E as ConfigCtrl,A as ConnectModalCtrl,P as CoreHelpers,L as ExplorerCtrl,M as ModalToastCtrl,S as RouterCtrl,v as getExplorerApi,g as initialAccountlState};
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};
//# sourceMappingURL=index.js.map
{
"name": "@web3modal/core",
"version": "2.0.0-6ce38ab",
"version": "2.0.0-787e037",
"main": "dist/index.js",
"unpkg": "dist/index.umd.js",
"type": "module",

@@ -15,3 +14,3 @@ "types": "dist/_types/index.d.ts",

"build:source": "rollup --silent --config rollup.config.js",
"build": "npm run build:clean; npm run build:types; npm run build:source",
"build": "npm run build:clean; npm run build:types & npm run build:source",
"dev": "rollup --config rollup.config.js --watch",

@@ -22,15 +21,7 @@ "typecheck": "tsc --noEmit"

"buffer": "6.0.3",
"valtio": "1.7.0"
"valtio": "1.7.6"
},
"devDependencies": {
"@web3modal/ethereum": "2.0.0-6ce38ab"
"@web3modal/ethereum": "2.0.0-787e037"
},
"peerDependencies": {
"@web3modal/ethereum": "*"
},
"peerDependenciesMeta": {
"@web3modal/ethereum": {
"optional": true
}
},
"keywords": [

@@ -45,3 +36,3 @@ "web3",

"author": "WalletConnect <walletconnect.com>",
"license": "MIT",
"license": "Apache-2.0",
"homepage": "https://github.com/web3modal/web3modal",

@@ -48,0 +39,0 @@ "repository": {

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