fix type errors

This commit is contained in:
hueso
2025-06-22 01:17:10 -03:00
parent 73ba77ca4f
commit 9d9ed7a3dd
7 changed files with 86 additions and 36 deletions

View File

@@ -11,12 +11,10 @@ import {
} from "viem";
import { sepolia, rootstock } from "viem/chains";
import { useUser } from "@/composables/useUser";
let publicClient: PublicClient | null = null;
let walletClient: WalletClient | null = null;
const getPublicClient: PublicClient | null = (onlyRpcProvider = false) => {
if (onlyRpcProvider) {
const getPublicClient = (): PublicClient => {
const user = useUser();
const rpcUrl = getProviderUrl();
return createPublicClient({
@@ -24,21 +22,22 @@ const getPublicClient: PublicClient | null = (onlyRpcProvider = false) => {
Number(user.networkName.value) === sepolia.id ? sepolia : rootstock,
transport: http(rpcUrl),
});
}
return publicClient;
};
const getWalletClient: WalletClient | null = () => {
const getWalletClient = (): WalletClient | null => {
return walletClient;
};
const getContract = async (onlyRpcProvider = false) => {
const client = getPublicClient(onlyRpcProvider);
const client = getPublicClient();
if (!client) {
throw new Error("Public client is not initialized");
}
const address = getP2PixAddress();
const abi = p2pix.abi;
const wallet = getWalletClient();
const [account] = wallet ? await wallet.getAddresses() : [""];
const [account] = wallet ? await wallet.getAddresses() : [null];
return { address, abi, client, wallet, account };
};