Skip to content

Commit 56a32b1

Browse files
committed
fix(lifecycle): add event listeners for validated and resolved states
1 parent 170f12e commit 56a32b1

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

Frontend/src/context/ChainWardDataProvider.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ const IncidentManagerAbi = [
2424
"function incidents(uint256) view returns (uint256 id, string incidentType, uint256 timestamp, address reporter, uint256 severity, string description, bool resolved, uint256 resolvedAt, uint256 validations, uint256 disputes, bool slashed)",
2525
"function getIncident(uint256 incidentId) view returns (tuple(uint256 id, string incidentType, uint256 timestamp, address reporter, uint256 severity, string description, bool resolved, uint256 resolvedAt, uint256 validations, uint256 disputes, bool slashed))",
2626
"event IncidentReported(uint256 indexed incidentId, address indexed reporter, string incidentType, uint256 severity, uint256 timestamp)",
27+
"event IncidentValidated(uint256 indexed incidentId, address indexed validator, bool approved)",
2728
"event IncidentResolved(uint256 indexed incidentId, uint256 timestamp)"
2829
];
2930

@@ -366,8 +367,13 @@ export const ChainWardDataProvider = ({ children }: { children: ReactNode }) =>
366367
const provider = getProvider();
367368
incidentManager = new ethers.Contract(incidentManagerAddress, IncidentManagerAbi, provider);
368369
incidentManager.on('IncidentReported', () => {
369-
// Debounce: wait a bit then refetch
370-
setTimeout(fetchAllData, 2000);
370+
setTimeout(fetchAllData, 1000);
371+
});
372+
incidentManager.on('IncidentValidated', () => {
373+
setTimeout(fetchAllData, 1000);
374+
});
375+
incidentManager.on('IncidentResolved', () => {
376+
setTimeout(fetchAllData, 1000);
371377
});
372378
}
373379

0 commit comments

Comments
 (0)