Skip to content

chore: code improvements#8

Merged
tinom9 merged 9 commits intomainfrom
chore/various
Mar 6, 2026
Merged

chore: code improvements#8
tinom9 merged 9 commits intomainfrom
chore/various

Conversation

@tinom9
Copy link
Copy Markdown
Owner

@tinom9 tinom9 commented Mar 6, 2026

Description

  • Replace raw strip_prefix("0x") / starts_with("0x") calls with canonical hex_utils helpers (strip_0x, require_0x) across trace_renderer.rs and selector_resolver.rs.
  • Use parse_rpc_response in fetch_chain_id instead of manual JSON parsing, so HTTP errors (e.g. 502) produce clear status messages instead of misleading "invalid JSON".
  • Add is_valid_address / is_valid_tx_hash predicates to hex_utils covering uppercase 0X prefix and hex digit validation; wire them into contract_resolver, validate_address, and a new validate_tx_hash used by tx.rs.
  • Replace stringly-typed serde_json::Value indexing with typed Deserialize structs (SelectorEntry, ContractInfo, Compilation) in both sourcify resolvers.
  • Inject sourcify base URLs via constructor Option<String> parameter (explicit > env var > default) for test-friendly dependency injection.
  • Centralize cache kind strings as constants (SELECTOR_CACHE, CONTRACT_CACHE, ALL_CACHE_KINDS) in disk_cache.rs; remove duplicated CACHE_KINDS from clean.rs.
  • Move CallTrace struct from cli/trace.rs to utils/trace_renderer.rs to fix utils/cli/ layering violation.
  • Emit resolver warnings on Sourcify JSON parse failures, treating them as transient misses.

@tinom9 tinom9 changed the title Chore/various chore: code improvements Mar 6, 2026
@tinom9 tinom9 merged commit feeacb7 into main Mar 6, 2026
1 check passed
@tinom9 tinom9 deleted the chore/various branch March 6, 2026 05:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant