@@ -60,14 +60,16 @@ export function useProposal(proposalId: string, autoRefresh = false) {
60
60
try {
61
61
const logs = await publicClient . getLogs ( {
62
62
address : PUBLIC_MACI_VOTING_PLUGIN_ADDRESS ,
63
- event : ProposalCreatedEvent as any ,
63
+ event : ProposalCreatedEvent ,
64
64
fromBlock : snapshotBlock ,
65
65
toBlock : snapshotBlock + 1n ,
66
66
} ) ;
67
67
68
68
if ( ! logs || ! logs . length ) throw new Error ( "No creation logs" ) ;
69
69
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 ;
71
73
72
74
setProposalCreationEvent ( log . args ) ;
73
75
setMetadata ( fromHex ( log . args . metadata as Hex , "string" ) ) ;
@@ -76,7 +78,7 @@ export function useProposal(proposalId: string, autoRefresh = false) {
76
78
console . error ( "Could not fetch the proposal details" , error ) ;
77
79
}
78
80
} ) ( ) ;
79
- } , [ proposalData , publicClient ] ) ;
81
+ } , [ proposalData , proposalId , publicClient ] ) ;
80
82
81
83
// JSON metadata
82
84
const {
0 commit comments