Skip to content

Commit

Permalink
fix: #3923
Browse files Browse the repository at this point in the history
  • Loading branch information
tmm committed May 13, 2024
1 parent 7ef0745 commit 6bf5592
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
6 changes: 5 additions & 1 deletion site/core/guides/ethers.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export function getEthersProvider(
{ chainId }: { chainId?: number } = {},
) {
const client = getClient(config, { chainId })
if (!client) return
return clientToProvider(client)
}
```
Expand Down Expand Up @@ -75,6 +76,7 @@ export function getEthersProvider(
{ chainId }: { chainId?: number } = {},
) {
const client = getClient(config, { chainId })
if (!client) return
return clientToProvider(client)
}
```
Expand Down Expand Up @@ -124,6 +126,7 @@ export function getEthersProvider(
{ chainId }: { chainId?: number } = {},
) {
const client = getClient(config, { chainId })
if (!client) return
return clientToProvider(client)
}

Expand Down Expand Up @@ -157,6 +160,7 @@ export function getEthersProvider(
{ chainId }: { chainId?: number } = {},
) {
const client = getClient(config, { chainId })
if (!client) return
return clientToProvider(client)
}
```
Expand Down Expand Up @@ -299,4 +303,4 @@ export async function getEthersSigner(

```

:::
:::
8 changes: 4 additions & 4 deletions site/react/guides/ethers.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export function useEthersProvider({
chainId,
}: { chainId?: number | undefined } = {}) {
const client = useClient<Config>({ chainId })
return useMemo(() => clientToProvider(client), [client])
return useMemo(() => (client ? clientToProvider(client) : undefined), [client])
}
```

Expand Down Expand Up @@ -73,7 +73,7 @@ export function clientToProvider(client: Client<Transport, Chain>) {
/** Action to convert a viem Client to an ethers.js Provider. */
export function useEthersProvider({ chainId }: { chainId?: number } = {}) {
const client = useClient<Config>({ chainId })
return useMemo(() => clientToProvider(client), [client])
return useMemo(() => (client ? clientToProvider(client) : undefined), [client])
}
```

Expand Down Expand Up @@ -121,7 +121,7 @@ export function useEthersProvider({
chainId,
}: { chainId?: number | undefined } = {}) {
const client = useClient<Config>({ chainId })
return useMemo(() => clientToProvider(client), [client])
return useMemo(() => (client ? clientToProvider(client) : undefined), [client])
}
```

Expand Down Expand Up @@ -151,7 +151,7 @@ export function clientToProvider(client: Client<Transport, Chain>) {
/** Action to convert a viem Client to an ethers.js Provider. */
export function useEthersProvider({ chainId }: { chainId?: number } = {}) {
const client = useClient<Config>({ chainId })
return useMemo(() => clientToProvider(client), [client])
return useMemo(() => (client ? clientToProvider(client) : undefined), [client])
}
```

Expand Down

0 comments on commit 6bf5592

Please sign in to comment.