I keep getting this error but if i run the view method on the cli, the deployed contract returns a value.
export const useContract = () => {
const { contract, accountId } = useWallet();
const getBalance = async () => {
if (!contract || !accountId) {
console.error(contract, accountId);
throw new Error("Contract is not initialized");
}
console.log("Contract ID:", contract.contractId);
console.log("Fetching balance for account:", accountId);
try {
const balance = await contract.view("ft_balance_of", {
account_id: accountId,
});
console.log("Balance fetched:", balance);
return balance;
} catch (error) {
console.error("Failed to fetch balance:", error);
throw new Error("Failed to fetch balance. Please try again later.");
}
};
return {
getBalance,
} as const;
};