Skip to content

Commit ef40135

Browse files
Merge branch 'main' into investe-truefi
2 parents b486532 + ffe505c commit ef40135

File tree

8 files changed

+173
-214
lines changed

8 files changed

+173
-214
lines changed

packages/web/src/app/profile/_components/overview-item.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ export const OverviewItem = ({
2323
{title}
2424
</h5>
2525
{isLoading ? (
26-
<Skeleton className="h-[20px] lg:h-[24px] w-[80px] lg:w-[100px]" />
26+
<Skeleton className="h-[20px] lg:h-[24px] w-[80px] lg:w-[100px] bg-foreground/10" />
2727
) : (
28-
<p className="text-[16px] lg:text-[18px] font-semibold leading-[100%] text-foreground break-words">
28+
<div className="text-[16px] lg:text-[18px] font-semibold leading-[100%] text-foreground break-words">
2929
{value || ""}
30-
</p>
30+
</div>
3131
)}
3232
</Link>
3333
) : (
@@ -36,11 +36,11 @@ export const OverviewItem = ({
3636
{title}
3737
</h5>
3838
{isLoading ? (
39-
<Skeleton className="h-[20px] lg:h-[24px] w-[80px] lg:w-[100px]" />
39+
<Skeleton className="h-[20px] lg:h-[24px] w-[80px] lg:w-[100px] bg-foreground/10" />
4040
) : (
41-
<p className="text-[16px] lg:text-[18px] font-semibold leading-[100%] text-foreground break-words">
41+
<div className="text-[16px] lg:text-[18px] font-semibold leading-[100%] text-foreground break-words">
4242
{value || ""}
43-
</p>
43+
</div>
4444
)}
4545
</div>
4646
);

packages/web/src/app/profile/_components/overview.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ export const Overview = ({
2525
isDelegateMappingsLoading,
2626
}: OverviewProps) => {
2727
const { formattedVotes, votes, isLoading } = useAddressVotes(address);
28-
const daoConfig = useDaoConfig();
2928

29+
const daoConfig = useDaoConfig();
3030
const { data: dataMetrics, isLoading: isMetricsLoading } = useQuery({
3131
queryKey: ["dataMetrics", daoConfig?.indexer?.endpoint],
3232
queryFn: () =>

packages/web/src/components/delegation-table/index.tsx

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import { useMemo } from "react";
2-
import { useReadContract } from "wagmi";
32

4-
import { abi as tokenAbi } from "@/config/abi/token";
5-
import { useDaoConfig } from "@/hooks/useDaoConfig";
63
import { useFormatGovernanceTokenAmount } from "@/hooks/useFormatGovernanceTokenAmount";
4+
import { useCurrentVotingPower } from "@/hooks/useSmartGetVotes";
75
import type { DelegateItem } from "@/services/graphql/types";
86

97
import { AddressWithAvatar } from "../address-with-avatar";
@@ -21,22 +19,8 @@ interface DelegationTableProps {
2119
export function DelegationTable({ address }: DelegationTableProps) {
2220
const formatTokenAmount = useFormatGovernanceTokenAmount();
2321
const { state, loadMoreData } = useDelegationData(address);
24-
const daoConfig = useDaoConfig();
25-
const tokenAddress = daoConfig?.contracts?.governorToken?.address as Address;
2622

27-
const { data: totalVotes } = useReadContract({
28-
address: tokenAddress,
29-
abi: tokenAbi,
30-
functionName: "getVotes",
31-
args: [address],
32-
chainId: daoConfig?.chain?.id,
33-
query: {
34-
enabled:
35-
Boolean(address) &&
36-
Boolean(tokenAddress) &&
37-
Boolean(daoConfig?.chain?.id),
38-
},
39-
});
23+
const { data: totalVotes } = useCurrentVotingPower(address);
4024

4125
const columns = useMemo<ColumnType<DelegateItem>[]>(
4226
() => [

packages/web/src/hooks/useAddressVotes.ts

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,22 @@
11
import { isNil } from "lodash-es";
2-
import { useReadContract } from "wagmi";
32

4-
import { abi as tokenAbi } from "@/config/abi/token";
53
import { formatBigIntForDisplay } from "@/utils/number";
64

7-
import { useDaoConfig } from "./useDaoConfig";
85
import { useGovernanceToken } from "./useGovernanceToken";
6+
import { useCurrentVotingPower } from "./useSmartGetVotes";
97

108
import type { Address } from "viem";
119

1210
export function useAddressVotes(address: Address) {
13-
const daoConfig = useDaoConfig();
14-
const tokenAddress = daoConfig?.contracts?.governorToken?.address as Address;
1511
const { data: tokenData, isLoading: isTokenLoading } = useGovernanceToken();
1612

1713
const {
1814
data: votes,
1915
isLoading: isVotesLoading,
2016
error,
2117
refetch,
22-
} = useReadContract({
23-
address: tokenAddress,
24-
abi: tokenAbi,
25-
functionName: "getVotes",
26-
args: [address!],
27-
chainId: daoConfig?.chain?.id,
28-
query: {
29-
enabled:
30-
Boolean(address) &&
31-
Boolean(tokenAddress) &&
32-
Boolean(daoConfig?.chain?.id),
33-
},
34-
});
18+
} = useCurrentVotingPower(address);
19+
3520
const formattedVotes =
3621
!isNil(votes) && !isNil(tokenData?.decimals)
3722
? formatBigIntForDisplay(votes, tokenData.decimals ?? 18)

packages/web/src/hooks/useMembersVotingPower.ts

Lines changed: 0 additions & 76 deletions
This file was deleted.
Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
import { isNil } from "lodash-es";
2-
import { useAccount, useReadContract } from "wagmi";
2+
import { useAccount } from "wagmi";
33

4-
import { abi as tokenAbi } from "@/config/abi/token";
54
import { formatBigIntForDisplay } from "@/utils/number";
65

7-
import { useDaoConfig } from "./useDaoConfig";
86
import { useGovernanceParams } from "./useGovernanceParams";
97
import { useGovernanceToken } from "./useGovernanceToken";
8+
import { useCurrentVotingPower } from "./useSmartGetVotes";
109

11-
import type { QueryObserverResult } from "@tanstack/react-query";
12-
import type { Address, ReadContractErrorType } from "viem";
10+
import type { Address } from "viem";
1311

1412
interface UseVotesReturn {
1513
votes?: bigint;
@@ -20,37 +18,21 @@ interface UseVotesReturn {
2018
isLoading: boolean;
2119
isFetching: boolean;
2220
error: Error | null;
23-
refetch: () => Promise<QueryObserverResult<bigint, ReadContractErrorType>>;
21+
refetch: () => void;
2422
}
2523

2624
export function useMyVotes(): UseVotesReturn {
2725
const { address } = useAccount();
28-
const daoConfig = useDaoConfig();
2926
const { data: tokenData, isLoading: isTokenLoading } = useGovernanceToken();
3027
const { data: governanceParams, isLoading: isParamsLoading } =
3128
useGovernanceParams();
3229

33-
const tokenAddress = daoConfig?.contracts?.governorToken?.address as Address;
34-
3530
const {
3631
data: votes,
3732
isLoading: isVotesLoading,
38-
isFetching: isFetchingVotes,
3933
error,
4034
refetch,
41-
} = useReadContract({
42-
address: tokenAddress,
43-
abi: tokenAbi,
44-
functionName: "getVotes",
45-
args: [address!],
46-
chainId: daoConfig?.chain?.id,
47-
query: {
48-
enabled:
49-
Boolean(address) &&
50-
Boolean(tokenAddress) &&
51-
Boolean(daoConfig?.chain?.id),
52-
},
53-
});
35+
} = useCurrentVotingPower(address as Address);
5436

5537
const formattedVotes =
5638
!isNil(votes) && !isNil(tokenData?.decimals)
@@ -75,7 +57,7 @@ export function useMyVotes(): UseVotesReturn {
7557
hasEnoughVotes,
7658
refetch,
7759
isLoading: isVotesLoading || isTokenLoading || isParamsLoading,
78-
isFetching: isFetchingVotes,
60+
isFetching: isVotesLoading,
7961
error,
8062
};
8163
}

0 commit comments

Comments
 (0)