Mock implementation of an Ethereum wallet for testing purposes. Simulates wallet behavior in a controlled environment, allowing for consistent and reproducible tests without relying on actual blockchain interactions.

Extends

  • EthereumWalletMockAbstract

Constructors

new EthereumWalletMock()

new EthereumWalletMock(page, wallet?): EthereumWalletMock

Creates an instance of EthereumWalletMock.

Parameters

ParameterTypeDescription
pagePageThe Playwright Page object to interact with.
wallet?WalletMockThe type of wallet to mock.

Returns

EthereumWalletMock

Overrides

EthereumWalletMockAbstract.constructor

Properties

PropertyTypeDescriptionInherited from
pagePageThe Playwright Page object to interact with.-
seedPhraseundefined | string-EthereumWalletMockAbstract.seedPhrase
walletWalletMock-EthereumWalletMockAbstract.wallet

Methods

addNetwork()

addNetwork(network): Promise<void>

Adds a new network.

Parameters

ParameterTypeDescription
networkNetworkThe network object to use for adding the new network.

Returns

Promise<void>

A promise that resolves when the network is added.

Overrides

EthereumWalletMockAbstract.addNetwork


addNewAccount()

addNewAccount(): Promise<void>

Adds a new account based on the initially imported seed phrase.

Returns

Promise<void>

A promise that resolves when the new account is added.

Overrides

EthereumWalletMockAbstract.addNewAccount


connectToDapp()

connectToDapp(wallet?): Promise<void>

Connects wallet to the dapp.

Parameters

ParameterTypeDescription
wallet?WalletMockThe wallet to connect to the dapp.

Returns

Promise<void>

A promise that resolves when the wallet is connected to the dapp.

Overrides

EthereumWalletMockAbstract.connectToDapp


getAccountAddress()

getAccountAddress(): Promise<undefined | `0x${string}`>

Retrieves the current account address.

Returns

Promise<undefined | `0x${string}`>

A promise that resolves to the current account address.

Overrides

EthereumWalletMockAbstract.getAccountAddress


getAllAccounts()

getAllAccounts(): Promise<undefined | `0x${string}`[]>

Retrieves all account addresses.

Returns

Promise<undefined | `0x${string}`[]>

A promise that resolves to an array of account addresses.

Overrides

EthereumWalletMockAbstract.getAllAccounts


importWallet()

importWallet(seedPhrase): Promise<void>

Imports a wallet using the given seed phrase.

Parameters

ParameterTypeDescription
seedPhrasestringThe seed phrase to import.

Returns

Promise<void>

A promise that resolves when the wallet is imported.

Overrides

EthereumWalletMockAbstract.importWallet


importWalletFromPrivateKey()

importWalletFromPrivateKey(privateKey): Promise<void>

Imports a wallet using the given private key.

Parameters

ParameterTypeDescription
privateKey`0x${string}`The private key to import.

Returns

Promise<void>

A promise that resolves when the wallet is imported.

Overrides

EthereumWalletMockAbstract.importWalletFromPrivateKey


switchAccount()

switchAccount(accountAddress): Promise<void>

Switches to the account with the given address.

Parameters

ParameterTypeDescription
accountAddressstringThe address of the account to switch to.

Returns

Promise<void>

A promise that resolves when the account switch is complete.

Overrides

EthereumWalletMockAbstract.switchAccount


switchNetwork()

switchNetwork(networkName): Promise<void>

Switches to the network with the given name.

Parameters

ParameterTypeDescription
networkNamestringThe name of the network to switch to.

Returns

Promise<void>

A promise that resolves when the network switch is complete.

Overrides

EthereumWalletMockAbstract.switchNetwork