@@ -18,7 +18,6 @@ package converter
18
18
19
19
import (
20
20
"encoding/json"
21
- "errors"
22
21
"fmt"
23
22
"math/big"
24
23
"strconv"
@@ -32,16 +31,19 @@ import (
32
31
"github.com/vulcanize/vulcanizedb/pkg/contract_watcher/shared/types"
33
32
)
34
33
34
+ // ConverterInterface is the interface for converting geth logs to our custom log type
35
35
type ConverterInterface interface {
36
36
Convert (logs []gethTypes.Log , event types.Event , headerID int64 ) ([]types.Log , error )
37
37
ConvertBatch (logs []gethTypes.Log , events map [string ]types.Event , headerID int64 ) (map [string ][]types.Log , error )
38
38
Update (info * contract.Contract )
39
39
}
40
40
41
+ // Converter is the underlying struct for the ConverterInterface
41
42
type Converter struct {
42
43
ContractInfo * contract.Contract
43
44
}
44
45
46
+ // Update is used to configure the converter with a specific contract
45
47
func (c * Converter ) Update (info * contract.Contract ) {
46
48
c .ContractInfo = info
47
49
}
@@ -98,7 +100,7 @@ func (c *Converter) Convert(logs []gethTypes.Log, event types.Event, headerID in
98
100
strValues [fieldName ] = converted .String ()
99
101
seenHashes = append (seenHashes , converted )
100
102
default :
101
- return nil , errors . New ( fmt .Sprintf ("error: unhandled abi type %T" , input ) )
103
+ return nil , fmt .Errorf ("error: unhandled abi type %T" , input )
102
104
}
103
105
}
104
106
@@ -114,7 +116,7 @@ func (c *Converter) Convert(logs []gethTypes.Log, event types.Event, headerID in
114
116
Values : strValues ,
115
117
Raw : raw ,
116
118
TransactionIndex : log .TxIndex ,
117
- Id : headerID ,
119
+ ID : headerID ,
118
120
})
119
121
120
122
// Cache emitted values if their caching is turned on
@@ -130,7 +132,7 @@ func (c *Converter) Convert(logs []gethTypes.Log, event types.Event, headerID in
130
132
return returnLogs , nil
131
133
}
132
134
133
- // Convert the given watched event logs into types.Logs; returns a map of event names to a slice of their converted logs
135
+ // ConvertBatch converts the given watched event logs into types.Logs; returns a map of event names to a slice of their converted logs
134
136
func (c * Converter ) ConvertBatch (logs []gethTypes.Log , events map [string ]types.Event , headerID int64 ) (map [string ][]types.Log , error ) {
135
137
boundContract := bind .NewBoundContract (common .HexToAddress (c .ContractInfo .Address ), c .ContractInfo .ParsedAbi , nil , nil , nil )
136
138
eventsToLogs := make (map [string ][]types.Log )
@@ -182,7 +184,7 @@ func (c *Converter) ConvertBatch(logs []gethTypes.Log, events map[string]types.E
182
184
strValues [fieldName ] = converted .String ()
183
185
seenHashes = append (seenHashes , converted )
184
186
default :
185
- return nil , errors . New ( fmt .Sprintf ("error: unhandled abi type %T" , input ) )
187
+ return nil , fmt .Errorf ("error: unhandled abi type %T" , input )
186
188
}
187
189
}
188
190
@@ -198,7 +200,7 @@ func (c *Converter) ConvertBatch(logs []gethTypes.Log, events map[string]types.E
198
200
Values : strValues ,
199
201
Raw : raw ,
200
202
TransactionIndex : log .TxIndex ,
201
- Id : headerID ,
203
+ ID : headerID ,
202
204
})
203
205
204
206
// Cache emitted values that pass the argument filter if their caching is turned on
0 commit comments