Skip to content

Commit

Permalink
Cleanning comments
Browse files Browse the repository at this point in the history
  • Loading branch information
hide-on-bush-x committed Sep 5, 2023
1 parent 91effec commit 2c9d58f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
12 changes: 6 additions & 6 deletions src/refactor/helpers/ethers.ts
Expand Up @@ -14,16 +14,16 @@ export const useEthersProvider = (): Provider | undefined => {
return provider;
};

export const useEthersSigner = (): {
data: Signer | undefined;
isLoading: boolean;
error: Error | null;
} => {
export const useEthersSigner = () => {
const { data: walletClient, isLoading, error } = useWalletClient();
const signer = useMemo(() => {
if (walletClient) walletClientToSigner(walletClient);
return undefined;
}, [walletClient]);

return { data: signer, isLoading, error };
return { data: signer, isLoading, error } as {
data?: Signer;
isLoading?: boolean;
error?: Error | null;
};
};
6 changes: 3 additions & 3 deletions src/refactor/helpers/wagmi.ts
Expand Up @@ -3,7 +3,7 @@ import { type PublicClient, type WalletClient } from 'wagmi';
import { providers } from 'ethers';
import { type HttpTransport } from 'viem';

export function publicClientToProvider(publicClient: PublicClient) {
export const publicClientToProvider = (publicClient: PublicClient) => {
const { chain, transport } = publicClient;
const network = {
chainId: chain.id,
Expand All @@ -17,9 +17,9 @@ export function publicClientToProvider(publicClient: PublicClient) {
)
);
return new providers.JsonRpcProvider(transport.url as string, network);
}
};

export function walletClientToSigner(walletClient: WalletClient) {
export const walletClientToSigner = (walletClient: WalletClient) => {
const { account, chain, transport } = walletClient;
const network = {
chainId: chain.id,
Expand Down
8 changes: 4 additions & 4 deletions src/refactor/wallet-client/wallet/use-wallet.ts
Expand Up @@ -10,7 +10,7 @@ import {
useAccount,
useBalance,
useDisconnect,
useWalletClient,
useWalletClient as useWalletClientWagmi,
usePublicClient,
PublicClient,
WalletClient,
Expand All @@ -28,8 +28,8 @@ export interface UseWalletReturn {
shortAddress?: `0x${string}`;
publicClient?: PublicClient;
walletClient?: WalletClient;
signer: Signer;
provider: Provider;
signer?: Signer;
provider?: Provider;
connector?: Connector;
isConnected?: boolean;
isConnecting?: boolean;
Expand Down Expand Up @@ -62,7 +62,7 @@ const useWallet = (): UseWalletReturn => {
// * NOTE: internal state to compare addresses
const [compareAddress, setCompareAddress] = useState(address);
const { data: walletClient, isLoading: isLoadingWalletClient } =
useWalletClient();
useWalletClientWagmi();

const { data: signer, isLoading: isLoadingSigner } = useEthersSigner();

Expand Down

0 comments on commit 2c9d58f

Please sign in to comment.