Skip to content

feat: add DecodeContext with builder pattern#234

Open
Mmesolove wants to merge 1 commit into
Toolbox-Lab:mainfrom
Mmesolove:feat/decode-context
Open

feat: add DecodeContext with builder pattern#234
Mmesolove wants to merge 1 commit into
Toolbox-Lab:mainfrom
Mmesolove:feat/decode-context

Conversation

@Mmesolove

@Mmesolove Mmesolove commented Jun 16, 2026

Copy link
Copy Markdown

Closes #233

Summary

Adds a DecodeContext struct that carries all runtime configuration — network, RPC URL (via NetworkConfig), verbosity level, and output format — through the entire decode pipeline. Eliminates hardcoded values and global state in analyzers.

Changes

  • crates/core/src/decode/decode_context.rs (new): DecodeContext struct, DecodeContextBuilder with From<&NetworkConfig> convenience impl, and OutputFormat enum (human / json / compact / short).
  • crates/core/src/decode/mod.rs: decode_transaction and decode_transaction_with_op_filter now accept &DecodeContext instead of &NetworkConfig. Re-exports the three new types.
  • crates/core/src/decode/contract_error.rs: resolve accepts &DecodeContext; delegates to the private resolve_with_network for the actual network call.
  • crates/core/src/lib.rs: Exports DecodeContext, DecodeContextBuilder, OutputFormat.
  • crates/cli/src/commands/decode.rs: Builds DecodeContext from parsed CLI args and passes &ctx down.
  • crates/cli/src/commands/inspect.rs: Same treatment as decode.

What was tested

  • Manual code review for type and borrow-checker correctness.
  • No global state or hardcoded network values remain in the decode pipeline; all configuration flows through DecodeContext.

…e pipeline

- Add DecodeContext struct with network, verbosity, and output_format fields
- Add DecodeContextBuilder with From<&NetworkConfig> convenience impl
- Add OutputFormat enum (human/json/compact/short) replacing raw &str
- Update decode_transaction / decode_transaction_with_op_filter to accept &DecodeContext
- Update contract_error::resolve to accept &DecodeContext, delegates to network internally
- Export DecodeContext, DecodeContextBuilder, OutputFormat from prism_core
- Update CLI decode and inspect commands to build DecodeContext from parsed args

No global state or hardcoded values remain in the decode pipeline.
@Mmesolove

Copy link
Copy Markdown
Author

please review and merge.

@codeZe-us codeZe-us self-requested a review June 16, 2026 10:50
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.

Build a DecodeContext Struct That Carries CLI Config into Every Analyzer

1 participant