Skip to main content

Class: EthersModalConnector

EthersAppContext.EthersModalConnector

Summary​

This is a connector for web3-react that allows it to interface with web3Modal. The provider selected by user via web3modal is interfaced to the web3-react context.

✨ Features​
  • This connector used with useEthersContext allows the app and all the hooks to effortlessly access the current network, provider, signer, address information IEthersContext
  • The connector centralizes and takes care of management of the web3 interaction and provides a consistent exprience for your app.
✏️ Notes​
  • inherits from web3-react class AbstractConnector

Hierarchy​

  • AbstractConnector

    ↳ EthersModalConnector

Implements​

Properties​

_options​

• Protected _options: Partial<ICoreOptions>

Defined in​

src/context/ethers-app/connectors/EthersModalConnector.ts:72


_providerBase​

• Protected Optional _providerBase: any

Defined in​

src/context/ethers-app/connectors/EthersModalConnector.ts:73


_ethersProvider​

• Protected Optional _ethersProvider: TEthersProvider

Defined in​

src/context/ethers-app/connectors/EthersModalConnector.ts:74


_web3Modal​

• Protected Optional _web3Modal: Core

Defined in​

src/context/ethers-app/connectors/EthersModalConnector.ts:75


_id​

• Protected _id: undefined | string

Defined in​

src/context/ethers-app/connectors/EthersModalConnector.ts:76


_debug​

• Protected _debug: boolean = false

Defined in​

src/context/ethers-app/connectors/EthersModalConnector.ts:77


_config​

• Protected _config: Readonly<TEthersModalConfig>

Defined in​

src/context/ethers-app/connectors/EthersModalConnector.ts:78


_signer​

• Protected _signer: undefined | Signer

Defined in​

src/context/ethers-app/connectors/EthersModalConnector.ts:79


_theme​

• Protected _theme: TWeb3ModalTheme | ThemeColors

Defined in​

src/context/ethers-app/connectors/EthersModalConnector.ts:80


isModalOpening​

▪ Static isModalOpening: boolean = false

Defined in​

src/context/ethers-app/connectors/EthersModalConnector.ts:81

Accessors​

config​

• get config(): Readonly<TEthersModalConfig>

Returns​

Readonly<TEthersModalConfig>

Defined in​

src/context/ethers-app/connectors/EthersModalConnector.ts:83

Methods​

hasCachedProvider​

▸ hasCachedProvider(): boolean

Returns​

boolean

Implementation of​

ICommonModalConnector.hasCachedProvider

Defined in​

src/context/ethers-app/connectors/EthersModalConnector.ts:87


log​

▸ Protected log(...args): void

Parameters​

NameType
...argsany[]

Returns​

void

Defined in​

src/context/ethers-app/connectors/EthersModalConnector.ts:117


loadWeb3Modal​

▸ loadWeb3Modal(): void

Returns​

void

Implementation of​

ICommonModalConnector.loadWeb3Modal

Defined in​

src/context/ethers-app/connectors/EthersModalConnector.ts:167


activate​

▸ activate(): Promise<ConnectorUpdate<string | number>>

Summary​

Inherits from AbstractConnector. This activates web3Modal and opens the modal.

✏️ Notes​

Once the user selects a provider

  • this will activate the provider and attach the appropriate event listeners.
  • get the account and signer
  • gets the ethers compatable provider
⚠️ Errors​

Returns​

Promise<ConnectorUpdate<string | number>>

Overrides​

AbstractConnector.activate

Defined in​

src/context/ethers-app/connectors/EthersModalConnector.ts:189


deactivate​

▸ deactivate(): void

Summary​

Safely deactivates the current provider and removes all event listeners

Returns​

void

Overrides​

AbstractConnector.deactivate

Defined in​

src/context/ethers-app/connectors/EthersModalConnector.ts:262


getProvider​

▸ getProvider(): Promise<undefined | TEthersProvider>

Returns​

Promise<undefined | TEthersProvider>

Overrides​

AbstractConnector.getProvider

Defined in​

src/context/ethers-app/connectors/EthersModalConnector.ts:282


getChainId​

▸ getChainId(): Promise<string | number>

Returns​

Promise<string | number>

Overrides​

AbstractConnector.getChainId

Defined in​

src/context/ethers-app/connectors/EthersModalConnector.ts:286


getAccount​

▸ getAccount(): Promise<null | string>

Returns​

Promise<null | string>

Overrides​

AbstractConnector.getAccount

Defined in​

src/context/ethers-app/connectors/EthersModalConnector.ts:296


getSigner​

▸ getSigner(): undefined | Signer

Returns​

undefined | Signer

Implementation of​

ICommonModalConnector.getSigner

Defined in​

src/context/ethers-app/connectors/EthersModalConnector.ts:308


getSignerFromAccount​

▸ getSignerFromAccount(): Promise<void>

Returns​

Promise<void>

Defined in​

src/context/ethers-app/connectors/EthersModalConnector.ts:312


changeSigner​

▸ changeSigner(signer): Promise<void>

Summary​

Change the current signer and account used by the connector

Parameters​

NameType
signerSigner

Returns​

Promise<void>

Implementation of​

ICommonModalConnector.changeSigner

Defined in​

src/context/ethers-app/connectors/EthersModalConnector.ts:323


validState​

▸ Protected validState(): boolean

Returns​

boolean

Defined in​

src/context/ethers-app/connectors/EthersModalConnector.ts:334


resetModal​

▸ resetModal(): void

Summary​

Resets the web3Modal and clears the cache

Returns​

void

Implementation of​

ICommonModalConnector.resetModal

Defined in​

src/context/ethers-app/connectors/EthersModalConnector.ts:342


setModalTheme​

▸ setModalTheme(theme): void

Summary​

Sets the web3modal theme: light | dark | ThemeColors

Parameters​

NameType
themeTWeb3ModalTheme | ThemeColors

Returns​

void

Implementation of​

ICommonModalConnector.setModalTheme

Defined in​

src/context/ethers-app/connectors/EthersModalConnector.ts:357


checkValidCachedProvider​

▸ checkValidCachedProvider(): boolean

Returns​

boolean

Defined in​

src/context/ethers-app/connectors/EthersModalConnector.ts:361

Constructors​

constructor​

• new EthersModalConnector(web3modalOptions, config?, id?, debug?)

Parameters​

NameTypeDefault valueDescription
web3modalOptionsPartial<ICoreOptions>undefinedsee web3modal docs for details. You can also check the scaffold-eth-typescript web3config for an example.
configTEthersModalConfigundefinedConfiguration for EthersModalConnector
id?stringundefinedallows you to connect directly to a specific provider. See docs
debugbooleanfalseturn on debug logging

Overrides​

AbstractConnector.constructor

Defined in​

src/context/ethers-app/connectors/EthersModalConnector.ts:97