Skip to content

Commit

Permalink
fix: export window instead of global declare
Browse files Browse the repository at this point in the history
  • Loading branch information
ugur-eren committed Nov 6, 2023
1 parent 67d8efc commit 552eece
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
5 changes: 3 additions & 2 deletions src/providers/EthooksProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {EthersContext, RootContextProvider, BlockNumberProvider} from '../contex
import {useAccountChange} from '../hooks';
import {useMount} from '../hooks/internal';
import useConnect from '../hooks/useConnect';
import {Chain, EthersProvider} from '../types';
import {Chain, EthersProvider, Window} from '../types';

export interface EthooksProviderProps
extends Partial<React.ComponentPropsWithoutRef<typeof RootContextProvider>> {
Expand Down Expand Up @@ -65,7 +65,8 @@ export const EthooksProvider: React.FC<EthooksProviderProps> = ({
}

const defaultProvider = useMemo(() => {
if ('ethereum' in window) return new providers.Web3Provider(window.ethereum, 'any');
if ('ethereum' in window) return new providers.Web3Provider((window as Window).ethereum, 'any');

return null;
}, []);

Expand Down
7 changes: 3 additions & 4 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import type {BigNumberish, providers} from 'ethers';

declare global {
interface Window {
export type Window = globalThis.Window &
typeof globalThis & {
ethereum: import('ethers').providers.ExternalProvider;
}
}
};

export type LooseAutoComplete<T extends string> = T | Omit<string, T>;

Expand Down

0 comments on commit 552eece

Please sign in to comment.