@@ -18,6 +18,7 @@ import (
1818
1919 "github.com/smartcontractkit/chainlink-sui/relayer/chainreader/database"
2020 "github.com/smartcontractkit/chainlink-sui/relayer/client"
21+ "github.com/smartcontractkit/chainlink-sui/relayer/common"
2122)
2223
2324type EventsIndexer struct {
@@ -158,55 +159,6 @@ func (eIndexer *EventsIndexer) SyncAllEvents(ctx context.Context) error {
158159 return nil
159160}
160161
161- // Converts snake_case to camelCase
162- func snakeToCamel (s string ) string {
163- parts := strings .Split (s , "_" )
164- for i := range parts {
165- if i > 0 && len (parts [i ]) > 0 {
166- parts [i ] = strings .ToUpper (string (parts [i ][0 ])) + parts [i ][1 :]
167- }
168- }
169-
170- return strings .Join (parts , "" )
171- }
172-
173- // Recursively convert all keys in the map to camelCase,
174- // with a special case for message.header.sequence_number → seqNum
175- func convertMapKeysToCamelCase (input any ) any {
176- return convertMapKeysToCamelCaseWithPath (input , "" )
177- }
178-
179- func convertMapKeysToCamelCaseWithPath (input any , path string ) any {
180- switch typed := input .(type ) {
181- case map [string ]any :
182- result := make (map [string ]any )
183- for k , v := range typed {
184- camelKey := snakeToCamel (k )
185- fullPath := path
186- if fullPath != "" {
187- fullPath += "." + camelKey
188- } else {
189- fullPath = camelKey
190- }
191-
192- if fullPath == "message.header.sequenceNumber" {
193- camelKey = "seqNum"
194- }
195-
196- result [camelKey ] = convertMapKeysToCamelCaseWithPath (v , fullPath )
197- }
198-
199- return result
200-
201- case []any :
202- for i , v := range typed {
203- typed [i ] = convertMapKeysToCamelCaseWithPath (v , path )
204- }
205- }
206-
207- return input
208- }
209-
210162func (eIndexer * EventsIndexer ) SyncEvent (ctx context.Context , selector * client.EventSelector ) error {
211163 if selector == nil {
212164 return fmt .Errorf ("unspecified selector for SyncEvent call" )
@@ -347,7 +299,7 @@ eventLoop:
347299 offset += uint64 (i ) + totalCount
348300
349301 // normalize the data, convert snake case to camel case
350- normalizedData := convertMapKeysToCamelCase (event .ParsedJson )
302+ normalizedData := common . ConvertMapKeysToCamelCase (event .ParsedJson )
351303
352304 // Convert the txDigest to hex
353305 txDigestHex := event .Id .TxDigest
@@ -375,6 +327,7 @@ eventLoop:
375327 // Sui returns block.Timestamp in ms; convert to seconds for consistency with CCIP readers.
376328 BlockTimestamp : block .Timestamp / 1000 ,
377329 Data : normalizedData .(map [string ]any ),
330+ IsSynthetic : false ,
378331 }
379332 batchRecords = append (batchRecords , record )
380333 }
0 commit comments