Skip to content

Commit 47ddfdf

Browse files
committed
fix: correct simulation severity mapping and transaction hash logging
1 parent b382775 commit 47ddfdf

2 files changed

Lines changed: 4 additions & 6 deletions

File tree

Frontend/src/components/SimulateIncident.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,8 @@ const SimulateIncident = () => {
4545

4646
if (res.ok) {
4747
addLog("Transaction confirmed on-chain!");
48-
const match = data.output?.match(/0x[a-fA-F0-9]{64}/);
49-
if (match) {
50-
addLog(`TX Hash: ${match[0]}`);
48+
if (data.txHash) {
49+
addLog(`TX Hash: ${data.txHash}`);
5150
}
5251
addLog(`Success: ${data.status}`);
5352
} else {

Frontend/src/pages/api/simulate-incident.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
99
const { type, priority, parentId } = req.body;
1010

1111
// Severity mapping: Frontend sends 0(P0), 1(P1), 2(P2), 3(P3).
12-
// Contract expects uint256 severity.
13-
// We'll map high severity (P0, P1) to 3, P2 to 2, P3 to 1.
14-
const severityScore = (priority === 0 || priority === 1) ? 3 : (priority === 2 ? 2 : 1);
12+
// Contract expects uint256 severity (0: low, 1: med, 2: critical).
13+
const severityScore = (priority === 0 || priority === 1) ? 2 : (priority === 2 ? 1 : 0);
1514

1615
try {
1716
console.log(`🚀 Simulating incident: ${type} with severity ${severityScore}, parent: ${parentId || 0}`);

0 commit comments

Comments
 (0)