You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: decouple rendering from intermediate decoded representation (#541)
- Created a `TextRenderer` as base renderer for the MarkdownRenderer to
decouple formatting assumptions from intermediate representations of the
decoded proposal.
- Separated templates into different files and modularized templates a
bit more to decouple more from code.
- Renamed `descriptors` to `fields` I think the new name is a bit easier
to follow.
- Added a `format` flag to the `analyze-proposal` command so users can
outputs either a text or markdown format
## AI Summary
This pull request refactors how decoded calls and their arguments are
represented and rendered in the analyzer package, and introduces support
for specifying output formats in the MCMSv2 CLI. The main focus is on
replacing the legacy `Descriptor`-based argument types with a more
structured `Field`-based approach, improving type safety and clarity for
transaction analysis (especially Aptos transactions). It also adds a
mechanism to select between markdown and text output formats for
proposal analysis.
### Analyzer Data Model Refactoring
* Replaced usage of `NamedDescriptor` and `Descriptor` types with new
`NamedField` and `FieldValue` types throughout the analyzer codebase,
including in `DecodedCall`, test cases, and Aptos transaction analysis.
This improves type safety and enables richer field representations such
as arrays and addresses.
[[1]](diffhunk://#diff-9ced6c2506531bf50bad8bbb81accf530d4e7f6f460223ed4fa3883670865f0dL42-R42)
[[2]](diffhunk://#diff-9ced6c2506531bf50bad8bbb81accf530d4e7f6f460223ed4fa3883670865f0dL51-R51)
[[3]](diffhunk://#diff-ac76cb897192140b4a87c2aed6f0741de1c49ce96aa22c45385c639ddd408d3aL42-R85)
[[4]](diffhunk://#diff-ac76cb897192140b4a87c2aed6f0741de1c49ce96aa22c45385c639ddd408d3aL98-R141)
[[5]](diffhunk://#diff-ac76cb897192140b4a87c2aed6f0741de1c49ce96aa22c45385c639ddd408d3aL154-R160)
[[6]](diffhunk://#diff-a6767ce2366447881f241f495e4c2472c269db4db906bb64b0d120cd6742f7f4L11-R85)
[[7]](diffhunk://#diff-56344cbdb586c128580c2fb36f2b1d40cba330f4e8589ae093ca6d3cd8e19f91R1-R46)
* Updated test assertions to compare field types and values using the
new field model, ensuring correctness of the new structure.
* Removed the legacy `Describe` method from `DecodedCall` and replaced
it with a new `String` method that uses the updated field model. The
actual rendering is now intended to be handled by dedicated renderer
classes.
[[1]](diffhunk://#diff-d3b59c27e8c4f64f8897bfc722028bb7ec8c39178c267fd8c87d37cded9b2d52L1-L51)
[[2]](diffhunk://#diff-56344cbdb586c128580c2fb36f2b1d40cba330f4e8589ae093ca6d3cd8e19f91R1-R46)
### CLI Output Format Support
* Added a `--format` flag to the MCMSv2 CLI `analyze-proposal` command,
allowing users to select between markdown and text output formats for
proposal analysis.
[[1]](diffhunk://#diff-726dd799d05204c24b69b8bda1f4ede5393c5955b360b076db8d11bc01f56a1bR713)
[[2]](diffhunk://#diff-726dd799d05204c24b69b8bda1f4ede5393c5955b360b076db8d11bc01f56a1bR766)
* Implemented the `createRendererFromFormat` helper function to
instantiate the appropriate renderer based on the requested format.
* Ensured the selected renderer is set in the proposal context before
analysis, enabling flexible output formatting.
### Test and Mock Updates
* Updated mock proposal context and related test utilities to support
the new renderer and field context APIs, maintaining test coverage and
compatibility with the refactored types.
---
These changes modernize the analyzer's internal data model, improve
output flexibility, and lay the groundwork for future enhancements in
transaction decoding and rendering.
0 commit comments