7
7
"errors"
8
8
"fmt"
9
9
"math/big"
10
- "reflect"
11
10
"slices"
12
11
"strconv"
13
12
"strings"
@@ -230,7 +229,7 @@ func (a *SolanaAccessor) convertCCIPMessageSent(logs []logpollertypes.Log, onram
230
229
// return nil, fmt.Errorf("failed to create type to decode event into: %w", err)
231
230
// }
232
231
// a.lggr.Debugf("created type to decode event into: %T", item)
233
- iter , err := a .decodeLogsIntoSequences (consts .EventNameCCIPMessageSent , logs , & ccip. EventCCIPMessageSent {} )
232
+ iter , err := a .decodeLogsIntoSequences (consts .EventNameCCIPMessageSent , logs )
234
233
if err != nil {
235
234
return nil , fmt .Errorf ("failed to decode logs into sequences: %w" , err )
236
235
}
@@ -332,7 +331,7 @@ func (a *SolanaAccessor) processCommitReports(
332
331
// if err != nil {
333
332
// return nil, fmt.Errorf("failed to create type to decode event into: %w", err)
334
333
// }
335
- iter , err := a .decodeLogsIntoSequences (consts .EventNameCommitReportAccepted , logs , & ccip. EventCommitReportAccepted {} )
334
+ iter , err := a .decodeLogsIntoSequences (consts .EventNameCommitReportAccepted , logs )
336
335
if err != nil {
337
336
return nil , fmt .Errorf ("failed to decode logs into sequences: %w" , err )
338
337
}
@@ -559,7 +558,7 @@ func (a *SolanaAccessor) processExecutionStateChangesEvents(logs []logpollertype
559
558
// if err != nil {
560
559
// return nil, fmt.Errorf("failed to create type to decode event into: %w", err)
561
560
// }
562
- iter , err := a .decodeLogsIntoSequences (consts .EventNameExecutionStateChanged , logs , & ccip. EventExecutionStateChanged {} )
561
+ iter , err := a .decodeLogsIntoSequences (consts .EventNameExecutionStateChanged , logs )
563
562
if err != nil {
564
563
return nil , fmt .Errorf ("failed to decode logs into sequences: %w" , err )
565
564
}
@@ -616,7 +615,6 @@ func validateExecutionStateChangedEvent(
616
615
func (a * SolanaAccessor ) decodeLogsIntoSequences (
617
616
event string ,
618
617
logs []logpollertypes.Log ,
619
- into any ,
620
618
) ([]types.Sequence , error ) {
621
619
sequences := make ([]types.Sequence , len (logs ))
622
620
@@ -630,29 +628,38 @@ func (a *SolanaAccessor) decodeLogsIntoSequences(
630
628
},
631
629
}
632
630
633
- var typeVal reflect.Value
631
+ // var typeVal reflect.Value
634
632
635
- typeInto := reflect .TypeOf (into )
636
- if typeInto .Kind () == reflect .Pointer {
637
- typeVal = reflect .New (typeInto .Elem ())
638
- } else {
639
- typeVal = reflect .Indirect (reflect .New (typeInto ))
640
- }
633
+ // typeInto := reflect.TypeOf(into)
634
+ // if typeInto.Kind() == reflect.Pointer {
635
+ // typeVal = reflect.New(typeInto.Elem())
636
+ // } else {
637
+ // typeVal = reflect.Indirect(reflect.New(typeInto))
638
+ // }
641
639
642
- // create a new value of the same type as 'into' for the data to be extracted to
643
- sequences [idx ].Data = typeVal .Interface ()
640
+ // // create a new value of the same type as 'into' for the data to be extracted to
641
+ // sequences[idx].Data = typeVal.Interface()
644
642
645
643
// if the event is `EventCommitReportAccepted`, we need to handle it separately
646
644
switch event {
647
645
case consts .EventNameCommitReportAccepted :
646
+ sequences [idx ].Data = ccip.EventCommitReportAccepted {}
648
647
derr := decodeCommitReportAcceptedEvent (logs [idx ].Data , & sequences [idx ].Data )
649
648
if derr != nil {
650
649
return nil , derr
651
650
}
652
- default :
651
+ case consts .EventNameCCIPMessageSent :
652
+ sequences [idx ].Data = ccip.EventCCIPMessageSent {}
653
653
if err := bin .UnmarshalBorsh (& sequences [idx ].Data , logs [idx ].Data ); err != nil {
654
654
return nil , err
655
655
}
656
+ case consts .EventNameExecutionStateChanged :
657
+ sequences [idx ].Data = ccip.EventExecutionStateChanged {}
658
+ if err := bin .UnmarshalBorsh (& sequences [idx ].Data , logs [idx ].Data ); err != nil {
659
+ return nil , err
660
+ }
661
+ default :
662
+ return nil , fmt .Errorf ("unsupported event %s" , event )
656
663
}
657
664
658
665
// if err := a.decodeLog(ctx, itemType, logs[idx], sequences[idx].Data); err != nil {
0 commit comments