Skip to content

Commit

Permalink
fix(frontend): remove config import in api configuration that was cau…
Browse files Browse the repository at this point in the history
…sing build issues (#610)

* fix(frontend): remove config import in api configuration that was causing build issues

* docs(frotend): add changeset
  • Loading branch information
guerrap authored Mar 6, 2024
1 parent dc75d30 commit ca68aea
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .changeset/shiny-bats-fly.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@carrot-kpi/host-frontend": patch
---

Remove wagmi config import in api configuration file that was causing build issues
5 changes: 3 additions & 2 deletions packages/frontend/src/hooks/useBlacklistedTokens.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import { type ChainId } from "@carrot-kpi/sdk";
import type { Address } from "viem";
import { useFeaturedBlacklistedKPITokenAddresses } from "./useFeaturedBlacklistedKPITokenAddresses";
import { useChainId } from "wagmi";
import { useChainId, usePublicClient } from "wagmi";

export const useBlacklistedTokens = (): {
loading: boolean;
blacklistedKPITokens: Address[];
} => {
const chainId = useChainId();
const publicClient = usePublicClient();
const {
isLoading: loadingFeaturedBlacklistedKPITokenAddresses,
data: featuredBlacklistedKPITokenAddresses,
} = useFeaturedBlacklistedKPITokenAddresses();
} = useFeaturedBlacklistedKPITokenAddresses({ publicClient });

return {
blacklistedKPITokens:
Expand Down
4 changes: 3 additions & 1 deletion packages/frontend/src/pages/home/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { usePublicClient } from "wagmi";
import React, { useEffect, useState } from "react";
import { Layout } from "../../components/layout";
import { Hero } from "./hero";
Expand All @@ -21,10 +22,11 @@ interface HomeProps {
}

export const Home = ({ templateId }: HomeProps) => {
const publicClient = usePublicClient();
const {
isLoading: loadingFeaturedBlacklistedKPITokenAddresses,
data: featuredBlacklistedKPITokenAddresses,
} = useFeaturedBlacklistedKPITokenAddresses();
} = useFeaturedBlacklistedKPITokenAddresses({ publicClient });
const { isLoading: loadingFeaturedKPITokens, data: featuredKPITokens } =
useFeaturedKPITokens(featuredBlacklistedKPITokenAddresses);
useFathomTrackPageWatch();
Expand Down
16 changes: 11 additions & 5 deletions packages/frontend/src/state/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ import {
type SupportedChain,
} from "@carrot-kpi/sdk";
import { fetchBaseQuery } from "@reduxjs/toolkit/query/react";
import { getAccount } from "@wagmi/core";
import type { Address, PublicClient, Transport } from "viem";
import { createCarrotApi } from "./hooks";
import { config } from "../standalone-entrypoint";
import { SUPPORTED_CHAINS } from "../constants";

export interface FetchFeaturedKPITokensParams {
publicClient?: PublicClient<Transport, SupportedChain | undefined>;
Expand All @@ -23,10 +22,17 @@ export const staticApi = createCarrotApi({
endpoints: (builder) => ({
fetchFeaturedBlacklistedKPITokenAddresses: builder.query<
FeaturedBlacklistedKPITokens,
void
{
publicClient?: PublicClient<
Transport,
SupportedChain | undefined
>;
}
>({
queryFn: async () => {
const { chain } = await getAccount(config);
queryFn: async ({ publicClient }) => {
const chain = SUPPORTED_CHAINS.find(
(chain) => chain.id === publicClient?.chain?.id,
);
if (!chain)
return {
error: {
Expand Down

0 comments on commit ca68aea

Please sign in to comment.