Skip to content

Commit

Permalink
hardhat providrr
Browse files Browse the repository at this point in the history
  • Loading branch information
estebanmino committed Sep 23, 2024
1 parent c6dd578 commit 8c35b5d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/core/wagmi/clientToProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import { getClient } from '@wagmi/core';
import { providers } from 'ethers';
import type { Chain, Client, Transport } from 'viem';

import { connectedToHardhatStore } from '../state/currentSettings/connectedToHardhat';
import { chainHardhat } from '../types/chains';

import { wagmiConfig } from '.';

export function clientToProvider(client: Client<Transport, Chain>) {
Expand All @@ -23,7 +26,10 @@ export function clientToProvider(client: Client<Transport, Chain>) {

/** Action to convert a viem Public Client to an ethers.js Provider. */
export function getProvider({ chainId }: { chainId?: number } = {}) {
const client = getClient(wagmiConfig, { chainId }) as Client<
const internalChainId = connectedToHardhatStore.getState().connectedToHardhat
? chainHardhat.id
: chainId;
const client = getClient(wagmiConfig, { chainId: internalChainId }) as Client<
Transport,
Chain
>;
Expand Down

0 comments on commit 8c35b5d

Please sign in to comment.