-
Notifications
You must be signed in to change notification settings - Fork 3
feat: decouple rendering from intermediate decoded representation #541
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 11 commits
8ec0379
6acdf17
09b661b
684fdf4
1c8850b
b5efeb2
7dab720
2d53b5b
e40c113
6c44bd9
1d9961f
1a1dc6e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "chainlink-deployments-framework": minor | ||
| --- | ||
|
|
||
| refactor proposal analyzer to add a text renderer and move templates to seprate files | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -711,6 +711,7 @@ func buildMCMSv2AnalyzeProposalCmd( | |
| lggr logger.Logger, domain cldf_domain.Domain, proposalCtxProvider analyzer.ProposalContextProvider, | ||
| ) *cobra.Command { | ||
| var outputFile string | ||
| var format string | ||
|
|
||
| cmd := &cobra.Command{ | ||
| Use: "analyze-proposal", | ||
|
|
@@ -731,6 +732,10 @@ func buildMCMSv2AnalyzeProposalCmd( | |
| return errors.New("expected proposal to be have non-nil *TimelockProposal") | ||
| } | ||
|
|
||
| // Set renderer based on format flag | ||
| renderer := createRendererFromFormat(format) | ||
| cfgv2.proposalCtx.SetRenderer(renderer) | ||
|
|
||
| var analyzedProposal string | ||
| if cfgv2.timelockProposal != nil { | ||
| analyzedProposal, err = analyzer.DescribeTimelockProposal(cfgv2.proposalCtx, cfgv2.timelockProposal) | ||
|
|
@@ -759,6 +764,7 @@ func buildMCMSv2AnalyzeProposalCmd( | |
| }) | ||
|
|
||
| cmd.Flags().StringVarP(&outputFile, "output", "o", "", "Output file to write analyze result") | ||
| cmd.Flags().StringVar(&format, "format", "markdown", "Output format: markdown (default), text") | ||
|
|
||
| return cmd | ||
| } | ||
|
|
@@ -1602,3 +1608,17 @@ func addCallProxyOption( | |
|
|
||
| return fmt.Errorf("failed to find call proxy contract for timelock %v", timelockAddress) | ||
| } | ||
|
|
||
| // createRendererFromFormat creates an appropriate renderer based on the format string. | ||
| // Defaults to markdown renderer for unknown formats. | ||
| func createRendererFromFormat(format string) analyzer.Renderer { | ||
| switch format { | ||
| case "text", "txt": | ||
| return analyzer.NewTextRenderer() | ||
| case "markdown", "md": | ||
| return analyzer.NewMarkdownRenderer() | ||
| default: | ||
| // Default to markdown if format is not specified or invalid | ||
| return analyzer.NewMarkdownRenderer() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should return an error, rather than silently defaulting to
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (I'm ok with the default being markdown; it's just the |
||
| } | ||
| } | ||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| package analyzer | ||
|
|
||
| const ( | ||
| // Magic number constants | ||
| MinStructFieldsForPrettyFormat = 2 | ||
| MinDataLengthForMethodID = 4 | ||
| DefaultAnalyzersCount = 2 | ||
| ) | ||
|
|
||
| type DecodedCall struct { | ||
| Address string | ||
| Method string | ||
| Inputs []NamedField | ||
| Outputs []NamedField | ||
| } | ||
|
|
||
| // String renders a human-readable representation of the decoded call using the default text renderer. | ||
| // This method is kept for backwards compatibility but rendering should be done through renderers. | ||
| func (d *DecodedCall) String(context *FieldContext) string { | ||
| // Use the text renderer to provide proper formatting | ||
| renderer := NewTextRenderer() | ||
| return renderer.RenderDecodedCall(d, context) | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.