From 8c35b5dd292cc9f335612dc4e961e29f676e1737 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20Mi=C3=B1o?= Date: Mon, 23 Sep 2024 15:20:54 -0300 Subject: [PATCH] hardhat providrr --- src/core/wagmi/clientToProvider.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/core/wagmi/clientToProvider.ts b/src/core/wagmi/clientToProvider.ts index ed75cb4a0f..3f0cac30da 100644 --- a/src/core/wagmi/clientToProvider.ts +++ b/src/core/wagmi/clientToProvider.ts @@ -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) { @@ -23,7 +26,10 @@ export function clientToProvider(client: Client) { /** 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 >;