From f64215d19935bd6092ba50f723659430b0b58195 Mon Sep 17 00:00:00 2001 From: Timidan Date: Thu, 28 May 2026 14:32:12 +0100 Subject: [PATCH] chore: tier-A CLAUDE.md cleanup pass (12 surgical fixes) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Applied 9 unambiguous fixes from a 10-zone CLAUDE.md audit (~150 total findings). Only items with zero behavior change, zero parallel-work conflict (PR #20 lifi-intents, #21 mezo, #22 cleanup), and clear dead-code or surface-confusion signal were applied; the rest are deferred to the PR description as a backlog. Net: 12 files, -65 lines net. Surface confusion (P1): - structStorageDecoding.ts:484 — collapse identical-branches ternary 'const elementSize = elementType === 'address' ? 1 : 1' → '= 1' - storageSlotCalculator.ts:86 — parseSlotInput dropped redundant hex branch (both branches called BigInt(trimmed)) - edbTraceConverter.ts:55 — same redundant-hex-branch in parseTraceValue Speculative API surface (P2): - SolidityViewer.tsx — removed unused props highlightLine, scrollToLine, theme (sole caller never passes any) - PackingVisualizer.tsx — removed unused rawHex prop + caller's pass - api/{lifi-composer,lifi-earn,edb-proxy}.ts — dropped 'HEAD' from ALLOWED_METHODS (no caller issues HEAD) Dead exports (P3): - scripts/bridge-security.mjs — sanitizeForLogging (zero callers) - scripts/bridge-config.mjs — TRACE_DETAIL_COMPACT_ARTIFACTS env constant (zero readers) - eslint.config.js — ignore globs for nonexistent dirs (current_bundle, test-results, test-*, **/test-*.js, test-app-*) --- api/edb-proxy.ts | 2 +- api/lifi-composer.ts | 2 +- api/lifi-earn.ts | 2 +- eslint.config.js | 5 --- scripts/bridge-config.mjs | 1 - scripts/bridge-security.mjs | 16 -------- src/components/explorer/SlotRow.tsx | 2 +- src/components/explorer/SolidityViewer.tsx | 38 +------------------ .../storage-viewer/PackingVisualizer.tsx | 3 +- src/contexts/debug/structStorageDecoding.ts | 2 +- src/utils/edbTraceConverter.ts | 3 -- src/utils/storageSlotCalculator.ts | 4 -- 12 files changed, 7 insertions(+), 73 deletions(-) diff --git a/api/edb-proxy.ts b/api/edb-proxy.ts index cbcf8d9..09514fd 100644 --- a/api/edb-proxy.ts +++ b/api/edb-proxy.ts @@ -8,7 +8,7 @@ export const config = { const MAX_BODY_BYTES = 50 * 1024 * 1024; // 50 MB (artifacts_inline can be large) const FETCH_TIMEOUT_MS = 120_000; // 2 min for regular requests -const ALLOWED_METHODS = new Set(["GET", "POST", "OPTIONS", "HEAD"]); +const ALLOWED_METHODS = new Set(["GET", "POST", "OPTIONS"]); // CORS allowlist — dev servers by default; extend via EDB_CORS_ALLOWED_ORIGINS (comma-separated). const DEFAULT_ALLOWED_ORIGINS = new Set([ diff --git a/api/lifi-composer.ts b/api/lifi-composer.ts index 813a83b..75a40ec 100644 --- a/api/lifi-composer.ts +++ b/api/lifi-composer.ts @@ -8,7 +8,7 @@ export const config = { const LIFI_BASE = "https://li.quest"; const LIFI_API_KEY = process.env.LIFI_API_KEY || ""; -const ALLOWED_METHODS = new Set(["GET", "OPTIONS", "HEAD"]); +const ALLOWED_METHODS = new Set(["GET", "OPTIONS"]); const ALLOWED_ORIGINS = new Set( (process.env.ALLOWED_ORIGINS || "").split(",").filter(Boolean) ); diff --git a/api/lifi-earn.ts b/api/lifi-earn.ts index 0b8551b..3c4a81a 100644 --- a/api/lifi-earn.ts +++ b/api/lifi-earn.ts @@ -8,7 +8,7 @@ export const config = { const LIFI_EARN_BASE = "https://earn.li.fi"; const LIFI_API_KEY = process.env.LIFI_API_KEY || ""; -const ALLOWED_METHODS = new Set(["GET", "OPTIONS", "HEAD"]); +const ALLOWED_METHODS = new Set(["GET", "OPTIONS"]); const ALLOWED_ORIGINS = new Set( (process.env.ALLOWED_ORIGINS || "").split(",").filter(Boolean) ); diff --git a/eslint.config.js b/eslint.config.js index 3eabd89..68144d3 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -8,14 +8,9 @@ export default tseslint.config( ignores: [ 'dist/**', 'node_modules/**', - 'current_bundle/**', - 'test-results/**', 'scripts/**', 'public/**', 'tests/**', - 'test-*/**', - '**/test-*.js', - 'test-app-*/**', '.claude/worktrees/**', 'edb/**', 'starknet-sim/**', diff --git a/scripts/bridge-config.mjs b/scripts/bridge-config.mjs index 5faac78..fcdc60b 100644 --- a/scripts/bridge-config.mjs +++ b/scripts/bridge-config.mjs @@ -22,7 +22,6 @@ export const TRACE_DETAIL_GZIP_MIN_BYTES = Number( ); export const TRACE_STRIP_OPCODE_LINES = process.env.TRACE_DETAIL_STRIP_OPCODE_LINES === "true"; export const TRACE_DETAIL_STRIP_OPCODE_TRACE = process.env.TRACE_DETAIL_STRIP_OPCODE_TRACE !== "false"; -export const TRACE_DETAIL_COMPACT_ARTIFACTS = process.env.TRACE_DETAIL_COMPACT_ARTIFACTS !== "false"; export const TRACE_V2_BRIDGE_JS_FALLBACK = process.env.SIM_TRACE_V2_BRIDGE_JS_FALLBACK === "true"; export const TRACE_LITE_TRANSPORT_ENABLED = process.env.SIM_TRACE_V2_LITE_TRANSPORT !== "false"; diff --git a/scripts/bridge-security.mjs b/scripts/bridge-security.mjs index b8851c5..b473762 100644 --- a/scripts/bridge-security.mjs +++ b/scripts/bridge-security.mjs @@ -33,19 +33,3 @@ export function redactRpcUrl(url) { } } -/** - * Sanitize an object for logging - redacts sensitive fields - * @param {Object} obj - * @returns {Object} - */ -export function sanitizeForLogging(obj) { - if (!obj || typeof obj !== "object") return obj; - const sanitized = { ...obj }; - if ("rpcUrl" in sanitized) { - sanitized.rpcUrl = redactRpcUrl(sanitized.rpcUrl); - } - if ("rpc_url" in sanitized) { - sanitized.rpc_url = redactRpcUrl(sanitized.rpc_url); - } - return sanitized; -} diff --git a/src/components/explorer/SlotRow.tsx b/src/components/explorer/SlotRow.tsx index 3e228eb..a282716 100644 --- a/src/components/explorer/SlotRow.tsx +++ b/src/components/explorer/SlotRow.tsx @@ -239,7 +239,7 @@ const InlineInspector: React.FC = ({ slot }) => { Slot Packing Layout
- +
)} diff --git a/src/components/explorer/SolidityViewer.tsx b/src/components/explorer/SolidityViewer.tsx index f36146e..1591e19 100644 --- a/src/components/explorer/SolidityViewer.tsx +++ b/src/components/explorer/SolidityViewer.tsx @@ -26,14 +26,8 @@ export interface SolidityViewerProps { selectedFile: string | null; /** Callback when file selection changes */ onFileSelect?: (path: string) => void; - /** Optional: Highlight specific line (1-indexed) */ - highlightLine?: number; - /** Optional: Scroll to line on mount/change */ - scrollToLine?: number; /** Optional: Show/hide the built-in file tree sidebar */ showFileTree?: boolean; - /** Optional: Custom theme */ - theme?: 'vs-dark' | 'vs-light' | 'hc-black'; /** Optional: Additional CSS class */ className?: string; /** Optional: Height (default: 100%) */ @@ -44,15 +38,11 @@ export const SolidityViewer: React.FC = ({ files, selectedFile, onFileSelect, - highlightLine, - scrollToLine, showFileTree = true, - theme = 'vs-dark', className, height = '100%', }) => { const editorRef = useRef(null); - const decorationsRef = useRef([]); const containerRef = useRef(null); // Force Monaco to remount when container becomes visible after display:none toggle. @@ -116,32 +106,6 @@ export const SolidityViewer: React.FC = ({ setupSolidityMonaco(monaco); }, []); - useEffect(() => { - if (!editorRef.current || !highlightLine) return; - - const editor = editorRef.current; - const monaco = (window as { monaco?: typeof import('monaco-editor') }).monaco; - if (!monaco) return; - - decorationsRef.current = editor.deltaDecorations(decorationsRef.current, []); - decorationsRef.current = editor.deltaDecorations([], [ - { - range: new monaco.Range(highlightLine, 1, highlightLine, 1), - options: { - isWholeLine: true, - className: 'highlighted-line', - linesDecorationsClassName: 'highlighted-line-gutter', - }, - }, - ]); - }, [highlightLine, currentContent]); - - useEffect(() => { - if (!editorRef.current || !scrollToLine) return; - - editorRef.current.revealLineInCenter(scrollToLine); - }, [scrollToLine, currentContent]); - const handleFileSelect = useCallback( (path: string) => { onFileSelect?.(path); @@ -155,7 +119,7 @@ export const SolidityViewer: React.FC = ({ height={height} language={getLanguageFromPath(selectedFile)} value={currentContent} - theme={theme === 'vs-dark' ? SOLIDITY_THEME_NAME : theme} + theme={SOLIDITY_THEME_NAME} options={SOLIDITY_EDITOR_OPTIONS} onMount={handleEditorMount} loading={ diff --git a/src/components/explorer/storage-viewer/PackingVisualizer.tsx b/src/components/explorer/storage-viewer/PackingVisualizer.tsx index 15fa036..7158757 100644 --- a/src/components/explorer/storage-viewer/PackingVisualizer.tsx +++ b/src/components/explorer/storage-viewer/PackingVisualizer.tsx @@ -19,7 +19,6 @@ import type { DecodedSlotField } from '../../../types/debug'; interface PackingVisualizerProps { fields: DecodedSlotField[]; - rawHex?: string; } /** Color palette for Solidity types */ @@ -50,7 +49,7 @@ interface ByteSegment { isGap: boolean; } -const PackingVisualizer: React.FC = ({ fields, rawHex }) => { +const PackingVisualizer: React.FC = ({ fields }) => { /** Build segments for the 32-byte lane */ const segments = useMemo((): ByteSegment[] => { if (fields.length === 0) return []; diff --git a/src/contexts/debug/structStorageDecoding.ts b/src/contexts/debug/structStorageDecoding.ts index 99eb063..bf8a65f 100644 --- a/src/contexts/debug/structStorageDecoding.ts +++ b/src/contexts/debug/structStorageDecoding.ts @@ -481,7 +481,7 @@ export async function fillUnreadFieldsFromStorage( } const elementType = child.type.replace('[]', ''); - const elementSize = elementType === 'address' ? 1 : 1; + const elementSize = 1; const arrayChildren: DebugVariable[] = []; const readBatchSize = 8; for (let start = 0; start < maxElements; start += readBatchSize) { diff --git a/src/utils/edbTraceConverter.ts b/src/utils/edbTraceConverter.ts index 03c77ff..26de1c8 100644 --- a/src/utils/edbTraceConverter.ts +++ b/src/utils/edbTraceConverter.ts @@ -53,9 +53,6 @@ const parseTraceValue = (value: unknown): ethers.BigNumber | null => { return null; } try { - if (trimmed.startsWith("0x") || trimmed.startsWith("0X")) { - return ethers.BigNumber.from(trimmed); - } return ethers.BigNumber.from(trimmed); } catch { return null; diff --git a/src/utils/storageSlotCalculator.ts b/src/utils/storageSlotCalculator.ts index 0b295e8..42da3a8 100644 --- a/src/utils/storageSlotCalculator.ts +++ b/src/utils/storageSlotCalculator.ts @@ -86,9 +86,5 @@ export const DIAMOND_NAMESPACES = [ export function parseSlotInput(input: string): bigint { const trimmed = input.trim(); if (!trimmed) throw new Error('Empty slot input'); - if (trimmed.startsWith('0x') || trimmed.startsWith('0X')) { - return BigInt(trimmed); - } - // Try decimal return BigInt(trimmed); }