@@ -18,12 +18,14 @@ type ProposalDecoder interface {
1818
1919// legacyDecoder adapts the legacy experimental/analyzer package to the new decoder interface
2020type legacyDecoder struct {
21- proposalContext experimentalanalyzer.ProposalContext
21+ evmABIMappings map [string ]string
22+ solanaDecoders map [string ]experimentalanalyzer.DecodeInstructionFn
2223}
2324
2425// NewLegacyDecoder creates a decoder that wraps legacy experimental/analyzer decoding logic.
2526// Use functional options to configure:
26- // - WithProposalContext: provide a custom ProposalContext (otherwise default is created)
27+ // - WithEVMABIMappings: override proposal context EVM ABI mappings
28+ // - WithSolanaDecoders: override proposal context Solana decoder mappings
2729func NewLegacyDecoder (opts ... DecoderOption ) ProposalDecoder {
2830 decoder := & legacyDecoder {}
2931
@@ -37,11 +39,17 @@ func NewLegacyDecoder(opts ...DecoderOption) ProposalDecoder {
3739// DecoderOption is a functional option for configuring the decoder
3840type DecoderOption func (* legacyDecoder )
3941
40- // WithProposalContext injects a custom ProposalContext for decoding.
41- // If not provided, a default context will be created during decoding.
42- func WithProposalContext (ctx experimentalanalyzer.ProposalContext ) DecoderOption {
42+ // WithEVMABIMappings overrides the proposal context EVM ABI mappings used during decoding.
43+ func WithEVMABIMappings (mappings map [string ]string ) DecoderOption {
4344 return func (d * legacyDecoder ) {
44- d .proposalContext = ctx
45+ d .evmABIMappings = mappings
46+ }
47+ }
48+
49+ // WithSolanaDecoders overrides the proposal context Solana decoder mappings used during decoding.
50+ func WithSolanaDecoders (decoders map [string ]experimentalanalyzer.DecodeInstructionFn ) DecoderOption {
51+ return func (d * legacyDecoder ) {
52+ d .solanaDecoders = decoders
4553 }
4654}
4755
@@ -50,18 +58,12 @@ func (d *legacyDecoder) Decode(
5058 env deployment.Environment ,
5159 proposal * mcms.TimelockProposal ,
5260) (types.DecodedTimelockProposal , error ) {
53- // Create proposal context for legacy experimental analyzer
54- // Use the provided context if available, otherwise create a default one
55- var proposalCtx experimentalanalyzer.ProposalContext
56-
57- if d .proposalContext != nil {
58- proposalCtx = d .proposalContext
59- } else {
60- var err error
61- proposalCtx , err = experimentalanalyzer .NewDefaultProposalContext (env )
62- if err != nil {
63- return nil , fmt .Errorf ("failed to create proposal context: %w" , err )
64- }
61+ proposalCtx , err := experimentalanalyzer .NewDefaultProposalContext (env ,
62+ experimentalanalyzer .WithEVMABIMappings (d .evmABIMappings ),
63+ experimentalanalyzer .WithSolanaDecoders (d .solanaDecoders ),
64+ )
65+ if err != nil {
66+ return nil , fmt .Errorf ("failed to create proposal context: %w" , err )
6567 }
6668
6769 // Build the report using legacy experimental analyzer
0 commit comments