diff --git a/README.md b/README.md
index 3d36055f..5122e0ec 100644
--- a/README.md
+++ b/README.md
@@ -350,11 +350,11 @@ type exporter string
var Exporter exporter
-func (e exporter) Export() []interface1.TransformerInitializer, []interface1.StorageTransformerInitializer {
- return []interface1.TransformerInitializer{
- transformer1.TransformerInitializer,
- transformer2.TransformerInitializer,
- transformer3.TransformerInitializer,
+func (e exporter) Export() []interface1.EventTransformerInitializer, []interface1.StorageTransformerInitializer {
+ return []interface1.EventTransformerInitializer{
+ transformer1.EventTransformerInitializer,
+ transformer2.EventTransformerInitializer,
+ transformer3.EventTransformerInitializer,
}, []interface1.StorageTransformerInitializer{
transformer4.StorageTransformerInitializer,
}
@@ -365,7 +365,7 @@ func (e exporter) Export() []interface1.TransformerInitializer, []interface1.Sto
To plug in an external transformer we need to:
* Create a [package](https://github.com/vulcanize/ens_transformers/blob/working/transformers/registry/new_owner/initializer/initializer.go)
-that exports a variable `TransformerInitializer` or `StorageTransformerInitializer` that are of type [TransformerInitializer](https://github.com/vulcanize/maker-vulcanizedb/blob/staging/libraries/shared/transformer/event_transformer.go#L33)
+that exports a variable `EventTransformerInitializer` or `StorageTransformerInitializer` that are of type [EventTransformerInitializer](https://github.com/vulcanize/maker-vulcanizedb/blob/staging/libraries/shared/transformer/event_transformer.go#L33)
or [StorageTransformerInitializer](https://github.com/vulcanize/maker-vulcanizedb/blob/staging/libraries/shared/transformer/storage_transformer.go#L31), respectively
* Design the transformers to work in the context of their [event](https://github.com/vulcanize/maker-vulcanizedb/blob/staging/libraries/shared/watcher/event_watcher.go#L83)
or [storage](https://github.com/vulcanize/maker-vulcanizedb/blob/staging/libraries/shared/watcher/storage_watcher.go#L58) watcher execution modes
diff --git a/cmd/composeAndExecute.go b/cmd/composeAndExecute.go
index ad24cf55..aef951a3 100644
--- a/cmd/composeAndExecute.go
+++ b/cmd/composeAndExecute.go
@@ -149,7 +149,7 @@ func composeAndExecute() {
os.Exit(1)
}
- // Use the Exporters export method to load the TransformerInitializer and StorageTransformerInitializer sets
+ // Use the Exporters export method to load the EventTransformerInitializer and StorageTransformerInitializer sets
ethEventInitializers, ethStorageInitializers := exporter.Export()
// Setup bc and db objects
diff --git a/cmd/execute.go b/cmd/execute.go
index 861ab0ff..da4bea4e 100644
--- a/cmd/execute.go
+++ b/cmd/execute.go
@@ -99,7 +99,7 @@ func execute() {
os.Exit(1)
}
- // Use the Exporters export method to load the TransformerInitializer and StorageTransformerInitializer sets
+ // Use the Exporters export method to load the EventTransformerInitializer and StorageTransformerInitializer sets
ethEventInitializers, ethStorageInitializers := exporter.Export()
// Setup bc and db objects
@@ -132,12 +132,12 @@ func init() {
}
type Exporter interface {
- Export() ([]transformer.TransformerInitializer, []transformer.StorageTransformerInitializer)
+ Export() ([]transformer.EventTransformerInitializer, []transformer.StorageTransformerInitializer)
}
func watchEthEvents(w *watcher.EventWatcher, wg *syn.WaitGroup) {
defer wg.Done()
- // Execute over the TransformerInitializer set using the watcher
+ // Execute over the EventTransformerInitializer set using the watcher
log.Info("executing event transformers")
var recheck constants.TransformerExecution
if recheckHeadersArg {
@@ -157,7 +157,7 @@ func watchEthEvents(w *watcher.EventWatcher, wg *syn.WaitGroup) {
func watchEthStorage(w *watcher.StorageWatcher, wg *syn.WaitGroup) {
defer wg.Done()
- // Execute over the TransformerInitializer set using the watcher
+ // Execute over the StorageTransformerInitializer set using the watcher
log.Info("executing storage transformers")
ticker := time.NewTicker(pollingInterval)
defer ticker.Stop()
diff --git a/libraries/shared/chunker/log_chunker.go b/libraries/shared/chunker/log_chunker.go
index 06066ec2..87861ba4 100644
--- a/libraries/shared/chunker/log_chunker.go
+++ b/libraries/shared/chunker/log_chunker.go
@@ -26,7 +26,7 @@ import (
)
type Chunker interface {
- AddConfigs(transformerConfigs []shared_t.TransformerConfig)
+ AddConfigs(transformerConfigs []shared_t.EventTransformerConfig)
ChunkLogs(logs []types.Log) map[string][]types.Log
}
@@ -45,7 +45,7 @@ func NewLogChunker() *LogChunker {
}
// Configures the chunker by adding more addreses and topics to consider.
-func (chunker *LogChunker) AddConfigs(transformerConfigs []shared_t.TransformerConfig) {
+func (chunker *LogChunker) AddConfigs(transformerConfigs []shared_t.EventTransformerConfig) {
for _, config := range transformerConfigs {
for _, address := range config.ContractAddresses {
var lowerCaseAddress = strings.ToLower(address)
diff --git a/libraries/shared/chunker/log_chunker_test.go b/libraries/shared/chunker/log_chunker_test.go
index 2a1b9b7e..daf23a50 100644
--- a/libraries/shared/chunker/log_chunker_test.go
+++ b/libraries/shared/chunker/log_chunker_test.go
@@ -28,29 +28,29 @@ import (
var _ = Describe("Log chunker", func() {
var (
- configs []shared_t.TransformerConfig
+ configs []shared_t.EventTransformerConfig
chunker *chunk.LogChunker
)
BeforeEach(func() {
- configA := shared_t.TransformerConfig{
+ configA := shared_t.EventTransformerConfig{
TransformerName: "TransformerA",
ContractAddresses: []string{"0x00000000000000000000000000000000000000A1", "0x00000000000000000000000000000000000000A2"},
Topic: "0xA",
}
- configB := shared_t.TransformerConfig{
+ configB := shared_t.EventTransformerConfig{
TransformerName: "TransformerB",
ContractAddresses: []string{"0x00000000000000000000000000000000000000B1"},
Topic: "0xB",
}
- configC := shared_t.TransformerConfig{
+ configC := shared_t.EventTransformerConfig{
TransformerName: "TransformerC",
ContractAddresses: []string{"0x00000000000000000000000000000000000000A2"},
Topic: "0xC",
}
- configs = []shared_t.TransformerConfig{configA, configB, configC}
+ configs = []shared_t.EventTransformerConfig{configA, configB, configC}
chunker = chunk.NewLogChunker()
chunker.AddConfigs(configs)
})
@@ -73,24 +73,24 @@ var _ = Describe("Log chunker", func() {
Describe("AddConfigs", func() {
It("can add more configs later", func() {
- configD := shared_t.TransformerConfig{
+ configD := shared_t.EventTransformerConfig{
TransformerName: "TransformerD",
ContractAddresses: []string{"0x000000000000000000000000000000000000000D"},
Topic: "0xD",
}
- chunker.AddConfigs([]shared_t.TransformerConfig{configD})
+ chunker.AddConfigs([]shared_t.EventTransformerConfig{configD})
Expect(chunker.AddressToNames).To(ContainElement([]string{"TransformerD"}))
Expect(chunker.NameToTopic0).To(ContainElement(common.HexToHash("0xD")))
})
It("lower cases address", func() {
- configD := shared_t.TransformerConfig{
+ configD := shared_t.EventTransformerConfig{
TransformerName: "TransformerD",
ContractAddresses: []string{"0x000000000000000000000000000000000000000D"},
Topic: "0xD",
}
- chunker.AddConfigs([]shared_t.TransformerConfig{configD})
+ chunker.AddConfigs([]shared_t.EventTransformerConfig{configD})
Expect(chunker.AddressToNames["0x000000000000000000000000000000000000000d"]).To(Equal([]string{"TransformerD"}))
})
diff --git a/libraries/shared/factories/README.md b/libraries/shared/factories/event/README.md
similarity index 95%
rename from libraries/shared/factories/README.md
rename to libraries/shared/factories/event/README.md
index 87fc9162..0a1aa33c 100644
--- a/libraries/shared/factories/README.md
+++ b/libraries/shared/factories/event/README.md
@@ -28,8 +28,8 @@ Using the `compose` or `composeAndExecute` command, event watchers can be loaded
The event transformer is responsible for converting event logs into more useful data objects and storing them in Postgres.
The event transformer is composed of converter and repository interfaces and a config struct:
```go
-type Transformer struct {
- Config transformer.TransformerConfig
+type EventTransformer struct {
+ Config transformer.EventTransformerConfig
Converter Converter
Repository Repository
}
@@ -86,7 +86,7 @@ In order to watch events at a smart contract, for those events the developer mus
1. Model - struct representing the final data model we want to write to Postgres.
1. Converter - an interface which can unpack event logs into our entities and convert those entities to our models.
1. Repository - an interface to write our models to Postgres.
-1. TransformerInitializer - a public variable which exports our configured transformer to be loaded as part of a plugin.
+1. EventTransformerInitializer - a public variable which exports our configured transformer to be loaded as part of a plugin.
1. DB migrations - migrations to generate the Postgres schema, tables, views, function, etc that are needed to store and interface with the transformed data models.
The example event we will use looks like:
@@ -101,7 +101,7 @@ it is working at, the contract's ABI, the topic (e.g. event signature; topic0) t
and ending block numbers.
```go
-type TransformerConfig struct {
+type EventTransformerConfig struct {
TransformerName string
ContractAddresses []string
ContractAbi string
@@ -318,14 +318,14 @@ func (repository ExampleRepository) RecheckHeaders(startingBlockNumber int64, en
}
```
-### TransformerInitializer
+### EventTransformerInitializer
A transformer initializer variable needs to be exported from somewhere within the transformer repository so that the transformer can be
-loaded as part of a plugin in the `compose` or `composeAndExecute` commands. It is important that this variable is named `TransformerInitializer` and
-it must be of `type TransformerInitializer func(db *postgres.DB) EventTransformer`.
+loaded as part of a plugin in the `compose` or `composeAndExecute` commands. It is important that this variable is named `EventTransformerInitializer` and
+it must be of `type EventTransformerInitializer func(db *postgres.DB) EventTransformer`.
```go
-var TransformerInitializer transformer.TransformerInitializer = factories.Transformer{
+var EventTransformerInitializer transformer.EventTransformerInitializer = factories.Transformer{
Config: exampleEventConfig,
Converter: ExampleConverter{},
Repository: &ExampleRepository{},
@@ -384,5 +384,5 @@ of which headers we have already filtered through for this event.
To create a transformer for a contract event we need to create entities for unpacking the raw log, models to represent
the final data structure, a converter to mediate this unpacking and conversion between entities to models, a repository to write
-these models to Postgres, db migrations to accommodate these models in Postgres, and a TransformerInitializer to export the
+these models to Postgres, db migrations to accommodate these models in Postgres, and a EventTransformerInitializer to export the
configured transformer and load it as a plugin to the `compose` or `composeAndExecute` commands as described in the [main readme](https://github.com/vulcanize/maker-vulcanizedb/blob/staging/README.md#composeandexecute-configuration).
diff --git a/libraries/shared/factories/converter.go b/libraries/shared/factories/event/converter.go
similarity index 98%
rename from libraries/shared/factories/converter.go
rename to libraries/shared/factories/event/converter.go
index 631a27f4..4fb647f2 100644
--- a/libraries/shared/factories/converter.go
+++ b/libraries/shared/factories/event/converter.go
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see .
-package factories
+package event
import "github.com/ethereum/go-ethereum/core/types"
diff --git a/libraries/shared/factories/factories_suite_test.go b/libraries/shared/factories/event/factories_suite_test.go
similarity index 97%
rename from libraries/shared/factories/factories_suite_test.go
rename to libraries/shared/factories/event/factories_suite_test.go
index c90b0fb1..f2687b75 100644
--- a/libraries/shared/factories/factories_suite_test.go
+++ b/libraries/shared/factories/event/factories_suite_test.go
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see .
-package factories_test
+package event_test
import (
"testing"
diff --git a/libraries/shared/factories/log_note_converter.go b/libraries/shared/factories/event/log_note_converter.go
similarity index 97%
rename from libraries/shared/factories/log_note_converter.go
rename to libraries/shared/factories/event/log_note_converter.go
index 9229a082..3b18c46c 100644
--- a/libraries/shared/factories/log_note_converter.go
+++ b/libraries/shared/factories/event/log_note_converter.go
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see .
-package factories
+package event
import "github.com/ethereum/go-ethereum/core/types"
diff --git a/libraries/shared/factories/log_note_transformer.go b/libraries/shared/factories/event/log_note_transformer.go
similarity index 93%
rename from libraries/shared/factories/log_note_transformer.go
rename to libraries/shared/factories/event/log_note_transformer.go
index a53bcf68..2b4699b6 100644
--- a/libraries/shared/factories/log_note_transformer.go
+++ b/libraries/shared/factories/event/log_note_transformer.go
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see .
-package factories
+package event
import (
"github.com/ethereum/go-ethereum/core/types"
@@ -27,7 +27,7 @@ import (
)
type LogNoteTransformer struct {
- Config transformer.TransformerConfig
+ Config transformer.EventTransformerConfig
Converter LogNoteConverter
Repository Repository
}
@@ -68,6 +68,6 @@ func (tr LogNoteTransformer) GetName() string {
return tr.Config.TransformerName
}
-func (tr LogNoteTransformer) GetConfig() transformer.TransformerConfig {
+func (tr LogNoteTransformer) GetConfig() transformer.EventTransformerConfig {
return tr.Config
}
diff --git a/libraries/shared/factories/log_note_transformer_test.go b/libraries/shared/factories/event/log_note_transformer_test.go
similarity index 97%
rename from libraries/shared/factories/log_note_transformer_test.go
rename to libraries/shared/factories/event/log_note_transformer_test.go
index cb084044..efc36d34 100644
--- a/libraries/shared/factories/log_note_transformer_test.go
+++ b/libraries/shared/factories/event/log_note_transformer_test.go
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see .
-package factories_test
+package event_test
import (
"math/rand"
@@ -24,7 +24,7 @@ import (
. "github.com/onsi/gomega"
"github.com/vulcanize/vulcanizedb/libraries/shared/constants"
- "github.com/vulcanize/vulcanizedb/libraries/shared/factories"
+ "github.com/vulcanize/vulcanizedb/libraries/shared/factories/event"
"github.com/vulcanize/vulcanizedb/libraries/shared/mocks"
"github.com/vulcanize/vulcanizedb/libraries/shared/test_data"
"github.com/vulcanize/vulcanizedb/libraries/shared/transformer"
@@ -46,7 +46,7 @@ var _ = Describe("LogNoteTransformer", func() {
BeforeEach(func() {
repository = mocks.MockRepository{}
converter = mocks.MockLogNoteConverter{}
- t = factories.LogNoteTransformer{
+ t = event.LogNoteTransformer{
Config: config,
Converter: &converter,
Repository: &repository,
diff --git a/libraries/shared/factories/repository.go b/libraries/shared/factories/event/repository.go
similarity index 98%
rename from libraries/shared/factories/repository.go
rename to libraries/shared/factories/event/repository.go
index e2ea8d46..e1d6e403 100644
--- a/libraries/shared/factories/repository.go
+++ b/libraries/shared/factories/event/repository.go
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see .
-package factories
+package event
import (
"github.com/vulcanize/vulcanizedb/pkg/core"
diff --git a/libraries/shared/factories/transformer.go b/libraries/shared/factories/event/transformer.go
similarity index 94%
rename from libraries/shared/factories/transformer.go
rename to libraries/shared/factories/event/transformer.go
index c0a74062..bf178948 100644
--- a/libraries/shared/factories/transformer.go
+++ b/libraries/shared/factories/event/transformer.go
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see .
-package factories
+package event
import (
"github.com/ethereum/go-ethereum/core/types"
@@ -27,7 +27,7 @@ import (
)
type Transformer struct {
- Config transformer.TransformerConfig
+ Config transformer.EventTransformerConfig
Converter Converter
Repository Repository
}
@@ -75,6 +75,6 @@ func (transformer Transformer) GetName() string {
return transformer.Config.TransformerName
}
-func (transformer Transformer) GetConfig() transformer.TransformerConfig {
+func (transformer Transformer) GetConfig() transformer.EventTransformerConfig {
return transformer.Config
}
diff --git a/libraries/shared/factories/transformer_test.go b/libraries/shared/factories/event/transformer_test.go
similarity index 97%
rename from libraries/shared/factories/transformer_test.go
rename to libraries/shared/factories/event/transformer_test.go
index 198fed89..a5065611 100644
--- a/libraries/shared/factories/transformer_test.go
+++ b/libraries/shared/factories/event/transformer_test.go
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see .
-package factories_test
+package event_test
import (
"math/rand"
@@ -24,7 +24,7 @@ import (
. "github.com/onsi/gomega"
"github.com/vulcanize/vulcanizedb/libraries/shared/constants"
- "github.com/vulcanize/vulcanizedb/libraries/shared/factories"
+ "github.com/vulcanize/vulcanizedb/libraries/shared/factories/event"
"github.com/vulcanize/vulcanizedb/libraries/shared/mocks"
"github.com/vulcanize/vulcanizedb/libraries/shared/test_data"
"github.com/vulcanize/vulcanizedb/libraries/shared/transformer"
@@ -46,7 +46,7 @@ var _ = Describe("Transformer", func() {
repository = mocks.MockRepository{}
converter = mocks.MockConverter{}
- t = factories.Transformer{
+ t = event.Transformer{
Repository: &repository,
Converter: &converter,
Config: config,
diff --git a/libraries/shared/mocks/transformer.go b/libraries/shared/mocks/transformer.go
index fef302d1..cf3e00e0 100644
--- a/libraries/shared/mocks/transformer.go
+++ b/libraries/shared/mocks/transformer.go
@@ -30,7 +30,7 @@ type MockTransformer struct {
ExecuteError error
PassedLogs []types.Log
PassedHeader core.Header
- config shared_t.TransformerConfig
+ config shared_t.EventTransformerConfig
}
func (mh *MockTransformer) Execute(logs []types.Log, header core.Header, recheckHeaders constants.TransformerExecution) error {
@@ -43,11 +43,11 @@ func (mh *MockTransformer) Execute(logs []types.Log, header core.Header, recheck
return nil
}
-func (mh *MockTransformer) GetConfig() shared_t.TransformerConfig {
+func (mh *MockTransformer) GetConfig() shared_t.EventTransformerConfig {
return mh.config
}
-func (mh *MockTransformer) SetTransformerConfig(config shared_t.TransformerConfig) {
+func (mh *MockTransformer) SetTransformerConfig(config shared_t.EventTransformerConfig) {
mh.config = config
}
@@ -55,7 +55,7 @@ func (mh *MockTransformer) FakeTransformerInitializer(db *postgres.DB) shared_t.
return mh
}
-var FakeTransformerConfig = shared_t.TransformerConfig{
+var FakeTransformerConfig = shared_t.EventTransformerConfig{
TransformerName: "FakeTransformer",
ContractAddresses: []string{"FakeAddress"},
Topic: "FakeTopic",
diff --git a/libraries/shared/test_data/generic.go b/libraries/shared/test_data/generic.go
index 12b79a27..eb68f03a 100644
--- a/libraries/shared/test_data/generic.go
+++ b/libraries/shared/test_data/generic.go
@@ -39,7 +39,7 @@ var GenericTestLogs = []types.Log{{
BlockNumber: uint64(startingBlockNumber),
}}
-var GenericTestConfig = transformer.TransformerConfig{
+var GenericTestConfig = transformer.EventTransformerConfig{
TransformerName: "generic-test-transformer",
ContractAddresses: []string{address},
ContractAbi: randomString(100),
diff --git a/libraries/shared/transformer/event_transformer.go b/libraries/shared/transformer/event_transformer.go
index 6fd43fa4..c38b5454 100644
--- a/libraries/shared/transformer/event_transformer.go
+++ b/libraries/shared/transformer/event_transformer.go
@@ -19,20 +19,20 @@ package transformer
import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
- "github.com/vulcanize/vulcanizedb/pkg/core"
"github.com/vulcanize/vulcanizedb/libraries/shared/constants"
+ "github.com/vulcanize/vulcanizedb/pkg/core"
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
)
type EventTransformer interface {
Execute(logs []types.Log, header core.Header, recheckHeaders constants.TransformerExecution) error
- GetConfig() TransformerConfig
+ GetConfig() EventTransformerConfig
}
-type TransformerInitializer func(db *postgres.DB) EventTransformer
+type EventTransformerInitializer func(db *postgres.DB) EventTransformer
-type TransformerConfig struct {
+type EventTransformerConfig struct {
TransformerName string
ContractAddresses []string
ContractAbi string
diff --git a/libraries/shared/watcher/event_watcher.go b/libraries/shared/watcher/event_watcher.go
index aae76b3b..cdb2561f 100644
--- a/libraries/shared/watcher/event_watcher.go
+++ b/libraries/shared/watcher/event_watcher.go
@@ -52,10 +52,10 @@ func NewEventWatcher(db *postgres.DB, bc core.BlockChain) EventWatcher {
}
// Adds transformers to the watcher and updates the chunker, so that it will consider the new transformers.
-func (watcher *EventWatcher) AddTransformers(initializers []transformer.TransformerInitializer) {
+func (watcher *EventWatcher) AddTransformers(initializers []transformer.EventTransformerInitializer) {
var contractAddresses []common.Address
var topic0s []common.Hash
- var configs []transformer.TransformerConfig
+ var configs []transformer.EventTransformerConfig
for _, initializer := range initializers {
t := initializer(watcher.DB)
diff --git a/libraries/shared/watcher/event_watcher_test.go b/libraries/shared/watcher/event_watcher_test.go
index 84487d9d..41b43372 100644
--- a/libraries/shared/watcher/event_watcher_test.go
+++ b/libraries/shared/watcher/event_watcher_test.go
@@ -52,7 +52,7 @@ var _ = Describe("Watcher", func() {
w := watcher.NewEventWatcher(nil, nil)
fakeTransformer := &mocks.MockTransformer{}
fakeTransformer.SetTransformerConfig(mocks.FakeTransformerConfig)
- w.AddTransformers([]transformer.TransformerInitializer{fakeTransformer.FakeTransformerInitializer})
+ w.AddTransformers([]transformer.EventTransformerInitializer{fakeTransformer.FakeTransformerInitializer})
Expect(len(w.Transformers)).To(Equal(1))
Expect(w.Transformers).To(ConsistOf(fakeTransformer))
@@ -68,8 +68,8 @@ var _ = Describe("Watcher", func() {
fakeTransformer2 := &mocks.MockTransformer{}
fakeTransformer2.SetTransformerConfig(mocks.FakeTransformerConfig)
- w.AddTransformers([]transformer.TransformerInitializer{fakeTransformer1.FakeTransformerInitializer})
- w.AddTransformers([]transformer.TransformerInitializer{fakeTransformer2.FakeTransformerInitializer})
+ w.AddTransformers([]transformer.EventTransformerInitializer{fakeTransformer1.FakeTransformerInitializer})
+ w.AddTransformers([]transformer.EventTransformerInitializer{fakeTransformer2.FakeTransformerInitializer})
Expect(len(w.Transformers)).To(Equal(2))
Expect(w.Topics).To(Equal([]common.Hash{common.HexToHash("FakeTopic"),
@@ -80,13 +80,13 @@ var _ = Describe("Watcher", func() {
It("calculates earliest starting block number", func() {
fakeTransformer1 := &mocks.MockTransformer{}
- fakeTransformer1.SetTransformerConfig(transformer.TransformerConfig{StartingBlockNumber: 5})
+ fakeTransformer1.SetTransformerConfig(transformer.EventTransformerConfig{StartingBlockNumber: 5})
fakeTransformer2 := &mocks.MockTransformer{}
- fakeTransformer2.SetTransformerConfig(transformer.TransformerConfig{StartingBlockNumber: 3})
+ fakeTransformer2.SetTransformerConfig(transformer.EventTransformerConfig{StartingBlockNumber: 3})
w := watcher.NewEventWatcher(nil, nil)
- w.AddTransformers([]transformer.TransformerInitializer{
+ w.AddTransformers([]transformer.EventTransformerInitializer{
fakeTransformer1.FakeTransformerInitializer,
fakeTransformer2.FakeTransformerInitializer,
})
@@ -123,7 +123,7 @@ var _ = Describe("Watcher", func() {
It("executes each transformer", func() {
fakeTransformer := &mocks.MockTransformer{}
- w.AddTransformers([]transformer.TransformerInitializer{fakeTransformer.FakeTransformerInitializer})
+ w.AddTransformers([]transformer.EventTransformerInitializer{fakeTransformer.FakeTransformerInitializer})
repository.SetMissingHeaders([]core.Header{fakes.FakeHeader})
err := w.Execute(constants.HeaderMissing)
@@ -133,7 +133,7 @@ var _ = Describe("Watcher", func() {
It("returns an error if transformer returns an error", func() {
fakeTransformer := &mocks.MockTransformer{ExecuteError: errors.New("Something bad happened")}
- w.AddTransformers([]transformer.TransformerInitializer{fakeTransformer.FakeTransformerInitializer})
+ w.AddTransformers([]transformer.EventTransformerInitializer{fakeTransformer.FakeTransformerInitializer})
repository.SetMissingHeaders([]core.Header{fakes.FakeHeader})
err := w.Execute(constants.HeaderMissing)
@@ -145,10 +145,10 @@ var _ = Describe("Watcher", func() {
transformerA := &mocks.MockTransformer{}
transformerB := &mocks.MockTransformer{}
- configA := transformer.TransformerConfig{TransformerName: "transformerA",
+ configA := transformer.EventTransformerConfig{TransformerName: "transformerA",
ContractAddresses: []string{"0x000000000000000000000000000000000000000A"},
Topic: "0xA"}
- configB := transformer.TransformerConfig{TransformerName: "transformerB",
+ configB := transformer.EventTransformerConfig{TransformerName: "transformerB",
ContractAddresses: []string{"0x000000000000000000000000000000000000000b"},
Topic: "0xB"}
@@ -163,7 +163,7 @@ var _ = Describe("Watcher", func() {
repository.SetMissingHeaders([]core.Header{fakes.FakeHeader})
w = watcher.NewEventWatcher(db, &mockBlockChain)
- w.AddTransformers([]transformer.TransformerInitializer{
+ w.AddTransformers([]transformer.EventTransformerInitializer{
transformerA.FakeTransformerInitializer, transformerB.FakeTransformerInitializer})
err := w.Execute(constants.HeaderMissing)
@@ -182,9 +182,9 @@ var _ = Describe("Watcher", func() {
It("fetches logs for added transformers", func() {
addresses := []string{"0xA", "0xB"}
topic := "0x1"
- fakeTransformer.SetTransformerConfig(transformer.TransformerConfig{
+ fakeTransformer.SetTransformerConfig(transformer.EventTransformerConfig{
Topic: topic, ContractAddresses: addresses})
- w.AddTransformers([]transformer.TransformerInitializer{fakeTransformer.FakeTransformerInitializer})
+ w.AddTransformers([]transformer.EventTransformerInitializer{fakeTransformer.FakeTransformerInitializer})
err := w.Execute(constants.HeaderMissing)
Expect(err).NotTo(HaveOccurred())
@@ -201,7 +201,7 @@ var _ = Describe("Watcher", func() {
fetcherError := errors.New("FetcherError")
mockBlockChain.SetGetEthLogsWithCustomQueryErr(fetcherError)
- w.AddTransformers([]transformer.TransformerInitializer{fakeTransformer.FakeTransformerInitializer})
+ w.AddTransformers([]transformer.EventTransformerInitializer{fakeTransformer.FakeTransformerInitializer})
err := w.Execute(constants.HeaderMissing)
Expect(err).To(MatchError(fetcherError))
})
diff --git a/pkg/plugin/writer/writer.go b/pkg/plugin/writer/writer.go
index 155bcb8b..6c0b4ffd 100644
--- a/pkg/plugin/writer/writer.go
+++ b/pkg/plugin/writer/writer.go
@@ -72,12 +72,12 @@ func (w *writer) WritePlugin() error {
f.Type().Id("exporter").String()
f.Var().Id("Exporter").Id("exporter")
f.Func().Params(Id("e").Id("exporter")).Id("Export").Params().Parens(List(
- Index().Qual("github.com/vulcanize/vulcanizedb/libraries/shared/transformer", "TransformerInitializer"),
+ Index().Qual("github.com/vulcanize/vulcanizedb/libraries/shared/transformer", "EventTransformerInitializer"),
Index().Qual("github.com/vulcanize/vulcanizedb/libraries/shared/transformer", "StorageTransformerInitializer"),
)).Block(Return(
Index().Qual(
"github.com/vulcanize/vulcanizedb/libraries/shared/transformer",
- "TransformerInitializer").Values(code[config.EthEvent]...),
+ "EventTransformerInitializer").Values(code[config.EthEvent]...),
Index().Qual(
"github.com/vulcanize/vulcanizedb/libraries/shared/transformer",
"StorageTransformerInitializer").Values(code[config.EthStorage]...))) // Exports the collected event and storage transformer initializers
@@ -97,7 +97,7 @@ func (w *writer) collectTransformers() (map[config.TransformerType][]Code, error
path := transformer.RepositoryPath + "/" + transformer.Path
switch transformer.Type {
case config.EthEvent:
- code[config.EthEvent] = append(code[config.EthEvent], Qual(path, "TransformerInitializer"))
+ code[config.EthEvent] = append(code[config.EthEvent], Qual(path, "EventTransformerInitializer"))
case config.EthStorage:
code[config.EthStorage] = append(code[config.EthStorage], Qual(path, "StorageTransformerInitializer"))
default: