mirror of
https://github.com/lux-tel/websites.git
synced 2026-10-30 20:31:36 +00:00
15 lines
413 B
TypeScript
15 lines
413 B
TypeScript
import { useWallet } from '@session/wallet/hooks/useWallet';
|
|
import { useMemo } from 'react';
|
|
import { http, type Chain, createPublicClient } from 'viem';
|
|
|
|
const initPublicClient = (chain: Chain) =>
|
|
createPublicClient({
|
|
chain,
|
|
transport: http(),
|
|
});
|
|
|
|
export function usePublicWeb3Client() {
|
|
const { chain } = useWallet();
|
|
return useMemo(() => (chain ? initPublicClient(chain) : null), [chain]);
|
|
}
|