From 6f0726c29e7b05258da2d6396ca50f6fe513d4cf Mon Sep 17 00:00:00 2001 From: Kellar Date: Wed, 11 Dec 2024 14:44:01 +0000 Subject: [PATCH 1/2] Remove `underlyingTokenAddress` and `loadUnderlyingERC20Token` --- .../loaders/governance/useERC20LinearToken.ts | 38 ++----------------- src/hooks/DAO/loaders/useFractalGovernance.ts | 4 +- .../DAO/loaders/useGovernanceContracts.ts | 2 - src/types/fractal.ts | 1 - 4 files changed, 4 insertions(+), 41 deletions(-) diff --git a/src/hooks/DAO/loaders/governance/useERC20LinearToken.ts b/src/hooks/DAO/loaders/governance/useERC20LinearToken.ts index 9a2434234..3ed34423d 100644 --- a/src/hooks/DAO/loaders/governance/useERC20LinearToken.ts +++ b/src/hooks/DAO/loaders/governance/useERC20LinearToken.ts @@ -1,5 +1,5 @@ import { abis } from '@fractal-framework/fractal-contracts'; -import { useCallback, useEffect, useMemo, useRef } from 'react'; +import { useCallback, useEffect, useRef } from 'react'; import { getContract } from 'viem'; import { useAccount, usePublicClient } from 'wagmi'; import { useFractal } from '../../../../providers/App/AppProvider'; @@ -10,25 +10,13 @@ export const useERC20LinearToken = ({ onMount = true }: { onMount?: boolean }) = const tokenAccount = useRef(); const { - governanceContracts: { votesTokenAddress, underlyingTokenAddress }, + governanceContracts: { votesTokenAddress }, action, } = useFractal(); const user = useAccount(); const account = user.address; const publicClient = usePublicClient(); - const underlyingTokenContract = useMemo(() => { - if (!underlyingTokenAddress || !publicClient) { - return; - } - - return getContract({ - abi: abis.VotesERC20, - address: underlyingTokenAddress, - client: publicClient, - }); - }, [publicClient, underlyingTokenAddress]); - const loadERC20Token = useCallback(async () => { if (!votesTokenAddress || !publicClient) { return; @@ -57,26 +45,6 @@ export const useERC20LinearToken = ({ onMount = true }: { onMount?: boolean }) = action.dispatch({ type: FractalGovernanceAction.SET_TOKEN_DATA, payload: tokenData }); }, [action, publicClient, votesTokenAddress]); - const loadUnderlyingERC20Token = useCallback(async () => { - if (!underlyingTokenContract) { - return; - } - - const [tokenName, tokenSymbol] = await Promise.all([ - underlyingTokenContract.read.name(), - underlyingTokenContract.read.symbol(), - ]); - const tokenData = { - name: tokenName, - symbol: tokenSymbol, - address: underlyingTokenContract.address, - }; - action.dispatch({ - type: FractalGovernanceAction.SET_UNDERLYING_TOKEN_DATA, - payload: tokenData, - }); - }, [underlyingTokenContract, action]); - const loadERC20TokenAccountData = useCallback(async () => { if (!account || !votesTokenAddress || !publicClient) { action.dispatch({ type: FractalGovernanceAction.RESET_TOKEN_ACCOUNT_DATA }); @@ -209,5 +177,5 @@ export const useERC20LinearToken = ({ onMount = true }: { onMount?: boolean }) = }; }, [account, loadERC20TokenAccountData, onMount, publicClient, votesTokenAddress]); - return { loadERC20Token, loadUnderlyingERC20Token, loadERC20TokenAccountData }; + return { loadERC20Token, loadERC20TokenAccountData }; }; diff --git a/src/hooks/DAO/loaders/useFractalGovernance.ts b/src/hooks/DAO/loaders/useFractalGovernance.ts index 761eeb5f8..75bb5e8fd 100644 --- a/src/hooks/DAO/loaders/useFractalGovernance.ts +++ b/src/hooks/DAO/loaders/useFractalGovernance.ts @@ -31,7 +31,7 @@ export const useFractalGovernance = () => { const loadDAOProposals = useLoadDAOProposals(); const loadERC20Strategy = useERC20LinearStrategy(); const loadERC721Strategy = useERC721LinearStrategy(); - const { loadERC20Token, loadUnderlyingERC20Token } = useERC20LinearToken({}); + const { loadERC20Token } = useERC20LinearToken({}); const { loadLockedVotesToken } = useLockRelease({}); const loadERC721Tokens = useERC721Tokens(); const ipfsClient = useIPFSClient(); @@ -117,7 +117,6 @@ export const useFractalGovernance = () => { }); loadERC20Strategy(); loadERC20Token(); - loadUnderlyingERC20Token(); if (lockReleaseAddress) { loadLockedVotesToken(); } @@ -138,7 +137,6 @@ export const useFractalGovernance = () => { } }, [ governanceContracts, - loadUnderlyingERC20Token, loadERC20Strategy, loadERC20Token, loadLockedVotesToken, diff --git a/src/hooks/DAO/loaders/useGovernanceContracts.ts b/src/hooks/DAO/loaders/useGovernanceContracts.ts index 5a6436e19..472d71d99 100644 --- a/src/hooks/DAO/loaders/useGovernanceContracts.ts +++ b/src/hooks/DAO/loaders/useGovernanceContracts.ts @@ -45,7 +45,6 @@ export const useGovernanceContracts = () => { let linearVotingErc20WithHatsWhitelistingAddress: Address | undefined; let linearVotingErc721WithHatsWhitelistingAddress: Address | undefined; let votesTokenAddress: Address | undefined; - let underlyingTokenAddress: Address | undefined; let lockReleaseAddress: Address | undefined; const setGovTokenAddress = async (erc20VotingStrategyAddress: Address) => { @@ -122,7 +121,6 @@ export const useGovernanceContracts = () => { linearVotingErc721Address, linearVotingErc721WithHatsWhitelistingAddress, votesTokenAddress, - underlyingTokenAddress, lockReleaseAddress, moduleAzoriusAddress: azoriusModule.moduleAddress, }, diff --git a/src/types/fractal.ts b/src/types/fractal.ts index 19fd85439..7013ab696 100644 --- a/src/types/fractal.ts +++ b/src/types/fractal.ts @@ -216,7 +216,6 @@ export interface FractalGovernanceContracts { moduleAzoriusAddress?: Address; votesTokenAddress?: Address; lockReleaseAddress?: Address; - underlyingTokenAddress?: Address; isLoaded: boolean; } From 28662e4e0841bb05f9da22af93ebbe8c06e4392b Mon Sep 17 00:00:00 2001 From: Kellar Date: Wed, 11 Dec 2024 16:12:03 +0000 Subject: [PATCH 2/2] remove some more refs to underlying token data --- src/providers/App/governance/action.ts | 6 ------ src/providers/App/governance/reducer.ts | 4 ---- src/types/account.ts | 5 ----- 3 files changed, 15 deletions(-) diff --git a/src/providers/App/governance/action.ts b/src/providers/App/governance/action.ts index db3dd64f2..42c7045b9 100644 --- a/src/providers/App/governance/action.ts +++ b/src/providers/App/governance/action.ts @@ -6,7 +6,6 @@ import { FractalProposalState, VotesData, VotingStrategy, - UnderlyingTokenData, GovernanceType, ERC721TokenData, } from '../../../types'; @@ -30,7 +29,6 @@ export enum FractalGovernanceAction { SET_TOKEN_ACCOUNT_DATA = 'SET_TOKEN_ACCOUNT_DATA', SET_CLAIMING_CONTRACT = 'SET_CLAIMING_CONTRACT', RESET_TOKEN_ACCOUNT_DATA = 'RESET_TOKEN_ACCOUNT_DATA', - SET_UNDERLYING_TOKEN_DATA = 'SET_UNDERLYING_TOKEN_DATA', PENDING_PROPOSAL_ADD = 'PENDING_PROPOSAL_ADD', } @@ -88,10 +86,6 @@ export type FractalGovernanceActions = type: FractalGovernanceAction.SET_TOKEN_DATA; payload: ERC20TokenData; } - | { - type: FractalGovernanceAction.SET_UNDERLYING_TOKEN_DATA; - payload: UnderlyingTokenData; - } | { type: FractalGovernanceAction.SET_TOKEN_ACCOUNT_DATA; payload: VotesData; diff --git a/src/providers/App/governance/reducer.ts b/src/providers/App/governance/reducer.ts index 83369377f..3e29e341b 100644 --- a/src/providers/App/governance/reducer.ts +++ b/src/providers/App/governance/reducer.ts @@ -185,10 +185,6 @@ export const governanceReducer = (state: FractalGovernance, action: FractalGover case FractalGovernanceAction.SET_ERC721_TOKENS_DATA: { return { ...state, erc721Tokens: action.payload }; } - case FractalGovernanceAction.SET_UNDERLYING_TOKEN_DATA: { - const { votesToken } = state as AzoriusGovernance; - return { ...state, votesToken: { ...votesToken, underlyingTokenData: action.payload } }; - } case FractalGovernanceAction.SET_TOKEN_ACCOUNT_DATA: { const { votesToken } = state as AzoriusGovernance; return { ...state, votesToken: { ...votesToken, ...action.payload } }; diff --git a/src/types/account.ts b/src/types/account.ts index 6f0281c86..c1585af17 100644 --- a/src/types/account.ts +++ b/src/types/account.ts @@ -6,10 +6,6 @@ export interface VotesData { delegatee: Address | null; votingWeight: bigint | null; } -export type UnderlyingTokenData = Omit< - ERC20TokenData, - 'totalSupply' | 'decimals' | 'underlyingTokenData' ->; export interface BaseTokenData { name: string; @@ -19,7 +15,6 @@ export interface BaseTokenData { export interface ERC20TokenData extends BaseTokenData { decimals: number; totalSupply: bigint; - underlyingTokenData?: UnderlyingTokenData; } export interface ERC721TokenData extends BaseTokenData {