@web3modal/core
Advanced tools
Comparing version 2.0.0-c2564bd to 2.0.0-d873f5c
@@ -8,5 +8,4 @@ export { ClientCtrl } from './src/controllers/ClientCtrl'; | ||
export { ToastCtrl } from './src/controllers/ToastCtrl'; | ||
export type { ConfigOptions, Listing, ListingResponse, RouterView } from './src/types/controllerTypes'; | ||
export type { ConfigCtrlState, DesktopConnectorData, Listing, ListingResponse, RouterView } from './src/types/controllerTypes'; | ||
export { CoreHelpers } from './src/utils/CoreHelpers'; | ||
export { getExplorerApi } from './src/utils/ExplorerApi'; | ||
import './src/utils/PolyfillUtil'; |
@@ -1,6 +0,7 @@ | ||
import type { ConfigCtrlState, ConfigOptions } from '../types/controllerTypes'; | ||
import type { ConfigCtrlState } from '../types/controllerTypes'; | ||
export declare const ConfigCtrl: { | ||
state: ConfigCtrlState; | ||
subscribe(callback: (newState: ConfigCtrlState) => void): () => boolean; | ||
setConfig(config: ConfigOptions): void; | ||
subscribe(callback: (newState: ConfigCtrlState) => void): () => void; | ||
setConfig(config: ConfigCtrlState): void; | ||
setThemeConfig(theme: Pick<ConfigCtrlState, 'themeBackground' | 'themeColor' | 'themeMode'>): void; | ||
}; |
import type { ExplorerCtrlState, PageParams } from '../types/controllerTypes'; | ||
export declare const ExplorerCtrl: { | ||
state: ExplorerCtrlState; | ||
subscribe(callback: (newState: ExplorerCtrlState) => void): () => boolean; | ||
getPreviewWallets(params: PageParams): Promise<import("../types/controllerTypes").Listing[]>; | ||
@@ -11,3 +10,4 @@ getRecomendedWallets(): Promise<void>; | ||
}>; | ||
getImageUrl(imageId: string): string; | ||
resetSearch(): void; | ||
}; |
import type { ModalCtrlState } from '../types/controllerTypes'; | ||
export declare const ModalCtrl: { | ||
state: ModalCtrlState; | ||
subscribe(callback: (newState: ModalCtrlState) => void): () => boolean; | ||
subscribe(callback: (newState: ModalCtrlState) => void): () => void; | ||
open(options?: { | ||
@@ -6,0 +6,0 @@ uri: string; |
@@ -8,2 +8,6 @@ import type { OptionsCtrlState } from '../types/controllerTypes'; | ||
setSelectedChainId(selectedChainId: OptionsCtrlState['selectedChainId']): void; | ||
setIsStandalone(isStandalone: OptionsCtrlState['isStandalone']): void; | ||
setIsCustomDesktop(isCustomDesktop: OptionsCtrlState['isCustomDesktop']): void; | ||
setIsCustomMobile(isCustomMobile: OptionsCtrlState['isCustomMobile']): void; | ||
setIsExplorer(isExplorer: OptionsCtrlState['isExplorer']): void; | ||
}; |
import type { RouterCtrlState } from '../types/controllerTypes'; | ||
export declare const RouterCtrl: { | ||
state: RouterCtrlState; | ||
subscribe(callback: (newState: RouterCtrlState) => void): () => boolean; | ||
subscribe(callback: (newState: RouterCtrlState) => void): () => void; | ||
push(view: RouterCtrlState['view'], data?: RouterCtrlState['data']): void; | ||
@@ -6,0 +6,0 @@ replace(view: RouterCtrlState['view']): void; |
import type { ToastCtrlState } from '../types/controllerTypes'; | ||
export declare const ToastCtrl: { | ||
state: ToastCtrlState; | ||
subscribe(callback: (newState: ToastCtrlState) => void): () => boolean; | ||
subscribe(callback: (newState: ToastCtrlState) => void): () => void; | ||
openToast(message: ToastCtrlState['message'], variant: ToastCtrlState['variant']): void; | ||
closeToast(): void; | ||
}; |
import type { EthereumClient } from '@web3modal/ethereum'; | ||
export interface ConfigOptions { | ||
projectId: string; | ||
theme?: 'dark' | 'light'; | ||
accentColor?: 'blackWhite' | 'blue' | 'default' | 'green' | 'magenta' | 'orange' | 'purple' | 'teal'; | ||
export interface MobileWallet { | ||
id: string; | ||
name: string; | ||
links: { | ||
universal: string; | ||
native?: string; | ||
}; | ||
} | ||
export interface DesktopWallet { | ||
id: string; | ||
name: string; | ||
links: { | ||
native: string; | ||
universal: string; | ||
}; | ||
} | ||
export interface ConfigCtrlState { | ||
projectId?: string; | ||
themeMode?: 'dark' | 'light'; | ||
themeColor?: 'blackWhite' | 'blue' | 'default' | 'green' | 'magenta' | 'orange' | 'purple' | 'teal'; | ||
themeBackground?: 'gradient' | 'themeColor'; | ||
standaloneChains?: string[]; | ||
mobileWallets?: MobileWallet[]; | ||
desktopWallets?: DesktopWallet[]; | ||
walletImages?: Record<string, string>; | ||
chainImages?: Record<string, string>; | ||
enableNetworkView?: boolean; | ||
enableStandaloneMode?: boolean; | ||
} | ||
export interface ConfigCtrlState extends ConfigOptions { | ||
configured: boolean; | ||
} | ||
export interface ModalCtrlState { | ||
@@ -19,2 +39,6 @@ open: boolean; | ||
standaloneUri?: string; | ||
isStandalone: boolean; | ||
isCustomDesktop: boolean; | ||
isCustomMobile: boolean; | ||
isExplorer: boolean; | ||
} | ||
@@ -85,3 +109,10 @@ export interface ExplorerCtrlState { | ||
} | ||
export declare type RouterView = 'CoinbaseExtensionConnector' | 'CoinbaseMobileConnector' | 'ConnectWallet' | 'DesktopConnector' | 'GetWallet' | 'Help' | 'InjectedConnector' | 'MetaMaskConnector' | 'Qrcode' | 'SelectNetwork' | 'WalletExplorer'; | ||
export type RouterView = 'CoinbaseExtensionConnector' | 'CoinbaseMobileConnector' | 'ConnectWallet' | 'DesktopConnector' | 'GetWallet' | 'Help' | 'InjectedConnector' | 'MetaMaskConnector' | 'Qrcode' | 'SelectNetwork' | 'WalletExplorer' | 'WalletFilter'; | ||
export interface DesktopConnectorData { | ||
name: string; | ||
native?: string; | ||
universal?: string; | ||
icon?: string; | ||
walletId?: string; | ||
} | ||
export interface RouterCtrlState { | ||
@@ -91,8 +122,3 @@ history: RouterView[]; | ||
data?: { | ||
DesktopConnector: { | ||
name: string; | ||
deeplink?: string; | ||
universal?: string; | ||
icon?: string; | ||
}; | ||
DesktopConnector: DesktopConnectorData; | ||
}; | ||
@@ -99,0 +125,0 @@ } |
import type { ListingResponse, PageParams } from '../types/controllerTypes'; | ||
export declare function getExplorerApi(): { | ||
url: string; | ||
projectId: string; | ||
}; | ||
export declare function fetchWallets(params: PageParams): Promise<ListingResponse>; | ||
export declare const EXPLORER_API = "https://explorer-api.walletconnect.com"; | ||
export declare function formatParams(params: PageParams): string; | ||
export declare function fetchWallets(projectId: string, params: PageParams): Promise<ListingResponse>; | ||
export declare function formatImageUrl(projectId: string, imageId: string): string; |
@@ -1,2 +0,2 @@ | ||
import{proxy as i,subscribe as w}from"valtio/vanilla";import{Buffer as v}from"buffer";const c=i({selectedChainId:void 0,chains:void 0,standaloneChains:void 0,standaloneUri:void 0}),h={state:c,setChains(e){c.chains=e},setStandaloneChains(e){c.standaloneChains=e},setStandaloneUri(e){c.standaloneUri=e},setSelectedChainId(e){c.selectedChainId=e}},d=i({initialized:!1,ethereumClient:void 0}),S={setEthereumClient(e){!d.initialized&&e&&(d.ethereumClient=e,h.setChains(e.chains),d.initialized=!0)},client(){if(d.ethereumClient)return d.ethereumClient;throw new Error("ClientCtrl has no client set")}};function y(){return typeof matchMedia<"u"&&matchMedia("(prefers-color-scheme: dark)").matches}const p=i({configured:!1,projectId:"",theme:y()?"dark":"light",accentColor:"default",standaloneChains:void 0}),O={state:p,subscribe(e){return w(p,()=>e(p))},setConfig(e){var t;if(!e.projectId)throw new Error("Web3Modal requires projectId that can be obtained at cloud.walletconnect.com");(t=e.standaloneChains)!=null&&t.length&&h.setStandaloneChains(e.standaloneChains),Object.assign(p,e),p.configured=!0}};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()}function j(){return{url:"https://explorer-api.walletconnect.com",projectId:O.state.projectId}}async function C(e){const{url:t,projectId:o}=j(),n=`${t}/v3/wallets?projectId=${o}&${W(e)}`;return(await fetch(n)).json()}const a=i({wallets:{listings:[],total:0,page:1},search:{listings:[],total:0,page:1},previewWallets:[],recomendedWallets:[]}),P={state:a,subscribe(e){return w(a,()=>e(a))},async getPreviewWallets(e){const{listings:t}=await C(e);return a.previewWallets=Object.values(t),a.previewWallets},async getRecomendedWallets(){const{listings:e}=await C({page:1,entries:6});a.recomendedWallets=Object.values(e)},async getPaginatedWallets(e){const{page:t,search:o}=e,{listings:n,total:l}=await C(e),g=Object.values(n),f=o?"search":"wallets";return a[f]={listings:[...a[f].listings,...g],total:l,page:t??1},{listings:g,total:l}},resetSearch(){a.search={listings:[],total:0,page:1}}},s=i({history:["ConnectWallet"],view:"ConnectWallet",data:void 0}),m={state:s,subscribe(e){return w(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}}},u=i({open:!1}),L={state:u,subscribe(e){return w(u,()=>e(u))},open(e){var t;const{chains:o}=h.state;o!=null&&o.length&&o.length>1?m.replace("SelectNetwork"):m.replace("ConnectWallet"),typeof e?.uri=="string"&&h.setStandaloneUri(e.uri),(t=e?.standaloneChains)!=null&&t.length&&h.setStandaloneChains(e.standaloneChains),u.open=!0},close(){u.open=!1}},r=i({open:!1,message:"",variant:"success"}),N={state:r,subscribe(e){return w(r,()=>e(r))},openToast(e,t){r.open=!0,r.message=e,r.variant=t},closeToast(){r.open=!1}},b="WALLETCONNECT_DEEPLINK_CHOICE",$={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 l=encodeURIComponent(t);return`${n}://wc?uri=${l}`},formatUniversalUrl(e,t,o){let n=e;e.endsWith("/")&&(n=e.slice(0,-1)),this.setWalletConnectDeepLink(n,o);const l=encodeURIComponent(t);return`${n}/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(b,JSON.stringify({href:e,name:t}))},removeWalletConnectDeepLink(){localStorage.removeItem(b)},isNull(e){return e===null}};typeof window<"u"&&(window.Buffer||(window.Buffer=v),window.global||(window.global=window),window.process||(window.process={env:{}}));export{S as ClientCtrl,O as ConfigCtrl,$ as CoreHelpers,P as ExplorerCtrl,L as ModalCtrl,h as OptionsCtrl,m as RouterCtrl,N as ToastCtrl,j as getExplorerApi}; | ||
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}; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@web3modal/core", | ||
"version": "2.0.0-c2564bd", | ||
"version": "2.0.0-d873f5c", | ||
"main": "dist/index.js", | ||
@@ -20,6 +20,6 @@ "type": "module", | ||
"buffer": "6.0.3", | ||
"valtio": "1.7.5" | ||
"valtio": "1.7.6" | ||
}, | ||
"devDependencies": { | ||
"@web3modal/ethereum": "2.0.0-c2564bd" | ||
"@web3modal/ethereum": "2.0.0-d873f5c" | ||
}, | ||
@@ -26,0 +26,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
33656
17
237
0
21
1
+ Addedvaltio@1.7.6(transitive)
- Removedvaltio@1.7.5(transitive)
Updatedvaltio@1.7.6