Skip to content

Commit

Permalink
Remove underlyingTokenAddress and loadUnderlyingERC20Token
Browse files Browse the repository at this point in the history
  • Loading branch information
DarksightKellar committed Dec 11, 2024
1 parent 55f2429 commit 6f0726c
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 41 deletions.
38 changes: 3 additions & 35 deletions src/hooks/DAO/loaders/governance/useERC20LinearToken.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -10,25 +10,13 @@ export const useERC20LinearToken = ({ onMount = true }: { onMount?: boolean }) =
const tokenAccount = useRef<string>();

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;
Expand Down Expand Up @@ -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 });
Expand Down Expand Up @@ -209,5 +177,5 @@ export const useERC20LinearToken = ({ onMount = true }: { onMount?: boolean }) =
};
}, [account, loadERC20TokenAccountData, onMount, publicClient, votesTokenAddress]);

return { loadERC20Token, loadUnderlyingERC20Token, loadERC20TokenAccountData };
return { loadERC20Token, loadERC20TokenAccountData };
};
4 changes: 1 addition & 3 deletions src/hooks/DAO/loaders/useFractalGovernance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -117,7 +117,6 @@ export const useFractalGovernance = () => {
});
loadERC20Strategy();
loadERC20Token();
loadUnderlyingERC20Token();
if (lockReleaseAddress) {
loadLockedVotesToken();
}
Expand All @@ -138,7 +137,6 @@ export const useFractalGovernance = () => {
}
}, [
governanceContracts,
loadUnderlyingERC20Token,
loadERC20Strategy,
loadERC20Token,
loadLockedVotesToken,
Expand Down
2 changes: 0 additions & 2 deletions src/hooks/DAO/loaders/useGovernanceContracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -122,7 +121,6 @@ export const useGovernanceContracts = () => {
linearVotingErc721Address,
linearVotingErc721WithHatsWhitelistingAddress,
votesTokenAddress,
underlyingTokenAddress,
lockReleaseAddress,
moduleAzoriusAddress: azoriusModule.moduleAddress,
},
Expand Down
1 change: 0 additions & 1 deletion src/types/fractal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ export interface FractalGovernanceContracts {
moduleAzoriusAddress?: Address;
votesTokenAddress?: Address;
lockReleaseAddress?: Address;
underlyingTokenAddress?: Address;
isLoaded: boolean;
}

Expand Down

0 comments on commit 6f0726c

Please sign in to comment.