Skip to content

Commit 17ce780

Browse files
committed
address review comments
1 parent 679f4c3 commit 17ce780

File tree

5 files changed

+20
-21
lines changed

5 files changed

+20
-21
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@
9595
"vite": "^7.1.12",
9696
"vite-plugin-top-level-await": "^1.4.4",
9797
"vite-plugin-wasm": "^3.5.0",
98-
"vitest": "^4.0.14"
98+
"vitest": "^4.0.14",
99+
"@swc/core": "^1.13.5"
99100
},
100101
"lint-staged": {
101102
"**/*.{ts,tsx}": [

src/components/DebuggerSettings/TraceConfigDialog.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
selectHostCallsTrace,
1010
selectAutoContinueOnHostCalls,
1111
} from "@/store/debugger/debuggerSlice";
12-
import { validateTrace, getTraceSummary, parseTrace } from "@/lib/host-call-trace";
12+
import { validateTraceContent, getTraceSummary, parseTrace } from "@/lib/host-call-trace";
1313
import CodeMirror from "@uiw/react-codemirror";
1414
import { useIsDarkMode } from "@/packages/ui-kit/DarkMode/utils";
1515
import classNames from "classnames";
@@ -77,10 +77,10 @@ export const TraceConfigDialog = ({ open, onOpenChange }: TraceConfigDialogProps
7777
return;
7878
}
7979

80-
const errors = validateTrace(content);
81-
setValidationErrors(errors.map((e) => `Line ${e.lineNumber}: ${e.message}`));
80+
const validation = validateTraceContent(content);
81+
setValidationErrors(validation.errors.map((e) => `Line ${e.lineNumber}: ${e.message}`));
8282

83-
if (errors.length === 0) {
83+
if (validation.errors.length === 0) {
8484
const fullParsed = parseTrace(content);
8585
setSummary(getTraceSummary(fullParsed));
8686
} else {

src/components/HostCallDialog/DefaultHostCallContent.tsx

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useCallback, useEffect, useState } from "react";
1+
import { useCallback, useEffect, useMemo, useState } from "react";
22
import { Input } from "@/components/ui/input";
33
import { valueToNumeralSystem } from "@/components/Instructions/utils";
44
import { DEFAULT_GAS, DEFAULT_REGS, ExpectedState, RegistersArray } from "@/types/pvm";
@@ -181,11 +181,15 @@ export const DefaultHostCallContent: React.FC<DefaultHostCallContentProps> = ({
181181
[onMemoryChange],
182182
);
183183

184-
// Extract memory writes from trace entry
185-
const pendingMemoryWrites = traceEntry?.memoryWrites.map((mw) => ({
186-
address: mw.address,
187-
data: mw.data,
188-
}));
184+
// Extract memory writes from trace entry (memoized to prevent unnecessary re-renders)
185+
const pendingMemoryWrites = useMemo(
186+
() =>
187+
traceEntry?.memoryWrites.map((mw) => ({
188+
address: mw.address,
189+
data: mw.data,
190+
})),
191+
[traceEntry?.memoryWrites],
192+
);
189193

190194
// Get initial address and length from first memory write in trace
191195
const firstMemWrite = traceEntry?.memoryWrites[0];

src/components/ProgramLoader/loading-utils.test.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,9 @@ import * as path from "path";
55
describe("loadingUtils", () => {
66
describe("tryParseTraceFile via loadFileFromUint8Array", () => {
77
it("should load io-trace-output.log without throwing", async () => {
8-
const tracePath = path.join(__dirname, "../../../io-trace-output.log");
8+
const tracePath = path.join(__dirname, "../../../tests/io-trace-output.log");
99

10-
if (!fs.existsSync(tracePath)) {
11-
console.warn("Skipping test: io-trace-output.log not found");
12-
return;
13-
}
10+
expect(fs.existsSync(tracePath), `Fixture file not found: ${tracePath}`).toBe(true);
1411

1512
const content = fs.readFileSync(tracePath);
1613
const uint8Array = new Uint8Array(content);

src/lib/host-call-trace.test.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,9 @@ start pc=0 gas=1000`;
6464

6565
describe("io-trace-output.log", () => {
6666
it("should parse the real trace file", () => {
67-
const tracePath = path.join(__dirname, "../../io-trace-output.log");
67+
const tracePath = path.join(__dirname, "../../tests/io-trace-output.log");
6868

69-
if (!fs.existsSync(tracePath)) {
70-
console.warn("Skipping test: io-trace-output.log not found");
71-
return;
72-
}
69+
expect(fs.existsSync(tracePath), `Fixture file not found: ${tracePath}`).toBe(true);
7370

7471
const content = fs.readFileSync(tracePath, "utf-8");
7572
const result = parseTrace(content);

0 commit comments

Comments
 (0)