Skip to content

Commit 7f15a22

Browse files
committed
fix: filter for proposal ids
1 parent 5394494 commit 7f15a22

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

plugins/maciVoting/hooks/useProposal.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,16 @@ export function useProposal(proposalId: string, autoRefresh = false) {
6060
try {
6161
const logs = await publicClient.getLogs({
6262
address: PUBLIC_MACI_VOTING_PLUGIN_ADDRESS,
63-
event: ProposalCreatedEvent as any,
63+
event: ProposalCreatedEvent,
6464
fromBlock: snapshotBlock,
6565
toBlock: snapshotBlock + 1n,
6666
});
6767

6868
if (!logs || !logs.length) throw new Error("No creation logs");
6969

70-
const log: ProposalCreatedLogResponse = logs[0] as any;
70+
const filteredLogs = logs.filter((log) => log.args.proposalId === BigInt(proposalId));
71+
if (!filteredLogs.length) return;
72+
const log: ProposalCreatedLogResponse = filteredLogs[0] as any;
7173

7274
setProposalCreationEvent(log.args);
7375
setMetadata(fromHex(log.args.metadata as Hex, "string"));
@@ -76,7 +78,7 @@ export function useProposal(proposalId: string, autoRefresh = false) {
7678
console.error("Could not fetch the proposal details", error);
7779
}
7880
})();
79-
}, [proposalData, publicClient]);
81+
}, [proposalData, proposalId, publicClient]);
8082

8183
// JSON metadata
8284
const {

0 commit comments

Comments
 (0)