diff --git a/libraries/shared/factories/event/transformer.go b/libraries/shared/factories/event/transformer.go index bf178948..72a1ae90 100644 --- a/libraries/shared/factories/event/transformer.go +++ b/libraries/shared/factories/event/transformer.go @@ -20,7 +20,6 @@ import ( "github.com/ethereum/go-ethereum/core/types" log "github.com/sirupsen/logrus" - "github.com/vulcanize/vulcanizedb/libraries/shared/constants" "github.com/vulcanize/vulcanizedb/libraries/shared/transformer" "github.com/vulcanize/vulcanizedb/pkg/core" "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" @@ -37,7 +36,7 @@ func (transformer Transformer) NewTransformer(db *postgres.DB) transformer.Event return transformer } -func (transformer Transformer) Execute(logs []types.Log, header core.Header, recheckHeaders constants.TransformerExecution) error { +func (transformer Transformer) Execute(logs []types.Log, header core.Header) error { transformerName := transformer.Config.TransformerName config := transformer.Config diff --git a/libraries/shared/factories/event/transformer_test.go b/libraries/shared/factories/event/transformer_test.go index a5065611..086b6707 100644 --- a/libraries/shared/factories/event/transformer_test.go +++ b/libraries/shared/factories/event/transformer_test.go @@ -23,7 +23,6 @@ import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - "github.com/vulcanize/vulcanizedb/libraries/shared/constants" "github.com/vulcanize/vulcanizedb/libraries/shared/factories/event" "github.com/vulcanize/vulcanizedb/libraries/shared/mocks" "github.com/vulcanize/vulcanizedb/libraries/shared/test_data" @@ -60,14 +59,14 @@ var _ = Describe("Transformer", func() { }) It("marks header checked if no logs returned", func() { - err := t.Execute([]types.Log{}, headerOne, constants.HeaderMissing) + err := t.Execute([]types.Log{}, headerOne) Expect(err).NotTo(HaveOccurred()) repository.AssertMarkHeaderCheckedCalledWith(headerOne.Id) }) It("doesn't attempt to convert or persist an empty collection when there are no logs", func() { - err := t.Execute([]types.Log{}, headerOne, constants.HeaderMissing) + err := t.Execute([]types.Log{}, headerOne) Expect(err).NotTo(HaveOccurred()) Expect(converter.ToEntitiesCalledCounter).To(Equal(0)) @@ -76,7 +75,7 @@ var _ = Describe("Transformer", func() { }) It("does not call repository.MarkCheckedHeader when there are logs", func() { - err := t.Execute(logs, headerOne, constants.HeaderMissing) + err := t.Execute(logs, headerOne) Expect(err).NotTo(HaveOccurred()) repository.AssertMarkHeaderCheckedNotCalled() @@ -85,14 +84,14 @@ var _ = Describe("Transformer", func() { It("returns error if marking header checked returns err", func() { repository.SetMarkHeaderCheckedError(fakes.FakeError) - err := t.Execute([]types.Log{}, headerOne, constants.HeaderMissing) + err := t.Execute([]types.Log{}, headerOne) Expect(err).To(HaveOccurred()) Expect(err).To(MatchError(fakes.FakeError)) }) It("converts an eth log to an entity", func() { - err := t.Execute(logs, headerOne, constants.HeaderMissing) + err := t.Execute(logs, headerOne) Expect(err).NotTo(HaveOccurred()) Expect(converter.ContractAbi).To(Equal(config.ContractAbi)) @@ -102,7 +101,7 @@ var _ = Describe("Transformer", func() { It("returns an error if converter fails", func() { converter.ToEntitiesError = fakes.FakeError - err := t.Execute(logs, headerOne, constants.HeaderMissing) + err := t.Execute(logs, headerOne) Expect(err).To(HaveOccurred()) Expect(err).To(MatchError(fakes.FakeError)) @@ -111,7 +110,7 @@ var _ = Describe("Transformer", func() { It("converts an entity to a model", func() { converter.EntitiesToReturn = []interface{}{test_data.GenericEntity{}} - err := t.Execute(logs, headerOne, constants.HeaderMissing) + err := t.Execute(logs, headerOne) Expect(err).NotTo(HaveOccurred()) Expect(converter.EntitiesToConvert[0]).To(Equal(test_data.GenericEntity{})) @@ -121,7 +120,7 @@ var _ = Describe("Transformer", func() { converter.EntitiesToReturn = []interface{}{test_data.GenericEntity{}} converter.ToModelsError = fakes.FakeError - err := t.Execute(logs, headerOne, constants.HeaderMissing) + err := t.Execute(logs, headerOne) Expect(err).To(HaveOccurred()) Expect(err).To(MatchError(fakes.FakeError)) @@ -130,7 +129,7 @@ var _ = Describe("Transformer", func() { It("persists the record", func() { converter.ModelsToReturn = []interface{}{test_data.GenericModel{}} - err := t.Execute(logs, headerOne, constants.HeaderMissing) + err := t.Execute(logs, headerOne) Expect(err).NotTo(HaveOccurred()) Expect(repository.PassedHeaderID).To(Equal(headerOne.Id)) @@ -139,7 +138,7 @@ var _ = Describe("Transformer", func() { It("returns error if persisting the record fails", func() { repository.SetCreateError(fakes.FakeError) - err := t.Execute(logs, headerOne, constants.HeaderMissing) + err := t.Execute(logs, headerOne) Expect(err).To(HaveOccurred()) Expect(err).To(MatchError(fakes.FakeError)) diff --git a/libraries/shared/mocks/transformer.go b/libraries/shared/mocks/transformer.go index cf3e00e0..f7b01de3 100644 --- a/libraries/shared/mocks/transformer.go +++ b/libraries/shared/mocks/transformer.go @@ -19,7 +19,6 @@ package mocks import ( "github.com/ethereum/go-ethereum/core/types" - "github.com/vulcanize/vulcanizedb/libraries/shared/constants" shared_t "github.com/vulcanize/vulcanizedb/libraries/shared/transformer" "github.com/vulcanize/vulcanizedb/pkg/core" "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" @@ -33,7 +32,7 @@ type MockTransformer struct { config shared_t.EventTransformerConfig } -func (mh *MockTransformer) Execute(logs []types.Log, header core.Header, recheckHeaders constants.TransformerExecution) error { +func (mh *MockTransformer) Execute(logs []types.Log, header core.Header) error { if mh.ExecuteError != nil { return mh.ExecuteError } diff --git a/libraries/shared/transformer/event_transformer.go b/libraries/shared/transformer/event_transformer.go index c38b5454..7bf517ef 100644 --- a/libraries/shared/transformer/event_transformer.go +++ b/libraries/shared/transformer/event_transformer.go @@ -20,13 +20,12 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" - "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 + Execute(logs []types.Log, header core.Header) error GetConfig() EventTransformerConfig } diff --git a/libraries/shared/watcher/event_watcher.go b/libraries/shared/watcher/event_watcher.go index 1fd6afde..4c5d2958 100644 --- a/libraries/shared/watcher/event_watcher.go +++ b/libraries/shared/watcher/event_watcher.go @@ -134,7 +134,7 @@ func (watcher *EventWatcher) transformLogs(logs []types.Log, header core.Header) for _, t := range watcher.Transformers { transformerName := t.GetConfig().TransformerName logChunk := chunkedLogs[transformerName] - err := t.Execute(logChunk, header, constants.HeaderMissing) + err := t.Execute(logChunk, header) if err != nil { logrus.Errorf("%v transformer failed to execute in watcher: %v", transformerName, err) return err