fix type errors
This commit is contained in:
@@ -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 };
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user