Skip to content

Commit

Permalink
Merge pull request #2004 from decentdao/remove-typechain-cleanup-3
Browse files Browse the repository at this point in the history
Remove typechain cleanup 3
  • Loading branch information
adamgall authored Jun 17, 2024
2 parents 4080038 + c224295 commit ce4dc84
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 122 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export function TxActions({ proposal }: { proposal: MultisigProposal }) {
const { t } = useTranslation(['proposal', 'common', 'transaction']);

const [asyncRequest, asyncRequestPending] = useAsyncRequest();
const [, contractCallPending, contractCallViem] = useTransaction();
const [contractCall, contractCallPending] = useTransaction();
const { loadSafeMultisigProposals } = useSafeMultisigProposals();
const { data: walletClient } = useWalletClient();

Expand Down Expand Up @@ -125,7 +125,7 @@ export function TxActions({ proposal }: { proposal: MultisigProposal }) {
address: getAddress(freezeGuardContractAddress),
client: walletClient,
});
contractCallViem({
contractCall({
contractFn: () =>
freezeGuard.write.timelockTransaction([
safeTx.to,
Expand Down Expand Up @@ -191,7 +191,7 @@ export function TxActions({ proposal }: { proposal: MultisigProposal }) {
}),
);

contractCallViem({
contractCall({
contractFn: () =>
safeContract.write.execTransaction([
safeTx.to,
Expand Down
4 changes: 2 additions & 2 deletions src/components/pages/DaoDashboard/ERC20Claim.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export function ERCO20Claim() {
const account = user.address;
const { tokenClaimContractAddress, type } = governance;
const { t } = useTranslation(['dashboard', 'transaction']);
const [, pending, contractCallViem] = useTransaction();
const [contractCall, pending] = useTransaction();
const azoriusGovernance = governance as AzoriusGovernance;
const publicClient = usePublicClient();
const { data: walletClient } = useWalletClient();
Expand Down Expand Up @@ -56,7 +56,7 @@ export function ERCO20Claim() {
address: tokenClaimContractAddress,
client: walletClient,
});
contractCallViem({
contractCall({
contractFn: () => tokenClaimContract.write.claimTokens([getAddress(account)]),
pendingMessage: t('pendingTokenClaim', {
symbol: azoriusGovernance.votesToken.symbol,
Expand Down
10 changes: 5 additions & 5 deletions src/components/ui/modals/DelegateModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export function DelegateModal({ close }: { close: Function }) {
const decentGovernance = azoriusGovernance as DecentGovernance;
const delegateeDisplayName = useDisplayName(azoriusGovernance?.votesToken?.delegatee);
const lockedDelegateeDisplayName = useDisplayName(decentGovernance?.lockedVotesToken?.delegatee);
const [, contractCallPendingViem, contractCallViem] = useTransaction();
const [contractCall, pending] = useTransaction();
const { addressValidationTest } = useValidationAddress();
const { data: walletClient } = useWalletClient();

Expand All @@ -51,7 +51,7 @@ export function DelegateModal({ close }: { close: Function }) {
client: walletClient,
});

contractCallViem({
contractCall({
contractFn: () => votingTokenContract.write.delegate([validAddress]),
pendingMessage: t('pendingDelegateVote'),
failedMessage: t('failedDelegateVote'),
Expand All @@ -74,7 +74,7 @@ export function DelegateModal({ close }: { close: Function }) {
client: walletClient,
});

contractCallViem({
contractCall({
contractFn: () => lockReleaseContract.write.delegate([getAddress(validAddress)]),
pendingMessage: t('pendingDelegateVote'),
failedMessage: t('failedDelegateVote'),
Expand Down Expand Up @@ -225,7 +225,7 @@ export function DelegateModal({ close }: { close: Function }) {
width="100%"
isDisabled={
!!errors.address ||
contractCallPendingViem ||
pending ||
!values.address ||
values.address === azoriusGovernance.votesToken?.delegatee
}
Expand All @@ -240,7 +240,7 @@ export function DelegateModal({ close }: { close: Function }) {
onClick={() => submitLockedDelegation({ address: values.address })}
isDisabled={
!!errors.address ||
contractCallPendingViem ||
pending ||
!values.address ||
values.address === decentGovernance.lockedVotesToken.delegatee
}
Expand Down
14 changes: 3 additions & 11 deletions src/components/ui/modals/UnwrapToken.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export function UnwrapToken({ close }: { close: () => void }) {
const { address: account } = useAccount();
const { loadERC20TokenAccountData } = useERC20LinearToken({ onMount: false });

const [, pending, contractCallViem] = useTransaction();
const [contractCall, pending] = useTransaction();
const {
approved,
approveTransaction,
Expand All @@ -48,7 +48,7 @@ export function UnwrapToken({ close }: { close: () => void }) {
client: walletClient,
});

contractCallViem({
contractCall({
contractFn: () => wrapperTokenContract.write.withdrawTo([account, amount.bigintValue!]),
pendingMessage: t('unwrapTokenPendingMessage'),
failedMessage: t('unwrapTokenFailedMessage'),
Expand All @@ -61,15 +61,7 @@ export function UnwrapToken({ close }: { close: () => void }) {
},
});
},
[
account,
contractCallViem,
governanceContracts,
walletClient,
close,
t,
loadERC20TokenAccountData,
],
[account, contractCall, governanceContracts, walletClient, close, t, loadERC20TokenAccountData],
);

if (
Expand Down
6 changes: 3 additions & 3 deletions src/components/ui/modals/WrapToken.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export function WrapToken({ close }: { close: () => void }) {
});

const { loadERC20TokenAccountData } = useERC20LinearToken({ onMount: false });
const [, pending, contractCallViem] = useTransaction();
const [contractCall, pending] = useTransaction();
const {
approved,
approveTransaction,
Expand Down Expand Up @@ -93,7 +93,7 @@ export function WrapToken({ close }: { close: () => void }) {
client: walletClient,
});

contractCallViem({
contractCall({
contractFn: () => wrapperTokenContract.write.depositFor([account, amount.bigintValue!]),
pendingMessage: t('wrapTokenPendingMessage'),
failedMessage: t('wrapTokenFailedMessage'),
Expand All @@ -108,7 +108,7 @@ export function WrapToken({ close }: { close: () => void }) {
},
[
account,
contractCallViem,
contractCall,
governanceContracts,
signer,
close,
Expand Down
16 changes: 7 additions & 9 deletions src/hooks/DAO/proposal/useCastVote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const useCastVote = ({
const azoriusGovernance = useMemo(() => governance as AzoriusGovernance, [governance]);
const { type } = azoriusGovernance;

const [, contractCallPending, contractCallCastVoteViem] = useTransaction();
const [contractCall, pending] = useTransaction();

const { remainingTokenIds, remainingTokenAddresses } = useUserERC721VotingTokens(
null,
Expand All @@ -63,11 +63,9 @@ const useCastVote = ({
const { getCanVote, getHasVoted } = useVoteContext();
const { data: walletClient } = useWalletClient();

useEffect(() => {
if (setPending) {
setPending(contractCallPending);
}
}, [setPending, contractCallPending]);
if (setPending) {
setPending(pending);
}

useEffect(() => {
if (extendedSnapshotProposal) {
Expand Down Expand Up @@ -95,7 +93,7 @@ const useCastVote = ({
address: getAddress(ozLinearVotingContractAddress),
client: walletClient,
});
contractCallCastVoteViem({
contractCall({
contractFn: () => ozLinearVotingContract.write.vote([Number(proposal.proposalId), vote]),
pendingMessage: t('pendingCastVote'),
failedMessage: t('failedCastVote'),
Expand All @@ -117,7 +115,7 @@ const useCastVote = ({
address: getAddress(erc721LinearVotingContractAddress),
client: walletClient,
});
contractCallCastVoteViem({
contractCall({
contractFn: () =>
erc721LinearVotingContract.write.vote([
Number(proposal.proposalId),
Expand All @@ -138,7 +136,7 @@ const useCastVote = ({
}
},
[
contractCallCastVoteViem,
contractCall,
erc721LinearVotingContractAddress,
getCanVote,
getHasVoted,
Expand Down
8 changes: 4 additions & 4 deletions src/hooks/DAO/proposal/useExecuteProposal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default function useExecuteProposal() {
governanceDispatch: action.dispatch,
});
const { data: walletClient } = useWalletClient();
const [, contractCallPending, contractCallViem] = useTransaction();
const [contractCall, pending] = useTransaction();

const executeProposal = useCallback(
(proposal: FractalProposal) => {
Expand Down Expand Up @@ -50,7 +50,7 @@ export default function useExecuteProposal() {
operations.push(tx.operation);
});

contractCallViem({
contractCall({
contractFn: () =>
azoriusContract.write.executeProposal([
Number(proposal.proposalId),
Expand All @@ -68,11 +68,11 @@ export default function useExecuteProposal() {
},
});
},
[azoriusContractAddress, contractCallViem, t, updateProposalState, walletClient],
[azoriusContractAddress, contractCall, t, updateProposalState, walletClient],
);

return {
pending: contractCallPending,
pending,
executeProposal,
};
}
16 changes: 7 additions & 9 deletions src/hooks/DAO/useCastFreezeVote.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useCallback, useEffect } from 'react';
import { useCallback } from 'react';
import { useTranslation } from 'react-i18next';
import { getContract, getAddress } from 'viem';
import { useWalletClient } from 'wagmi';
Expand All @@ -15,7 +15,7 @@ const useCastFreezeVote = ({
}: {
setPending: React.Dispatch<React.SetStateAction<boolean>>;
}) => {
const [, contractCallPending, contractCallCastFreezeViem] = useTransaction();
const [contractCall, pending] = useTransaction();
const {
guardContracts: { freezeVotingContractAddress, freezeVotingType },
node: {
Expand All @@ -24,9 +24,7 @@ const useCastFreezeVote = ({
} = useFractal();
const { getUserERC721VotingTokens } = useUserERC721VotingTokens(null, undefined, false);

useEffect(() => {
setPending(contractCallPending);
}, [setPending, contractCallPending]);
setPending(pending);

const { t } = useTranslation('transaction');
const { data: walletClient } = useWalletClient();
Expand All @@ -37,7 +35,7 @@ const useCastFreezeVote = ({
if (freezeVotingType === FreezeVotingType.ERC721) {
if (!walletClient) return;

contractCallCastFreezeViem({
contractCall({
contractFn: () => {
const freezeERC721VotingContract = getContract({
abi: ERC721FreezeVotingAbi,
Expand All @@ -58,7 +56,7 @@ const useCastFreezeVote = ({
} else if (freezeVotingType === FreezeVotingType.ERC20) {
if (!walletClient) return;

contractCallCastFreezeViem({
contractCall({
contractFn: () => {
const freezeERC20VotingContract = getContract({
abi: ERC20FreezeVotingAbi,
Expand All @@ -74,7 +72,7 @@ const useCastFreezeVote = ({
} else if (freezeVotingType === FreezeVotingType.MULTISIG) {
if (!walletClient) return;

contractCallCastFreezeViem({
contractCall({
contractFn: () => {
const freezeMultisigVotingContract = getContract({
abi: MultisigFreezeVotingAbi,
Expand All @@ -91,7 +89,7 @@ const useCastFreezeVote = ({
throw new Error('unknown freezeVotingType');
}
}, [
contractCallCastFreezeViem,
contractCall,
freezeVotingContractAddress,
freezeVotingType,
getUserERC721VotingTokens,
Expand Down
8 changes: 4 additions & 4 deletions src/hooks/DAO/useDeployDAO.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { useTransaction } from '../utils/useTransaction';
import useBuildDAOTx from './useBuildDAOTx';

const useDeployDAO = () => {
const [, contractCallPending, contractCallDeployViem] = useTransaction();
const [contractCall, pending] = useTransaction();
const [build] = useBuildDAOTx();

const { t } = useTranslation('transaction');
Expand Down Expand Up @@ -48,7 +48,7 @@ const useDeployDAO = () => {
client: walletClient,
});

contractCallDeployViem({
contractCall({
contractFn: () => multiSendCallOnlyContract.write.multiSend([safeTx]),
pendingMessage: t('pendingDeploySafe'),
failedMessage: t('failedDeploySafe'),
Expand All @@ -59,10 +59,10 @@ const useDeployDAO = () => {

deploy();
},
[addressPrefix, build, contractCallDeployViem, multiSendCallOnly, t, walletClient],
[addressPrefix, build, contractCall, multiSendCallOnly, t, walletClient],
);

return [deployDao, contractCallPending] as const;
return [deployDao, pending] as const;
};

export default useDeployDAO;
6 changes: 3 additions & 3 deletions src/hooks/utils/useApproval.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const useApproval = (tokenAddress?: string, spenderAddress?: string, userBalance
const { address: account } = useAccount();
const [allowance, setAllowance] = useState(0n);
const [approved, setApproved] = useState(false);
const [, pending, contractCallViem] = useTransaction();
const [contractCall, pending] = useTransaction();
const { t } = useTranslation('treasury');
const { data: walletClient } = useWalletClient();

Expand All @@ -35,7 +35,7 @@ const useApproval = (tokenAddress?: string, spenderAddress?: string, userBalance
const approveTransaction = useCallback(async () => {
if (!tokenContract || !account || !spenderAddress) return;

contractCallViem({
contractCall({
contractFn: () => tokenContract.write.approve([getAddress(spenderAddress), maxUint256]),
pendingMessage: t('approvalPendingMessage'),
failedMessage: t('approvalFailedMessage'),
Expand All @@ -44,7 +44,7 @@ const useApproval = (tokenAddress?: string, spenderAddress?: string, userBalance
setApproved(true);
},
});
}, [account, contractCallViem, tokenContract, spenderAddress, t]);
}, [account, contractCall, tokenContract, spenderAddress, t]);

useEffect(() => {
fetchAllowance();
Expand Down
Loading

0 comments on commit ce4dc84

Please sign in to comment.