Skip to content

Commit

Permalink
feat: fixing vetoing; for now it's harcoded the amount till we have t…
Browse files Browse the repository at this point in the history
…he permit
  • Loading branch information
carlosgj94 committed Mar 13, 2024
1 parent 181b343 commit e70ca5f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
17 changes: 7 additions & 10 deletions plugins/lockToVote/hooks/useProposalVeto.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ import {
useWriteContract,
} from "wagmi";
import { useProposal } from "./useProposal";
import { useProposalVetoes } from "@/plugins/dualGovernance/hooks/useProposalVetoes";
import { useUserCanVeto } from "@/plugins/dualGovernance/hooks/useUserCanVeto";
import { OptimisticTokenVotingPluginAbi } from "@/plugins/dualGovernance/artifacts/OptimisticTokenVotingPlugin.sol";
import { useProposalVetoes } from "@/plugins/lockToVote/hooks/useProposalVetoes";
import { useUserCanVeto } from "@/plugins/lockToVote/hooks/useUserCanVeto";
import { OptimisticTokenVotingPluginAbi } from "@/plugins/lockToVote/artifacts/OptimisticTokenVotingPlugin.sol";
import { useAlertContext, AlertContextProps } from "@/context/AlertContext";
import { PUB_CHAIN, PUB_LOCK_TO_VOTE_PLUGIN_ADDRESS } from "@/constants";
import { LockToVetoPluginAbi } from "../artifacts/LockToVetoPlugin.sol";

export function useProposalVeto(proposalId: string) {
const publicClient = usePublicClient({ chainId: PUB_CHAIN.id });
Expand Down Expand Up @@ -39,10 +40,6 @@ export function useProposalVeto(proposalId: string) {
BigInt(proposalId)
);

useEffect(() => {
console.log(canVeto);
}, [canVeto]);

useEffect(() => {
if (vetoingStatus === "idle" || vetoingStatus === "pending") return;
else if (vetoingStatus === "error") {
Expand All @@ -51,7 +48,7 @@ export function useProposalVeto(proposalId: string) {
timeout: 4 * 1000,
});
} else {
addAlert("Could not create the proposal", { type: "error" });
addAlert("Could not create the veto", { type: "error" });
}
return;
}
Expand All @@ -77,10 +74,10 @@ export function useProposalVeto(proposalId: string) {

const vetoProposal = () => {
vetoWrite({
abi: OptimisticTokenVotingPluginAbi,
abi: LockToVetoPluginAbi,
address: PUB_LOCK_TO_VOTE_PLUGIN_ADDRESS,
functionName: "veto",
args: [proposalId],
args: [proposalId, 50000000000000000000],
});
};

Expand Down
4 changes: 2 additions & 2 deletions plugins/lockToVote/hooks/useUserCanVeto.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useAccount, useBlockNumber, useReadContract } from "wagmi";
import { OptimisticTokenVotingPluginAbi } from "@/plugins/lockToVote/artifacts/OptimisticTokenVotingPlugin.sol";
import { useEffect } from "react";
import { PUB_CHAIN, PUB_LOCK_TO_VOTE_PLUGIN_ADDRESS } from "@/constants";
import { LockToVetoPluginAbi } from "../artifacts/LockToVetoPlugin.sol";

export function useUserCanVeto(proposalId: bigint) {
const { address } = useAccount();
Expand All @@ -10,7 +10,7 @@ export function useUserCanVeto(proposalId: bigint) {
const { data: canVeto, refetch } = useReadContract({
chainId: PUB_CHAIN.id,
address: PUB_LOCK_TO_VOTE_PLUGIN_ADDRESS,
abi: OptimisticTokenVotingPluginAbi,
abi: LockToVetoPluginAbi,
functionName: "canVeto",
args: [proposalId, address],
});
Expand Down

0 comments on commit e70ca5f

Please sign in to comment.