diff --git a/.travis.yml b/.travis.yml index b00ed01f..5467285b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,7 +12,8 @@ addons: go_import_path: github.com/vulcanize/vulcanizedb before_install: - # ginkgo golint dep goose + # ginkgo golint dep migrate + - echo -e "Host github.com\n\tHostName github.com\n\tUser git\n\tIdentityFile ~/.ssh/id_rsa\n" >> ~/.ssh/config - make installtools - bash ./scripts/install-postgres-10.sh - npm install -g ganache-cli @@ -25,7 +26,7 @@ before_script: - sudo -u postgres createdb vulcanize_private - make version_migrations - make migrate NAME=vulcanize_private - - bash ./pkg/transformers/start_test_chain.sh + - bash ./scripts/start_test_chain.sh - cd postgraphile && yarn script: @@ -38,5 +39,6 @@ notifications: email: false after_script: - - bash ./pkg/transformers/stop_test_chain.sh + - bash ./scripts/stop_test_chain.sh - bash ./bin/deploy.sh + diff --git a/Makefile b/Makefile index 12ebbf20..d3ef32c4 100644 --- a/Makefile +++ b/Makefile @@ -48,16 +48,15 @@ lint: .PHONY: test test: | $(GINKGO) $(LINT) - go get -t ./... go vet ./... go fmt ./... - $(GINKGO) -r --skipPackage=integration_tests,integration + $(GINKGO) -r .PHONY: integrationtest integrationtest: | $(GINKGO) $(LINT) go vet ./... go fmt ./... - $(GINKGO) -r pkg/transformers/integration_tests/ integration_test/ + $(GINKGO) -r integration_test/ .PHONY: dep dep: | $(DEP) diff --git a/cmd/composeAndExecute.go b/cmd/composeAndExecute.go index e0d1b18b..7201fb78 100644 --- a/cmd/composeAndExecute.go +++ b/cmd/composeAndExecute.go @@ -23,6 +23,7 @@ import ( "time" "github.com/spf13/cobra" + "github.com/spf13/viper" "github.com/vulcanize/vulcanizedb/libraries/shared/transformer" "github.com/vulcanize/vulcanizedb/libraries/shared/watcher" @@ -47,8 +48,7 @@ var composeAndExecuteCmd = &cobra.Command{ ipcPath = "http://kovan0.vulcanize.io:8545" [exporter] - filePath = "$GOPATH/src/github.com/vulcanize/vulcanizedb/plugins/" - fileName = "exporter" + name = "exporter" [exporter.transformers] transformer1 = "github.com/path/to/transformer1" transformer2 = "github.com/path/to/transformer2" @@ -75,9 +75,20 @@ loaded into and executed over by a generic watcher`, func composeAndExecute() { // generate code to build the plugin according to the config file + autogenConfig = autogen.Config{ + FilePath: "$GOPATH/src/github.com/vulcanize/vulcanizedb/plugins", + FileName: viper.GetString("exporter.name"), + Save: viper.GetBool("exporter.save"), + Initializers: viper.GetStringMapString("exporter.transformers"), + Dependencies: viper.GetStringMapString("exporter.repositories"), + Migrations: viper.GetStringMapString("exporter.migrations"), + } + + fmt.Println("generating plugin") generator := autogen.NewGenerator(autogenConfig, databaseConfig) err := generator.GenerateExporterPlugin() if err != nil { + fmt.Println("generating plugin failed") log.Fatal(err) } @@ -86,14 +97,21 @@ func composeAndExecute() { if err != nil { log.Fatal(err) } + if !autogenConfig.Save { + defer utils.ClearFiles(pluginPath) + } + fmt.Println("opening plugin") plug, err := plugin.Open(pluginPath) if err != nil { + fmt.Println("opening pluggin failed") log.Fatal(err) } // Load the `Exporter` symbol from the plugin + fmt.Println("loading transformers from plugin") symExporter, err := plug.Lookup("Exporter") if err != nil { + fmt.Println("loading Exporter symbol failed") log.Fatal(err) } @@ -116,6 +134,7 @@ func composeAndExecute() { w.AddTransformers(initializers) // Execute over the TransformerInitializer set using the watcher + fmt.Println("executing transformers") ticker := time.NewTicker(pollingInterval) defer ticker.Stop() for range ticker.C { diff --git a/cmd/getSignatures.go b/cmd/getSignatures.go deleted file mode 100644 index a03a2e28..00000000 --- a/cmd/getSignatures.go +++ /dev/null @@ -1,74 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package cmd - -import ( - "fmt" - "github.com/spf13/cobra" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" -) - -// getSignaturesCmd represents the getSignatures command -var getSignaturesCmd = &cobra.Command{ - Use: "getSignatures", - Short: "A command to see transformer method and event signatures", - Long: `A convenience command to see method/event signatures for Maker transformers -vulcanizedb getSignatures`, - Run: func(cmd *cobra.Command, args []string) { - getSignatures() - }, -} - -func getSignatures() { - signatures := make(map[string]string) - signatures["BiteSignature"] = constants.GetBiteSignature() - signatures["CatFileChopLumpSignature"] = constants.GetCatFileChopLumpSignature() - signatures["CatFileFlipSignature"] = constants.GetCatFileFlipSignature() - signatures["CatFilePitVowSignature"] = constants.GetCatFilePitVowSignature() - signatures["DealSignature"] = constants.GetDealSignature() - signatures["DentFunctionSignature"] = constants.GetDentFunctionSignature() - signatures["DripDripSignature"] = constants.GetDripDripSignature() - signatures["DripFileIlkSignature"] = constants.GetDripFileIlkSignature() - signatures["DripFileRepoSignature"] = constants.GetDripFileRepoSignature() - signatures["DripFileVowSignature"] = constants.GetDripFileVowSignature() - signatures["FlapKickSignature"] = constants.GetFlapKickSignature() - signatures["FlipKickSignature"] = constants.GetFlipKickSignature() - signatures["FlopKickSignature"] = constants.GetFlopKickSignature() - signatures["FrobSignature"] = constants.GetFrobSignature() - signatures["LogValueSignature"] = constants.GetLogValueSignature() - signatures["PitFileDebtCeilingSignature"] = constants.GetPitFileDebtCeilingSignature() - signatures["PitFileIlkSignature"] = constants.GetPitFileIlkSignature() - signatures["TendFunctionSignature"] = constants.GetTendFunctionSignature() - signatures["VatFluxSignature"] = constants.GetVatFluxSignature() - signatures["VatFoldSignature"] = constants.GetVatFoldSignature() - signatures["VatGrabSignature"] = constants.GetVatGrabSignature() - signatures["VatHealSignature"] = constants.GetVatHealSignature() - signatures["VatInitSignature"] = constants.GetVatInitSignature() - signatures["VatMoveSignature"] = constants.GetVatMoveSignature() - signatures["VatSlipSignature"] = constants.GetVatSlipSignature() - signatures["VatTollSignature"] = constants.GetVatTollSignature() - signatures["VatTuneSignature"] = constants.GetVatTuneSignature() - signatures["VowFlogSignature"] = constants.GetVowFlogSignature() - - for name, sig := range signatures { - fmt.Println(name, ": ", sig) - } -} - -func init() { - rootCmd.AddCommand(getSignaturesCmd) -} diff --git a/cmd/root.go b/cmd/root.go index 8e2e0a74..77c75f17 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -55,7 +55,7 @@ const ( var rootCmd = &cobra.Command{ Use: "vulcanizedb", - PersistentPreRun: configure, + PersistentPreRun: database, } func Execute() { @@ -65,7 +65,7 @@ func Execute() { } } -func configure(cmd *cobra.Command, args []string) { +func database(cmd *cobra.Command, args []string) { ipc = viper.GetString("client.ipcpath") levelDbPath = viper.GetString("client.leveldbpath") storageDiffsPath = viper.GetString("filesystem.storageDiffsPath") @@ -76,13 +76,6 @@ func configure(cmd *cobra.Command, args []string) { User: viper.GetString("database.user"), Password: viper.GetString("database.password"), } - autogenConfig = autogen.Config{ - FilePath: viper.GetString("exporter.filePath"), - FileName: viper.GetString("exporter.fileName"), - Initializers: viper.GetStringMapString("exporter.transformers"), - Dependencies: viper.GetStringMapString("exporter.repositories"), - Migrations: viper.GetStringMapString("exporter.migrations"), - } viper.Set("database.config", databaseConfig) } diff --git a/environments/compose.toml b/environments/compose.toml index 3d760048..ae84d490 100644 --- a/environments/compose.toml +++ b/environments/compose.toml @@ -12,8 +12,8 @@ name = "maker_vdb_staging" [exporter] - filePath = "$GOPATH/src/github.com/vulcanize/vulcanizedb/plugins/" - fileName = "exporter" + name = "exporter" + save = false [exporter.transformers] bite = "github.com/vulcanize/mcd_transformers/transformers/bite" cat_chop_lump = "github.com/vulcanize/mcd_transformers/transformers/cat_file/chop_lump" @@ -45,8 +45,6 @@ vow_flog = "github.com/vulcanize/mcd_transformers/transformers/vow_flog" [exporter.repositories] mcd_transformers = "github.com/vulcanize/mcd_transformers" - [exporter.migrations] - mcd_transformers = "db/migrations" [contract] [contract.address] diff --git a/pkg/transformers/shared/log_chunker.go b/libraries/shared/chunker/log_chunker.go similarity index 99% rename from pkg/transformers/shared/log_chunker.go rename to libraries/shared/chunker/log_chunker.go index 75e1062a..a8bbe089 100644 --- a/pkg/transformers/shared/log_chunker.go +++ b/libraries/shared/chunker/log_chunker.go @@ -14,12 +14,13 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -package shared +package chunker import ( + "strings" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" - "strings" shared_t "github.com/vulcanize/vulcanizedb/libraries/shared/transformer" ) diff --git a/pkg/transformers/shared/log_chunker_test.go b/libraries/shared/chunker/log_chunker_test.go similarity index 96% rename from pkg/transformers/shared/log_chunker_test.go rename to libraries/shared/chunker/log_chunker_test.go index c783c40b..9a724485 100644 --- a/pkg/transformers/shared/log_chunker_test.go +++ b/libraries/shared/chunker/log_chunker_test.go @@ -14,21 +14,22 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -package shared_test +package chunker_test import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" + + chunk "github.com/vulcanize/vulcanizedb/libraries/shared/chunker" shared_t "github.com/vulcanize/vulcanizedb/libraries/shared/transformer" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared" ) var _ = Describe("Log chunker", func() { var ( configs []shared_t.TransformerConfig - chunker *shared.LogChunker + chunker *chunk.LogChunker ) BeforeEach(func() { @@ -50,7 +51,7 @@ var _ = Describe("Log chunker", func() { } configs = []shared_t.TransformerConfig{configA, configB, configC} - chunker = shared.NewLogChunker() + chunker = chunk.NewLogChunker() chunker.AddConfigs(configs) }) diff --git a/pkg/transformers/price_feeds/constants.go b/libraries/shared/constants/checked_headers.go similarity index 78% rename from pkg/transformers/price_feeds/constants.go rename to libraries/shared/constants/checked_headers.go index 88df5115..2e02d3f9 100644 --- a/pkg/transformers/price_feeds/constants.go +++ b/libraries/shared/constants/checked_headers.go @@ -14,15 +14,12 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -package price_feeds +package constants -import ( - "errors" - "math/big" -) +type TransformerExecution bool -var ( - ErrNoMatchingLog = errors.New("no matching log") - Ether = big.NewFloat(1e18) - Ray = big.NewFloat(1e27) +const ( + HeaderRecheck TransformerExecution = true + HeaderMissing TransformerExecution = false + RecheckHeaderCap = "4" ) diff --git a/pkg/transformers/factories/log_note_converter.go b/libraries/shared/constants/data.go similarity index 80% rename from pkg/transformers/factories/log_note_converter.go rename to libraries/shared/constants/data.go index 646ad13a..e55ae76c 100644 --- a/pkg/transformers/factories/log_note_converter.go +++ b/libraries/shared/constants/data.go @@ -14,10 +14,9 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -package factories +package constants -import "github.com/ethereum/go-ethereum/core/types" +var DataItemLength = 32 -type LogNoteConverter interface { - ToModels(ethLog []types.Log) ([]interface{}, error) -} +// TODO Grab this from DB, since it can change through governance +var TTL = int64(10800) // 60 * 60 * 3 == 10800 seconds == 3 hours diff --git a/pkg/transformers/shared/log_fetcher.go b/libraries/shared/fetcher/log_fetcher.go similarity index 99% rename from pkg/transformers/shared/log_fetcher.go rename to libraries/shared/fetcher/log_fetcher.go index e786d48c..225c1469 100644 --- a/pkg/transformers/shared/log_fetcher.go +++ b/libraries/shared/fetcher/log_fetcher.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 shared +package fetcher import ( "github.com/ethereum/go-ethereum" diff --git a/pkg/transformers/shared/log_fetcher_test.go b/libraries/shared/fetcher/log_fetcher_test.go similarity index 92% rename from pkg/transformers/shared/log_fetcher_test.go rename to libraries/shared/fetcher/log_fetcher_test.go index 2c3ff75b..c8f23cf1 100644 --- a/pkg/transformers/shared/log_fetcher_test.go +++ b/libraries/shared/fetcher/log_fetcher_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 shared_test +package fetcher_test import ( "github.com/ethereum/go-ethereum" @@ -22,16 +22,16 @@ import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" + fetch "github.com/vulcanize/vulcanizedb/libraries/shared/fetcher" "github.com/vulcanize/vulcanizedb/pkg/core" "github.com/vulcanize/vulcanizedb/pkg/fakes" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared" ) var _ = Describe("Fetcher", func() { Describe("FetchLogs", func() { It("fetches logs based on the given query", func() { blockChain := fakes.NewMockBlockChain() - fetcher := shared.NewFetcher(blockChain) + fetcher := fetch.NewFetcher(blockChain) header := fakes.FakeHeader addresses := []common.Address{ @@ -59,7 +59,7 @@ var _ = Describe("Fetcher", func() { It("returns an error if fetching the logs fails", func() { blockChain := fakes.NewMockBlockChain() blockChain.SetGetEthLogsWithCustomQueryErr(fakes.FakeError) - fetcher := shared.NewFetcher(blockChain) + fetcher := fetch.NewFetcher(blockChain) _, err := fetcher.FetchLogs([]common.Address{}, []common.Hash{}, core.Header{}) diff --git a/pkg/transformers/test_data/mocks/mock_watcher_repository.go b/libraries/shared/mocks/mock_watcher_repository.go similarity index 70% rename from pkg/transformers/test_data/mocks/mock_watcher_repository.go rename to libraries/shared/mocks/mock_watcher_repository.go index 323fdddf..fe9d70a6 100644 --- a/pkg/transformers/test_data/mocks/mock_watcher_repository.go +++ b/libraries/shared/mocks/mock_watcher_repository.go @@ -1,3 +1,19 @@ +// VulcanizeDB +// Copyright © 2018 Vulcanize + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. + +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + package mocks import ( diff --git a/pkg/transformers/factories/repository.go b/libraries/shared/mocks/storage_repository.go similarity index 53% rename from pkg/transformers/factories/repository.go rename to libraries/shared/mocks/storage_repository.go index d953249b..035adf16 100644 --- a/pkg/transformers/factories/repository.go +++ b/libraries/shared/mocks/storage_repository.go @@ -14,17 +14,29 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -package factories +package mocks import ( - "github.com/vulcanize/vulcanizedb/pkg/core" + "github.com/vulcanize/vulcanizedb/libraries/shared/utils" "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" ) -type Repository interface { - Create(headerID int64, models []interface{}) error - MarkHeaderChecked(headerID int64) error - MissingHeaders(startingBlockNumber, endingBlockNumber int64) ([]core.Header, error) - RecheckHeaders(startingBlockNumber, endingBlockNUmber int64) ([]core.Header, error) - SetDB(db *postgres.DB) +type MockStorageRepository struct { + CreateErr error + PassedBlockNumber int + PassedBlockHash string + PassedMetadata utils.StorageValueMetadata + PassedValue interface{} +} + +func (repository *MockStorageRepository) Create(blockNumber int, blockHash string, metadata utils.StorageValueMetadata, value interface{}) error { + repository.PassedBlockNumber = blockNumber + repository.PassedBlockHash = blockHash + repository.PassedMetadata = metadata + repository.PassedValue = value + return repository.CreateErr +} + +func (*MockStorageRepository) SetDB(db *postgres.DB) { + panic("implement me") } diff --git a/pkg/transformers/price_feeds/model.go b/libraries/shared/mocks/storage_transformer.go similarity index 52% rename from pkg/transformers/price_feeds/model.go rename to libraries/shared/mocks/storage_transformer.go index f21d75f5..f5a778b2 100644 --- a/pkg/transformers/price_feeds/model.go +++ b/libraries/shared/mocks/storage_transformer.go @@ -14,35 +14,31 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -package price_feeds +package mocks import ( - "math/big" - "github.com/ethereum/go-ethereum/common" + + "github.com/vulcanize/vulcanizedb/libraries/shared/transformer" + "github.com/vulcanize/vulcanizedb/libraries/shared/utils" + "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" ) -type LogValueEntity struct { - Val common.Address +type MockStorageTransformer struct { + Address common.Address + ExecuteErr error + PassedRow utils.StorageDiffRow } -type PriceFeedModel struct { - BlockNumber uint64 `db:"block_number"` - MedianizerAddress string `db:"medianizer_address"` - UsdValue string `db:"usd_value"` - LogIndex uint `db:"log_idx"` - TransactionIndex uint `db:"tx_idx"` - Raw []byte `db:"raw_log"` +func (transformer *MockStorageTransformer) Execute(row utils.StorageDiffRow) error { + transformer.PassedRow = row + return transformer.ExecuteErr } -func Convert(conversion string, value string, prec int) string { - var bgflt = big.NewFloat(0.0) - bgflt.SetString(value) - switch conversion { - case "ray": - bgflt.Quo(bgflt, Ray) - case "wad": - bgflt.Quo(bgflt, Ether) - } - return bgflt.Text('g', prec) +func (transformer *MockStorageTransformer) ContractAddress() common.Address { + return transformer.Address +} + +func (transformer *MockStorageTransformer) FakeTransformerInitializer(db *postgres.DB) transformer.StorageTransformer { + return transformer } diff --git a/pkg/transformers/test_data/mocks/transformer.go b/libraries/shared/mocks/transformer.go similarity index 58% rename from pkg/transformers/test_data/mocks/transformer.go rename to libraries/shared/mocks/transformer.go index f0d5da49..f8a74c80 100644 --- a/pkg/transformers/test_data/mocks/transformer.go +++ b/libraries/shared/mocks/transformer.go @@ -1,12 +1,28 @@ +// VulcanizeDB +// Copyright © 2018 Vulcanize + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. + +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + 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" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" ) type MockTransformer struct { @@ -35,7 +51,7 @@ func (mh *MockTransformer) SetTransformerConfig(config shared_t.TransformerConfi mh.config = config } -func (mh *MockTransformer) FakeTransformerInitializer(db *postgres.DB) shared_t.Transformer { +func (mh *MockTransformer) FakeTransformerInitializer(db *postgres.DB) shared_t.EventTransformer { return mh } diff --git a/pkg/transformers/shared/repository.go b/libraries/shared/repository/repository.go similarity index 87% rename from pkg/transformers/shared/repository.go rename to libraries/shared/repository/repository.go index bf156067..35dd6935 100644 --- a/pkg/transformers/shared/repository.go +++ b/libraries/shared/repository/repository.go @@ -1,13 +1,30 @@ -package shared +// VulcanizeDB +// Copyright © 2018 Vulcanize + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. + +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +package repository import ( "bytes" "database/sql" "database/sql/driver" "fmt" + + "github.com/vulcanize/vulcanizedb/libraries/shared/constants" "github.com/vulcanize/vulcanizedb/pkg/core" "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" ) func GetOrCreateIlk(ilk string, db *postgres.DB) (int, error) { diff --git a/pkg/transformers/shared/repository_utility_test.go b/libraries/shared/repository/repository_utility_test.go similarity index 97% rename from pkg/transformers/shared/repository_utility_test.go rename to libraries/shared/repository/repository_utility_test.go index 1a8f762b..a66e3838 100644 --- a/pkg/transformers/shared/repository_utility_test.go +++ b/libraries/shared/repository/repository_utility_test.go @@ -14,21 +14,23 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -package shared_test +package repository_test import ( "fmt" + "math/rand" + . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" + + "github.com/vulcanize/vulcanizedb/libraries/shared/constants" + shared "github.com/vulcanize/vulcanizedb/libraries/shared/repository" "github.com/vulcanize/vulcanizedb/pkg/core" "github.com/vulcanize/vulcanizedb/pkg/datastore" "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres/repositories" "github.com/vulcanize/vulcanizedb/pkg/fakes" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" "github.com/vulcanize/vulcanizedb/test_config" - "math/rand" ) var _ = Describe("Repository utilities", func() { diff --git a/libraries/shared/transformer/transformer.go b/libraries/shared/transformer/event_transformer.go similarity index 53% rename from libraries/shared/transformer/transformer.go rename to libraries/shared/transformer/event_transformer.go index e9e68a5e..3b0fd626 100644 --- a/libraries/shared/transformer/transformer.go +++ b/libraries/shared/transformer/event_transformer.go @@ -1,5 +1,18 @@ -// Auto-gen this code for different transformer interfaces/configs -// based on config file to allow for more modularity +// VulcanizeDB +// Copyright © 2018 Vulcanize + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. + +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . package transformer @@ -8,16 +21,16 @@ import ( "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/datastore/postgres" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" ) -type Transformer interface { +type EventTransformer interface { Execute(logs []types.Log, header core.Header, recheckHeaders constants.TransformerExecution) error GetConfig() TransformerConfig } -type TransformerInitializer func(db *postgres.DB) Transformer +type TransformerInitializer func(db *postgres.DB) EventTransformer type TransformerConfig struct { TransformerName string diff --git a/pkg/transformers/storage_diffs/repository.go b/libraries/shared/transformer/storage_transformer.go similarity index 71% rename from pkg/transformers/storage_diffs/repository.go rename to libraries/shared/transformer/storage_transformer.go index 7baedb6a..19203314 100644 --- a/pkg/transformers/storage_diffs/repository.go +++ b/libraries/shared/transformer/storage_transformer.go @@ -14,14 +14,18 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -package storage_diffs +package transformer import ( + "github.com/ethereum/go-ethereum/common" + + "github.com/vulcanize/vulcanizedb/libraries/shared/utils" "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" - "github.com/vulcanize/vulcanizedb/pkg/transformers/storage_diffs/shared" ) -type Repository interface { - Create(blockNumber int, blockHash string, metadata shared.StorageValueMetadata, value interface{}) error - SetDB(db *postgres.DB) +type StorageTransformer interface { + Execute(row utils.StorageDiffRow) error + ContractAddress() common.Address } + +type StorageTransformerInitializer func(db *postgres.DB) StorageTransformer diff --git a/libraries/shared/transformer/transformer_suite_test.go b/libraries/shared/transformer/transformer_suite_test.go deleted file mode 100644 index 83486c5e..00000000 --- a/libraries/shared/transformer/transformer_suite_test.go +++ /dev/null @@ -1,35 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package transformer_test - -import ( - "io/ioutil" - "log" - "testing" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -func TestShared(t *testing.T) { - RegisterFailHandler(Fail) - RunSpecs(t, "Shared Transformer Suite") -} - -var _ = BeforeSuite(func() { - log.SetOutput(ioutil.Discard) -}) diff --git a/libraries/shared/transformer/transformer_test.go b/libraries/shared/transformer/transformer_test.go deleted file mode 100644 index bc6e0255..00000000 --- a/libraries/shared/transformer/transformer_test.go +++ /dev/null @@ -1,17 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package transformer_test diff --git a/pkg/transformers/storage_diffs/shared/decoder.go b/libraries/shared/utils/decoder.go similarity index 98% rename from pkg/transformers/storage_diffs/shared/decoder.go rename to libraries/shared/utils/decoder.go index 2fcc39ef..f179355e 100644 --- a/pkg/transformers/storage_diffs/shared/decoder.go +++ b/libraries/shared/utils/decoder.go @@ -14,12 +14,13 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -package shared +package utils import ( "fmt" - "github.com/ethereum/go-ethereum/common" "math/big" + + "github.com/ethereum/go-ethereum/common" ) func Decode(row StorageDiffRow, metadata StorageValueMetadata) (interface{}, error) { diff --git a/pkg/transformers/storage_diffs/shared/decoder_test.go b/libraries/shared/utils/decoder_test.go similarity index 75% rename from pkg/transformers/storage_diffs/shared/decoder_test.go rename to libraries/shared/utils/decoder_test.go index 9e1e3a6c..7bd7238e 100644 --- a/pkg/transformers/storage_diffs/shared/decoder_test.go +++ b/libraries/shared/utils/decoder_test.go @@ -14,23 +14,25 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -package shared_test +package utils_test import ( + "math/big" + "github.com/ethereum/go-ethereum/common" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - "github.com/vulcanize/vulcanizedb/pkg/transformers/storage_diffs/shared" - "math/big" + + "github.com/vulcanize/vulcanizedb/libraries/shared/utils" ) var _ = Describe("Storage decoder", func() { It("decodes uint256", func() { fakeInt := common.HexToHash("0000000000000000000000000000000000000000000000000000000000000539") - row := shared.StorageDiffRow{StorageValue: fakeInt} - metadata := shared.StorageValueMetadata{Type: shared.Uint256} + row := utils.StorageDiffRow{StorageValue: fakeInt} + metadata := utils.StorageValueMetadata{Type: utils.Uint256} - result, err := shared.Decode(row, metadata) + result, err := utils.Decode(row, metadata) Expect(err).NotTo(HaveOccurred()) Expect(result).To(Equal(big.NewInt(0).SetBytes(fakeInt.Bytes()).String())) @@ -38,10 +40,10 @@ var _ = Describe("Storage decoder", func() { It("decodes address", func() { fakeAddress := common.HexToAddress("0x12345") - row := shared.StorageDiffRow{StorageValue: fakeAddress.Hash()} - metadata := shared.StorageValueMetadata{Type: shared.Address} + row := utils.StorageDiffRow{StorageValue: fakeAddress.Hash()} + metadata := utils.StorageValueMetadata{Type: utils.Address} - result, err := shared.Decode(row, metadata) + result, err := utils.Decode(row, metadata) Expect(err).NotTo(HaveOccurred()) Expect(result).To(Equal(fakeAddress.Hex())) diff --git a/pkg/transformers/storage_diffs/shared/errors.go b/libraries/shared/utils/errors.go similarity index 98% rename from pkg/transformers/storage_diffs/shared/errors.go rename to libraries/shared/utils/errors.go index b33fc3ee..2d698f27 100644 --- a/pkg/transformers/storage_diffs/shared/errors.go +++ b/libraries/shared/utils/errors.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 shared +package utils import ( "fmt" diff --git a/pkg/transformers/storage_diffs/shared/row.go b/libraries/shared/utils/row.go similarity index 99% rename from pkg/transformers/storage_diffs/shared/row.go rename to libraries/shared/utils/row.go index 3f981def..840a8883 100644 --- a/pkg/transformers/storage_diffs/shared/row.go +++ b/libraries/shared/utils/row.go @@ -14,11 +14,12 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -package shared +package utils import ( - "github.com/ethereum/go-ethereum/common" "strconv" + + "github.com/ethereum/go-ethereum/common" ) const ExpectedRowLength = 5 diff --git a/pkg/transformers/storage_diffs/shared/row_test.go b/libraries/shared/utils/row_test.go similarity index 84% rename from pkg/transformers/storage_diffs/shared/row_test.go rename to libraries/shared/utils/row_test.go index a75201fb..c1ae1e7d 100644 --- a/pkg/transformers/storage_diffs/shared/row_test.go +++ b/libraries/shared/utils/row_test.go @@ -14,13 +14,14 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -package shared_test +package utils_test import ( "github.com/ethereum/go-ethereum/common" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - "github.com/vulcanize/vulcanizedb/pkg/transformers/storage_diffs/shared" + + "github.com/vulcanize/vulcanizedb/libraries/shared/utils" ) var _ = Describe("Storage row parsing", func() { @@ -32,7 +33,7 @@ var _ = Describe("Storage row parsing", func() { storageValue := "0x654" data := []string{contract, blockHash, blockHeight, storageKey, storageValue} - result, err := shared.FromStrings(data) + result, err := utils.FromStrings(data) Expect(err).NotTo(HaveOccurred()) Expect(result.Contract).To(Equal(common.HexToAddress(contract))) @@ -43,14 +44,14 @@ var _ = Describe("Storage row parsing", func() { }) It("returns an error if row is missing data", func() { - _, err := shared.FromStrings([]string{"0x123"}) + _, err := utils.FromStrings([]string{"0x123"}) Expect(err).To(HaveOccurred()) - Expect(err).To(MatchError(shared.ErrRowMalformed{Length: 1})) + Expect(err).To(MatchError(utils.ErrRowMalformed{Length: 1})) }) It("returns error if block height malformed", func() { - _, err := shared.FromStrings([]string{"", "", "", "", ""}) + _, err := utils.FromStrings([]string{"", "", "", "", ""}) Expect(err).To(HaveOccurred()) }) diff --git a/pkg/transformers/storage_diffs/shared/shared_suite_test.go b/libraries/shared/utils/shared_suite_test.go similarity index 98% rename from pkg/transformers/storage_diffs/shared/shared_suite_test.go rename to libraries/shared/utils/shared_suite_test.go index 865d8158..b20597b7 100644 --- a/pkg/transformers/storage_diffs/shared/shared_suite_test.go +++ b/libraries/shared/utils/shared_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 shared_test +package utils_test import ( "github.com/sirupsen/logrus" diff --git a/pkg/transformers/storage_diffs/shared/value.go b/libraries/shared/utils/value.go similarity index 98% rename from pkg/transformers/storage_diffs/shared/value.go rename to libraries/shared/utils/value.go index e5543bce..6207da2d 100644 --- a/pkg/transformers/storage_diffs/shared/value.go +++ b/libraries/shared/utils/value.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 shared +package utils type ValueType int diff --git a/libraries/shared/watcher/event_watcher.go b/libraries/shared/watcher/event_watcher.go index ef11caef..b957c878 100644 --- a/libraries/shared/watcher/event_watcher.go +++ b/libraries/shared/watcher/event_watcher.go @@ -22,26 +22,28 @@ import ( "github.com/ethereum/go-ethereum/common" log "github.com/sirupsen/logrus" + chunk "github.com/vulcanize/vulcanizedb/libraries/shared/chunker" + "github.com/vulcanize/vulcanizedb/libraries/shared/constants" + fetch "github.com/vulcanize/vulcanizedb/libraries/shared/fetcher" + repo "github.com/vulcanize/vulcanizedb/libraries/shared/repository" "github.com/vulcanize/vulcanizedb/libraries/shared/transformer" "github.com/vulcanize/vulcanizedb/pkg/core" "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" ) type EventWatcher struct { - Transformers []transformer.Transformer + Transformers []transformer.EventTransformer DB *postgres.DB - Fetcher shared.LogFetcher - Chunker shared.Chunker + Fetcher fetch.LogFetcher + Chunker chunk.Chunker Addresses []common.Address Topics []common.Hash StartingBlock *int64 } func NewEventWatcher(db *postgres.DB, bc core.BlockChain) EventWatcher { - chunker := shared.NewLogChunker() - fetcher := shared.NewFetcher(bc) + chunker := chunk.NewLogChunker() + fetcher := fetch.NewFetcher(bc) return EventWatcher{ DB: db, Fetcher: fetcher, @@ -83,13 +85,13 @@ func (watcher *EventWatcher) Execute(recheckHeaders constants.TransformerExecuti return fmt.Errorf("No transformers added to watcher") } - checkedColumnNames, err := shared.GetCheckedColumnNames(watcher.DB) + checkedColumnNames, err := repo.GetCheckedColumnNames(watcher.DB) if err != nil { return err } - notCheckedSQL := shared.CreateNotCheckedSQL(checkedColumnNames, recheckHeaders) + notCheckedSQL := repo.CreateNotCheckedSQL(checkedColumnNames, recheckHeaders) - missingHeaders, err := shared.MissingHeaders(*watcher.StartingBlock, -1, watcher.DB, notCheckedSQL) + missingHeaders, err := repo.MissingHeaders(*watcher.StartingBlock, -1, watcher.DB, notCheckedSQL) if err != nil { log.Error("Fetching of missing headers failed in watcher!") return err diff --git a/libraries/shared/watcher/event_watcher_test.go b/libraries/shared/watcher/event_watcher_test.go index 345756ab..5d8e2ae1 100644 --- a/libraries/shared/watcher/event_watcher_test.go +++ b/libraries/shared/watcher/event_watcher_test.go @@ -25,14 +25,14 @@ import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" + "github.com/vulcanize/vulcanizedb/libraries/shared/constants" + "github.com/vulcanize/vulcanizedb/libraries/shared/mocks" "github.com/vulcanize/vulcanizedb/libraries/shared/transformer" "github.com/vulcanize/vulcanizedb/libraries/shared/watcher" "github.com/vulcanize/vulcanizedb/pkg/core" "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres/repositories" "github.com/vulcanize/vulcanizedb/pkg/fakes" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" - "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data/mocks" "github.com/vulcanize/vulcanizedb/test_config" ) diff --git a/libraries/shared/storage_watcher.go b/libraries/shared/watcher/storage_watcher.go similarity index 76% rename from libraries/shared/storage_watcher.go rename to libraries/shared/watcher/storage_watcher.go index 49dea19e..ac554701 100644 --- a/libraries/shared/storage_watcher.go +++ b/libraries/shared/watcher/storage_watcher.go @@ -14,17 +14,18 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -package shared +package watcher import ( + "strings" + "reflect" + "github.com/ethereum/go-ethereum/common" "github.com/sirupsen/logrus" - "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/storage" - "github.com/vulcanize/vulcanizedb/pkg/transformers/storage_diffs/shared" - "reflect" - "strings" + "github.com/vulcanize/vulcanizedb/libraries/shared/transformer" + "github.com/vulcanize/vulcanizedb/libraries/shared/utils" + "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" "github.com/vulcanize/vulcanizedb/pkg/fs" ) @@ -32,11 +33,11 @@ type StorageWatcher struct { db *postgres.DB tailer fs.Tailer Queue IStorageQueue - Transformers map[common.Address]storage.Transformer + Transformers map[common.Address]transformer.StorageTransformer } func NewStorageWatcher(tailer fs.Tailer, db *postgres.DB) StorageWatcher { - transformers := make(map[common.Address]storage.Transformer) + transformers := make(map[common.Address]transformer.StorageTransformer) queue := NewStorageQueue(db) return StorageWatcher{ db: db, @@ -46,7 +47,7 @@ func NewStorageWatcher(tailer fs.Tailer, db *postgres.DB) StorageWatcher { } } -func (watcher StorageWatcher) AddTransformers(initializers []storage.TransformerInitializer) { +func (watcher StorageWatcher) AddTransformers(initializers []transformer.StorageTransformerInitializer) { for _, initializer := range initializers { transformer := initializer(watcher.db) watcher.Transformers[transformer.ContractAddress()] = transformer @@ -59,13 +60,13 @@ func (watcher StorageWatcher) Execute() error { return tailErr } for line := range t.Lines { - row, parseErr := shared.FromStrings(strings.Split(line.Text, ",")) + row, parseErr := utils.FromStrings(strings.Split(line.Text, ",")) if parseErr != nil { return parseErr } transformer, ok := watcher.Transformers[row.Contract] if !ok { - logrus.Warn(shared.ErrContractNotFound{Contract: row.Contract.Hex()}.Error()) + logrus.Warn(utils.ErrContractNotFound{Contract: row.Contract.Hex()}.Error()) continue } executeErr := transformer.Execute(row) @@ -85,5 +86,5 @@ func (watcher StorageWatcher) Execute() error { } func isKeyNotFound(executeErr error) bool { - return reflect.TypeOf(executeErr) == reflect.TypeOf(shared.ErrStorageKeyNotFound{}) + return reflect.TypeOf(executeErr) == reflect.TypeOf(utils.ErrStorageKeyNotFound{}) } diff --git a/libraries/shared/storage_watcher_test.go b/libraries/shared/watcher/storage_watcher_test.go similarity index 67% rename from libraries/shared/storage_watcher_test.go rename to libraries/shared/watcher/storage_watcher_test.go index e0c67740..6376250f 100644 --- a/libraries/shared/storage_watcher_test.go +++ b/libraries/shared/watcher/storage_watcher_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 shared_test +package watcher_test import ( "errors" @@ -30,12 +30,12 @@ import ( . "github.com/onsi/gomega" "github.com/sirupsen/logrus" - "github.com/vulcanize/vulcanizedb/libraries/shared" + "github.com/vulcanize/vulcanizedb/libraries/shared/mocks" + "github.com/vulcanize/vulcanizedb/libraries/shared/transformer" + "github.com/vulcanize/vulcanizedb/libraries/shared/utils" + "github.com/vulcanize/vulcanizedb/libraries/shared/watcher" "github.com/vulcanize/vulcanizedb/pkg/core" "github.com/vulcanize/vulcanizedb/pkg/fakes" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/storage" - shared2 "github.com/vulcanize/vulcanizedb/pkg/transformers/storage_diffs/shared" - "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data/mocks" "github.com/vulcanize/vulcanizedb/test_config" ) @@ -43,39 +43,39 @@ var _ = Describe("Storage Watcher", func() { It("adds transformers", func() { fakeAddress := common.HexToAddress("0x12345") fakeTransformer := &mocks.MockStorageTransformer{Address: fakeAddress} - watcher := shared.NewStorageWatcher(&fakes.MockTailer{}, test_config.NewTestDB(core.Node{})) + w := watcher.NewStorageWatcher(&fakes.MockTailer{}, test_config.NewTestDB(core.Node{})) - watcher.AddTransformers([]storage.TransformerInitializer{fakeTransformer.FakeTransformerInitializer}) + w.AddTransformers([]transformer.StorageTransformerInitializer{fakeTransformer.FakeTransformerInitializer}) - Expect(watcher.Transformers[fakeAddress]).To(Equal(fakeTransformer)) + Expect(w.Transformers[fakeAddress]).To(Equal(fakeTransformer)) }) It("reads the tail of the storage diffs file", func() { mockTailer := fakes.NewMockTailer() - watcher := shared.NewStorageWatcher(mockTailer, test_config.NewTestDB(core.Node{})) + w := watcher.NewStorageWatcher(mockTailer, test_config.NewTestDB(core.Node{})) assert(func(err error) { Expect(err).To(BeNil()) Expect(mockTailer.TailCalled).To(BeTrue()) - }, watcher, mockTailer, []*tail.Line{}) + }, w, mockTailer, []*tail.Line{}) }) It("returns error if row parsing fails", func() { mockTailer := fakes.NewMockTailer() - watcher := shared.NewStorageWatcher(mockTailer, test_config.NewTestDB(core.Node{})) + w := watcher.NewStorageWatcher(mockTailer, test_config.NewTestDB(core.Node{})) line := &tail.Line{Text: "oops"} assert(func(err error) { Expect(err).To(HaveOccurred()) - Expect(err).To(MatchError(shared2.ErrRowMalformed{Length: 1})) - }, watcher, mockTailer, []*tail.Line{line}) + Expect(err).To(MatchError(utils.ErrRowMalformed{Length: 1})) + }, w, mockTailer, []*tail.Line{line}) }) It("logs error if no transformer can parse storage row", func() { mockTailer := fakes.NewMockTailer() address := common.HexToAddress("0x12345") line := getFakeLine(address.Bytes()) - watcher := shared.NewStorageWatcher(mockTailer, test_config.NewTestDB(core.Node{})) + w := watcher.NewStorageWatcher(mockTailer, test_config.NewTestDB(core.Node{})) tempFile, err := ioutil.TempFile("", "log") defer os.Remove(tempFile.Name()) Expect(err).NotTo(HaveOccurred()) @@ -85,24 +85,24 @@ var _ = Describe("Storage Watcher", func() { Expect(err).NotTo(HaveOccurred()) logContent, readErr := ioutil.ReadFile(tempFile.Name()) Expect(readErr).NotTo(HaveOccurred()) - Expect(string(logContent)).To(ContainSubstring(shared2.ErrContractNotFound{Contract: address.Hex()}.Error())) - }, watcher, mockTailer, []*tail.Line{line}) + Expect(string(logContent)).To(ContainSubstring(utils.ErrContractNotFound{Contract: address.Hex()}.Error())) + }, w, mockTailer, []*tail.Line{line}) }) It("executes transformer with storage row", func() { address := []byte{1, 2, 3} line := getFakeLine(address) mockTailer := fakes.NewMockTailer() - watcher := shared.NewStorageWatcher(mockTailer, test_config.NewTestDB(core.Node{})) + w := watcher.NewStorageWatcher(mockTailer, test_config.NewTestDB(core.Node{})) fakeTransformer := &mocks.MockStorageTransformer{Address: common.BytesToAddress(address)} - watcher.AddTransformers([]storage.TransformerInitializer{fakeTransformer.FakeTransformerInitializer}) + w.AddTransformers([]transformer.StorageTransformerInitializer{fakeTransformer.FakeTransformerInitializer}) assert(func(err error) { Expect(err).To(BeNil()) - expectedRow, err := shared2.FromStrings(strings.Split(line.Text, ",")) + expectedRow, err := utils.FromStrings(strings.Split(line.Text, ",")) Expect(err).NotTo(HaveOccurred()) Expect(fakeTransformer.PassedRow).To(Equal(expectedRow)) - }, watcher, mockTailer, []*tail.Line{line}) + }, w, mockTailer, []*tail.Line{line}) }) Describe("when executing transformer fails", func() { @@ -110,30 +110,30 @@ var _ = Describe("Storage Watcher", func() { address := []byte{1, 2, 3} line := getFakeLine(address) mockTailer := fakes.NewMockTailer() - watcher := shared.NewStorageWatcher(mockTailer, test_config.NewTestDB(core.Node{})) + w := watcher.NewStorageWatcher(mockTailer, test_config.NewTestDB(core.Node{})) mockQueue := &mocks.MockStorageQueue{} - watcher.Queue = mockQueue - keyNotFoundError := shared2.ErrStorageKeyNotFound{Key: "unknown_storage_key"} + w.Queue = mockQueue + keyNotFoundError := utils.ErrStorageKeyNotFound{Key: "unknown_storage_key"} fakeTransformer := &mocks.MockStorageTransformer{Address: common.BytesToAddress(address), ExecuteErr: keyNotFoundError} - watcher.AddTransformers([]storage.TransformerInitializer{fakeTransformer.FakeTransformerInitializer}) + w.AddTransformers([]transformer.StorageTransformerInitializer{fakeTransformer.FakeTransformerInitializer}) assert(func(err error) { Expect(err).NotTo(HaveOccurred()) Expect(mockQueue.AddCalled).To(BeTrue()) - }, watcher, mockTailer, []*tail.Line{line}) + }, w, mockTailer, []*tail.Line{line}) }) It("logs error if queuing row fails", func() { address := []byte{1, 2, 3} line := getFakeLine(address) mockTailer := fakes.NewMockTailer() - watcher := shared.NewStorageWatcher(mockTailer, test_config.NewTestDB(core.Node{})) + w := watcher.NewStorageWatcher(mockTailer, test_config.NewTestDB(core.Node{})) mockQueue := &mocks.MockStorageQueue{} mockQueue.AddError = fakes.FakeError - watcher.Queue = mockQueue - keyNotFoundError := shared2.ErrStorageKeyNotFound{Key: "unknown_storage_key"} + w.Queue = mockQueue + keyNotFoundError := utils.ErrStorageKeyNotFound{Key: "unknown_storage_key"} fakeTransformer := &mocks.MockStorageTransformer{Address: common.BytesToAddress(address), ExecuteErr: keyNotFoundError} - watcher.AddTransformers([]storage.TransformerInitializer{fakeTransformer.FakeTransformerInitializer}) + w.AddTransformers([]transformer.StorageTransformerInitializer{fakeTransformer.FakeTransformerInitializer}) tempFile, err := ioutil.TempFile("", "log") defer os.Remove(tempFile.Name()) Expect(err).NotTo(HaveOccurred()) @@ -145,17 +145,17 @@ var _ = Describe("Storage Watcher", func() { logContent, readErr := ioutil.ReadFile(tempFile.Name()) Expect(readErr).NotTo(HaveOccurred()) Expect(string(logContent)).To(ContainSubstring(fakes.FakeError.Error())) - }, watcher, mockTailer, []*tail.Line{line}) + }, w, mockTailer, []*tail.Line{line}) }) It("logs any other error", func() { address := []byte{1, 2, 3} line := getFakeLine(address) mockTailer := fakes.NewMockTailer() - watcher := shared.NewStorageWatcher(mockTailer, test_config.NewTestDB(core.Node{})) + w := watcher.NewStorageWatcher(mockTailer, test_config.NewTestDB(core.Node{})) executionError := errors.New("storage watcher failed attempting to execute transformer") fakeTransformer := &mocks.MockStorageTransformer{Address: common.BytesToAddress(address), ExecuteErr: executionError} - watcher.AddTransformers([]storage.TransformerInitializer{fakeTransformer.FakeTransformerInitializer}) + w.AddTransformers([]transformer.StorageTransformerInitializer{fakeTransformer.FakeTransformerInitializer}) tempFile, err := ioutil.TempFile("", "log") defer os.Remove(tempFile.Name()) Expect(err).NotTo(HaveOccurred()) @@ -166,12 +166,12 @@ var _ = Describe("Storage Watcher", func() { logContent, readErr := ioutil.ReadFile(tempFile.Name()) Expect(readErr).NotTo(HaveOccurred()) Expect(string(logContent)).To(ContainSubstring(executionError.Error())) - }, watcher, mockTailer, []*tail.Line{line}) + }, w, mockTailer, []*tail.Line{line}) }) }) }) -func assert(assertion func(err error), watcher shared.StorageWatcher, mockTailer *fakes.MockTailer, lines []*tail.Line) { +func assert(assertion func(err error), watcher watcher.StorageWatcher, mockTailer *fakes.MockTailer, lines []*tail.Line) { errs := make(chan error, 1) done := make(chan bool, 1) go execute(watcher, errs, done) @@ -190,8 +190,8 @@ func assert(assertion func(err error), watcher shared.StorageWatcher, mockTailer } } -func execute(watcher shared.StorageWatcher, errs chan error, done chan bool) { - err := watcher.Execute() +func execute(w watcher.StorageWatcher, errs chan error, done chan bool) { + err := w.Execute() if err != nil { errs <- err } else { diff --git a/pkg/autogen/config.go b/pkg/autogen/config.go index 383270f5..0bdfed1e 100644 --- a/pkg/autogen/config.go +++ b/pkg/autogen/config.go @@ -26,11 +26,12 @@ import ( ) type Config struct { - Initializers map[string]string // Map of import aliases to transformer paths + Initializers map[string]string // Map of import aliases to transformer initializer paths Dependencies map[string]string // Map of vendor dep names to their repositories - Migrations map[string]string // Map of migration names to their paths within the vendored deps + Migrations map[string]string // Map of vendor dep names to relative path from repository to db migrations FilePath string FileName string + Save bool } func (c *Config) GetPluginPaths() (string, string, error) { diff --git a/pkg/autogen/generator.go b/pkg/autogen/generator.go index 21862bdb..7e5ce5f2 100644 --- a/pkg/autogen/generator.go +++ b/pkg/autogen/generator.go @@ -24,6 +24,7 @@ import ( "os/exec" "path/filepath" "strconv" + "strings" . "github.com/dave/jennifer/jen" @@ -50,14 +51,14 @@ func NewGenerator(gc Config, dbc config.Database) *generator { } func (g *generator) GenerateExporterPlugin() error { - if g.GenConfig == nil { - return errors.New("generator needs a config file") - } - if g.GenConfig.FilePath == "" { - return errors.New("generator is missing file path") - } if len(g.GenConfig.Initializers) < 1 { - return errors.New("generator needs to be configured with imports") + return errors.New("generator needs to be configured with TransformerInitializer import paths") + } + if len(g.GenConfig.Dependencies) < 1 { + return errors.New("generator needs to be configured with root repository path(s)") + } + if len(g.GenConfig.Migrations) < 1 { + fmt.Fprintf(os.Stderr, "warning: no db migration paths have been provided\r\n") } // Get plugin file paths @@ -66,14 +67,8 @@ func (g *generator) GenerateExporterPlugin() error { return err } - // Clear .go and .so files of the same name if they exist (overwrite) - err = utils.ClearFiles(goFile, soFile) - if err != nil { - return err - } - // Generate Exporter code - err = g.generateCode(goFile) + err = g.generateCode(goFile, soFile) if err != nil { return err } @@ -83,24 +78,32 @@ func (g *generator) GenerateExporterPlugin() error { if err != nil { return err } - defer g.cleanUp() // Clear these up when we are done building our plugin + + // Clear tmp files and directories when we exit + defer g.cleanUp(goFile) // Build the .go file into a .so plugin err = exec.Command("go", "build", "-buildmode=plugin", "-o", soFile, goFile).Run() if err != nil { - return err + return errors.New(fmt.Sprintf("unable to build .so file: %s", err.Error())) } + // Run migrations only after successfully building .so file return g.runMigrations() } // Generates the plugin code -func (g *generator) generateCode(goFile string) error { +func (g *generator) generateCode(goFile, soFile string) error { + // Clear .go and .so files of the same name if they exist + err := utils.ClearFiles(goFile, soFile) + if err != nil { + return err + } // Begin code generation f := NewFile("main") f.HeaderComment("This exporter is generated to export the configured transformer initializers") - // Import TransformerInitializers + // Import TransformerInitializers specified in config f.ImportAlias("github.com/vulcanize/vulcanizedb/libraries/shared/transformer", "interface") for alias, imp := range g.GenConfig.Initializers { f.ImportAlias(imp, alias) @@ -112,12 +115,10 @@ func (g *generator) generateCode(goFile string) error { importedInitializers = append(importedInitializers, Qual(path, "TransformerInitializer")) } - // Create Exporter variable with method to export a set of the configured TransformerInitializers + // Create Exporter variable with method to export the set of the imported TransformerInitializers f.Type().Id("exporter").String() f.Var().Id("Exporter").Id("exporter") - f.Func().Params( - Id("e").Id("exporter"), - ).Id("Export").Params().Index().Qual( + f.Func().Params(Id("e").Id("exporter")).Id("Export").Params().Index().Qual( "github.com/vulcanize/vulcanizedb/libraries/shared/transformer", "TransformerInitializer").Block( Return(Index().Qual( @@ -128,6 +129,49 @@ func (g *generator) generateCode(goFile string) error { return f.Save(goFile) } +// Sets up temporary vendor libs and migration directories +func (g *generator) setupTempDirs() error { + // TODO: Less hacky way of handling plugin build deps + dirPath, err := utils.CleanPath("$GOPATH/src/github.com/vulcanize/vulcanizedb/") + if err != nil { + return err + } + vendorPath := filepath.Join(dirPath, "vendor") + + // Keep track of where we are writing transformer vendor libs, so that we can remove them afterwards + g.tmpVenDirs = make([]string, 0, len(g.GenConfig.Dependencies)) + // Import transformer dependencies so that we build our plugin + for name, importPath := range g.GenConfig.Dependencies { + index := strings.Index(importPath, "/") + gitPath := importPath[:index] + ":" + importPath[index+1:] + importURL := "git@" + gitPath + ".git" + depPath := filepath.Join(vendorPath, importPath) + err = exec.Command("git", "clone", importURL, depPath).Run() + if err != nil { + return errors.New(fmt.Sprintf("unable to clone %s transformer dependency: %s", name, err.Error())) + } + + err := os.RemoveAll(filepath.Join(depPath, "vendor/")) + if err != nil { + return err + } + + g.tmpVenDirs = append(g.tmpVenDirs, depPath) + } + + // Initialize temp directory for transformer migrations + g.tmpMigDir, err = utils.CleanPath("$GOPATH/src/github.com/vulcanize/vulcanizedb/db/plugin_migrations") + if err != nil { + return err + } + err = os.RemoveAll(g.tmpMigDir) + if err != nil { + return errors.New(fmt.Sprintf("unable to remove file found at %s where tmp directory needs to be written", g.tmpMigDir)) + } + + return os.Mkdir(g.tmpMigDir, os.FileMode(0777)) +} + func (g *generator) runMigrations() error { // Get paths to db migrations paths, err := g.GenConfig.GetMigrationsPaths() @@ -149,78 +193,8 @@ func (g *generator) runMigrations() error { } // Run the copied migrations - location := "file://" + g.tmpMigDir - pgStr := fmt.Sprintf("postgres://%s:%d/%s?sslmode=disable up", g.DBConfig.Hostname, g.DBConfig.Port, g.DBConfig.Name) - return exec.Command("migrate", "-source", location, pgStr).Run() -} - -// Sets up temporary vendor libs and migration directories -func (g *generator) setupTempDirs() error { - // TODO: Less hacky way of handling plugin build deps - dirPath, err := utils.CleanPath("$GOPATH/src/github.com/vulcanize/vulcanizedb/") - if err != nil { - return err - } - vendorPath := filepath.Join(dirPath, "vendor/") - - /* - // Keep track of where we are writing transformer vendor libs, so that we can remove them afterwards - g.tmpVenDirs = make([]string, 0, len(g.GenConfig.Dependencies)) - // Import transformer dependencies so that we build our plugin - for _, importPath := range g.GenConfig.Dependencies { - importURL := "https://" + importPath + ".git" - depPath := filepath.Join(vendorPath, importPath) - err = exec.Command("git", "clone", importURL, depPath).Run() - if err != nil { - return err - } - err := os.RemoveAll(filepath.Join(depPath, "vendor/")) - if err != nil { - return err - } - g.tmpVenDirs = append(g.tmpVenDirs, depPath) - } - */ - - // Keep track of where we are writing transformer vendor libs, so that we can remove them afterwards - g.tmpVenDirs = make([]string, 0, len(g.GenConfig.Dependencies)) - for _, importPath := range g.GenConfig.Dependencies { - depPath := filepath.Join(vendorPath, importPath) - g.tmpVenDirs = append(g.tmpVenDirs, depPath) - } - - // Dep ensure to make sure vendor pkgs are in place for building the plugin - err = exec.Command("dep", "ensure").Run() - if err != nil { - return errors.New("failed to vendor transformer packages required to build plugin") - } - - // Git checkout our head-state vendor libraries - // This is necessary because we currently need to manual edit our vendored - // go-ethereum abi library to allow for unpacking in empty interfaces and maps - // This can be removed once the PRs against geth merged - err = exec.Command("git", "checkout", dirPath).Run() - if err != nil { - return errors.New("failed to checkout vendored go-ethereum lib") - } - - // Initialize temp directory for transformer migrations - g.tmpMigDir, err = utils.CleanPath("$GOPATH/src/github.com/vulcanize/vulcanizedb/db/plugin_migrations") - if err != nil { - return err - } - stat, err := os.Stat(g.tmpMigDir) - if err == nil { - if !stat.IsDir() { - return errors.New(fmt.Sprintf("file %s found where directory is expected", stat.Name())) - } - } else if os.IsNotExist(err) { - os.Mkdir(g.tmpMigDir, os.FileMode(0777)) - } else { - return err - } - - return nil + pgStr := fmt.Sprintf("postgres://%s:%d/%s?sslmode=disable", g.DBConfig.Hostname, g.DBConfig.Port, g.DBConfig.Name) + return exec.Command("migrate", "-path", g.tmpMigDir, "-database", pgStr, "up").Run() } func (g *generator) createMigrationCopies(paths []string) error { @@ -230,21 +204,19 @@ func (g *generator) createMigrationCopies(paths []string) error { return err } for _, file := range dir { - if file.IsDir() || len(file.Name()) < 15 { // (10 digit unix time stamp + x + .sql) is bare minimum + if file.IsDir() || len(file.Name()) < 15 || filepath.Ext(file.Name()) != ".sql" { // (10 digit unix time stamp + x + .sql) is bare minimum continue } _, err := strconv.Atoi(file.Name()[:10]) if err != nil { - fmt.Fprintf(os.Stderr, "migration file name %s does not posses 10 digit timestamp prefix", file.Name()) + fmt.Fprintf(os.Stderr, "migration file name %s does not posses 10 digit timestamp prefix\r\n", file.Name()) continue } - if filepath.Ext(file.Name()) == "sql" { - src := filepath.Join(path, file.Name()) - dst := filepath.Join(g.tmpMigDir, "1"+file.Name()) - err = utils.CopyFile(src, dst) - if err != nil { - return err - } + src := filepath.Join(path, file.Name()) + dst := filepath.Join(g.tmpMigDir, "1"+file.Name()) + err = utils.CopyFile(src, dst) + if err != nil { + return err } } } @@ -252,7 +224,14 @@ func (g *generator) createMigrationCopies(paths []string) error { return nil } -func (g *generator) cleanUp() error { +func (g *generator) cleanUp(goFile string) error { + if !g.GenConfig.Save { + err := utils.ClearFiles(goFile) + if err != nil { + return err + } + } + for _, venDir := range g.tmpVenDirs { err := os.RemoveAll(venDir) if err != nil { diff --git a/pkg/autogen/generator_test.go b/pkg/autogen/generator_test.go index ebd33cb9..6736fed3 100644 --- a/pkg/autogen/generator_test.go +++ b/pkg/autogen/generator_test.go @@ -31,20 +31,10 @@ import ( "github.com/vulcanize/vulcanizedb/pkg/core" "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres/repositories" - "github.com/vulcanize/vulcanizedb/pkg/transformers/bite" "github.com/vulcanize/vulcanizedb/utils" ) -var localConfig = autogen.Config{ - Initializers: map[string]string{ - "bite": "github.com/vulcanize/vulcanizedb/pkg/autogen/test_helpers/bite", - "deal": "github.com/vulcanize/vulcanizedb/pkg/autogen/test_helpers/deal", - }, - FileName: "localTestTransformerSet", - FilePath: "$GOPATH/src/github.com/vulcanize/vulcanizedb/pkg/autogen/test_helpers/test/", -} - -var externalConfig = autogen.Config{ +var genConfig = autogen.Config{ Initializers: map[string]string{ "bite": "github.com/vulcanize/mcd_transformers/transformers/bite", "deal": "github.com/vulcanize/mcd_transformers/transformers/deal", @@ -53,7 +43,8 @@ var externalConfig = autogen.Config{ "mcd_transformers": "github.com/vulcanize/mcd_transformers", }, FileName: "externalTestTransformerSet", - FilePath: "$GOPATH/src/github.com/vulcanize/vulcanizedb/pkg/autogen/test_helpers/test/", + FilePath: "$GOPATH/src/github.com/vulcanize/vulcanizedb/pkg/autogen/test_helpers/test", + Save: false, } type Exporter interface { @@ -71,147 +62,82 @@ var _ = Describe("Generator test", func() { viper.SetConfigName("compose") viper.AddConfigPath("$GOPATH/src/github.com/vulcanize/vulcanizedb/environments/") - Describe("Using local config", func() { - BeforeEach(func() { - goPath, soPath, err = localConfig.GetPluginPaths() - Expect(err).ToNot(HaveOccurred()) - g = autogen.NewGenerator(localConfig, config.Database{}) - err = g.GenerateExporterPlugin() - Expect(err).ToNot(HaveOccurred()) - }) - - AfterEach(func() { - err := utils.ClearFiles(goPath, soPath) - Expect(err).ToNot(HaveOccurred()) - }) - - Describe("GenerateTransformerPlugin", func() { - It("It bundles the specified transformer initializers into a Exporter object and creates .so", func() { - plug, err := plugin.Open(soPath) - Expect(err).ToNot(HaveOccurred()) - symExporter, err := plug.Lookup("Exporter") - Expect(err).ToNot(HaveOccurred()) - exporter, ok := symExporter.(Exporter) - Expect(ok).To(Equal(true)) - initializers := exporter.Export() - Expect(len(initializers)).To(Equal(2)) - }) - - It("Loads our generated Exporter and uses it to import an arbitrary set of TransformerInitializers that we can execute over", func() { - db, bc = test_helpers.SetupDBandBC() - defer test_helpers.TearDown(db) - - hr = repositories.NewHeaderRepository(db) - header1, err := bc.GetHeaderByNumber(9377319) - Expect(err).ToNot(HaveOccurred()) - headerID, err = hr.CreateOrUpdateHeader(header1) - Expect(err).ToNot(HaveOccurred()) - - plug, err := plugin.Open(soPath) - Expect(err).ToNot(HaveOccurred()) - symExporter, err := plug.Lookup("Exporter") - Expect(err).ToNot(HaveOccurred()) - exporter, ok := symExporter.(Exporter) - Expect(ok).To(Equal(true)) - initializers := exporter.Export() - - w := watcher.NewWatcher(db, bc) - w.AddTransformers(initializers) - err = w.Execute() - Expect(err).ToNot(HaveOccurred()) - - type model struct { - bite.BiteModel - Id int64 `db:"id"` - HeaderId int64 `db:"header_id"` - } - - returned := model{} - - err = db.Get(&returned, `SELECT * FROM maker.bite WHERE header_id = $1`, headerID) - Expect(err).ToNot(HaveOccurred()) - Expect(returned.Ilk).To(Equal("ETH")) - Expect(returned.Urn).To(Equal("0x0000d8b4147eDa80Fec7122AE16DA2479Cbd7ffB")) - Expect(returned.Ink).To(Equal("80000000000000000000")) - Expect(returned.Art).To(Equal("11000000000000000000000")) - Expect(returned.IArt).To(Equal("12496609999999999999992")) - Expect(returned.Tab).To(Equal("11000000000000000000000")) - Expect(returned.NFlip).To(Equal("7")) - Expect(returned.TransactionIndex).To(Equal(uint(1))) - Expect(returned.LogIndex).To(Equal(uint(4))) - }) - }) + BeforeEach(func() { + goPath, soPath, err = genConfig.GetPluginPaths() + Expect(err).ToNot(HaveOccurred()) + g = autogen.NewGenerator(genConfig, config.Database{}) + err = g.GenerateExporterPlugin() + Expect(err).ToNot(HaveOccurred()) }) - Describe("Using external config", func() { - BeforeEach(func() { - goPath, soPath, err = externalConfig.GetPluginPaths() + AfterEach(func() { + err := utils.ClearFiles(goPath, soPath) + Expect(err).ToNot(HaveOccurred()) + }) + + Describe("GenerateTransformerPlugin", func() { + It("It bundles the specified transformer initializers into a Exporter object and creates .so", func() { + plug, err := plugin.Open(soPath) Expect(err).ToNot(HaveOccurred()) - g = autogen.NewGenerator(externalConfig, config.Database{}) - err = g.GenerateExporterPlugin() + symExporter, err := plug.Lookup("Exporter") Expect(err).ToNot(HaveOccurred()) + exporter, ok := symExporter.(Exporter) + Expect(ok).To(Equal(true)) + initializers := exporter.Export() + Expect(len(initializers)).To(Equal(2)) }) - AfterEach(func() { - err := utils.ClearFiles(goPath, soPath) + It("Loads our generated Exporter and uses it to import an arbitrary set of TransformerInitializers that we can execute over", func() { + db, bc = test_helpers.SetupDBandBC() + defer test_helpers.TearDown(db) + + hr = repositories.NewHeaderRepository(db) + header1, err := bc.GetHeaderByNumber(9377319) + Expect(err).ToNot(HaveOccurred()) + headerID, err = hr.CreateOrUpdateHeader(header1) Expect(err).ToNot(HaveOccurred()) - }) - Describe("GenerateTransformerPlugin", func() { - It("It bundles the specified transformer initializers into a Exporter object and creates .so", func() { - plug, err := plugin.Open(soPath) - Expect(err).ToNot(HaveOccurred()) - symExporter, err := plug.Lookup("Exporter") - Expect(err).ToNot(HaveOccurred()) - exporter, ok := symExporter.(Exporter) - Expect(ok).To(Equal(true)) - initializers := exporter.Export() - Expect(len(initializers)).To(Equal(2)) - }) + plug, err := plugin.Open(soPath) + Expect(err).ToNot(HaveOccurred()) + symExporter, err := plug.Lookup("Exporter") + Expect(err).ToNot(HaveOccurred()) + exporter, ok := symExporter.(Exporter) + Expect(ok).To(Equal(true)) + initializers := exporter.Export() - It("Loads our generated Exporter and uses it to import an arbitrary set of TransformerInitializers that we can execute over", func() { - db, bc = test_helpers.SetupDBandBC() - defer test_helpers.TearDown(db) + w := watcher.NewWatcher(db, bc) + w.AddTransformers(initializers) + err = w.Execute() + Expect(err).ToNot(HaveOccurred()) - hr = repositories.NewHeaderRepository(db) - header1, err := bc.GetHeaderByNumber(9377319) - Expect(err).ToNot(HaveOccurred()) - headerID, err = hr.CreateOrUpdateHeader(header1) - Expect(err).ToNot(HaveOccurred()) + type model struct { + Ilk string + Urn string + Ink string + Art string + IArt string + Tab string + NFlip string + LogIndex uint `db:"log_idx"` + TransactionIndex uint `db:"tx_idx"` + Raw []byte `db:"raw_log"` + Id int64 `db:"id"` + HeaderId int64 `db:"header_id"` + } - plug, err := plugin.Open(soPath) - Expect(err).ToNot(HaveOccurred()) - symExporter, err := plug.Lookup("Exporter") - Expect(err).ToNot(HaveOccurred()) - exporter, ok := symExporter.(Exporter) - Expect(ok).To(Equal(true)) - initializers := exporter.Export() + returned := model{} - w := watcher.NewWatcher(db, bc) - w.AddTransformers(initializers) - err = w.Execute() - Expect(err).ToNot(HaveOccurred()) - - type model struct { - bite.BiteModel - Id int64 `db:"id"` - HeaderId int64 `db:"header_id"` - } - - returned := model{} - - err = db.Get(&returned, `SELECT * FROM maker.bite WHERE header_id = $1`, headerID) - Expect(err).ToNot(HaveOccurred()) - Expect(returned.Ilk).To(Equal("ETH")) - Expect(returned.Urn).To(Equal("0x0000d8b4147eDa80Fec7122AE16DA2479Cbd7ffB")) - Expect(returned.Ink).To(Equal("80000000000000000000")) - Expect(returned.Art).To(Equal("11000000000000000000000")) - Expect(returned.IArt).To(Equal("12496609999999999999992")) - Expect(returned.Tab).To(Equal("11000000000000000000000")) - Expect(returned.NFlip).To(Equal("7")) - Expect(returned.TransactionIndex).To(Equal(uint(1))) - Expect(returned.LogIndex).To(Equal(uint(4))) - }) + err = db.Get(&returned, `SELECT * FROM maker.bite WHERE header_id = $1`, headerID) + Expect(err).ToNot(HaveOccurred()) + Expect(returned.Ilk).To(Equal("ETH")) + Expect(returned.Urn).To(Equal("0x0000d8b4147eDa80Fec7122AE16DA2479Cbd7ffB")) + Expect(returned.Ink).To(Equal("80000000000000000000")) + Expect(returned.Art).To(Equal("11000000000000000000000")) + Expect(returned.IArt).To(Equal("12496609999999999999992")) + Expect(returned.Tab).To(Equal("11000000000000000000000")) + Expect(returned.NFlip).To(Equal("7")) + Expect(returned.TransactionIndex).To(Equal(uint(1))) + Expect(returned.LogIndex).To(Equal(uint(4))) }) }) }) diff --git a/pkg/autogen/test_helpers/bite/initializer.go b/pkg/autogen/test_helpers/bite/initializer.go deleted file mode 100644 index 1ce446dd..00000000 --- a/pkg/autogen/test_helpers/bite/initializer.go +++ /dev/null @@ -1,8 +0,0 @@ -package bite - -import ( - "github.com/vulcanize/vulcanizedb/libraries/shared/transformer" - "github.com/vulcanize/vulcanizedb/pkg/transformers" -) - -var TransformerInitializer transformer.TransformerInitializer = transformers.GetBiteTransformer().NewTransformer diff --git a/pkg/autogen/test_helpers/deal/initializer.go b/pkg/autogen/test_helpers/deal/initializer.go deleted file mode 100644 index 84a44263..00000000 --- a/pkg/autogen/test_helpers/deal/initializer.go +++ /dev/null @@ -1,8 +0,0 @@ -package deal - -import ( - "github.com/vulcanize/vulcanizedb/libraries/shared/transformer" - "github.com/vulcanize/vulcanizedb/pkg/transformers" -) - -var TransformerInitializer transformer.TransformerInitializer = transformers.GetDealTransformer().NewLogNoteTransformer diff --git a/pkg/autogen/test_helpers/test/README.md b/pkg/autogen/test_helpers/test/README.md index 6a93702e..4f86bf4b 100644 --- a/pkg/autogen/test_helpers/test/README.md +++ b/pkg/autogen/test_helpers/test/README.md @@ -1,3 +1,3 @@ ### Test -This empty directory is for holding the output code generated, and then deleted, during the generator_tests \ No newline at end of file +This empty directory is for holding the temporary .so and .go files generated during the generator_tests \ No newline at end of file diff --git a/pkg/fakes/data.go b/pkg/fakes/data.go index 59a43a2d..07492d40 100644 --- a/pkg/fakes/data.go +++ b/pkg/fakes/data.go @@ -24,8 +24,8 @@ 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/transformers/shared/constants" ) var ( diff --git a/pkg/transformers/DOCUMENTATION.md b/pkg/transformers/DOCUMENTATION.md deleted file mode 100644 index de85a455..00000000 --- a/pkg/transformers/DOCUMENTATION.md +++ /dev/null @@ -1,129 +0,0 @@ -# Transformers - -## Architecture - -Transformers fetch logs from Ethereum, convert/decode them into usable data, and then persist them in postgres. - -A transformer consists of: - -- A fetcher -> Fetches raw logs from the blockchain and encodes them as go datatypes -- A converter -> Converts this raw data into a human friendly representation suitable for consumption in the API -- A repository -> Abstracts the database - -For Maker, vulcanize will be run in `lightSync` mode, so it will store all headers, and then fetchers pull relevant logs by making RPC calls. - -## Event Types - -For Maker there are two main types of log events that we're tracking: - -1. Custom events that are defined in the contract solidity code. -1. `LogNote` events which utilize the [DSNote library](https://github.com/dapphub/ds-note). -1. `Note` events in the `Vat` - -The transformer process for each of these different log types is the same, except for the converting process, as denoted below. - -## Creating a Transformer - -1. Pull an example event (from kovan / ganache etc.) -1. Add event & method sig, contract address, `checked_headers` column name, and label to relevant files in [`constants`](./shared/constants) -1. Write a test for the event sig in [`event_signature_generator_test.go`](./shared/event_signature_generator_test.go) -1. Create DB table (using [`create_migration`](../../scripts/create_migration)) -1. Create columns in `checked_headers` in the _same_ migration -1. Add a line to clean the new table `CleanTestDB` (in [`test_config.go`](../../test_config/test_config.go)) -1. Define `model.go` -1. Create test event in [`test_data`](./test_data) -1. Write converter + converter tests -1. Write repository + repository tests -1. Create converter + repository mocks -1. Create an config object [`shared.TransformerConfig`](./shared/transformer.go) in `config.go` -1. Wire up transformer in [`transformers.go`](./transformers.go), remembering to add it to `TransformerInitializers()` -1. Wire up transformer in [`continuousLogSync.go`](../../cmd/continuousLogSync.go) -1. Manually trigger an event and check that it gets persisted to postgres -1. Create an integration test for the shiny new transformer in [`integration_tests`](./integration_tests) - -**Fetching Logs** - -1. Generate an example raw log event, by either: - - - Pulling the log directly from the Kovan deployment ([address.go](https://github.com/8thlight/maker-vulcanizedb/blob/master/pkg/transformers/shared/constants/address.go)). - - Deploying the contract to a local chain and emiting the event manually. - -1. Fetch the logs from the chain based on the example event's topic zero: - - - The topic zero is based on the keccak-256 hash of the log event's method signature. These are located in [`pkg/transformers/shared/constants/signature.go`](./shared/constants/signature.go). - - Fetching is done in batch from the [`watcher`](../../libraries/shared/watcher.go). - - The logs are then chunked up by the [`chunker`](./shared/log_chunker.go) before being delegated to each transformer. - -**Coverting logs** - -- **Converting most custom events** (such as FlopKick) - - 1. Convert the raw log into a Go struct. - - We've been using [go-ethereum's abigen tool](https://github.com/ethereum/go-ethereum/tree/master/cmd/abigen) to get the contract's ABI, and a Go struct that represents the event log. We will unpack the raw logs into this struct. - - To use abigen: `abigen --sol flip.sol --pkg flip --out {/path/to/output_file}` - - sol: this is the path to the solidity contract - - pkg: a package name for the generated Go code - - out: the file path for the generated Go code (optional) - - the output for `flop.sol` will include the FlopperAbi and the FlopperKick struct: - ```go - type FlopperKick struct { - Id *big.Int - Lot *big.Int - Bid *big.Int - Gal common.Address - End *big.Int - Raw types.Log - } - ``` - - Using go-ethereum's `contract.UnpackLog` method we can unpack the raw log into the FlopperKick struct (which we're referring to as the `entity`). - - See the `ToEntity` method in [`pkg/transformers/flop_kick/converter.go`](./flop_kick/converter.go). - 1. Convert the entity into a database model. See the `ToModel` method in `pkg/transformers/flop_kick/converter`. - -- **Converting Price Feed custom events** - - - Price Feed contracts use the [LogNote event](https://github.com/makerdao/medianizer/blob/master/src/medianizer.sol#L23) - - The LogNote event takes in the value of the price feed as it's sole argument, and does not index it. This means that this value can be taken directly from the log's data, and then properly converted using the `price_feeds.Convert` method (located in the model.go file). - - Since this conversion from raw log to model includes less fields than some others, we've chosen to convert it directly to the database model, skipping the `ToEntity` step. - -- **Converting LogNote events** (such as tend) - - Since LogNote events are a generic structure, they depend on the method signature of the method that is calling them. For example, the `tend` method is called on the [flip.sol contract](https://github.com/makerdao/dss/blob/master/src/flip.sol#L117), and it's method signature looks like this: `tend(uint,uint,uint)`. - - The first four bytes of the Keccak-256 hashed method signature will be located in `topic[0]` on the log. - - The message sender will be in `topic[1]`. - - The first parameter passed to `tend` becomes `topic[2]`. - - The second parameter passed to `tend` will be `topic[3]`. - - Any additional parameters will be in the log's data field. - - More detail is located in the [DSNote repo](https://github.com/dapphub/ds-note). - -**Get all MissingHeaders** - -- Headers are inserted into VulcanizeDB as part of the `lightSync` command. Then for each transformer we check each header for matching logs. -- The MissingHeaders method queries the `checked_headers` table to see if the header has been checked for the given log type. - -**Persist the log record to VulcanizeDB** - -- Each event log has it's own table in the database, as well as it's own column in the `checked_headers` table. - - The `checked_headers` table allows us to keep track of which headers have been checked for a given log type. -- To create a new migration file: `./scripts/create_migration create_flop_kick` - - See `db/migrations/1536942529_create_flop_kick.up.sql`. - - The specific log event tables are all created in the `maker` schema. - - There is a one-many association between `headers` and the log - event tables. This is so that if a header is removed due to a reorg, the associated log event records are also removed. -- To run the migrations: `make migrate HOST=local_host PORT=5432 NAME=vulcanize_private` -- When a new log record is inserted into VulcanizeDB, we also need to make sure to insert a record into the `checked_headers` table for the given log type. -- We have been using the repository pattern (i.e. wrapping all SQL/ORM invocations in isolated namespaces per table) to interact with the database, see the `Create` method in `pkg/transformers/flop_kick/repository.go`. - -**MarkHeaderChecked** - -- There is a chance that a header does not have a log for the given transformer's log type, and in this instance we also want to record that the header has been "checked" so that we don't continue to query that header over and over. -- In the transformer we'll make sure to insert a row for the header indicating that it has been checked for the log type that the transformer is responsible for. - -**Wire each component up in the transformer** - -- We use a [`TransformerInitializer`](./shared/transformer.go) struct for each transformer so that we can inject ethRPC and postgresDB connections as well as configuration data (including the contract address, block range, etc.) into the transformer. -- See any of `pkg/transformers/flop_kick/transformer.go` -- All of the transformers are then initialized in `pkg/transformers/transformers.go` with their configuration. -- The transformers can be executed by using the `continuousLogSync` command, which can be configured to run specific transformers or all transformers. - -## Useful Documents - -[Ethereum Event ABI Specification](https://solidity.readthedocs.io/en/develop/abi-spec.html#events) diff --git a/pkg/transformers/bite/bite_suite_test.go b/pkg/transformers/bite/bite_suite_test.go deleted file mode 100644 index b85d4a0a..00000000 --- a/pkg/transformers/bite/bite_suite_test.go +++ /dev/null @@ -1,35 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package bite_test - -import ( - "testing" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - log "github.com/sirupsen/logrus" - "io/ioutil" -) - -func TestBite(t *testing.T) { - RegisterFailHandler(Fail) - RunSpecs(t, "Bite Suite") -} - -var _ = BeforeSuite(func() { - log.SetOutput(ioutil.Discard) -}) diff --git a/pkg/transformers/bite/config.go b/pkg/transformers/bite/config.go deleted file mode 100644 index c965f212..00000000 --- a/pkg/transformers/bite/config.go +++ /dev/null @@ -1,33 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package bite - -import ( - shared_t "github.com/vulcanize/vulcanizedb/libraries/shared/transformer" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" -) - -func GetBiteConfig() shared_t.TransformerConfig { - return shared_t.TransformerConfig{ - TransformerName: constants.BiteLabel, - ContractAddresses: []string{constants.CatContractAddress()}, - ContractAbi: constants.CatABI(), - Topic: constants.GetBiteSignature(), - StartingBlockNumber: constants.CatDeploymentBlock(), - EndingBlockNumber: -1, - } -} diff --git a/pkg/transformers/bite/converter.go b/pkg/transformers/bite/converter.go deleted file mode 100644 index aa367d3c..00000000 --- a/pkg/transformers/bite/converter.go +++ /dev/null @@ -1,94 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package bite - -import ( - "encoding/json" - "fmt" - "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/core/types" - "github.com/vulcanize/vulcanizedb/pkg/geth" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared" -) - -type BiteConverter struct{} - -func (BiteConverter) ToEntities(contractAbi string, ethLogs []types.Log) ([]interface{}, error) { - var entities []interface{} - for _, ethLog := range ethLogs { - entity := &BiteEntity{} - address := ethLog.Address - abi, err := geth.ParseAbi(contractAbi) - if err != nil { - return nil, err - } - - contract := bind.NewBoundContract(address, abi, nil, nil, nil) - - err = contract.UnpackLog(entity, "Bite", ethLog) - if err != nil { - return nil, err - } - - entity.Raw = ethLog - entity.LogIndex = ethLog.Index - entity.TransactionIndex = ethLog.TxIndex - - entities = append(entities, *entity) - } - - return entities, nil -} - -func (converter BiteConverter) ToModels(entities []interface{}) ([]interface{}, error) { - var models []interface{} - for _, entity := range entities { - biteEntity, ok := entity.(BiteEntity) - if !ok { - return nil, fmt.Errorf("entity of type %T, not %T", entity, BiteEntity{}) - } - - ilk := shared.GetHexWithoutPrefix(biteEntity.Ilk[:]) - urn := shared.GetHexWithoutPrefix(biteEntity.Urn[:]) - ink := biteEntity.Ink - art := biteEntity.Art - iArt := biteEntity.IArt - tab := biteEntity.Tab - flip := biteEntity.Flip - logIdx := biteEntity.LogIndex - txIdx := biteEntity.TransactionIndex - rawLog, err := json.Marshal(biteEntity.Raw) - if err != nil { - return nil, err - } - - model := BiteModel{ - Ilk: ilk, - Urn: urn, - Ink: shared.BigIntToString(ink), - Art: shared.BigIntToString(art), - IArt: shared.BigIntToString(iArt), - Tab: shared.BigIntToString(tab), - NFlip: shared.BigIntToString(flip), - LogIndex: logIdx, - TransactionIndex: txIdx, - Raw: rawLog, - } - models = append(models, model) - } - return models, nil -} diff --git a/pkg/transformers/bite/converter_test.go b/pkg/transformers/bite/converter_test.go deleted file mode 100644 index 6e95a12c..00000000 --- a/pkg/transformers/bite/converter_test.go +++ /dev/null @@ -1,91 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package bite_test - -import ( - "encoding/json" - - "github.com/ethereum/go-ethereum/core/types" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - - "github.com/vulcanize/vulcanizedb/pkg/transformers/bite" - "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data" -) - -var _ = Describe("Bite Converter", func() { - var converter = bite.BiteConverter{} - - Describe("ToEntity", func() { - It("converts an eth log to a bite entity", func() { - entities, err := converter.ToEntities(test_data.KovanCatABI, []types.Log{test_data.EthBiteLog}) - - Expect(err).NotTo(HaveOccurred()) - Expect(len(entities)).To(Equal(1)) - entity := entities[0] - Expect(entity).To(Equal(test_data.BiteEntity)) - }) - - It("returns an error if converting log to entity fails", func() { - _, err := converter.ToEntities("error abi", []types.Log{test_data.EthBiteLog}) - - Expect(err).To(HaveOccurred()) - }) - }) - - Describe("ToModel", func() { - var emptyEntity = bite.BiteEntity{} - - It("converts an Entity to a Model", func() { - models, err := converter.ToModels([]interface{}{test_data.BiteEntity}) - - Expect(err).NotTo(HaveOccurred()) - Expect(len(models)).To(Equal(1)) - model := models[0] - Expect(model).To(Equal(test_data.BiteModel)) - }) - - It("returns an error if the entity type is wrong", func() { - _, err := converter.ToModels([]interface{}{test_data.WrongEntity{}}) - - Expect(err).To(HaveOccurred()) - Expect(err.Error()).To(ContainSubstring("entity of type test_data.WrongEntity, not bite.BiteEntity")) - }) - - It("handles nil values", func() { - emptyLog, err := json.Marshal(types.Log{}) - Expect(err).NotTo(HaveOccurred()) - expectedModel := bite.BiteModel{ - Ilk: "0000000000000000000000000000000000000000000000000000000000000000", - Urn: "0000000000000000000000000000000000000000000000000000000000000000", - Ink: "", - Art: "", - IArt: "", - Tab: "", - NFlip: "", - TransactionIndex: 0, - Raw: emptyLog, - } - models, err := converter.ToModels([]interface{}{emptyEntity}) - - Expect(err).NotTo(HaveOccurred()) - Expect(len(models)).To(Equal(1)) - model := models[0] - Expect(model).To(Equal(expectedModel)) - }) - }) -}) diff --git a/pkg/transformers/bite/entity.go b/pkg/transformers/bite/entity.go deleted file mode 100644 index 16fbdf58..00000000 --- a/pkg/transformers/bite/entity.go +++ /dev/null @@ -1,35 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package bite - -import ( - "github.com/ethereum/go-ethereum/core/types" - "math/big" -) - -type BiteEntity struct { - Ilk [32]byte - Urn [32]byte - Ink *big.Int - Art *big.Int - Tab *big.Int - Flip *big.Int - IArt *big.Int - LogIndex uint - TransactionIndex uint - Raw types.Log -} diff --git a/pkg/transformers/bite/model.go b/pkg/transformers/bite/model.go deleted file mode 100644 index e2fde40a..00000000 --- a/pkg/transformers/bite/model.go +++ /dev/null @@ -1,30 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package bite - -type BiteModel struct { - Ilk string - Urn string - Ink string - Art string - IArt string - Tab string - NFlip string - LogIndex uint `db:"log_idx"` - TransactionIndex uint `db:"tx_idx"` - Raw []byte `db:"raw_log"` -} diff --git a/pkg/transformers/cat_file/chop_lump/chop_lump_suite_test.go b/pkg/transformers/cat_file/chop_lump/chop_lump_suite_test.go deleted file mode 100644 index 8bd2695d..00000000 --- a/pkg/transformers/cat_file/chop_lump/chop_lump_suite_test.go +++ /dev/null @@ -1,35 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package chop_lump_test - -import ( - log "github.com/sirupsen/logrus" - "io/ioutil" - "testing" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -func TestChopLump(t *testing.T) { - RegisterFailHandler(Fail) - RunSpecs(t, "ChopLump Suite") -} - -var _ = BeforeSuite(func() { - log.SetOutput(ioutil.Discard) -}) diff --git a/pkg/transformers/cat_file/chop_lump/config.go b/pkg/transformers/cat_file/chop_lump/config.go deleted file mode 100644 index 8398b16e..00000000 --- a/pkg/transformers/cat_file/chop_lump/config.go +++ /dev/null @@ -1,33 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package chop_lump - -import ( - shared_t "github.com/vulcanize/vulcanizedb/libraries/shared/transformer" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" -) - -func GetCatFileChopLumpConfig() shared_t.TransformerConfig { - return shared_t.TransformerConfig{ - TransformerName: constants.CatFileChopLumpLabel, - ContractAddresses: []string{constants.CatContractAddress()}, - ContractAbi: constants.CatABI(), - Topic: constants.GetCatFileChopLumpSignature(), - StartingBlockNumber: constants.CatDeploymentBlock(), - EndingBlockNumber: -1, - } -} diff --git a/pkg/transformers/cat_file/chop_lump/converter.go b/pkg/transformers/cat_file/chop_lump/converter.go deleted file mode 100644 index 753dd76c..00000000 --- a/pkg/transformers/cat_file/chop_lump/converter.go +++ /dev/null @@ -1,84 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package chop_lump - -import ( - "bytes" - "encoding/json" - "errors" - "github.com/ethereum/go-ethereum/core/types" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" - "math/big" -) - -var ( - chop = "chop" - lump = "lump" -) - -type CatFileChopLumpConverter struct{} - -func (CatFileChopLumpConverter) ToModels(ethLogs []types.Log) ([]interface{}, error) { - var results []interface{} - for _, ethLog := range ethLogs { - err := verifyLog(ethLog) - if err != nil { - return nil, err - } - ilk := shared.GetHexWithoutPrefix(ethLog.Topics[2].Bytes()) - what := string(bytes.Trim(ethLog.Topics[3].Bytes(), "\x00")) - dataBytes := ethLog.Data[len(ethLog.Data)-constants.DataItemLength:] - data := big.NewInt(0).SetBytes(dataBytes).String() - - raw, err := json.Marshal(ethLog) - if err != nil { - return nil, err - } - result := CatFileChopLumpModel{ - Ilk: ilk, - What: what, - Data: convertData(what, data), - TransactionIndex: ethLog.TxIndex, - LogIndex: ethLog.Index, - Raw: raw, - } - results = append(results, result) - } - return results, nil -} - -func convertData(what, data string) string { - var convertedData string - if what == chop { - convertedData = shared.ConvertToRay(data) - } else if what == lump { - convertedData = shared.ConvertToWad(data) - } - - return convertedData -} - -func verifyLog(log types.Log) error { - if len(log.Topics) < 4 { - return errors.New("log missing topics") - } - if len(log.Data) < constants.DataItemLength { - return errors.New("log missing data") - } - return nil -} diff --git a/pkg/transformers/cat_file/chop_lump/converter_test.go b/pkg/transformers/cat_file/chop_lump/converter_test.go deleted file mode 100644 index 7f0f0da8..00000000 --- a/pkg/transformers/cat_file/chop_lump/converter_test.go +++ /dev/null @@ -1,71 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package chop_lump_test - -import ( - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/types" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - - "github.com/vulcanize/vulcanizedb/pkg/transformers/cat_file/chop_lump" - "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data" -) - -var _ = Describe("Cat file chop lump converter", func() { - var converter chop_lump.CatFileChopLumpConverter - - BeforeEach(func() { - converter = chop_lump.CatFileChopLumpConverter{} - }) - - Context("chop events", func() { - It("converts a chop log to a model", func() { - models, err := converter.ToModels([]types.Log{test_data.EthCatFileChopLog}) - - Expect(err).NotTo(HaveOccurred()) - Expect(models).To(Equal([]interface{}{test_data.CatFileChopModel})) - }) - }) - - Context("lump events", func() { - It("converts a lump log to a model", func() { - models, err := converter.ToModels([]types.Log{test_data.EthCatFileLumpLog}) - - Expect(err).NotTo(HaveOccurred()) - Expect(models).To(Equal([]interface{}{test_data.CatFileLumpModel})) - }) - }) - - It("returns err if log is missing topics", func() { - badLog := types.Log{ - Data: []byte{1, 1, 1, 1, 1}, - } - - _, err := converter.ToModels([]types.Log{badLog}) - Expect(err).To(HaveOccurred()) - }) - - It("returns err if log is missing data", func() { - badLog := types.Log{ - Topics: []common.Hash{{}, {}, {}, {}}, - } - - _, err := converter.ToModels([]types.Log{badLog}) - Expect(err).To(HaveOccurred()) - }) -}) diff --git a/pkg/transformers/cat_file/chop_lump/model.go b/pkg/transformers/cat_file/chop_lump/model.go deleted file mode 100644 index ada429ce..00000000 --- a/pkg/transformers/cat_file/chop_lump/model.go +++ /dev/null @@ -1,26 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package chop_lump - -type CatFileChopLumpModel struct { - Ilk string - What string - Data string - TransactionIndex uint `db:"tx_idx"` - LogIndex uint `db:"log_idx"` - Raw []byte `db:"raw_log"` -} diff --git a/pkg/transformers/cat_file/flip/config.go b/pkg/transformers/cat_file/flip/config.go deleted file mode 100644 index b8e010fc..00000000 --- a/pkg/transformers/cat_file/flip/config.go +++ /dev/null @@ -1,33 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package flip - -import ( - shared_t "github.com/vulcanize/vulcanizedb/libraries/shared/transformer" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" -) - -func GetCatFileFlipConfig() shared_t.TransformerConfig { - return shared_t.TransformerConfig{ - TransformerName: constants.CatFileFlipLabel, - ContractAddresses: []string{constants.CatContractAddress()}, - ContractAbi: constants.CatABI(), - Topic: constants.GetCatFileFlipSignature(), - StartingBlockNumber: constants.CatDeploymentBlock(), - EndingBlockNumber: -1, - } -} diff --git a/pkg/transformers/cat_file/flip/converter.go b/pkg/transformers/cat_file/flip/converter.go deleted file mode 100644 index eb748972..00000000 --- a/pkg/transformers/cat_file/flip/converter.go +++ /dev/null @@ -1,68 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package flip - -import ( - "bytes" - "encoding/json" - "errors" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/types" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" -) - -type CatFileFlipConverter struct{} - -func (CatFileFlipConverter) ToModels(ethLogs []types.Log) ([]interface{}, error) { - var results []interface{} - for _, ethLog := range ethLogs { - err := verifyLog(ethLog) - if err != nil { - return nil, err - } - ilk := shared.GetHexWithoutPrefix(ethLog.Topics[2].Bytes()) - what := string(bytes.Trim(ethLog.Topics[3].Bytes(), "\x00")) - flipBytes := ethLog.Data[len(ethLog.Data)-constants.DataItemLength:] - flip := common.BytesToAddress(flipBytes).String() - - raw, err := json.Marshal(ethLog) - if err != nil { - return nil, err - } - result := CatFileFlipModel{ - Ilk: ilk, - What: what, - Flip: flip, - TransactionIndex: ethLog.TxIndex, - LogIndex: ethLog.Index, - Raw: raw, - } - results = append(results, result) - } - return results, nil -} - -func verifyLog(log types.Log) error { - if len(log.Topics) < 4 { - return errors.New("log missing topics") - } - if len(log.Data) < constants.DataItemLength { - return errors.New("log missing data") - } - return nil -} diff --git a/pkg/transformers/cat_file/flip/converter_test.go b/pkg/transformers/cat_file/flip/converter_test.go deleted file mode 100644 index dd73dc53..00000000 --- a/pkg/transformers/cat_file/flip/converter_test.go +++ /dev/null @@ -1,60 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package flip_test - -import ( - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/types" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - - "github.com/vulcanize/vulcanizedb/pkg/transformers/cat_file/flip" - "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data" -) - -var _ = Describe("Cat file flip converter", func() { - var converter flip.CatFileFlipConverter - - BeforeEach(func() { - converter = flip.CatFileFlipConverter{} - }) - - It("returns err if log is missing topics", func() { - badLog := types.Log{ - Data: []byte{1, 1, 1, 1, 1}, - } - - _, err := converter.ToModels([]types.Log{badLog}) - Expect(err).To(HaveOccurred()) - }) - - It("returns err if log is missing data", func() { - badLog := types.Log{ - Topics: []common.Hash{{}, {}, {}, {}}, - } - - _, err := converter.ToModels([]types.Log{badLog}) - Expect(err).To(HaveOccurred()) - }) - - It("converts a log to an model", func() { - models, err := converter.ToModels([]types.Log{test_data.EthCatFileFlipLog}) - - Expect(err).NotTo(HaveOccurred()) - Expect(models).To(Equal([]interface{}{test_data.CatFileFlipModel})) - }) -}) diff --git a/pkg/transformers/cat_file/flip/flip_suite_test.go b/pkg/transformers/cat_file/flip/flip_suite_test.go deleted file mode 100644 index 83a58761..00000000 --- a/pkg/transformers/cat_file/flip/flip_suite_test.go +++ /dev/null @@ -1,35 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package flip_test - -import ( - log "github.com/sirupsen/logrus" - "io/ioutil" - "testing" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -func TestFlip(t *testing.T) { - RegisterFailHandler(Fail) - RunSpecs(t, "Flip Suite") -} - -var _ = BeforeSuite(func() { - log.SetOutput(ioutil.Discard) -}) diff --git a/pkg/transformers/cat_file/flip/model.go b/pkg/transformers/cat_file/flip/model.go deleted file mode 100644 index 31dcdaa8..00000000 --- a/pkg/transformers/cat_file/flip/model.go +++ /dev/null @@ -1,26 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package flip - -type CatFileFlipModel struct { - Ilk string - What string - Flip string - TransactionIndex uint `db:"tx_idx"` - LogIndex uint `db:"log_idx"` - Raw []byte `db:"raw_log"` -} diff --git a/pkg/transformers/cat_file/flip/repository.go b/pkg/transformers/cat_file/flip/repository.go deleted file mode 100644 index 648effea..00000000 --- a/pkg/transformers/cat_file/flip/repository.go +++ /dev/null @@ -1,89 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package flip - -import ( - "fmt" - - log "github.com/sirupsen/logrus" - - "github.com/vulcanize/vulcanizedb/pkg/core" - "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" -) - -type CatFileFlipRepository struct { - db *postgres.DB -} - -func (repository CatFileFlipRepository) Create(headerID int64, models []interface{}) error { - tx, dBaseErr := repository.db.Begin() - if dBaseErr != nil { - return dBaseErr - } - for _, model := range models { - flip, ok := model.(CatFileFlipModel) - if !ok { - rollbackErr := tx.Rollback() - if rollbackErr != nil { - log.Error("failed to rollback ", rollbackErr) - } - return fmt.Errorf("model of type %T, not %T", model, CatFileFlipModel{}) - } - - _, execErr := repository.db.Exec( - `INSERT into maker.cat_file_flip (header_id, ilk, what, flip, tx_idx, log_idx, raw_log) - VALUES($1, $2, $3, $4, $5, $6, $7) - ON CONFLICT (header_id, tx_idx, log_idx) DO UPDATE SET ilk = $2, what = $3, flip = $4, raw_log = $7;`, - headerID, flip.Ilk, flip.What, flip.Flip, flip.TransactionIndex, flip.LogIndex, flip.Raw, - ) - if execErr != nil { - rollbackErr := tx.Rollback() - if rollbackErr != nil { - log.Error("failed to rollback ", rollbackErr) - } - return execErr - } - } - - checkHeaderErr := shared.MarkHeaderCheckedInTransaction(headerID, tx, constants.CatFileFlipChecked) - if checkHeaderErr != nil { - rollbackErr := tx.Rollback() - if rollbackErr != nil { - log.Error("failed to rollback ", rollbackErr) - } - return checkHeaderErr - } - return tx.Commit() -} - -func (repository CatFileFlipRepository) MarkHeaderChecked(headerID int64) error { - return shared.MarkHeaderChecked(headerID, repository.db, constants.CatFileFlipChecked) -} - -func (repository CatFileFlipRepository) MissingHeaders(startingBlockNumber, endingBlockNumber int64) ([]core.Header, error) { - return shared.MissingHeaders(startingBlockNumber, endingBlockNumber, repository.db, constants.CatFileFlipChecked) -} - -func (repository CatFileFlipRepository) RecheckHeaders(startingBlockNumber, endingBlockNumber int64) ([]core.Header, error) { - return shared.RecheckHeaders(startingBlockNumber, endingBlockNumber, repository.db, constants.CatFileFlipChecked) -} - -func (repository *CatFileFlipRepository) SetDB(db *postgres.DB) { - repository.db = db -} diff --git a/pkg/transformers/cat_file/flip/repository_test.go b/pkg/transformers/cat_file/flip/repository_test.go deleted file mode 100644 index fd345ff1..00000000 --- a/pkg/transformers/cat_file/flip/repository_test.go +++ /dev/null @@ -1,88 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package flip_test - -import ( - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - - "github.com/vulcanize/vulcanizedb/pkg/datastore" - "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" - "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres/repositories" - "github.com/vulcanize/vulcanizedb/pkg/fakes" - "github.com/vulcanize/vulcanizedb/pkg/transformers/cat_file/flip" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" - "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data" - "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data/shared_behaviors" - "github.com/vulcanize/vulcanizedb/test_config" -) - -var _ = Describe("Cat file flip repository", func() { - var ( - catFileFlipRepository flip.CatFileFlipRepository - db *postgres.DB - headerRepository datastore.HeaderRepository - ) - - BeforeEach(func() { - db = test_config.NewTestDB(test_config.NewTestNode()) - test_config.CleanTestDB(db) - headerRepository = repositories.NewHeaderRepository(db) - catFileFlipRepository = flip.CatFileFlipRepository{} - catFileFlipRepository.SetDB(db) - }) - - Describe("Create", func() { - catFileFlipWithDifferentIdx := test_data.CatFileFlipModel - catFileFlipWithDifferentIdx.LogIndex++ - inputs := shared_behaviors.CreateBehaviorInputs{ - CheckedHeaderColumnName: constants.CatFileFlipChecked, - LogEventTableName: "maker.cat_file_flip", - TestModel: test_data.CatFileFlipModel, - ModelWithDifferentLogIdx: catFileFlipWithDifferentIdx, - Repository: &catFileFlipRepository, - } - - shared_behaviors.SharedRepositoryCreateBehaviors(&inputs) - - It("adds a cat file flip event", func() { - headerID, err := headerRepository.CreateOrUpdateHeader(fakes.FakeHeader) - Expect(err).NotTo(HaveOccurred()) - err = catFileFlipRepository.Create(headerID, []interface{}{test_data.CatFileFlipModel}) - - Expect(err).NotTo(HaveOccurred()) - var dbResult flip.CatFileFlipModel - err = db.Get(&dbResult, `SELECT ilk, what, flip, tx_idx, log_idx, raw_log FROM maker.cat_file_flip WHERE header_id = $1`, headerID) - Expect(err).NotTo(HaveOccurred()) - Expect(dbResult.Ilk).To(Equal(test_data.CatFileFlipModel.Ilk)) - Expect(dbResult.What).To(Equal(test_data.CatFileFlipModel.What)) - Expect(dbResult.Flip).To(Equal(test_data.CatFileFlipModel.Flip)) - Expect(dbResult.TransactionIndex).To(Equal(test_data.CatFileFlipModel.TransactionIndex)) - Expect(dbResult.LogIndex).To(Equal(test_data.CatFileFlipModel.LogIndex)) - Expect(dbResult.Raw).To(MatchJSON(test_data.CatFileFlipModel.Raw)) - }) - }) - - Describe("MarkHeaderChecked", func() { - inputs := shared_behaviors.MarkedHeaderCheckedBehaviorInputs{ - CheckedHeaderColumnName: constants.CatFileFlipChecked, - Repository: &catFileFlipRepository, - } - - shared_behaviors.SharedRepositoryMarkHeaderCheckedBehaviors(&inputs) - }) -}) diff --git a/pkg/transformers/cat_file/pit_vow/config.go b/pkg/transformers/cat_file/pit_vow/config.go deleted file mode 100644 index 8db450b9..00000000 --- a/pkg/transformers/cat_file/pit_vow/config.go +++ /dev/null @@ -1,33 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package pit_vow - -import ( - shared_t "github.com/vulcanize/vulcanizedb/libraries/shared/transformer" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" -) - -func GetCatFilePitVowConfig() shared_t.TransformerConfig { - return shared_t.TransformerConfig{ - TransformerName: constants.CatFilePitVowLabel, - ContractAddresses: []string{constants.CatContractAddress()}, - ContractAbi: constants.CatABI(), - Topic: constants.GetCatFilePitVowSignature(), - StartingBlockNumber: constants.CatDeploymentBlock(), - EndingBlockNumber: -1, - } -} diff --git a/pkg/transformers/cat_file/pit_vow/converter.go b/pkg/transformers/cat_file/pit_vow/converter.go deleted file mode 100644 index ad35e4a9..00000000 --- a/pkg/transformers/cat_file/pit_vow/converter.go +++ /dev/null @@ -1,66 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package pit_vow - -import ( - "bytes" - "encoding/json" - "errors" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/types" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" -) - -type CatFilePitVowConverter struct{} - -func (CatFilePitVowConverter) ToModels(ethLogs []types.Log) ([]interface{}, error) { - var results []interface{} - for _, ethLog := range ethLogs { - err := verifyLog(ethLog) - if err != nil { - return nil, err - } - - what := string(bytes.Trim(ethLog.Topics[2].Bytes(), "\x00")) - data := common.BytesToAddress(ethLog.Topics[3].Bytes()).String() - - raw, err := json.Marshal(ethLog) - if err != nil { - return nil, err - } - - result := CatFilePitVowModel{ - What: what, - Data: data, - TransactionIndex: ethLog.TxIndex, - LogIndex: ethLog.Index, - Raw: raw, - } - results = append(results, result) - } - return results, nil -} - -func verifyLog(log types.Log) error { - if len(log.Topics) < 4 { - return errors.New("log missing topics") - } - if len(log.Data) < constants.DataItemLength { - return errors.New("log missing data") - } - return nil -} diff --git a/pkg/transformers/cat_file/pit_vow/converter_test.go b/pkg/transformers/cat_file/pit_vow/converter_test.go deleted file mode 100644 index 6ccf1152..00000000 --- a/pkg/transformers/cat_file/pit_vow/converter_test.go +++ /dev/null @@ -1,60 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package pit_vow_test - -import ( - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/types" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - - "github.com/vulcanize/vulcanizedb/pkg/transformers/cat_file/pit_vow" - "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data" -) - -var _ = Describe("Cat file pit vow converter", func() { - var converter pit_vow.CatFilePitVowConverter - - BeforeEach(func() { - converter = pit_vow.CatFilePitVowConverter{} - }) - - It("returns err if log is missing topics", func() { - badLog := types.Log{ - Data: []byte{1, 1, 1, 1, 1}, - } - - _, err := converter.ToModels([]types.Log{badLog}) - Expect(err).To(HaveOccurred()) - }) - - It("returns err if log is missing data", func() { - badLog := types.Log{ - Topics: []common.Hash{{}, {}, {}, {}}, - } - - _, err := converter.ToModels([]types.Log{badLog}) - Expect(err).To(HaveOccurred()) - }) - - It("converts a log to an model", func() { - models, err := converter.ToModels([]types.Log{test_data.EthCatFilePitVowLog}) - - Expect(err).NotTo(HaveOccurred()) - Expect(models).To(Equal([]interface{}{test_data.CatFilePitVowModel})) - }) -}) diff --git a/pkg/transformers/cat_file/pit_vow/model.go b/pkg/transformers/cat_file/pit_vow/model.go deleted file mode 100644 index 02539305..00000000 --- a/pkg/transformers/cat_file/pit_vow/model.go +++ /dev/null @@ -1,25 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package pit_vow - -type CatFilePitVowModel struct { - What string - Data string - TransactionIndex uint `db:"tx_idx"` - LogIndex uint `db:"log_idx"` - Raw []byte `db:"raw_log"` -} diff --git a/pkg/transformers/cat_file/pit_vow/pit_vow_suite_test.go b/pkg/transformers/cat_file/pit_vow/pit_vow_suite_test.go deleted file mode 100644 index 9116a813..00000000 --- a/pkg/transformers/cat_file/pit_vow/pit_vow_suite_test.go +++ /dev/null @@ -1,35 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package pit_vow_test - -import ( - log "github.com/sirupsen/logrus" - "io/ioutil" - "testing" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -func TestPitVow(t *testing.T) { - RegisterFailHandler(Fail) - RunSpecs(t, "PitVow Suite") -} - -var _ = BeforeSuite(func() { - log.SetOutput(ioutil.Discard) -}) diff --git a/pkg/transformers/cat_file/pit_vow/repository.go b/pkg/transformers/cat_file/pit_vow/repository.go deleted file mode 100644 index bc737c29..00000000 --- a/pkg/transformers/cat_file/pit_vow/repository.go +++ /dev/null @@ -1,89 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package pit_vow - -import ( - "fmt" - - log "github.com/sirupsen/logrus" - - "github.com/vulcanize/vulcanizedb/pkg/core" - "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" -) - -type CatFilePitVowRepository struct { - db *postgres.DB -} - -func (repository CatFilePitVowRepository) Create(headerID int64, models []interface{}) error { - tx, dBaseErr := repository.db.Begin() - if dBaseErr != nil { - return dBaseErr - } - for _, model := range models { - vow, ok := model.(CatFilePitVowModel) - if !ok { - rollbackErr := tx.Rollback() - if rollbackErr != nil { - log.Error("failed to rollback ", rollbackErr) - } - return fmt.Errorf("model of type %T, not %T", model, CatFilePitVowModel{}) - } - - _, execErr := repository.db.Exec( - `INSERT into maker.cat_file_pit_vow (header_id, what, data, tx_idx, log_idx, raw_log) - VALUES($1, $2, $3, $4, $5, $6) - ON CONFLICT (header_id, tx_idx, log_idx) DO UPDATE SET what = $2, data = $3, raw_log = $6;`, - headerID, vow.What, vow.Data, vow.TransactionIndex, vow.LogIndex, vow.Raw, - ) - if execErr != nil { - rollbackErr := tx.Rollback() - if rollbackErr != nil { - log.Error("failed to rollback ", rollbackErr) - } - return execErr - } - } - - checkHeaderErr := shared.MarkHeaderCheckedInTransaction(headerID, tx, constants.CatFilePitVowChecked) - if checkHeaderErr != nil { - rollbackErr := tx.Rollback() - if rollbackErr != nil { - log.Error("failed to rollback ", rollbackErr) - } - return checkHeaderErr - } - return tx.Commit() -} - -func (repository CatFilePitVowRepository) MarkHeaderChecked(headerID int64) error { - return shared.MarkHeaderChecked(headerID, repository.db, constants.CatFilePitVowChecked) -} - -func (repository CatFilePitVowRepository) MissingHeaders(startingBlockNumber, endingBlockNumber int64) ([]core.Header, error) { - return shared.MissingHeaders(startingBlockNumber, endingBlockNumber, repository.db, constants.CatFilePitVowChecked) -} - -func (repository CatFilePitVowRepository) RecheckHeaders(startingBlockNumber, endingBlockNumber int64) ([]core.Header, error) { - return shared.RecheckHeaders(startingBlockNumber, endingBlockNumber, repository.db, constants.CatFilePitVowChecked) -} - -func (repository *CatFilePitVowRepository) SetDB(db *postgres.DB) { - repository.db = db -} diff --git a/pkg/transformers/cat_file/pit_vow/repository_test.go b/pkg/transformers/cat_file/pit_vow/repository_test.go deleted file mode 100644 index f476c820..00000000 --- a/pkg/transformers/cat_file/pit_vow/repository_test.go +++ /dev/null @@ -1,86 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package pit_vow_test - -import ( - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - - "github.com/vulcanize/vulcanizedb/pkg/datastore" - "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" - "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres/repositories" - "github.com/vulcanize/vulcanizedb/pkg/fakes" - "github.com/vulcanize/vulcanizedb/pkg/transformers/cat_file/pit_vow" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" - "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data" - "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data/shared_behaviors" - "github.com/vulcanize/vulcanizedb/test_config" -) - -var _ = Describe("Cat file pit vow repository", func() { - var ( - catFilePitVowRepository pit_vow.CatFilePitVowRepository - db *postgres.DB - headerRepository datastore.HeaderRepository - ) - - BeforeEach(func() { - db = test_config.NewTestDB(test_config.NewTestNode()) - test_config.CleanTestDB(db) - headerRepository = repositories.NewHeaderRepository(db) - catFilePitVowRepository = pit_vow.CatFilePitVowRepository{} - catFilePitVowRepository.SetDB(db) - }) - - Describe("Create", func() { - modelWithDifferentLogIdx := test_data.CatFilePitVowModel - modelWithDifferentLogIdx.LogIndex++ - inputs := shared_behaviors.CreateBehaviorInputs{ - CheckedHeaderColumnName: constants.CatFilePitVowChecked, - LogEventTableName: "maker.cat_file_pit_vow", - TestModel: test_data.CatFilePitVowModel, - ModelWithDifferentLogIdx: modelWithDifferentLogIdx, - Repository: &catFilePitVowRepository, - } - - shared_behaviors.SharedRepositoryCreateBehaviors(&inputs) - - It("adds a cat file pit vow event", func() { - headerID, err := headerRepository.CreateOrUpdateHeader(fakes.FakeHeader) - Expect(err).NotTo(HaveOccurred()) - err = catFilePitVowRepository.Create(headerID, []interface{}{test_data.CatFilePitVowModel}) - - Expect(err).NotTo(HaveOccurred()) - var dbResult pit_vow.CatFilePitVowModel - err = db.Get(&dbResult, `SELECT what, data, tx_idx, log_idx, raw_log FROM maker.cat_file_pit_vow WHERE header_id = $1`, headerID) - Expect(err).NotTo(HaveOccurred()) - Expect(dbResult.What).To(Equal(test_data.CatFilePitVowModel.What)) - Expect(dbResult.Data).To(Equal(test_data.CatFilePitVowModel.Data)) - Expect(dbResult.TransactionIndex).To(Equal(test_data.CatFilePitVowModel.TransactionIndex)) - Expect(dbResult.LogIndex).To(Equal(test_data.CatFilePitVowModel.LogIndex)) - Expect(dbResult.Raw).To(MatchJSON(test_data.CatFilePitVowModel.Raw)) - }) - }) - - Describe("MarkHeaderChecked", func() { - inputs := shared_behaviors.MarkedHeaderCheckedBehaviorInputs{ - CheckedHeaderColumnName: constants.CatFilePitVowChecked, - Repository: &catFilePitVowRepository, - } - shared_behaviors.SharedRepositoryMarkHeaderCheckedBehaviors(&inputs) - }) -}) diff --git a/pkg/transformers/deal/config.go b/pkg/transformers/deal/config.go deleted file mode 100644 index 398a1738..00000000 --- a/pkg/transformers/deal/config.go +++ /dev/null @@ -1,35 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package deal - -import ( - shared_t "github.com/vulcanize/vulcanizedb/libraries/shared/transformer" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" -) - -func GetDealConfig() shared_t.TransformerConfig { - return shared_t.TransformerConfig{ - TransformerName: constants.DealLabel, - ContractAddresses: []string{constants.FlapperContractAddress(), constants.FlipperContractAddress(), constants.FlopperContractAddress()}, - ContractAbi: constants.FlipperABI(), - Topic: constants.GetDealSignature(), - StartingBlockNumber: shared.MinInt64([]int64{ - constants.FlapperDeploymentBlock(), constants.FlipperDeploymentBlock(), constants.FlopperDeploymentBlock()}), - EndingBlockNumber: -1, - } -} diff --git a/pkg/transformers/deal/converter.go b/pkg/transformers/deal/converter.go deleted file mode 100644 index d9545b21..00000000 --- a/pkg/transformers/deal/converter.go +++ /dev/null @@ -1,59 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package deal - -import ( - "encoding/json" - "errors" - - "github.com/ethereum/go-ethereum/core/types" -) - -type DealConverter struct{} - -func (DealConverter) ToModels(ethLogs []types.Log) (result []interface{}, err error) { - for _, log := range ethLogs { - err := validateLog(log) - if err != nil { - return nil, err - } - - bidId := log.Topics[2].Big() - raw, err := json.Marshal(log) - if err != nil { - return nil, err - } - - model := DealModel{ - BidId: bidId.String(), - ContractAddress: log.Address.Hex(), - LogIndex: log.Index, - TransactionIndex: log.TxIndex, - Raw: raw, - } - result = append(result, model) - } - - return result, nil -} - -func validateLog(ethLog types.Log) error { - if len(ethLog.Topics) < 3 { - return errors.New("deal log does not contain expected topics") - } - return nil -} diff --git a/pkg/transformers/deal/converter_test.go b/pkg/transformers/deal/converter_test.go deleted file mode 100644 index b2284aed..00000000 --- a/pkg/transformers/deal/converter_test.go +++ /dev/null @@ -1,50 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package deal_test - -import ( - "github.com/ethereum/go-ethereum/common" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - - "github.com/ethereum/go-ethereum/core/types" - "github.com/vulcanize/vulcanizedb/pkg/transformers/deal" - "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data" -) - -var _ = Describe("Flip Deal Converter", func() { - It("converts logs to models", func() { - converter := deal.DealConverter{} - - models, err := converter.ToModels([]types.Log{test_data.DealLogNote}) - - Expect(err).NotTo(HaveOccurred()) - Expect(len(models)).To(Equal(1)) - Expect(models[0]).To(Equal(test_data.DealModel)) - }) - - It("returns an error if the expected amount of topics aren't in the log", func() { - converter := deal.DealConverter{} - invalidLog := test_data.DealLogNote - invalidLog.Topics = []common.Hash{} - - _, err := converter.ToModels([]types.Log{invalidLog}) - - Expect(err).To(HaveOccurred()) - Expect(err).To(MatchError("deal log does not contain expected topics")) - }) -}) diff --git a/pkg/transformers/deal/deal_suite_test.go b/pkg/transformers/deal/deal_suite_test.go deleted file mode 100644 index 064213b2..00000000 --- a/pkg/transformers/deal/deal_suite_test.go +++ /dev/null @@ -1,19 +0,0 @@ -package deal_test - -import ( - "testing" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - log "github.com/sirupsen/logrus" - "io/ioutil" -) - -func TestFlipDeal(t *testing.T) { - RegisterFailHandler(Fail) - RunSpecs(t, "Deal Suite") -} - -var _ = BeforeSuite(func() { - log.SetOutput(ioutil.Discard) -}) diff --git a/pkg/transformers/deal/model.go b/pkg/transformers/deal/model.go deleted file mode 100644 index fe0210f6..00000000 --- a/pkg/transformers/deal/model.go +++ /dev/null @@ -1,25 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package deal - -type DealModel struct { - BidId string `db:"bid_id"` - ContractAddress string `db:"contract_address"` - LogIndex uint `db:"log_idx"` - TransactionIndex uint `db:"tx_idx"` - Raw []byte `db:"raw_log"` -} diff --git a/pkg/transformers/deal/repository.go b/pkg/transformers/deal/repository.go deleted file mode 100644 index b0572abd..00000000 --- a/pkg/transformers/deal/repository.go +++ /dev/null @@ -1,90 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package deal - -import ( - "fmt" - - log "github.com/sirupsen/logrus" - - "github.com/vulcanize/vulcanizedb/pkg/core" - "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" -) - -type DealRepository struct { - db *postgres.DB -} - -func (repository DealRepository) Create(headerID int64, models []interface{}) error { - tx, dBaseErr := repository.db.Begin() - if dBaseErr != nil { - return dBaseErr - } - - for _, model := range models { - dealModel, ok := model.(DealModel) - if !ok { - rollbackErr := tx.Rollback() - if rollbackErr != nil { - log.Error("failed to rollback ", rollbackErr) - } - return fmt.Errorf("model of type %T, not %T", model, DealModel{}) - } - - _, execErr := tx.Exec( - `INSERT into maker.deal (header_id, bid_id, contract_address, log_idx, tx_idx, raw_log) - VALUES($1, $2, $3, $4, $5, $6) - ON CONFLICT (header_id, tx_idx, log_idx) DO UPDATE SET bid_id = $2, contract_address = $3, raw_log = $6;`, - headerID, dealModel.BidId, dealModel.ContractAddress, dealModel.LogIndex, dealModel.TransactionIndex, dealModel.Raw, - ) - if execErr != nil { - rollbackErr := tx.Rollback() - if rollbackErr != nil { - log.Error("failed to rollback ", rollbackErr) - } - return execErr - } - } - - checkHeaderErr := shared.MarkHeaderCheckedInTransaction(headerID, tx, constants.DealChecked) - if checkHeaderErr != nil { - rollbackErr := tx.Rollback() - if rollbackErr != nil { - log.Error("failed to rollback ", rollbackErr) - } - return checkHeaderErr - } - return tx.Commit() -} - -func (repository DealRepository) MarkHeaderChecked(headerID int64) error { - return shared.MarkHeaderChecked(headerID, repository.db, constants.DealChecked) -} - -func (repository DealRepository) MissingHeaders(startingBlockNumber, endingBlockNumber int64) ([]core.Header, error) { - return shared.MissingHeaders(startingBlockNumber, endingBlockNumber, repository.db, constants.DealChecked) -} - -func (repository DealRepository) RecheckHeaders(startingBlockNumber, endingBlockNumber int64) ([]core.Header, error) { - return shared.RecheckHeaders(startingBlockNumber, endingBlockNumber, repository.db, constants.DealChecked) -} - -func (repository *DealRepository) SetDB(db *postgres.DB) { - repository.db = db -} diff --git a/pkg/transformers/deal/repository_test.go b/pkg/transformers/deal/repository_test.go deleted file mode 100644 index 96a31685..00000000 --- a/pkg/transformers/deal/repository_test.go +++ /dev/null @@ -1,89 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package deal_test - -import ( - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - - "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" - "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres/repositories" - "github.com/vulcanize/vulcanizedb/pkg/fakes" - "github.com/vulcanize/vulcanizedb/pkg/transformers/deal" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" - "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data" - "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data/shared_behaviors" - "github.com/vulcanize/vulcanizedb/test_config" -) - -var _ = Describe("Deal Repository", func() { - var ( - db *postgres.DB - dealRepository deal.DealRepository - headerRepository repositories.HeaderRepository - ) - - BeforeEach(func() { - db = test_config.NewTestDB(test_config.NewTestNode()) - test_config.CleanTestDB(db) - dealRepository = deal.DealRepository{} - dealRepository.SetDB(db) - headerRepository = repositories.NewHeaderRepository(db) - }) - - Describe("Create", func() { - modelWithDifferentLogIdx := test_data.DealModel - modelWithDifferentLogIdx.LogIndex = modelWithDifferentLogIdx.LogIndex + 1 - inputs := shared_behaviors.CreateBehaviorInputs{ - CheckedHeaderColumnName: constants.DealChecked, - LogEventTableName: "maker.deal", - TestModel: test_data.DealModel, - ModelWithDifferentLogIdx: modelWithDifferentLogIdx, - Repository: &dealRepository, - } - - shared_behaviors.SharedRepositoryCreateBehaviors(&inputs) - - It("persists a deal record", func() { - headerId, err := headerRepository.CreateOrUpdateHeader(fakes.FakeHeader) - Expect(err).NotTo(HaveOccurred()) - err = dealRepository.Create(headerId, []interface{}{test_data.DealModel}) - - Expect(err).NotTo(HaveOccurred()) - var count int - db.QueryRow(`SELECT count(*) FROM maker.deal`).Scan(&count) - Expect(count).To(Equal(1)) - var dbResult deal.DealModel - err = db.Get(&dbResult, `SELECT bid_id, contract_address, log_idx, tx_idx, raw_log FROM maker.deal WHERE header_id = $1`, headerId) - Expect(err).NotTo(HaveOccurred()) - Expect(dbResult.BidId).To(Equal(test_data.DealModel.BidId)) - Expect(dbResult.ContractAddress).To(Equal(test_data.DealModel.ContractAddress)) - Expect(dbResult.LogIndex).To(Equal(test_data.DealModel.LogIndex)) - Expect(dbResult.TransactionIndex).To(Equal(test_data.DealModel.TransactionIndex)) - Expect(dbResult.Raw).To(MatchJSON(test_data.DealModel.Raw)) - }) - }) - - Describe("MarkHeaderChecked", func() { - inputs := shared_behaviors.MarkedHeaderCheckedBehaviorInputs{ - CheckedHeaderColumnName: constants.DealChecked, - Repository: &dealRepository, - } - - shared_behaviors.SharedRepositoryMarkHeaderCheckedBehaviors(&inputs) - }) -}) diff --git a/pkg/transformers/dent/config.go b/pkg/transformers/dent/config.go deleted file mode 100644 index e1cd5cfd..00000000 --- a/pkg/transformers/dent/config.go +++ /dev/null @@ -1,34 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package dent - -import ( - shared_t "github.com/vulcanize/vulcanizedb/libraries/shared/transformer" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" -) - -func GetDentConfig() shared_t.TransformerConfig { - return shared_t.TransformerConfig{ - TransformerName: constants.DentLabel, - ContractAddresses: []string{constants.FlipperContractAddress(), constants.FlopperContractAddress()}, - ContractAbi: constants.FlipperABI(), - Topic: constants.GetDentFunctionSignature(), - StartingBlockNumber: shared.MinInt64([]int64{constants.FlipperDeploymentBlock(), constants.FlopperDeploymentBlock()}), - EndingBlockNumber: -1, - } -} diff --git a/pkg/transformers/dent/converter.go b/pkg/transformers/dent/converter.go deleted file mode 100644 index 70f83b00..00000000 --- a/pkg/transformers/dent/converter.go +++ /dev/null @@ -1,88 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package dent - -import ( - "encoding/json" - "errors" - "math/big" - - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/types" -) - -type DentConverter struct{} - -func NewDentConverter() DentConverter { - return DentConverter{} -} - -func (c DentConverter) ToModels(ethLogs []types.Log) (result []interface{}, err error) { - for _, log := range ethLogs { - err := validateLog(log) - if err != nil { - return nil, err - } - - bidId := log.Topics[2].Big() - lot := log.Topics[3].Big().String() - bidValue := getBidValue(log) - // TODO: verify guy is available on Topics[1] (looks like it may just be an int id) - guy := common.HexToAddress(log.Topics[1].Hex()).String() - - logIndex := log.Index - transactionIndex := log.TxIndex - - raw, err := json.Marshal(log) - if err != nil { - return nil, err - } - - model := DentModel{ - BidId: bidId.String(), - Lot: lot, - Bid: bidValue, - Guy: guy, - LogIndex: logIndex, - TransactionIndex: transactionIndex, - Raw: raw, - } - result = append(result, model) - } - return result, err -} - -func validateLog(ethLog types.Log) error { - if len(ethLog.Data) <= 0 { - return errors.New("dent log data is empty") - } - - if len(ethLog.Topics) < 4 { - return errors.New("dent log does not contain expected topics") - } - - return nil -} - -func getBidValue(ethLog types.Log) string { - itemByteLength := 32 - lastDataItemStartIndex := len(ethLog.Data) - itemByteLength - lastItem := ethLog.Data[lastDataItemStartIndex:] - lastValue := big.NewInt(0).SetBytes(lastItem) - - return lastValue.String() -} diff --git a/pkg/transformers/dent/converter_test.go b/pkg/transformers/dent/converter_test.go deleted file mode 100644 index 0a68fd9b..00000000 --- a/pkg/transformers/dent/converter_test.go +++ /dev/null @@ -1,59 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package dent_test - -import ( - "github.com/ethereum/go-ethereum/common" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - - "github.com/ethereum/go-ethereum/core/types" - "github.com/vulcanize/vulcanizedb/pkg/transformers/dent" - "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data" -) - -var _ = Describe("Dent Converter", func() { - var converter dent.DentConverter - - BeforeEach(func() { - converter = dent.NewDentConverter() - }) - - It("converts an eth log to a db model", func() { - models, err := converter.ToModels([]types.Log{test_data.DentLog}) - - Expect(err).NotTo(HaveOccurred()) - Expect(len(models)).To(Equal(1)) - Expect(models[0].(dent.DentModel)).To(Equal(test_data.DentModel)) - }) - - It("returns an error if the expected amount of topics aren't in the log", func() { - invalidLog := test_data.DentLog - invalidLog.Topics = []common.Hash{} - _, err := converter.ToModels([]types.Log{invalidLog}) - Expect(err).To(HaveOccurred()) - Expect(err).To(MatchError("dent log does not contain expected topics")) - }) - - It("returns an error if the log data is empty", func() { - emptyDataLog := test_data.DentLog - emptyDataLog.Data = []byte{} - _, err := converter.ToModels([]types.Log{emptyDataLog}) - Expect(err).To(HaveOccurred()) - Expect(err).To(MatchError("dent log data is empty")) - }) -}) diff --git a/pkg/transformers/dent/dent_suite_test.go b/pkg/transformers/dent/dent_suite_test.go deleted file mode 100644 index 6fa8d633..00000000 --- a/pkg/transformers/dent/dent_suite_test.go +++ /dev/null @@ -1,19 +0,0 @@ -package dent_test - -import ( - "testing" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - log "github.com/sirupsen/logrus" - "io/ioutil" -) - -func TestDent(t *testing.T) { - RegisterFailHandler(Fail) - RunSpecs(t, "Dent Suite") -} - -var _ = BeforeSuite(func() { - log.SetOutput(ioutil.Discard) -}) diff --git a/pkg/transformers/dent/model.go b/pkg/transformers/dent/model.go deleted file mode 100644 index 24f038ac..00000000 --- a/pkg/transformers/dent/model.go +++ /dev/null @@ -1,27 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package dent - -type DentModel struct { - BidId string `db:"bid_id"` - Lot string - Bid string - Guy string - LogIndex uint `db:"log_idx"` - TransactionIndex uint `db:"tx_idx"` - Raw []byte `db:"raw_log"` -} diff --git a/pkg/transformers/dent/repository.go b/pkg/transformers/dent/repository.go deleted file mode 100644 index ceac4e95..00000000 --- a/pkg/transformers/dent/repository.go +++ /dev/null @@ -1,93 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package dent - -import ( - "fmt" - - log "github.com/sirupsen/logrus" - - "github.com/vulcanize/vulcanizedb/pkg/core" - "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" -) - -type DentRepository struct { - db *postgres.DB -} - -func (repository DentRepository) Create(headerID int64, models []interface{}) error { - tx, dBaseErr := repository.db.Begin() - if dBaseErr != nil { - return dBaseErr - } - - tic, getTicErr := shared.GetTicInTx(headerID, tx) - if getTicErr != nil { - rollbackErr := tx.Rollback() - if rollbackErr != nil { - log.Error("failed to rollback ", rollbackErr) - } - return getTicErr - } - - for _, model := range models { - dent, ok := model.(DentModel) - if !ok { - rollbackErr := tx.Rollback() - if rollbackErr != nil { - log.Error("failed to rollback ", rollbackErr) - } - return fmt.Errorf("model of type %T, not %T", model, DentModel{}) - } - - _, execErr := tx.Exec( - `INSERT into maker.dent (header_id, bid_id, lot, bid, guy, tic, log_idx, tx_idx, raw_log) - VALUES($1, $2, $3, $4, $5, $6, $7, $8, $9) - ON CONFLICT (header_id, tx_idx, log_idx) DO UPDATE SET bid_Id = $2, lot = $3, bid = $4, guy = $5, tic = $6, raw_log = $9;`, - headerID, dent.BidId, dent.Lot, dent.Bid, dent.Guy, tic, dent.LogIndex, dent.TransactionIndex, dent.Raw, - ) - if execErr != nil { - tx.Rollback() - return execErr - } - } - - err := shared.MarkHeaderCheckedInTransaction(headerID, tx, constants.DentChecked) - if err != nil { - tx.Rollback() - return err - } - return tx.Commit() -} - -func (repository DentRepository) MarkHeaderChecked(headerId int64) error { - return shared.MarkHeaderChecked(headerId, repository.db, constants.DentChecked) -} - -func (repository DentRepository) MissingHeaders(startingBlockNumber, endingBlockNumber int64) ([]core.Header, error) { - return shared.MissingHeaders(startingBlockNumber, endingBlockNumber, repository.db, constants.DentChecked) -} - -func (repository DentRepository) RecheckHeaders(startingBlockNumber, endingBlockNumber int64) ([]core.Header, error) { - return shared.RecheckHeaders(startingBlockNumber, endingBlockNumber, repository.db, constants.DentChecked) -} - -func (repository *DentRepository) SetDB(db *postgres.DB) { - repository.db = db -} diff --git a/pkg/transformers/dent/repository_test.go b/pkg/transformers/dent/repository_test.go deleted file mode 100644 index 4e075f4b..00000000 --- a/pkg/transformers/dent/repository_test.go +++ /dev/null @@ -1,97 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package dent_test - -import ( - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - - "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" - "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres/repositories" - "github.com/vulcanize/vulcanizedb/pkg/fakes" - "github.com/vulcanize/vulcanizedb/pkg/transformers/dent" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" - "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data" - "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data/shared_behaviors" - "github.com/vulcanize/vulcanizedb/test_config" -) - -var _ = Describe("Dent Repository", func() { - var ( - db *postgres.DB - dentRepository dent.DentRepository - headerRepository repositories.HeaderRepository - ) - - BeforeEach(func() { - db = test_config.NewTestDB(test_config.NewTestNode()) - test_config.CleanTestDB(db) - dentRepository = dent.DentRepository{} - dentRepository.SetDB(db) - headerRepository = repositories.NewHeaderRepository(db) - }) - - Describe("Create", func() { - modelWithDifferentLogIdx := test_data.DentModel - modelWithDifferentLogIdx.LogIndex++ - inputs := shared_behaviors.CreateBehaviorInputs{ - CheckedHeaderColumnName: constants.DentChecked, - LogEventTableName: "maker.dent", - TestModel: test_data.DentModel, - ModelWithDifferentLogIdx: modelWithDifferentLogIdx, - Repository: &dentRepository, - } - - shared_behaviors.SharedRepositoryCreateBehaviors(&inputs) - - It("persists a dent record", func() { - headerID, err := headerRepository.CreateOrUpdateHeader(fakes.FakeHeader) - Expect(err).NotTo(HaveOccurred()) - err = dentRepository.Create(headerID, []interface{}{test_data.DentModel}) - Expect(err).NotTo(HaveOccurred()) - - var count int - db.QueryRow(`SELECT count(*) FROM maker.dent`).Scan(&count) - Expect(count).To(Equal(1)) - - var dbResult dent.DentModel - err = db.Get(&dbResult, `SELECT bid_id, lot, bid, guy, log_idx, tx_idx, raw_log FROM maker.dent WHERE header_id = $1`, headerID) - Expect(err).NotTo(HaveOccurred()) - Expect(dbResult.BidId).To(Equal(test_data.DentModel.BidId)) - Expect(dbResult.Lot).To(Equal(test_data.DentModel.Lot)) - Expect(dbResult.Bid).To(Equal(test_data.DentModel.Bid)) - Expect(dbResult.Guy).To(Equal(test_data.DentModel.Guy)) - Expect(dbResult.LogIndex).To(Equal(test_data.DentModel.LogIndex)) - Expect(dbResult.TransactionIndex).To(Equal(test_data.DentModel.TransactionIndex)) - Expect(dbResult.Raw).To(MatchJSON(test_data.DentModel.Raw)) - - var dbTic int64 - err = db.Get(&dbTic, `SELECT tic FROM maker.dent WHERE header_id = $1`, headerID) - Expect(err).NotTo(HaveOccurred()) - Expect(dbTic).To(Equal(fakes.FakeHeaderTic)) - }) - }) - - Describe("MarkHeaderChecked", func() { - inputs := shared_behaviors.MarkedHeaderCheckedBehaviorInputs{ - CheckedHeaderColumnName: constants.DentChecked, - Repository: &dentRepository, - } - - shared_behaviors.SharedRepositoryMarkHeaderCheckedBehaviors(&inputs) - }) -}) diff --git a/pkg/transformers/drip_drip/config.go b/pkg/transformers/drip_drip/config.go deleted file mode 100644 index 4411ce03..00000000 --- a/pkg/transformers/drip_drip/config.go +++ /dev/null @@ -1,32 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package drip_drip - -import ( - shared_t "github.com/vulcanize/vulcanizedb/libraries/shared/transformer" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" -) - -func GetDripDripConfig() shared_t.TransformerConfig { - return shared_t.TransformerConfig{ - ContractAddresses: []string{constants.DripContractAddress()}, - ContractAbi: constants.DripABI(), - Topic: constants.GetDripDripSignature(), - StartingBlockNumber: constants.DripDeploymentBlock(), - EndingBlockNumber: -1, - } -} diff --git a/pkg/transformers/drip_drip/converter.go b/pkg/transformers/drip_drip/converter.go deleted file mode 100644 index 534242e1..00000000 --- a/pkg/transformers/drip_drip/converter.go +++ /dev/null @@ -1,56 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package drip_drip - -import ( - "encoding/json" - "errors" - "github.com/ethereum/go-ethereum/core/types" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared" -) - -type DripDripConverter struct{} - -func (DripDripConverter) ToModels(ethLogs []types.Log) ([]interface{}, error) { - var models []interface{} - for _, ethLog := range ethLogs { - err := verifyLog(ethLog) - if err != nil { - return nil, err - } - ilk := shared.GetHexWithoutPrefix(ethLog.Topics[2].Bytes()) - raw, err := json.Marshal(ethLog) - if err != nil { - return nil, err - } - model := DripDripModel{ - Ilk: ilk, - LogIndex: ethLog.Index, - TransactionIndex: ethLog.TxIndex, - Raw: raw, - } - models = append(models, model) - } - return models, nil -} - -func verifyLog(log types.Log) error { - if len(log.Topics) < 3 { - return errors.New("log missing topics") - } - return nil -} diff --git a/pkg/transformers/drip_drip/converter_test.go b/pkg/transformers/drip_drip/converter_test.go deleted file mode 100644 index faeb9308..00000000 --- a/pkg/transformers/drip_drip/converter_test.go +++ /dev/null @@ -1,46 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package drip_drip_test - -import ( - "github.com/ethereum/go-ethereum/core/types" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - - "github.com/vulcanize/vulcanizedb/pkg/transformers/drip_drip" - "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data" -) - -var _ = Describe("Drip drip converter", func() { - It("returns err if log is missing topics", func() { - converter := drip_drip.DripDripConverter{} - badLog := types.Log{} - - _, err := converter.ToModels([]types.Log{badLog}) - - Expect(err).To(HaveOccurred()) - }) - - It("converts a log to an model", func() { - converter := drip_drip.DripDripConverter{} - - model, err := converter.ToModels([]types.Log{test_data.EthDripDripLog}) - - Expect(err).NotTo(HaveOccurred()) - Expect(model).To(Equal([]interface{}{test_data.DripDripModel})) - }) -}) diff --git a/pkg/transformers/drip_drip/drip_drip_suite_test.go b/pkg/transformers/drip_drip/drip_drip_suite_test.go deleted file mode 100644 index ec70dc7e..00000000 --- a/pkg/transformers/drip_drip/drip_drip_suite_test.go +++ /dev/null @@ -1,35 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package drip_drip_test - -import ( - log "github.com/sirupsen/logrus" - "io/ioutil" - "testing" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -func TestDripDrip(t *testing.T) { - RegisterFailHandler(Fail) - RunSpecs(t, "DripDrip Suite") -} - -var _ = BeforeSuite(func() { - log.SetOutput(ioutil.Discard) -}) diff --git a/pkg/transformers/drip_drip/model.go b/pkg/transformers/drip_drip/model.go deleted file mode 100644 index 4e7b19ee..00000000 --- a/pkg/transformers/drip_drip/model.go +++ /dev/null @@ -1,24 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package drip_drip - -type DripDripModel struct { - Ilk string - LogIndex uint `db:"log_idx"` - TransactionIndex uint `db:"tx_idx"` - Raw []byte `db:"raw_log"` -} diff --git a/pkg/transformers/drip_file/ilk/config.go b/pkg/transformers/drip_file/ilk/config.go deleted file mode 100644 index ffb202e5..00000000 --- a/pkg/transformers/drip_file/ilk/config.go +++ /dev/null @@ -1,33 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package ilk - -import ( - shared_t "github.com/vulcanize/vulcanizedb/libraries/shared/transformer" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" -) - -func GetDripFileIlkConfig() shared_t.TransformerConfig { - return shared_t.TransformerConfig{ - TransformerName: constants.DripFileIlkLabel, - ContractAddresses: []string{constants.DripContractAddress()}, - ContractAbi: constants.DripABI(), - Topic: constants.GetDripFileIlkSignature(), - StartingBlockNumber: constants.DripDeploymentBlock(), - EndingBlockNumber: -1, - } -} diff --git a/pkg/transformers/drip_file/ilk/converter.go b/pkg/transformers/drip_file/ilk/converter.go deleted file mode 100644 index 8dfaafb3..00000000 --- a/pkg/transformers/drip_file/ilk/converter.go +++ /dev/null @@ -1,70 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package ilk - -import ( - "encoding/json" - "errors" - "math/big" - - "github.com/ethereum/go-ethereum/core/types" - - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" -) - -type DripFileIlkConverter struct{} - -func (DripFileIlkConverter) ToModels(ethLogs []types.Log) ([]interface{}, error) { - var models []interface{} - for _, ethLog := range ethLogs { - err := verifyLog(ethLog) - if err != nil { - return nil, err - } - - ilk := shared.GetHexWithoutPrefix(ethLog.Topics[2].Bytes()) - vow := shared.GetHexWithoutPrefix(ethLog.Topics[3].Bytes()) - taxBytes := ethLog.Data[len(ethLog.Data)-constants.DataItemLength:] - tax := shared.ConvertToRay(big.NewInt(0).SetBytes(taxBytes).String()) - raw, err := json.Marshal(ethLog) - if err != nil { - return nil, err - } - - model := DripFileIlkModel{ - Ilk: ilk, - Vow: vow, - Tax: tax, - LogIndex: ethLog.Index, - TransactionIndex: ethLog.TxIndex, - Raw: raw, - } - models = append(models, model) - } - return models, nil -} - -func verifyLog(log types.Log) error { - if len(log.Topics) < 4 { - return errors.New("log missing topics") - } - if len(log.Data) < constants.DataItemLength { - return errors.New("log missing data") - } - return nil -} diff --git a/pkg/transformers/drip_file/ilk/converter_test.go b/pkg/transformers/drip_file/ilk/converter_test.go deleted file mode 100644 index 7af73627..00000000 --- a/pkg/transformers/drip_file/ilk/converter_test.go +++ /dev/null @@ -1,63 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package ilk_test - -import ( - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/types" - "github.com/vulcanize/vulcanizedb/pkg/transformers/drip_file/ilk" - "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data" -) - -var _ = Describe("Drip file ilk converter", func() { - It("returns err if log missing topics", func() { - converter := ilk.DripFileIlkConverter{} - badLog := types.Log{ - Topics: []common.Hash{{}}, - Data: []byte{1, 1, 1, 1, 1}, - } - - _, err := converter.ToModels([]types.Log{badLog}) - - Expect(err).To(HaveOccurred()) - }) - - It("returns err if log missing data", func() { - converter := ilk.DripFileIlkConverter{} - badLog := types.Log{ - Topics: []common.Hash{{}, {}, {}, {}}, - } - - _, err := converter.ToModels([]types.Log{badLog}) - - Expect(err).To(HaveOccurred()) - - }) - - It("converts a log to a model", func() { - converter := ilk.DripFileIlkConverter{} - - models, err := converter.ToModels([]types.Log{test_data.EthDripFileIlkLog}) - - Expect(err).NotTo(HaveOccurred()) - Expect(len(models)).To(Equal(1)) - Expect(models[0].(ilk.DripFileIlkModel)).To(Equal(test_data.DripFileIlkModel)) - }) -}) diff --git a/pkg/transformers/drip_file/ilk/ilk_suite_test.go b/pkg/transformers/drip_file/ilk/ilk_suite_test.go deleted file mode 100644 index 469bede6..00000000 --- a/pkg/transformers/drip_file/ilk/ilk_suite_test.go +++ /dev/null @@ -1,35 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package ilk_test - -import ( - log "github.com/sirupsen/logrus" - "io/ioutil" - "testing" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -func TestIlk(t *testing.T) { - RegisterFailHandler(Fail) - RunSpecs(t, "Ilk Suite") -} - -var _ = BeforeSuite(func() { - log.SetOutput(ioutil.Discard) -}) diff --git a/pkg/transformers/drip_file/ilk/model.go b/pkg/transformers/drip_file/ilk/model.go deleted file mode 100644 index f2e6fdb8..00000000 --- a/pkg/transformers/drip_file/ilk/model.go +++ /dev/null @@ -1,26 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package ilk - -type DripFileIlkModel struct { - Ilk string - Vow string - Tax string - LogIndex uint `db:"log_idx"` - TransactionIndex uint `db:"tx_idx"` - Raw []byte `db:"raw_log"` -} diff --git a/pkg/transformers/drip_file/repo/config.go b/pkg/transformers/drip_file/repo/config.go deleted file mode 100644 index 56ec6248..00000000 --- a/pkg/transformers/drip_file/repo/config.go +++ /dev/null @@ -1,33 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package repo - -import ( - shared_t "github.com/vulcanize/vulcanizedb/libraries/shared/transformer" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" -) - -func GetDripFileRepoConfig() shared_t.TransformerConfig { - return shared_t.TransformerConfig{ - TransformerName: constants.DripFileRepoLabel, - ContractAddresses: []string{constants.DripContractAddress()}, - ContractAbi: constants.DripABI(), - Topic: constants.GetDripFileRepoSignature(), - StartingBlockNumber: constants.DripDeploymentBlock(), - EndingBlockNumber: -1, - } -} diff --git a/pkg/transformers/drip_file/repo/converter.go b/pkg/transformers/drip_file/repo/converter.go deleted file mode 100644 index 0c851bc7..00000000 --- a/pkg/transformers/drip_file/repo/converter.go +++ /dev/null @@ -1,61 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package repo - -import ( - "bytes" - "encoding/json" - "errors" - "github.com/ethereum/go-ethereum/core/types" - "math/big" -) - -type DripFileRepoConverter struct{} - -func (DripFileRepoConverter) ToModels(ethLogs []types.Log) ([]interface{}, error) { - var models []interface{} - for _, ethLog := range ethLogs { - err := verifyLog(ethLog) - if err != nil { - return nil, err - } - - what := string(bytes.Trim(ethLog.Topics[2].Bytes(), "\x00")) - data := big.NewInt(0).SetBytes(ethLog.Topics[3].Bytes()).String() - raw, err := json.Marshal(ethLog) - if err != nil { - return nil, err - } - - model := DripFileRepoModel{ - What: what, - Data: data, - LogIndex: ethLog.Index, - TransactionIndex: ethLog.TxIndex, - Raw: raw, - } - models = append(models, model) - } - return models, nil -} - -func verifyLog(log types.Log) error { - if len(log.Topics) < 4 { - return errors.New("log missing topics") - } - return nil -} diff --git a/pkg/transformers/drip_file/repo/converter_test.go b/pkg/transformers/drip_file/repo/converter_test.go deleted file mode 100644 index ae4e2144..00000000 --- a/pkg/transformers/drip_file/repo/converter_test.go +++ /dev/null @@ -1,51 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package repo_test - -import ( - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/types" - "github.com/vulcanize/vulcanizedb/pkg/transformers/drip_file/repo" - "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data" -) - -var _ = Describe("Drip file repo converter", func() { - It("returns err if log missing topics", func() { - converter := repo.DripFileRepoConverter{} - badLog := types.Log{ - Topics: []common.Hash{{}}, - Data: []byte{1, 1, 1, 1, 1}, - } - - _, err := converter.ToModels([]types.Log{badLog}) - - Expect(err).To(HaveOccurred()) - }) - - It("converts a log to a model", func() { - converter := repo.DripFileRepoConverter{} - - models, err := converter.ToModels([]types.Log{test_data.EthDripFileRepoLog}) - - Expect(err).NotTo(HaveOccurred()) - Expect(len(models)).To(Equal(1)) - Expect(models[0].(repo.DripFileRepoModel)).To(Equal(test_data.DripFileRepoModel)) - }) -}) diff --git a/pkg/transformers/drip_file/repo/model.go b/pkg/transformers/drip_file/repo/model.go deleted file mode 100644 index cb5da51e..00000000 --- a/pkg/transformers/drip_file/repo/model.go +++ /dev/null @@ -1,25 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package repo - -type DripFileRepoModel struct { - What string - Data string - LogIndex uint `db:"log_idx"` - TransactionIndex uint `db:"tx_idx"` - Raw []byte `db:"raw_log"` -} diff --git a/pkg/transformers/drip_file/repo/repo_suite_test.go b/pkg/transformers/drip_file/repo/repo_suite_test.go deleted file mode 100644 index 965d83d8..00000000 --- a/pkg/transformers/drip_file/repo/repo_suite_test.go +++ /dev/null @@ -1,35 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package repo_test - -import ( - log "github.com/sirupsen/logrus" - "io/ioutil" - "testing" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -func TestRepo(t *testing.T) { - RegisterFailHandler(Fail) - RunSpecs(t, "Repo Suite") -} - -var _ = BeforeSuite(func() { - log.SetOutput(ioutil.Discard) -}) diff --git a/pkg/transformers/drip_file/repo/repository.go b/pkg/transformers/drip_file/repo/repository.go deleted file mode 100644 index 4490af00..00000000 --- a/pkg/transformers/drip_file/repo/repository.go +++ /dev/null @@ -1,91 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package repo - -import ( - "fmt" - - log "github.com/sirupsen/logrus" - - "github.com/vulcanize/vulcanizedb/pkg/core" - "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" -) - -type DripFileRepoRepository struct { - db *postgres.DB -} - -func (repository DripFileRepoRepository) Create(headerID int64, models []interface{}) error { - tx, dBaseErr := repository.db.Begin() - if dBaseErr != nil { - return dBaseErr - } - - for _, model := range models { - repo, ok := model.(DripFileRepoModel) - if !ok { - rollbackErr := tx.Rollback() - if rollbackErr != nil { - log.Error("failed to rollback ", rollbackErr) - } - return fmt.Errorf("model of type %T, not %T", model, DripFileRepoModel{}) - } - - _, execErr := tx.Exec( - `INSERT into maker.drip_file_repo (header_id, what, data, log_idx, tx_idx, raw_log) - VALUES($1, $2, $3::NUMERIC, $4, $5, $6)`, - headerID, repo.What, repo.Data, repo.LogIndex, repo.TransactionIndex, repo.Raw, - ) - - if execErr != nil { - rollbackErr := tx.Rollback() - if rollbackErr != nil { - log.Error("failed to rollback ", rollbackErr) - } - return execErr - } - } - - checkHeaderErr := shared.MarkHeaderCheckedInTransaction(headerID, tx, constants.DripFileRepoChecked) - if checkHeaderErr != nil { - rollbackErr := tx.Rollback() - if rollbackErr != nil { - log.Error("failed to rollback ", rollbackErr) - } - return checkHeaderErr - } - - return tx.Commit() -} - -func (repository DripFileRepoRepository) MarkHeaderChecked(headerID int64) error { - return shared.MarkHeaderChecked(headerID, repository.db, constants.DripFileRepoChecked) -} - -func (repository DripFileRepoRepository) MissingHeaders(startingBlockNumber, endingBlockNumber int64) ([]core.Header, error) { - return shared.MissingHeaders(startingBlockNumber, endingBlockNumber, repository.db, constants.DripFileRepoChecked) -} - -func (repository DripFileRepoRepository) RecheckHeaders(startingBlockNumber, endingBlockNumber int64) ([]core.Header, error) { - return shared.RecheckHeaders(startingBlockNumber, endingBlockNumber, repository.db, constants.DripFileRepoChecked) -} - -func (repository *DripFileRepoRepository) SetDB(db *postgres.DB) { - repository.db = db -} diff --git a/pkg/transformers/drip_file/repo/repository_test.go b/pkg/transformers/drip_file/repo/repository_test.go deleted file mode 100644 index 5f4c021e..00000000 --- a/pkg/transformers/drip_file/repo/repository_test.go +++ /dev/null @@ -1,87 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package repo_test - -import ( - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - - "github.com/vulcanize/vulcanizedb/pkg/datastore" - "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" - "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres/repositories" - "github.com/vulcanize/vulcanizedb/pkg/fakes" - "github.com/vulcanize/vulcanizedb/pkg/transformers/drip_file/repo" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" - "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data" - "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data/shared_behaviors" - "github.com/vulcanize/vulcanizedb/test_config" -) - -var _ = Describe("Drip file repo repository", func() { - var ( - db *postgres.DB - dripFileRepoRepository repo.DripFileRepoRepository - headerRepository datastore.HeaderRepository - ) - - BeforeEach(func() { - db = test_config.NewTestDB(test_config.NewTestNode()) - test_config.CleanTestDB(db) - headerRepository = repositories.NewHeaderRepository(db) - dripFileRepoRepository = repo.DripFileRepoRepository{} - dripFileRepoRepository.SetDB(db) - }) - - Describe("Create", func() { - modelWithDifferentLogIdx := test_data.DripFileRepoModel - modelWithDifferentLogIdx.LogIndex++ - inputs := shared_behaviors.CreateBehaviorInputs{ - CheckedHeaderColumnName: constants.DripFileRepoChecked, - LogEventTableName: "maker.drip_file_repo", - TestModel: test_data.DripFileRepoModel, - ModelWithDifferentLogIdx: modelWithDifferentLogIdx, - Repository: &dripFileRepoRepository, - } - - shared_behaviors.SharedRepositoryCreateBehaviors(&inputs) - - It("adds a drip file repo event", func() { - headerID, err := headerRepository.CreateOrUpdateHeader(fakes.FakeHeader) - Expect(err).NotTo(HaveOccurred()) - err = dripFileRepoRepository.Create(headerID, []interface{}{test_data.DripFileRepoModel}) - - Expect(err).NotTo(HaveOccurred()) - var dbDripFileRepo repo.DripFileRepoModel - err = db.Get(&dbDripFileRepo, `SELECT what, data, log_idx, tx_idx, raw_log FROM maker.drip_file_repo WHERE header_id = $1`, headerID) - Expect(err).NotTo(HaveOccurred()) - Expect(dbDripFileRepo.What).To(Equal(test_data.DripFileRepoModel.What)) - Expect(dbDripFileRepo.Data).To(Equal(test_data.DripFileRepoModel.Data)) - Expect(dbDripFileRepo.LogIndex).To(Equal(test_data.DripFileRepoModel.LogIndex)) - Expect(dbDripFileRepo.TransactionIndex).To(Equal(test_data.DripFileRepoModel.TransactionIndex)) - Expect(dbDripFileRepo.Raw).To(MatchJSON(test_data.DripFileRepoModel.Raw)) - }) - }) - - Describe("MarkHeaderChecked", func() { - inputs := shared_behaviors.MarkedHeaderCheckedBehaviorInputs{ - CheckedHeaderColumnName: constants.DripFileRepoChecked, - Repository: &dripFileRepoRepository, - } - - shared_behaviors.SharedRepositoryMarkHeaderCheckedBehaviors(&inputs) - }) -}) diff --git a/pkg/transformers/drip_file/vow/config.go b/pkg/transformers/drip_file/vow/config.go deleted file mode 100644 index 9910a149..00000000 --- a/pkg/transformers/drip_file/vow/config.go +++ /dev/null @@ -1,33 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package vow - -import ( - shared_t "github.com/vulcanize/vulcanizedb/libraries/shared/transformer" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" -) - -func GetDripFileVowConfig() shared_t.TransformerConfig { - return shared_t.TransformerConfig{ - TransformerName: constants.DripFileVowLabel, - ContractAddresses: []string{constants.DripContractAddress()}, - ContractAbi: constants.DripABI(), - Topic: constants.GetDripFileVowSignature(), - StartingBlockNumber: constants.DripDeploymentBlock(), - EndingBlockNumber: -1, - } -} diff --git a/pkg/transformers/drip_file/vow/converter.go b/pkg/transformers/drip_file/vow/converter.go deleted file mode 100644 index d1a47d7f..00000000 --- a/pkg/transformers/drip_file/vow/converter.go +++ /dev/null @@ -1,61 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package vow - -import ( - "bytes" - "encoding/json" - "errors" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/types" -) - -type DripFileVowConverter struct{} - -func (DripFileVowConverter) ToModels(ethLogs []types.Log) ([]interface{}, error) { - var models []interface{} - for _, ethLog := range ethLogs { - err := verifyLog(ethLog) - if err != nil { - return nil, err - } - - what := string(bytes.Trim(ethLog.Topics[2].Bytes(), "\x00")) - data := common.BytesToAddress(ethLog.Topics[3].Bytes()).String() - raw, err := json.Marshal(ethLog) - if err != nil { - return nil, err - } - - model := DripFileVowModel{ - What: what, - Data: data, - LogIndex: ethLog.Index, - TransactionIndex: ethLog.TxIndex, - Raw: raw, - } - models = append(models, model) - } - return models, nil -} - -func verifyLog(log types.Log) error { - if len(log.Topics) < 4 { - return errors.New("log missing topics") - } - return nil -} diff --git a/pkg/transformers/drip_file/vow/converter_test.go b/pkg/transformers/drip_file/vow/converter_test.go deleted file mode 100644 index 370dd575..00000000 --- a/pkg/transformers/drip_file/vow/converter_test.go +++ /dev/null @@ -1,51 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package vow_test - -import ( - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/types" - "github.com/vulcanize/vulcanizedb/pkg/transformers/drip_file/vow" - "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data" -) - -var _ = Describe("Drip file repo converter", func() { - It("returns err if log missing topics", func() { - converter := vow.DripFileVowConverter{} - badLog := types.Log{ - Topics: []common.Hash{{}}, - Data: []byte{1, 1, 1, 1, 1}, - } - - _, err := converter.ToModels([]types.Log{badLog}) - - Expect(err).To(HaveOccurred()) - }) - - It("converts a log to a model", func() { - converter := vow.DripFileVowConverter{} - - models, err := converter.ToModels([]types.Log{test_data.EthDripFileVowLog}) - - Expect(err).NotTo(HaveOccurred()) - Expect(len(models)).To(Equal(1)) - Expect(models[0].(vow.DripFileVowModel)).To(Equal(test_data.DripFileVowModel)) - }) -}) diff --git a/pkg/transformers/drip_file/vow/model.go b/pkg/transformers/drip_file/vow/model.go deleted file mode 100644 index 1e0cbd9c..00000000 --- a/pkg/transformers/drip_file/vow/model.go +++ /dev/null @@ -1,25 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package vow - -type DripFileVowModel struct { - What string - Data string - LogIndex uint `db:"log_idx"` - TransactionIndex uint `db:"tx_idx"` - Raw []byte `db:"raw_log"` -} diff --git a/pkg/transformers/drip_file/vow/repository.go b/pkg/transformers/drip_file/vow/repository.go deleted file mode 100644 index 2f008dc5..00000000 --- a/pkg/transformers/drip_file/vow/repository.go +++ /dev/null @@ -1,91 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package vow - -import ( - "fmt" - - log "github.com/sirupsen/logrus" - - "github.com/vulcanize/vulcanizedb/pkg/core" - "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" -) - -type DripFileVowRepository struct { - db *postgres.DB -} - -func (repository DripFileVowRepository) Create(headerID int64, models []interface{}) error { - tx, dBaseErr := repository.db.Begin() - if dBaseErr != nil { - return dBaseErr - } - - for _, model := range models { - vow, ok := model.(DripFileVowModel) - if !ok { - rollbackErr := tx.Rollback() - if rollbackErr != nil { - log.Error("failed to rollback ", rollbackErr) - } - return fmt.Errorf("model of type %T, not %T", model, DripFileVowModel{}) - } - - _, execErr := tx.Exec( - `INSERT into maker.drip_file_vow (header_id, what, data, log_idx, tx_idx, raw_log) - VALUES($1, $2, $3, $4, $5, $6) - ON CONFLICT (header_id, tx_idx, log_idx) DO UPDATE SET what = $2, data = $3, raw_log = $6;`, - headerID, vow.What, vow.Data, vow.LogIndex, vow.TransactionIndex, vow.Raw, - ) - if execErr != nil { - rollbackErr := tx.Rollback() - if rollbackErr != nil { - log.Error("failed to rollback ", rollbackErr) - } - return execErr - } - } - - checkHeaderErr := shared.MarkHeaderCheckedInTransaction(headerID, tx, constants.DripFileVowChecked) - if checkHeaderErr != nil { - rollbackErr := tx.Rollback() - if rollbackErr != nil { - log.Error("failed to rollback ", rollbackErr) - } - return checkHeaderErr - } - - return tx.Commit() -} - -func (repository DripFileVowRepository) MarkHeaderChecked(headerID int64) error { - return shared.MarkHeaderChecked(headerID, repository.db, constants.DripFileVowChecked) -} - -func (repository DripFileVowRepository) MissingHeaders(startingBlockNumber, endingBlockNumber int64) ([]core.Header, error) { - return shared.MissingHeaders(startingBlockNumber, endingBlockNumber, repository.db, constants.DripFileVowChecked) -} - -func (repository DripFileVowRepository) RecheckHeaders(startingBlockNumber, endingBlockNumber int64) ([]core.Header, error) { - return shared.RecheckHeaders(startingBlockNumber, endingBlockNumber, repository.db, constants.DripFileVowChecked) -} - -func (repository *DripFileVowRepository) SetDB(db *postgres.DB) { - repository.db = db -} diff --git a/pkg/transformers/drip_file/vow/repository_test.go b/pkg/transformers/drip_file/vow/repository_test.go deleted file mode 100644 index 067e0cad..00000000 --- a/pkg/transformers/drip_file/vow/repository_test.go +++ /dev/null @@ -1,86 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package vow_test - -import ( - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - "github.com/vulcanize/vulcanizedb/pkg/datastore" - "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" - "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres/repositories" - "github.com/vulcanize/vulcanizedb/pkg/fakes" - "github.com/vulcanize/vulcanizedb/pkg/transformers/drip_file/vow" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" - "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data" - "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data/shared_behaviors" - "github.com/vulcanize/vulcanizedb/test_config" -) - -var _ = Describe("Drip file vow repository", func() { - var ( - db *postgres.DB - dripFileVowRepository vow.DripFileVowRepository - headerRepository datastore.HeaderRepository - ) - - BeforeEach(func() { - db = test_config.NewTestDB(test_config.NewTestNode()) - test_config.CleanTestDB(db) - headerRepository = repositories.NewHeaderRepository(db) - dripFileVowRepository = vow.DripFileVowRepository{} - dripFileVowRepository.SetDB(db) - }) - - Describe("Create", func() { - modelWithDifferentLogIdx := test_data.DripFileVowModel - modelWithDifferentLogIdx.LogIndex++ - inputs := shared_behaviors.CreateBehaviorInputs{ - CheckedHeaderColumnName: constants.DripFileVowChecked, - LogEventTableName: "maker.drip_file_vow", - TestModel: test_data.DripFileVowModel, - ModelWithDifferentLogIdx: modelWithDifferentLogIdx, - Repository: &dripFileVowRepository, - } - - shared_behaviors.SharedRepositoryCreateBehaviors(&inputs) - - It("adds a drip file vow event", func() { - headerID, err := headerRepository.CreateOrUpdateHeader(fakes.FakeHeader) - Expect(err).NotTo(HaveOccurred()) - err = dripFileVowRepository.Create(headerID, []interface{}{test_data.DripFileVowModel}) - - Expect(err).NotTo(HaveOccurred()) - var dbDripFileVow vow.DripFileVowModel - err = db.Get(&dbDripFileVow, `SELECT what, data, log_idx, tx_idx, raw_log FROM maker.drip_file_vow WHERE header_id = $1`, headerID) - Expect(err).NotTo(HaveOccurred()) - Expect(dbDripFileVow.What).To(Equal(test_data.DripFileVowModel.What)) - Expect(dbDripFileVow.Data).To(Equal(test_data.DripFileVowModel.Data)) - Expect(dbDripFileVow.LogIndex).To(Equal(test_data.DripFileVowModel.LogIndex)) - Expect(dbDripFileVow.TransactionIndex).To(Equal(test_data.DripFileVowModel.TransactionIndex)) - Expect(dbDripFileVow.Raw).To(MatchJSON(test_data.DripFileVowModel.Raw)) - }) - }) - - Describe("MarkHeaderChecked", func() { - inputs := shared_behaviors.MarkedHeaderCheckedBehaviorInputs{ - CheckedHeaderColumnName: constants.DripFileVowChecked, - Repository: &dripFileVowRepository, - } - - shared_behaviors.SharedRepositoryMarkHeaderCheckedBehaviors(&inputs) - }) -}) diff --git a/pkg/transformers/drip_file/vow/vow_suite_test.go b/pkg/transformers/drip_file/vow/vow_suite_test.go deleted file mode 100644 index fc8a56b1..00000000 --- a/pkg/transformers/drip_file/vow/vow_suite_test.go +++ /dev/null @@ -1,35 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package vow_test - -import ( - log "github.com/sirupsen/logrus" - "io/ioutil" - "testing" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -func TestVow(t *testing.T) { - RegisterFailHandler(Fail) - RunSpecs(t, "Vow Suite") -} - -var _ = BeforeSuite(func() { - log.SetOutput(ioutil.Discard) -}) diff --git a/pkg/transformers/factories/converter.go b/pkg/transformers/factories/converter.go deleted file mode 100644 index 1d46a048..00000000 --- a/pkg/transformers/factories/converter.go +++ /dev/null @@ -1,24 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package factories - -import "github.com/ethereum/go-ethereum/core/types" - -type Converter interface { - ToEntities(contractAbi string, ethLog []types.Log) ([]interface{}, error) - ToModels([]interface{}) ([]interface{}, error) -} diff --git a/pkg/transformers/factories/factories_suite_test.go b/pkg/transformers/factories/factories_suite_test.go deleted file mode 100644 index fa938ceb..00000000 --- a/pkg/transformers/factories/factories_suite_test.go +++ /dev/null @@ -1,19 +0,0 @@ -package factories_test - -import ( - "testing" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - log "github.com/sirupsen/logrus" - "io/ioutil" -) - -func TestFactories(t *testing.T) { - RegisterFailHandler(Fail) - RunSpecs(t, "Factories Suite") -} - -var _ = BeforeSuite(func() { - log.SetOutput(ioutil.Discard) -}) diff --git a/pkg/transformers/factories/log_note_transformer.go b/pkg/transformers/factories/log_note_transformer.go deleted file mode 100644 index 08092b8c..00000000 --- a/pkg/transformers/factories/log_note_transformer.go +++ /dev/null @@ -1,73 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package factories - -import ( - "github.com/ethereum/go-ethereum/core/types" - log "github.com/sirupsen/logrus" - - shared_t "github.com/vulcanize/vulcanizedb/libraries/shared/transformer" - "github.com/vulcanize/vulcanizedb/pkg/core" - "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" -) - -type LogNoteTransformer struct { - Config shared_t.TransformerConfig - Converter LogNoteConverter - Repository Repository -} - -func (transformer LogNoteTransformer) NewLogNoteTransformer(db *postgres.DB) shared_t.Transformer { - transformer.Repository.SetDB(db) - return transformer -} - -func (transformer LogNoteTransformer) Execute(logs []types.Log, header core.Header, recheckedHeader constants.TransformerExecution) error { - transformerName := transformer.Config.TransformerName - - // No matching logs, mark the header as checked for this type of logs - if len(logs) < 1 { - err := transformer.Repository.MarkHeaderChecked(header.Id) - if err != nil { - log.Printf("Error marking header as checked in %v: %v", transformerName, err) - return err - } - return nil - } - - models, err := transformer.Converter.ToModels(logs) - if err != nil { - log.Printf("Error converting logs in %v: %v", transformerName, err) - return err - } - - err = transformer.Repository.Create(header.Id, models) - if err != nil { - log.Printf("Error persisting %v record: %v", transformerName, err) - return err - } - return nil -} - -func (transformer LogNoteTransformer) GetName() string { - return transformer.Config.TransformerName -} - -func (transformer LogNoteTransformer) GetConfig() shared_t.TransformerConfig { - return transformer.Config -} diff --git a/pkg/transformers/factories/log_note_transformer_test.go b/pkg/transformers/factories/log_note_transformer_test.go deleted file mode 100644 index fa35624f..00000000 --- a/pkg/transformers/factories/log_note_transformer_test.go +++ /dev/null @@ -1,126 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package factories_test - -import ( - "math/rand" - - "github.com/ethereum/go-ethereum/core/types" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - - shared_t "github.com/vulcanize/vulcanizedb/libraries/shared/transformer" - "github.com/vulcanize/vulcanizedb/pkg/core" - "github.com/vulcanize/vulcanizedb/pkg/fakes" - "github.com/vulcanize/vulcanizedb/pkg/transformers/factories" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" - "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data" - "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data/mocks" -) - -var _ = Describe("LogNoteTransformer", func() { - var ( - repository mocks.MockRepository - converter mocks.MockLogNoteConverter - headerOne core.Header - transformer shared_t.Transformer - model test_data.GenericModel - config = test_data.GenericTestConfig - logs = test_data.GenericTestLogs - ) - - BeforeEach(func() { - repository = mocks.MockRepository{} - converter = mocks.MockLogNoteConverter{} - transformer = factories.LogNoteTransformer{ - Config: config, - Converter: &converter, - Repository: &repository, - }.NewLogNoteTransformer(nil) - - headerOne = core.Header{Id: rand.Int63(), BlockNumber: rand.Int63()} - }) - - It("sets the database", func() { - Expect(repository.SetDbCalled).To(BeTrue()) - }) - - It("marks header checked if no logs are provided", func() { - err := transformer.Execute([]types.Log{}, headerOne, constants.HeaderMissing) - - 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 := transformer.Execute([]types.Log{}, headerOne, constants.HeaderMissing) - - Expect(err).NotTo(HaveOccurred()) - Expect(converter.ToModelsCalledCounter).To(Equal(0)) - Expect(repository.CreateCalledCounter).To(Equal(0)) - }) - - It("does not call repository.MarkCheckedHeader when there are logs", func() { - err := transformer.Execute(logs, headerOne, constants.HeaderMissing) - - Expect(err).NotTo(HaveOccurred()) - repository.AssertMarkHeaderCheckedNotCalled() - }) - - It("returns error if marking header checked returns err", func() { - repository.SetMarkHeaderCheckedError(fakes.FakeError) - - err := transformer.Execute([]types.Log{}, headerOne, constants.HeaderMissing) - - Expect(err).To(HaveOccurred()) - Expect(err).To(MatchError(fakes.FakeError)) - }) - - It("converts matching logs to models", func() { - err := transformer.Execute(logs, headerOne, constants.HeaderMissing) - - Expect(err).NotTo(HaveOccurred()) - Expect(converter.PassedLogs).To(Equal(logs)) - }) - - It("returns error if converter returns error", func() { - converter.SetConverterError(fakes.FakeError) - - err := transformer.Execute(logs, headerOne, constants.HeaderMissing) - - Expect(err).To(HaveOccurred()) - Expect(err).To(MatchError(fakes.FakeError)) - }) - - It("persists the model", func() { - converter.SetReturnModels([]interface{}{model}) - err := transformer.Execute(logs, headerOne, constants.HeaderMissing) - - Expect(err).NotTo(HaveOccurred()) - Expect(repository.PassedHeaderID).To(Equal(headerOne.Id)) - Expect(repository.PassedModels).To(Equal([]interface{}{model})) - }) - - It("returns error if repository returns error for create", func() { - repository.SetCreateError(fakes.FakeError) - - err := transformer.Execute(logs, headerOne, constants.HeaderMissing) - - Expect(err).To(HaveOccurred()) - Expect(err).To(MatchError(fakes.FakeError)) - }) -}) diff --git a/pkg/transformers/factories/storage/storage_suite_test.go b/pkg/transformers/factories/storage/storage_suite_test.go deleted file mode 100644 index b8e3232e..00000000 --- a/pkg/transformers/factories/storage/storage_suite_test.go +++ /dev/null @@ -1,29 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package storage_test - -import ( - "testing" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -func TestStorage(t *testing.T) { - RegisterFailHandler(Fail) - RunSpecs(t, "Storage Suite") -} diff --git a/pkg/transformers/factories/storage/transformer.go b/pkg/transformers/factories/storage/transformer.go deleted file mode 100644 index 68baf5f7..00000000 --- a/pkg/transformers/factories/storage/transformer.go +++ /dev/null @@ -1,53 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package storage - -import ( - "github.com/ethereum/go-ethereum/common" - "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/storage" - "github.com/vulcanize/vulcanizedb/pkg/transformers/storage_diffs" - "github.com/vulcanize/vulcanizedb/pkg/transformers/storage_diffs/shared" -) - -type Transformer struct { - Address common.Address - Mappings storage_diffs.Mappings - Repository storage_diffs.Repository -} - -func (transformer Transformer) NewTransformer(db *postgres.DB) storage.Transformer { - transformer.Mappings.SetDB(db) - transformer.Repository.SetDB(db) - return transformer -} - -func (transformer Transformer) ContractAddress() common.Address { - return transformer.Address -} - -func (transformer Transformer) Execute(row shared.StorageDiffRow) error { - metadata, lookupErr := transformer.Mappings.Lookup(row.StorageKey) - if lookupErr != nil { - return lookupErr - } - value, decodeErr := shared.Decode(row, metadata) - if decodeErr != nil { - return decodeErr - } - return transformer.Repository.Create(row.BlockHeight, row.BlockHash.Hex(), metadata, value) -} diff --git a/pkg/transformers/factories/storage/transformer_test.go b/pkg/transformers/factories/storage/transformer_test.go deleted file mode 100644 index 43821e46..00000000 --- a/pkg/transformers/factories/storage/transformer_test.go +++ /dev/null @@ -1,102 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package storage_test - -import ( - "github.com/ethereum/go-ethereum/common" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - "github.com/vulcanize/vulcanizedb/pkg/fakes" - "github.com/vulcanize/vulcanizedb/pkg/transformers/factories/storage" - "github.com/vulcanize/vulcanizedb/pkg/transformers/storage_diffs/shared" - "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data/mocks" -) - -var _ = Describe("Storage transformer", func() { - var ( - mappings *mocks.MockMappings - repository *mocks.MockStorageRepository - transformer storage.Transformer - ) - - BeforeEach(func() { - mappings = &mocks.MockMappings{} - repository = &mocks.MockStorageRepository{} - transformer = storage.Transformer{ - Address: common.Address{}, - Mappings: mappings, - Repository: repository, - } - }) - - It("returns the contract address being watched", func() { - fakeAddress := common.HexToAddress("0x12345") - transformer.Address = fakeAddress - - Expect(transformer.ContractAddress()).To(Equal(fakeAddress)) - }) - - It("looks up metadata for storage key", func() { - transformer.Execute(shared.StorageDiffRow{}) - - Expect(mappings.LookupCalled).To(BeTrue()) - }) - - It("returns error if lookup fails", func() { - mappings.LookupErr = fakes.FakeError - - err := transformer.Execute(shared.StorageDiffRow{}) - - Expect(err).To(HaveOccurred()) - Expect(err).To(MatchError(fakes.FakeError)) - }) - - It("creates storage row with decoded data", func() { - fakeMetadata := shared.StorageValueMetadata{Type: shared.Address} - mappings.Metadata = fakeMetadata - rawValue := common.HexToAddress("0x12345") - fakeBlockNumber := 123 - fakeBlockHash := "0x67890" - fakeRow := shared.StorageDiffRow{ - Contract: common.Address{}, - BlockHash: common.HexToHash(fakeBlockHash), - BlockHeight: fakeBlockNumber, - StorageKey: common.Hash{}, - StorageValue: rawValue.Hash(), - } - - err := transformer.Execute(fakeRow) - - Expect(err).NotTo(HaveOccurred()) - Expect(repository.PassedBlockNumber).To(Equal(fakeBlockNumber)) - Expect(repository.PassedBlockHash).To(Equal(common.HexToHash(fakeBlockHash).Hex())) - Expect(repository.PassedMetadata).To(Equal(fakeMetadata)) - Expect(repository.PassedValue.(string)).To(Equal(rawValue.Hex())) - }) - - It("returns error if creating row fails", func() { - rawValue := common.HexToAddress("0x12345") - fakeMetadata := shared.StorageValueMetadata{Type: shared.Address} - mappings.Metadata = fakeMetadata - repository.CreateErr = fakes.FakeError - - err := transformer.Execute(shared.StorageDiffRow{StorageValue: rawValue.Hash()}) - - Expect(err).To(HaveOccurred()) - Expect(err).To(MatchError(fakes.FakeError)) - }) -}) diff --git a/pkg/transformers/factories/transformer.go b/pkg/transformers/factories/transformer.go deleted file mode 100644 index 9ed98e77..00000000 --- a/pkg/transformers/factories/transformer.go +++ /dev/null @@ -1,80 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package factories - -import ( - "github.com/ethereum/go-ethereum/core/types" - log "github.com/sirupsen/logrus" - - shared_t "github.com/vulcanize/vulcanizedb/libraries/shared/transformer" - "github.com/vulcanize/vulcanizedb/pkg/core" - "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" -) - -type Transformer struct { - Config shared_t.TransformerConfig - Converter Converter - Repository Repository -} - -func (transformer Transformer) NewTransformer(db *postgres.DB) shared_t.Transformer { - transformer.Repository.SetDB(db) - return transformer -} - -func (transformer Transformer) Execute(logs []types.Log, header core.Header, recheckHeaders constants.TransformerExecution) error { - transformerName := transformer.Config.TransformerName - config := transformer.Config - - if len(logs) < 1 { - err := transformer.Repository.MarkHeaderChecked(header.Id) - if err != nil { - log.Printf("Error marking header as checked in %v: %v", transformerName, err) - return err - } - return nil - } - - entities, err := transformer.Converter.ToEntities(config.ContractAbi, logs) - if err != nil { - log.Printf("Error converting logs to entities in %v: %v", transformerName, err) - return err - } - - models, err := transformer.Converter.ToModels(entities) - if err != nil { - log.Printf("Error converting entities to models in %v: %v", transformerName, err) - return err - } - - err = transformer.Repository.Create(header.Id, models) - if err != nil { - log.Printf("Error persisting %v record: %v", transformerName, err) - return err - } - - return nil -} - -func (transformer Transformer) GetName() string { - return transformer.Config.TransformerName -} - -func (transformer Transformer) GetConfig() shared_t.TransformerConfig { - return transformer.Config -} diff --git a/pkg/transformers/factories/transformer_test.go b/pkg/transformers/factories/transformer_test.go deleted file mode 100644 index ce5ffc98..00000000 --- a/pkg/transformers/factories/transformer_test.go +++ /dev/null @@ -1,147 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package factories_test - -import ( - "math/rand" - - "github.com/ethereum/go-ethereum/core/types" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - - shared_t "github.com/vulcanize/vulcanizedb/libraries/shared/transformer" - "github.com/vulcanize/vulcanizedb/pkg/core" - "github.com/vulcanize/vulcanizedb/pkg/fakes" - "github.com/vulcanize/vulcanizedb/pkg/transformers/factories" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" - "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data" - "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data/mocks" -) - -var _ = Describe("Transformer", func() { - var ( - repository mocks.MockRepository - converter mocks.MockConverter - transformer shared_t.Transformer - headerOne core.Header - config = test_data.GenericTestConfig - logs = test_data.GenericTestLogs - ) - - BeforeEach(func() { - repository = mocks.MockRepository{} - converter = mocks.MockConverter{} - - transformer = factories.Transformer{ - Repository: &repository, - Converter: &converter, - Config: config, - }.NewTransformer(nil) - - headerOne = core.Header{Id: rand.Int63(), BlockNumber: rand.Int63()} - }) - - It("sets the db", func() { - Expect(repository.SetDbCalled).To(BeTrue()) - }) - - It("marks header checked if no logs returned", func() { - err := transformer.Execute([]types.Log{}, headerOne, constants.HeaderMissing) - - 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 := transformer.Execute([]types.Log{}, headerOne, constants.HeaderMissing) - - Expect(err).NotTo(HaveOccurred()) - Expect(converter.ToEntitiesCalledCounter).To(Equal(0)) - Expect(converter.ToModelsCalledCounter).To(Equal(0)) - Expect(repository.CreateCalledCounter).To(Equal(0)) - }) - - It("does not call repository.MarkCheckedHeader when there are logs", func() { - err := transformer.Execute(logs, headerOne, constants.HeaderMissing) - - Expect(err).NotTo(HaveOccurred()) - repository.AssertMarkHeaderCheckedNotCalled() - }) - - It("returns error if marking header checked returns err", func() { - repository.SetMarkHeaderCheckedError(fakes.FakeError) - - err := transformer.Execute([]types.Log{}, headerOne, constants.HeaderMissing) - - Expect(err).To(HaveOccurred()) - Expect(err).To(MatchError(fakes.FakeError)) - }) - - It("converts an eth log to an entity", func() { - err := transformer.Execute(logs, headerOne, constants.HeaderMissing) - - Expect(err).NotTo(HaveOccurred()) - Expect(converter.ContractAbi).To(Equal(config.ContractAbi)) - Expect(converter.LogsToConvert).To(Equal(logs)) - }) - - It("returns an error if converter fails", func() { - converter.ToEntitiesError = fakes.FakeError - - err := transformer.Execute(logs, headerOne, constants.HeaderMissing) - - Expect(err).To(HaveOccurred()) - Expect(err).To(MatchError(fakes.FakeError)) - }) - - It("converts an entity to a model", func() { - converter.EntitiesToReturn = []interface{}{test_data.GenericEntity{}} - - err := transformer.Execute(logs, headerOne, constants.HeaderMissing) - - Expect(err).NotTo(HaveOccurred()) - Expect(converter.EntitiesToConvert[0]).To(Equal(test_data.GenericEntity{})) - }) - - It("returns an error if converting to models fails", func() { - converter.EntitiesToReturn = []interface{}{test_data.GenericEntity{}} - converter.ToModelsError = fakes.FakeError - - err := transformer.Execute(logs, headerOne, constants.HeaderMissing) - - Expect(err).To(HaveOccurred()) - Expect(err).To(MatchError(fakes.FakeError)) - }) - - It("persists the record", func() { - converter.ModelsToReturn = []interface{}{test_data.GenericModel{}} - - err := transformer.Execute(logs, headerOne, constants.HeaderMissing) - - Expect(err).NotTo(HaveOccurred()) - Expect(repository.PassedHeaderID).To(Equal(headerOne.Id)) - Expect(repository.PassedModels[0]).To(Equal(test_data.GenericModel{})) - }) - - It("returns error if persisting the record fails", func() { - repository.SetCreateError(fakes.FakeError) - err := transformer.Execute(logs, headerOne, constants.HeaderMissing) - - Expect(err).To(HaveOccurred()) - Expect(err).To(MatchError(fakes.FakeError)) - }) -}) diff --git a/pkg/transformers/flap_kick/config.go b/pkg/transformers/flap_kick/config.go deleted file mode 100644 index 914d86d8..00000000 --- a/pkg/transformers/flap_kick/config.go +++ /dev/null @@ -1,33 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package flap_kick - -import ( - shared_t "github.com/vulcanize/vulcanizedb/libraries/shared/transformer" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" -) - -func GetFlapKickConfig() shared_t.TransformerConfig { - return shared_t.TransformerConfig{ - TransformerName: constants.FlapKickLabel, - ContractAddresses: []string{constants.FlapperContractAddress()}, - ContractAbi: constants.FlapperABI(), - Topic: constants.GetFlapKickSignature(), - StartingBlockNumber: constants.FlapperDeploymentBlock(), - EndingBlockNumber: -1, - } -} diff --git a/pkg/transformers/flap_kick/converter.go b/pkg/transformers/flap_kick/converter.go deleted file mode 100644 index 811d0495..00000000 --- a/pkg/transformers/flap_kick/converter.go +++ /dev/null @@ -1,91 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package flap_kick - -import ( - "encoding/json" - "errors" - "fmt" - "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/core/types" - "github.com/vulcanize/vulcanizedb/pkg/geth" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared" - "time" -) - -type FlapKickConverter struct { -} - -func (FlapKickConverter) ToEntities(contractAbi string, ethLogs []types.Log) ([]interface{}, error) { - var entities []interface{} - for _, ethLog := range ethLogs { - entity := &FlapKickEntity{} - address := ethLog.Address - abi, err := geth.ParseAbi(contractAbi) - if err != nil { - return nil, err - } - contract := bind.NewBoundContract(address, abi, nil, nil, nil) - err = contract.UnpackLog(entity, "Kick", ethLog) - if err != nil { - return nil, err - } - entity.Raw = ethLog - entity.TransactionIndex = ethLog.TxIndex - entity.LogIndex = ethLog.Index - entities = append(entities, *entity) - } - return entities, nil -} - -func (FlapKickConverter) ToModels(entities []interface{}) ([]interface{}, error) { - var models []interface{} - for _, entity := range entities { - flapKickEntity, ok := entity.(FlapKickEntity) - if !ok { - return nil, fmt.Errorf("entity of type %T, not %T", entity, FlapKickEntity{}) - } - - if flapKickEntity.Id == nil { - return nil, errors.New("FlapKick log ID cannot be nil.") - } - - id := flapKickEntity.Id.String() - lot := shared.BigIntToString(flapKickEntity.Lot) - bid := shared.BigIntToString(flapKickEntity.Bid) - gal := flapKickEntity.Gal.String() - endValue := shared.BigIntToInt64(flapKickEntity.End) - end := time.Unix(endValue, 0) - rawLog, err := json.Marshal(flapKickEntity.Raw) - if err != nil { - return nil, err - } - - model := FlapKickModel{ - BidId: id, - Lot: lot, - Bid: bid, - Gal: gal, - End: end, - TransactionIndex: flapKickEntity.TransactionIndex, - LogIndex: flapKickEntity.LogIndex, - Raw: rawLog, - } - models = append(models, model) - } - return models, nil -} diff --git a/pkg/transformers/flap_kick/converter_test.go b/pkg/transformers/flap_kick/converter_test.go deleted file mode 100644 index b83f8a31..00000000 --- a/pkg/transformers/flap_kick/converter_test.go +++ /dev/null @@ -1,97 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package flap_kick_test - -import ( - "encoding/json" - "github.com/ethereum/go-ethereum/core/types" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - "github.com/vulcanize/vulcanizedb/pkg/transformers/flap_kick" - "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data" - "math/big" - "time" -) - -var _ = Describe("Flap kick converter", func() { - var converter = flap_kick.FlapKickConverter{} - - Describe("ToEntity", func() { - It("converts an Eth Log to a FlapKickEntity", func() { - entities, err := converter.ToEntities(test_data.KovanFlapperABI, []types.Log{test_data.EthFlapKickLog}) - - Expect(err).NotTo(HaveOccurred()) - Expect(len(entities)).To(Equal(1)) - Expect(entities[0]).To(Equal(test_data.FlapKickEntity)) - }) - - It("returns an error if converting log to entity fails", func() { - _, err := converter.ToEntities("error abi", []types.Log{test_data.EthFlapKickLog}) - - Expect(err).To(HaveOccurred()) - }) - }) - - Describe("ToModel", func() { - - BeforeEach(func() { - }) - - It("converts an Entity to a Model", func() { - models, err := converter.ToModels([]interface{}{test_data.FlapKickEntity}) - - Expect(err).NotTo(HaveOccurred()) - Expect(len(models)).To(Equal(1)) - Expect(models[0]).To(Equal(test_data.FlapKickModel)) - }) - - It("handles nil values", func() { - emptyAddressHex := "0x0000000000000000000000000000000000000000" - emptyString := "" - emptyTime := time.Unix(0, 0) - emptyEntity := flap_kick.FlapKickEntity{} - emptyEntity.Id = big.NewInt(1) - emptyRawLogJson, err := json.Marshal(types.Log{}) - Expect(err).NotTo(HaveOccurred()) - - models, err := converter.ToModels([]interface{}{emptyEntity}) - - Expect(err).NotTo(HaveOccurred()) - Expect(len(models)).To(Equal(1)) - model := models[0].(flap_kick.FlapKickModel) - Expect(model.BidId).To(Equal("1")) - Expect(model.Lot).To(Equal(emptyString)) - Expect(model.Bid).To(Equal(emptyString)) - Expect(model.Gal).To(Equal(emptyAddressHex)) - Expect(model.End).To(Equal(emptyTime)) - Expect(model.Raw).To(Equal(emptyRawLogJson)) - }) - - It("returns an error if the flap kick event id is nil", func() { - _, err := converter.ToModels([]interface{}{flap_kick.FlapKickEntity{}}) - - Expect(err).To(HaveOccurred()) - }) - - It("returns an error if the wrong entity type is passed in", func() { - _, err := converter.ToModels([]interface{}{test_data.WrongEntity{}}) - - Expect(err).To(HaveOccurred()) - Expect(err.Error()).To(ContainSubstring("entity of type")) - }) - }) -}) diff --git a/pkg/transformers/flap_kick/entity.go b/pkg/transformers/flap_kick/entity.go deleted file mode 100644 index 5f680b78..00000000 --- a/pkg/transformers/flap_kick/entity.go +++ /dev/null @@ -1,35 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package flap_kick - -import ( - "math/big" - - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/types" -) - -type FlapKickEntity struct { - Id *big.Int - Lot *big.Int - Bid *big.Int - Gal common.Address - End *big.Int - Raw types.Log - TransactionIndex uint - LogIndex uint -} diff --git a/pkg/transformers/flap_kick/flap_kick_suite_test.go b/pkg/transformers/flap_kick/flap_kick_suite_test.go deleted file mode 100644 index 7925e9fe..00000000 --- a/pkg/transformers/flap_kick/flap_kick_suite_test.go +++ /dev/null @@ -1,35 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package flap_kick_test - -import ( - log "github.com/sirupsen/logrus" - "io/ioutil" - "testing" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -func TestFlapKick(t *testing.T) { - RegisterFailHandler(Fail) - RunSpecs(t, "FlapKick Suite") -} - -var _ = BeforeSuite(func() { - log.SetOutput(ioutil.Discard) -}) diff --git a/pkg/transformers/flap_kick/model.go b/pkg/transformers/flap_kick/model.go deleted file mode 100644 index 7c7635e4..00000000 --- a/pkg/transformers/flap_kick/model.go +++ /dev/null @@ -1,30 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package flap_kick - -import "time" - -type FlapKickModel struct { - BidId string `db:"bid_id"` - Lot string - Bid string - Gal string - End time.Time - LogIndex uint `db:"log_idx"` - TransactionIndex uint `db:"tx_idx"` - Raw []byte `db:"raw_log"` -} diff --git a/pkg/transformers/flap_kick/repository.go b/pkg/transformers/flap_kick/repository.go deleted file mode 100644 index ea9547dc..00000000 --- a/pkg/transformers/flap_kick/repository.go +++ /dev/null @@ -1,85 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package flap_kick - -import ( - "fmt" - - log "github.com/sirupsen/logrus" - - "github.com/vulcanize/vulcanizedb/pkg/core" - "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" -) - -type FlapKickRepository struct { - db *postgres.DB -} - -func (repository *FlapKickRepository) Create(headerID int64, models []interface{}) error { - tx, dBaseErr := repository.db.Begin() - if dBaseErr != nil { - return dBaseErr - } - for _, model := range models { - flapKickModel, ok := model.(FlapKickModel) - if !ok { - return fmt.Errorf("model of type %T, not %T", model, FlapKickModel{}) - } - - _, execErr := tx.Exec( - `INSERT into maker.flap_kick (header_id, bid_id, lot, bid, gal, "end", tx_idx, log_idx, raw_log) - VALUES($1, $2::NUMERIC, $3::NUMERIC, $4::NUMERIC, $5, $6, $7, $8, $9) - ON CONFLICT (header_id, tx_idx, log_idx) DO UPDATE SET bid_id = $2, lot = $3, bid = $4, gal = $5, "end" = $6, raw_log = $9;`, - headerID, flapKickModel.BidId, flapKickModel.Lot, flapKickModel.Bid, flapKickModel.Gal, flapKickModel.End, flapKickModel.TransactionIndex, flapKickModel.LogIndex, flapKickModel.Raw, - ) - if execErr != nil { - rollbackErr := tx.Rollback() - if rollbackErr != nil { - log.Error("failed to rollback ", rollbackErr) - } - return execErr - } - } - - checkHeaderErr := shared.MarkHeaderCheckedInTransaction(headerID, tx, constants.FlapKickChecked) - if checkHeaderErr != nil { - rollbackErr := tx.Rollback() - if rollbackErr != nil { - log.Error("failed to rollback ", rollbackErr) - } - return checkHeaderErr - } - return tx.Commit() -} - -func (repository *FlapKickRepository) MarkHeaderChecked(headerID int64) error { - return shared.MarkHeaderChecked(headerID, repository.db, constants.FlapKickChecked) -} - -func (repository FlapKickRepository) MissingHeaders(startingBlockNumber, endingBlockNumber int64) ([]core.Header, error) { - return shared.MissingHeaders(startingBlockNumber, endingBlockNumber, repository.db, constants.FlapKickChecked) -} - -func (repository FlapKickRepository) RecheckHeaders(startingBlockNumber, endingBlockNumber int64) ([]core.Header, error) { - return shared.RecheckHeaders(startingBlockNumber, endingBlockNumber, repository.db, constants.FlapKickChecked) -} - -func (repository *FlapKickRepository) SetDB(db *postgres.DB) { - repository.db = db -} diff --git a/pkg/transformers/flap_kick/repository_test.go b/pkg/transformers/flap_kick/repository_test.go deleted file mode 100644 index 3c38b246..00000000 --- a/pkg/transformers/flap_kick/repository_test.go +++ /dev/null @@ -1,92 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package flap_kick_test - -import ( - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - - "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" - "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres/repositories" - "github.com/vulcanize/vulcanizedb/pkg/fakes" - "github.com/vulcanize/vulcanizedb/pkg/transformers/flap_kick" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" - "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data" - "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data/shared_behaviors" - "github.com/vulcanize/vulcanizedb/test_config" -) - -var _ = Describe("Flap Kick Repository", func() { - var ( - db *postgres.DB - flapKickRepository flap_kick.FlapKickRepository - headerRepository repositories.HeaderRepository - ) - - BeforeEach(func() { - db = test_config.NewTestDB(test_config.NewTestNode()) - test_config.CleanTestDB(db) - flapKickRepository = flap_kick.FlapKickRepository{} - flapKickRepository.SetDB(db) - headerRepository = repositories.NewHeaderRepository(db) - }) - - Describe("Create", func() { - modelWithDifferentLogIdx := test_data.FlapKickModel - modelWithDifferentLogIdx.LogIndex = modelWithDifferentLogIdx.LogIndex + 1 - inputs := shared_behaviors.CreateBehaviorInputs{ - CheckedHeaderColumnName: constants.FlapKickChecked, - LogEventTableName: "maker.flap_kick", - TestModel: test_data.FlapKickModel, - ModelWithDifferentLogIdx: modelWithDifferentLogIdx, - Repository: &flapKickRepository, - } - - shared_behaviors.SharedRepositoryCreateBehaviors(&inputs) - - It("persists a flap kick record", func() { - headerId, err := headerRepository.CreateOrUpdateHeader(fakes.FakeHeader) - Expect(err).NotTo(HaveOccurred()) - err = flapKickRepository.Create(headerId, []interface{}{test_data.FlapKickModel}) - - Expect(err).NotTo(HaveOccurred()) - var count int - db.QueryRow(`SELECT count(*) FROM maker.flap_kick`).Scan(&count) - Expect(count).To(Equal(1)) - var dbResult flap_kick.FlapKickModel - err = db.Get(&dbResult, `SELECT bid, bid_id, "end", gal, lot, log_idx, tx_idx, raw_log FROM maker.flap_kick WHERE header_id = $1`, headerId) - Expect(err).NotTo(HaveOccurred()) - Expect(dbResult.Bid).To(Equal(test_data.FlapKickModel.Bid)) - Expect(dbResult.BidId).To(Equal(test_data.FlapKickModel.BidId)) - Expect(dbResult.End.Equal(test_data.FlapKickModel.End)).To(BeTrue()) - Expect(dbResult.Gal).To(Equal(test_data.FlapKickModel.Gal)) - Expect(dbResult.Lot).To(Equal(test_data.FlapKickModel.Lot)) - Expect(dbResult.LogIndex).To(Equal(test_data.FlapKickModel.LogIndex)) - Expect(dbResult.TransactionIndex).To(Equal(test_data.FlapKickModel.TransactionIndex)) - Expect(dbResult.Raw).To(MatchJSON(test_data.FlapKickModel.Raw)) - }) - }) - - Describe("MarkHeaderChecked", func() { - inputs := shared_behaviors.MarkedHeaderCheckedBehaviorInputs{ - CheckedHeaderColumnName: constants.FlapKickChecked, - Repository: &flapKickRepository, - } - - shared_behaviors.SharedRepositoryMarkHeaderCheckedBehaviors(&inputs) - }) -}) diff --git a/pkg/transformers/flip_kick/config.go b/pkg/transformers/flip_kick/config.go deleted file mode 100644 index 63e786be..00000000 --- a/pkg/transformers/flip_kick/config.go +++ /dev/null @@ -1,33 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package flip_kick - -import ( - shared_t "github.com/vulcanize/vulcanizedb/libraries/shared/transformer" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" -) - -func GetFlipKickConfig() shared_t.TransformerConfig { - return shared_t.TransformerConfig{ - TransformerName: constants.FlipKickLabel, - ContractAddresses: []string{constants.FlipperContractAddress()}, - ContractAbi: constants.FlipperABI(), - Topic: constants.GetFlipKickSignature(), - StartingBlockNumber: constants.FlipperDeploymentBlock(), - EndingBlockNumber: -1, - } -} diff --git a/pkg/transformers/flip_kick/converter.go b/pkg/transformers/flip_kick/converter.go deleted file mode 100644 index 93ba551b..00000000 --- a/pkg/transformers/flip_kick/converter.go +++ /dev/null @@ -1,100 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package flip_kick - -import ( - "encoding/json" - "errors" - "time" - - "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/types" - - "fmt" - "github.com/vulcanize/vulcanizedb/pkg/geth" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared" -) - -type FlipKickConverter struct{} - -func (FlipKickConverter) ToEntities(contractAbi string, ethLogs []types.Log) ([]interface{}, error) { - var entities []interface{} - for _, ethLog := range ethLogs { - entity := &FlipKickEntity{} - address := ethLog.Address - abi, err := geth.ParseAbi(contractAbi) - if err != nil { - return nil, err - } - - contract := bind.NewBoundContract(address, abi, nil, nil, nil) - - err = contract.UnpackLog(entity, "Kick", ethLog) - if err != nil { - return nil, err - } - entity.Raw = ethLog - entity.TransactionIndex = ethLog.TxIndex - entity.LogIndex = ethLog.Index - entities = append(entities, *entity) - } - - return entities, nil -} - -func (FlipKickConverter) ToModels(entities []interface{}) ([]interface{}, error) { - var models []interface{} - for _, entity := range entities { - flipKickEntity, ok := entity.(FlipKickEntity) - if !ok { - return nil, fmt.Errorf("entity of type %T, not %T", entity, FlipKickEntity{}) - } - - if flipKickEntity.Id == nil { - return nil, errors.New("FlipKick log ID cannot be nil.") - } - - id := flipKickEntity.Id.String() - lot := shared.BigIntToString(flipKickEntity.Lot) - bid := shared.BigIntToString(flipKickEntity.Bid) - gal := flipKickEntity.Gal.String() - endValue := shared.BigIntToInt64(flipKickEntity.End) - end := time.Unix(endValue, 0) - urn := common.BytesToAddress(flipKickEntity.Urn[:common.AddressLength]).String() - tab := shared.BigIntToString(flipKickEntity.Tab) - rawLog, err := json.Marshal(flipKickEntity.Raw) - if err != nil { - return nil, err - } - - model := FlipKickModel{ - BidId: id, - Lot: lot, - Bid: bid, - Gal: gal, - End: end, - Urn: urn, - Tab: tab, - TransactionIndex: flipKickEntity.TransactionIndex, - LogIndex: flipKickEntity.LogIndex, - Raw: rawLog, - } - models = append(models, model) - } - return models, nil -} diff --git a/pkg/transformers/flip_kick/converter_test.go b/pkg/transformers/flip_kick/converter_test.go deleted file mode 100644 index a12c4006..00000000 --- a/pkg/transformers/flip_kick/converter_test.go +++ /dev/null @@ -1,104 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package flip_kick_test - -import ( - "encoding/json" - "math/big" - "time" - - "github.com/ethereum/go-ethereum/core/types" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - - "github.com/vulcanize/vulcanizedb/pkg/transformers/flip_kick" - "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data" -) - -var _ = Describe("FlipKick Converter", func() { - var converter = flip_kick.FlipKickConverter{} - - Describe("ToEntity", func() { - It("converts an Eth Log to a FlipKickEntity", func() { - entities, err := converter.ToEntities(test_data.KovanFlipperABI, []types.Log{test_data.EthFlipKickLog}) - - Expect(err).NotTo(HaveOccurred()) - Expect(len(entities)).To(Equal(1)) - entity := entities[0] - Expect(entity).To(Equal(test_data.FlipKickEntity)) - }) - - It("returns an error if converting log to entity fails", func() { - _, err := converter.ToEntities("error abi", []types.Log{test_data.EthFlipKickLog}) - - Expect(err).To(HaveOccurred()) - }) - }) - - Describe("ToModel", func() { - var emptyAddressHex = "0x0000000000000000000000000000000000000000" - var emptyString = "" - var emptyTime = time.Unix(0, 0) - var emptyEntity = flip_kick.FlipKickEntity{} - var emptyRawLog []byte - var err error - - BeforeEach(func() { - emptyEntity.Id = big.NewInt(1) - emptyRawLog, err = json.Marshal(types.Log{}) - Expect(err).NotTo(HaveOccurred()) - }) - - It("converts an Entity to a Model", func() { - models, err := converter.ToModels([]interface{}{test_data.FlipKickEntity}) - - Expect(err).NotTo(HaveOccurred()) - Expect(len(models)).To(Equal(1)) - Expect(models[0]).To(Equal(test_data.FlipKickModel)) - }) - - It("handles nil values", func() { - models, err := converter.ToModels([]interface{}{emptyEntity}) - - Expect(err).NotTo(HaveOccurred()) - Expect(len(models)).To(Equal(1)) - model := models[0].(flip_kick.FlipKickModel) - Expect(model.BidId).To(Equal("1")) - Expect(model.Lot).To(Equal(emptyString)) - Expect(model.Bid).To(Equal(emptyString)) - Expect(model.Gal).To(Equal(emptyAddressHex)) - Expect(model.End).To(Equal(emptyTime)) - Expect(model.Urn).To(Equal(emptyAddressHex)) - Expect(model.Tab).To(Equal(emptyString)) - Expect(model.Raw).To(Equal(emptyRawLog)) - }) - - It("returns an error if the flip kick event id is nil", func() { - emptyEntity.Id = nil - _, err := converter.ToModels([]interface{}{emptyEntity}) - - Expect(err).To(HaveOccurred()) - }) - - It("returns an error if the wrong entity type is passed in", func() { - _, err := converter.ToModels([]interface{}{test_data.WrongEntity{}}) - - Expect(err).To(HaveOccurred()) - Expect(err.Error()).To(ContainSubstring("entity of type")) - }) - }) -}) diff --git a/pkg/transformers/flip_kick/entity.go b/pkg/transformers/flip_kick/entity.go deleted file mode 100644 index 057225eb..00000000 --- a/pkg/transformers/flip_kick/entity.go +++ /dev/null @@ -1,37 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package flip_kick - -import ( - "math/big" - - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/types" -) - -type FlipKickEntity struct { - Id *big.Int - Lot *big.Int - Bid *big.Int - Gal common.Address - End *big.Int - Urn [32]byte - Tab *big.Int - TransactionIndex uint - LogIndex uint - Raw types.Log -} diff --git a/pkg/transformers/flip_kick/flip_kick_suite_test.go b/pkg/transformers/flip_kick/flip_kick_suite_test.go deleted file mode 100644 index b813aef9..00000000 --- a/pkg/transformers/flip_kick/flip_kick_suite_test.go +++ /dev/null @@ -1,35 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package flip_kick - -import ( - log "github.com/sirupsen/logrus" - "io/ioutil" - "testing" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -func TestFlipKick(t *testing.T) { - RegisterFailHandler(Fail) - RunSpecs(t, "FlipKick Suite") -} - -var _ = BeforeSuite(func() { - log.SetOutput(ioutil.Discard) -}) diff --git a/pkg/transformers/flip_kick/model.go b/pkg/transformers/flip_kick/model.go deleted file mode 100644 index bc817886..00000000 --- a/pkg/transformers/flip_kick/model.go +++ /dev/null @@ -1,32 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package flip_kick - -import "time" - -type FlipKickModel struct { - BidId string `db:"bid_id"` - Lot string - Bid string - Gal string - End time.Time - Urn string - Tab string - TransactionIndex uint `db:"tx_idx"` - LogIndex uint `db:"log_idx"` - Raw []byte `db:"raw_log"` -} diff --git a/pkg/transformers/flip_kick/repository.go b/pkg/transformers/flip_kick/repository.go deleted file mode 100644 index fb18c9f3..00000000 --- a/pkg/transformers/flip_kick/repository.go +++ /dev/null @@ -1,83 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package flip_kick - -import ( - "fmt" - log "github.com/sirupsen/logrus" - - "github.com/vulcanize/vulcanizedb/pkg/core" - "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" -) - -type FlipKickRepository struct { - db *postgres.DB -} - -func (repository FlipKickRepository) Create(headerID int64, models []interface{}) error { - tx, dBaseErr := repository.db.Begin() - if dBaseErr != nil { - return dBaseErr - } - for _, model := range models { - flipKickModel, ok := model.(FlipKickModel) - if !ok { - return fmt.Errorf("model of type %T, not %T", model, FlipKickModel{}) - } - - _, execErr := tx.Exec( - `INSERT into maker.flip_kick (header_id, bid_id, lot, bid, gal, "end", urn, tab, tx_idx, log_idx, raw_log) - VALUES($1, $2::NUMERIC, $3::NUMERIC, $4::NUMERIC, $5, $6, $7, $8::NUMERIC, $9, $10, $11) - ON CONFLICT (header_id, tx_idx, log_idx) DO UPDATE SET bid_id = $2, lot = $3, bid = $4, gal = $5, "end" = $6, urn= $7, tab = $8, raw_log = $11;`, - headerID, flipKickModel.BidId, flipKickModel.Lot, flipKickModel.Bid, flipKickModel.Gal, flipKickModel.End, flipKickModel.Urn, flipKickModel.Tab, flipKickModel.TransactionIndex, flipKickModel.LogIndex, flipKickModel.Raw, - ) - if execErr != nil { - rollbackErr := tx.Rollback() - if rollbackErr != nil { - log.Error("failed to rollback ", rollbackErr) - } - return execErr - } - } - checkHeaderErr := shared.MarkHeaderCheckedInTransaction(headerID, tx, constants.FlipKickChecked) - if checkHeaderErr != nil { - rollbackErr := tx.Rollback() - if rollbackErr != nil { - log.Error("failed to rollback ", rollbackErr) - } - return checkHeaderErr - } - return tx.Commit() -} - -func (repository FlipKickRepository) MarkHeaderChecked(headerId int64) error { - return shared.MarkHeaderChecked(headerId, repository.db, constants.FlipKickChecked) -} - -func (repository FlipKickRepository) MissingHeaders(startingBlockNumber, endingBlockNumber int64) ([]core.Header, error) { - return shared.MissingHeaders(startingBlockNumber, endingBlockNumber, repository.db, constants.FlipKickChecked) -} - -func (repository FlipKickRepository) RecheckHeaders(startingBlockNumber, endingBlockNumber int64) ([]core.Header, error) { - return shared.RecheckHeaders(startingBlockNumber, endingBlockNumber, repository.db, constants.FlipKickChecked) -} - -func (repository *FlipKickRepository) SetDB(db *postgres.DB) { - repository.db = db -} diff --git a/pkg/transformers/flip_kick/repository_test.go b/pkg/transformers/flip_kick/repository_test.go deleted file mode 100644 index 9d9d42f8..00000000 --- a/pkg/transformers/flip_kick/repository_test.go +++ /dev/null @@ -1,100 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package flip_kick_test - -import ( - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - - "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" - "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres/repositories" - "github.com/vulcanize/vulcanizedb/pkg/fakes" - "github.com/vulcanize/vulcanizedb/pkg/transformers/flip_kick" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" - "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data" - "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data/shared_behaviors" - "github.com/vulcanize/vulcanizedb/test_config" -) - -var _ = Describe("FlipKick Repository", func() { - var db *postgres.DB - var flipKickRepository flip_kick.FlipKickRepository - - BeforeEach(func() { - db = test_config.NewTestDB(test_config.NewTestNode()) - test_config.CleanTestDB(db) - flipKickRepository = flip_kick.FlipKickRepository{} - flipKickRepository.SetDB(db) - }) - - Describe("Create", func() { - modelWithDifferentLogIdx := test_data.FlipKickModel - modelWithDifferentLogIdx.LogIndex++ - inputs := shared_behaviors.CreateBehaviorInputs{ - CheckedHeaderColumnName: constants.FlipKickChecked, - LogEventTableName: "maker.flip_kick", - TestModel: test_data.FlipKickModel, - ModelWithDifferentLogIdx: modelWithDifferentLogIdx, - Repository: &flipKickRepository, - } - - shared_behaviors.SharedRepositoryCreateBehaviors(&inputs) - - It("persists flip_kick records", func() { - headerRepository := repositories.NewHeaderRepository(db) - headerId, err := headerRepository.CreateOrUpdateHeader(fakes.FakeHeader) - Expect(err).NotTo(HaveOccurred()) - - err = flipKickRepository.Create(headerId, []interface{}{test_data.FlipKickModel}) - Expect(err).NotTo(HaveOccurred()) - - assertDBRecordCount(db, "maker.flip_kick", 1) - - dbResult := test_data.FlipKickDBRow{} - err = db.QueryRowx(`SELECT * FROM maker.flip_kick`).StructScan(&dbResult) - Expect(err).NotTo(HaveOccurred()) - Expect(dbResult.HeaderId).To(Equal(headerId)) - Expect(dbResult.BidId).To(Equal(test_data.FlipKickModel.BidId)) - Expect(dbResult.Lot).To(Equal(test_data.FlipKickModel.Lot)) - Expect(dbResult.Bid).To(Equal(test_data.FlipKickModel.Bid)) - Expect(dbResult.Gal).To(Equal(test_data.FlipKickModel.Gal)) - Expect(dbResult.End.Equal(test_data.FlipKickModel.End)).To(BeTrue()) - Expect(dbResult.Urn).To(Equal(test_data.FlipKickModel.Urn)) - Expect(dbResult.Tab).To(Equal(test_data.FlipKickModel.Tab)) - Expect(dbResult.TransactionIndex).To(Equal(test_data.FlipKickModel.TransactionIndex)) - Expect(dbResult.LogIndex).To(Equal(test_data.FlipKickModel.LogIndex)) - Expect(dbResult.Raw).To(MatchJSON(test_data.FlipKickModel.Raw)) - }) - }) - - Describe("MarkHeaderChecked", func() { - inputs := shared_behaviors.MarkedHeaderCheckedBehaviorInputs{ - CheckedHeaderColumnName: constants.FlipKickChecked, - Repository: &flipKickRepository, - } - - shared_behaviors.SharedRepositoryMarkHeaderCheckedBehaviors(&inputs) - }) -}) - -func assertDBRecordCount(db *postgres.DB, dbTable string, expectedCount int) { - var count int - query := `SELECT count(*) FROM ` + dbTable - err := db.QueryRow(query).Scan(&count) - Expect(err).NotTo(HaveOccurred()) - Expect(count).To(Equal(expectedCount)) -} diff --git a/pkg/transformers/flop_kick/config.go b/pkg/transformers/flop_kick/config.go deleted file mode 100644 index c3f3c5bc..00000000 --- a/pkg/transformers/flop_kick/config.go +++ /dev/null @@ -1,33 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package flop_kick - -import ( - shared_t "github.com/vulcanize/vulcanizedb/libraries/shared/transformer" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" -) - -func GetFlopKickConfig() shared_t.TransformerConfig { - return shared_t.TransformerConfig{ - TransformerName: constants.FlopKickLabel, - ContractAddresses: []string{constants.FlopperContractAddress()}, - ContractAbi: constants.FlopperABI(), - Topic: constants.GetFlopKickSignature(), - StartingBlockNumber: constants.FlopperDeploymentBlock(), - EndingBlockNumber: -1, - } -} diff --git a/pkg/transformers/flop_kick/converter.go b/pkg/transformers/flop_kick/converter.go deleted file mode 100644 index 412a7e4d..00000000 --- a/pkg/transformers/flop_kick/converter.go +++ /dev/null @@ -1,85 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package flop_kick - -import ( - "encoding/json" - "time" - - "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/core/types" - - "fmt" - "github.com/vulcanize/vulcanizedb/pkg/geth" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared" -) - -type FlopKickConverter struct{} - -func (FlopKickConverter) ToEntities(contractAbi string, ethLogs []types.Log) ([]interface{}, error) { - var results []interface{} - for _, ethLog := range ethLogs { - entity := Entity{} - address := ethLog.Address - abi, err := geth.ParseAbi(contractAbi) - if err != nil { - return nil, err - } - - contract := bind.NewBoundContract(address, abi, nil, nil, nil) - - err = contract.UnpackLog(&entity, "Kick", ethLog) - if err != nil { - return nil, err - } - entity.Raw = ethLog - entity.TransactionIndex = ethLog.TxIndex - entity.LogIndex = ethLog.Index - results = append(results, entity) - } - return results, nil -} - -func (FlopKickConverter) ToModels(entities []interface{}) ([]interface{}, error) { - var results []interface{} - for _, entity := range entities { - flopKickEntity, ok := entity.(Entity) - if !ok { - return nil, fmt.Errorf("entity of type %T, not %T", entity, Entity{}) - } - - endValue := shared.BigIntToInt64(flopKickEntity.End) - rawLogJson, err := json.Marshal(flopKickEntity.Raw) - if err != nil { - return nil, err - } - - model := Model{ - BidId: shared.BigIntToString(flopKickEntity.Id), - Lot: shared.BigIntToString(flopKickEntity.Lot), - Bid: shared.BigIntToString(flopKickEntity.Bid), - Gal: flopKickEntity.Gal.String(), - End: time.Unix(endValue, 0), - TransactionIndex: flopKickEntity.TransactionIndex, - LogIndex: flopKickEntity.LogIndex, - Raw: rawLogJson, - } - results = append(results, model) - } - - return results, nil -} diff --git a/pkg/transformers/flop_kick/converter_test.go b/pkg/transformers/flop_kick/converter_test.go deleted file mode 100644 index ee9faf3c..00000000 --- a/pkg/transformers/flop_kick/converter_test.go +++ /dev/null @@ -1,93 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package flop_kick_test - -import ( - "encoding/json" - "time" - - "github.com/ethereum/go-ethereum/core/types" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - - "github.com/vulcanize/vulcanizedb/pkg/transformers/flop_kick" - "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data" -) - -var _ = Describe("FlopKick Converter", func() { - Describe("ToEntities", func() { - It("converts a log to a FlopKick entity", func() { - converter := flop_kick.FlopKickConverter{} - entities, err := converter.ToEntities(test_data.KovanFlopperABI, []types.Log{test_data.FlopKickLog}) - - Expect(err).NotTo(HaveOccurred()) - entity := entities[0] - Expect(entity).To(Equal(test_data.FlopKickEntity)) - }) - - It("returns an error if converting the log to an entity fails", func() { - converter := flop_kick.FlopKickConverter{} - entities, err := converter.ToEntities("error abi", []types.Log{test_data.FlopKickLog}) - - Expect(err).To(HaveOccurred()) - Expect(entities).To(BeNil()) - }) - }) - - Describe("ToModels", func() { - var emptyAddressHex = "0x0000000000000000000000000000000000000000" - var emptyString = "" - var emptyTime = time.Unix(0, 0) - var emptyEntity = flop_kick.Entity{} - - It("converts an Entity to a Model", func() { - converter := flop_kick.FlopKickConverter{} - models, err := converter.ToModels([]interface{}{test_data.FlopKickEntity}) - - Expect(err).NotTo(HaveOccurred()) - Expect(models[0]).To(Equal(test_data.FlopKickModel)) - }) - - It("returns error if wrong entity", func() { - converter := flop_kick.FlopKickConverter{} - _, err := converter.ToModels([]interface{}{test_data.WrongEntity{}}) - - Expect(err).To(HaveOccurred()) - Expect(err.Error()).To(ContainSubstring("entity of type test_data.WrongEntity, not flop_kick.Entity")) - }) - - It("handles nil values", func() { - emptyLog, err := json.Marshal(types.Log{}) - - converter := flop_kick.FlopKickConverter{} - expectedModel := flop_kick.Model{ - BidId: emptyString, - Lot: emptyString, - Bid: emptyString, - Gal: emptyAddressHex, - End: emptyTime, - TransactionIndex: 0, - Raw: emptyLog, - } - - models, err := converter.ToModels([]interface{}{emptyEntity}) - model := models[0] - Expect(err).NotTo(HaveOccurred()) - Expect(model).To(Equal(expectedModel)) - }) - }) -}) diff --git a/pkg/transformers/flop_kick/entity.go b/pkg/transformers/flop_kick/entity.go deleted file mode 100644 index 3a598288..00000000 --- a/pkg/transformers/flop_kick/entity.go +++ /dev/null @@ -1,35 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package flop_kick - -import ( - "math/big" - - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/types" -) - -type Entity struct { - Id *big.Int - Lot *big.Int - Bid *big.Int - Gal common.Address - End *big.Int - TransactionIndex uint - LogIndex uint - Raw types.Log -} diff --git a/pkg/transformers/flop_kick/model.go b/pkg/transformers/flop_kick/model.go deleted file mode 100644 index d78547cf..00000000 --- a/pkg/transformers/flop_kick/model.go +++ /dev/null @@ -1,30 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package flop_kick - -import "time" - -type Model struct { - BidId string `db:"bid_id"` - Lot string - Bid string - Gal string - End time.Time - TransactionIndex uint `db:"tx_idx"` - LogIndex uint `db:"log_idx"` - Raw []byte `db:"raw_log"` -} diff --git a/pkg/transformers/flop_kick/repository.go b/pkg/transformers/flop_kick/repository.go deleted file mode 100644 index a71a618b..00000000 --- a/pkg/transformers/flop_kick/repository.go +++ /dev/null @@ -1,87 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package flop_kick - -import ( - "fmt" - - log "github.com/sirupsen/logrus" - - "github.com/vulcanize/vulcanizedb/pkg/core" - "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" -) - -type FlopKickRepository struct { - db *postgres.DB -} - -func (repository FlopKickRepository) Create(headerID int64, models []interface{}) error { - tx, dBaseErr := repository.db.Begin() - if dBaseErr != nil { - return dBaseErr - } - for _, flopKick := range models { - flopKickModel, ok := flopKick.(Model) - - if !ok { - return fmt.Errorf("model of type %T, not %T", flopKick, Model{}) - } - - _, execErr := tx.Exec( - `INSERT into maker.flop_kick (header_id, bid_id, lot, bid, gal, "end", tx_idx, log_idx, raw_log) - VALUES($1, $2::NUMERIC, $3::NUMERIC, $4::NUMERIC, $5, $6, $7, $8, $9) - ON CONFLICT (header_id, tx_idx, log_idx) DO UPDATE SET bid_id = $2, lot = $3, bid = $4, gal = $5, "end" = $6, raw_log = $9;`, - headerID, flopKickModel.BidId, flopKickModel.Lot, flopKickModel.Bid, flopKickModel.Gal, flopKickModel.End, flopKickModel.TransactionIndex, flopKickModel.LogIndex, flopKickModel.Raw, - ) - if execErr != nil { - rollbackErr := tx.Rollback() - if rollbackErr != nil { - log.Error("failed to rollback ", rollbackErr) - } - return execErr - } - } - - checkHeaderErr := shared.MarkHeaderCheckedInTransaction(headerID, tx, constants.FlopKickChecked) - if checkHeaderErr != nil { - rollbackErr := tx.Rollback() - if rollbackErr != nil { - log.Error("failed to rollback ", rollbackErr) - } - return checkHeaderErr - } - - return tx.Commit() -} - -func (repository FlopKickRepository) MarkHeaderChecked(headerId int64) error { - return shared.MarkHeaderChecked(headerId, repository.db, constants.FlopKickChecked) -} - -func (repository FlopKickRepository) MissingHeaders(startingBlockNumber, endingBlockNumber int64) ([]core.Header, error) { - return shared.MissingHeaders(startingBlockNumber, endingBlockNumber, repository.db, constants.FlopKickChecked) -} - -func (repository FlopKickRepository) RecheckHeaders(startingBlockNumber, endingBlockNumber int64) ([]core.Header, error) { - return shared.RecheckHeaders(startingBlockNumber, endingBlockNumber, repository.db, constants.FlopKickChecked) -} - -func (repository *FlopKickRepository) SetDB(db *postgres.DB) { - repository.db = db -} diff --git a/pkg/transformers/flop_kick/repository_test.go b/pkg/transformers/flop_kick/repository_test.go deleted file mode 100644 index cf2990ce..00000000 --- a/pkg/transformers/flop_kick/repository_test.go +++ /dev/null @@ -1,90 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package flop_kick_test - -import ( - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - - "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" - "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres/repositories" - "github.com/vulcanize/vulcanizedb/pkg/fakes" - "github.com/vulcanize/vulcanizedb/pkg/transformers/flop_kick" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" - "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data" - "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data/shared_behaviors" - "github.com/vulcanize/vulcanizedb/test_config" -) - -var _ = Describe("FlopRepository", func() { - var ( - db *postgres.DB - repository flop_kick.FlopKickRepository - ) - - BeforeEach(func() { - db = test_config.NewTestDB(test_config.NewTestNode()) - test_config.CleanTestDB(db) - repository = flop_kick.FlopKickRepository{} - repository.SetDB(db) - }) - - Describe("Create", func() { - modelWithDifferentLogIdx := test_data.FlopKickModel - modelWithDifferentLogIdx.LogIndex++ - inputs := shared_behaviors.CreateBehaviorInputs{ - CheckedHeaderColumnName: constants.FlopKickChecked, - LogEventTableName: "maker.flop_kick", - TestModel: test_data.FlopKickModel, - ModelWithDifferentLogIdx: modelWithDifferentLogIdx, - Repository: &repository, - } - - shared_behaviors.SharedRepositoryCreateBehaviors(&inputs) - - It("creates FlopKick records", func() { - headerRepository := repositories.NewHeaderRepository(db) - headerId, err := headerRepository.CreateOrUpdateHeader(fakes.FakeHeader) - Expect(err).NotTo(HaveOccurred()) - - err = repository.Create(headerId, []interface{}{test_data.FlopKickModel}) - Expect(err).NotTo(HaveOccurred()) - - dbResult := test_data.FlopKickDBResult{} - err = db.QueryRowx(`SELECT * FROM maker.flop_kick WHERE header_id = $1`, headerId).StructScan(&dbResult) - Expect(err).NotTo(HaveOccurred()) - Expect(dbResult.HeaderId).To(Equal(headerId)) - Expect(dbResult.BidId).To(Equal(test_data.FlopKickModel.BidId)) - Expect(dbResult.Lot).To(Equal(test_data.FlopKickModel.Lot)) - Expect(dbResult.Bid).To(Equal(test_data.FlopKickModel.Bid)) - Expect(dbResult.Gal).To(Equal(test_data.FlopKickModel.Gal)) - Expect(dbResult.End.Equal(test_data.FlopKickModel.End)).To(BeTrue()) - Expect(dbResult.TransactionIndex).To(Equal(test_data.FlopKickModel.TransactionIndex)) - Expect(dbResult.LogIndex).To(Equal(test_data.FlopKickModel.LogIndex)) - Expect(dbResult.Raw).To(MatchJSON(test_data.FlopKickModel.Raw)) - }) - }) - - Describe("MarkedHeadersChecked", func() { - inputs := shared_behaviors.MarkedHeaderCheckedBehaviorInputs{ - CheckedHeaderColumnName: constants.FlopKickChecked, - Repository: &repository, - } - - shared_behaviors.SharedRepositoryMarkHeaderCheckedBehaviors(&inputs) - }) -}) diff --git a/pkg/transformers/frob/config.go b/pkg/transformers/frob/config.go deleted file mode 100644 index 3499d39d..00000000 --- a/pkg/transformers/frob/config.go +++ /dev/null @@ -1,33 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package frob - -import ( - shared_t "github.com/vulcanize/vulcanizedb/libraries/shared/transformer" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" -) - -func GetFrobConfig() shared_t.TransformerConfig { - return shared_t.TransformerConfig{ - TransformerName: constants.FrobLabel, - ContractAddresses: []string{constants.PitContractAddress()}, - ContractAbi: constants.PitABI(), - Topic: constants.GetFrobSignature(), - StartingBlockNumber: constants.PitDeploymentBlock(), - EndingBlockNumber: -1, - } -} diff --git a/pkg/transformers/frob/converter.go b/pkg/transformers/frob/converter.go deleted file mode 100644 index a69809bb..00000000 --- a/pkg/transformers/frob/converter.go +++ /dev/null @@ -1,81 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package frob - -import ( - "encoding/json" - "fmt" - "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/core/types" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared" - - "github.com/vulcanize/vulcanizedb/pkg/geth" -) - -type FrobConverter struct{} - -func (FrobConverter) ToEntities(contractAbi string, ethLogs []types.Log) ([]interface{}, error) { - var entities []interface{} - for _, ethLog := range ethLogs { - entity := FrobEntity{} - address := ethLog.Address - abi, err := geth.ParseAbi(contractAbi) - if err != nil { - return nil, err - } - contract := bind.NewBoundContract(address, abi, nil, nil, nil) - err = contract.UnpackLog(&entity, "Frob", ethLog) - if err != nil { - return entities, err - } - entity.LogIndex = ethLog.Index - entity.TransactionIndex = ethLog.TxIndex - entity.Raw = ethLog - entities = append(entities, entity) - } - - return entities, nil -} - -func (FrobConverter) ToModels(entities []interface{}) ([]interface{}, error) { - var models []interface{} - for _, entity := range entities { - frobEntity, ok := entity.(FrobEntity) - if !ok { - return nil, fmt.Errorf("entity of type %T, not %T", entity, FrobEntity{}) - } - - rawLog, err := json.Marshal(frobEntity.Raw) - if err != nil { - return nil, err - } - model := FrobModel{ - Ilk: shared.GetHexWithoutPrefix(frobEntity.Ilk[:]), - Urn: shared.GetHexWithoutPrefix(frobEntity.Urn[:]), - Ink: frobEntity.Ink.String(), - Art: frobEntity.Art.String(), - Dink: frobEntity.Dink.String(), - Dart: frobEntity.Dart.String(), - IArt: frobEntity.IArt.String(), - LogIndex: frobEntity.LogIndex, - TransactionIndex: frobEntity.TransactionIndex, - Raw: rawLog, - } - models = append(models, model) - } - return models, nil -} diff --git a/pkg/transformers/frob/converter_test.go b/pkg/transformers/frob/converter_test.go deleted file mode 100644 index 75b7ccf1..00000000 --- a/pkg/transformers/frob/converter_test.go +++ /dev/null @@ -1,58 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package frob_test - -import ( - "github.com/ethereum/go-ethereum/core/types" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - - "github.com/vulcanize/vulcanizedb/pkg/transformers/frob" - "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data" -) - -var _ = Describe("Frob converter", func() { - var converter = frob.FrobConverter{} - It("converts a log to an entity", func() { - entities, err := converter.ToEntities(test_data.KovanPitABI, []types.Log{test_data.EthFrobLog}) - - Expect(err).NotTo(HaveOccurred()) - Expect(len(entities)).To(Equal(1)) - Expect(entities[0]).To(Equal(test_data.FrobEntity)) - }) - - It("returns an error if converting to an entity fails", func() { - _, err := converter.ToEntities("bad abi", []types.Log{test_data.EthFrobLog}) - - Expect(err).To(HaveOccurred()) - }) - - It("converts an entity to a model", func() { - models, err := converter.ToModels([]interface{}{test_data.FrobEntity}) - - Expect(err).NotTo(HaveOccurred()) - Expect(len(models)).To(Equal(1)) - Expect(models[0]).To(Equal(test_data.FrobModel)) - }) - - It("returns an error if the entity type is wrong", func() { - _, err := converter.ToModels([]interface{}{test_data.WrongEntity{}}) - - Expect(err).To(HaveOccurred()) - Expect(err.Error()).To(ContainSubstring("entity of type test_data.WrongEntity, not frob.FrobEntity")) - }) -}) diff --git a/pkg/transformers/frob/entity.go b/pkg/transformers/frob/entity.go deleted file mode 100644 index ddd9fcc0..00000000 --- a/pkg/transformers/frob/entity.go +++ /dev/null @@ -1,36 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package frob - -import ( - "math/big" - - "github.com/ethereum/go-ethereum/core/types" -) - -type FrobEntity struct { - Ilk [32]byte - Urn [32]byte - Ink *big.Int - Art *big.Int - Dink *big.Int - Dart *big.Int - IArt *big.Int - LogIndex uint - TransactionIndex uint - Raw types.Log -} diff --git a/pkg/transformers/frob/frob_suite_test.go b/pkg/transformers/frob/frob_suite_test.go deleted file mode 100644 index 16b3b57a..00000000 --- a/pkg/transformers/frob/frob_suite_test.go +++ /dev/null @@ -1,35 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package frob_test - -import ( - log "github.com/sirupsen/logrus" - "io/ioutil" - "testing" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -func TestFrob(t *testing.T) { - RegisterFailHandler(Fail) - RunSpecs(t, "Frob Suite") -} - -var _ = BeforeSuite(func() { - log.SetOutput(ioutil.Discard) -}) diff --git a/pkg/transformers/frob/model.go b/pkg/transformers/frob/model.go deleted file mode 100644 index 86acc6a9..00000000 --- a/pkg/transformers/frob/model.go +++ /dev/null @@ -1,30 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package frob - -type FrobModel struct { - Ilk string - Urn string - Ink string - Art string - Dink string - Dart string - IArt string - LogIndex uint `db:"log_idx"` - TransactionIndex uint `db:"tx_idx"` - Raw []byte `db:"raw_log"` -} diff --git a/pkg/transformers/integration_tests/deal.go b/pkg/transformers/integration_tests/deal.go deleted file mode 100644 index c8a7f361..00000000 --- a/pkg/transformers/integration_tests/deal.go +++ /dev/null @@ -1,155 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package integration_tests - -import ( - "github.com/ethereum/go-ethereum/common" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" - "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data" - - shared_t "github.com/vulcanize/vulcanizedb/libraries/shared/transformer" - "github.com/vulcanize/vulcanizedb/pkg/core" - "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" - "github.com/vulcanize/vulcanizedb/pkg/transformers/deal" - "github.com/vulcanize/vulcanizedb/pkg/transformers/factories" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared" - "github.com/vulcanize/vulcanizedb/test_config" -) - -var _ = Describe("Deal transformer", func() { - var ( - db *postgres.DB - blockChain core.BlockChain - config shared_t.TransformerConfig - initializer factories.LogNoteTransformer - fetcher *shared.Fetcher - addresses []common.Address - topics []common.Hash - ) - - BeforeEach(func() { - rpcClient, ethClient, err := getClients(ipc) - Expect(err).NotTo(HaveOccurred()) - blockChain, err = getBlockChain(rpcClient, ethClient) - Expect(err).NotTo(HaveOccurred()) - db = test_config.NewTestDB(blockChain.Node()) - test_config.CleanTestDB(db) - - config = shared_t.TransformerConfig{ - TransformerName: constants.DealLabel, - ContractAddresses: []string{test_data.KovanFlapperContractAddress, test_data.KovanFlipperContractAddress, test_data.KovanFlopperContractAddress}, - ContractAbi: test_data.KovanFlipperABI, - Topic: test_data.KovanDealSignature, - StartingBlockNumber: 0, - EndingBlockNumber: -1, - } - - initializer = factories.LogNoteTransformer{ - Config: config, - Converter: &deal.DealConverter{}, - Repository: &deal.DealRepository{}, - } - - fetcher = shared.NewFetcher(blockChain) - addresses = shared_t.HexStringsToAddresses(config.ContractAddresses) - topics = []common.Hash{common.HexToHash(config.Topic)} - - }) - - It("persists a flip deal log event", func() { - // transaction: 0x05b5eabac2ace136f0f7e0efc61d7d42abe8e8938cc0f04fbf1a6ba545d59e58 - flipBlockNumber := int64(8958007) - header, err := persistHeader(db, flipBlockNumber, blockChain) - Expect(err).NotTo(HaveOccurred()) - - initializer.Config.StartingBlockNumber = flipBlockNumber - initializer.Config.EndingBlockNumber = flipBlockNumber - - logs, err := fetcher.FetchLogs(addresses, topics, header) - Expect(err).NotTo(HaveOccurred()) - - transformer := initializer.NewLogNoteTransformer(db) - err = transformer.Execute(logs, header, constants.HeaderMissing) - Expect(err).NotTo(HaveOccurred()) - - var dbResult []deal.DealModel - err = db.Select(&dbResult, `SELECT bid_id, contract_address FROM maker.deal`) - Expect(err).NotTo(HaveOccurred()) - - Expect(len(dbResult)).To(Equal(1)) - Expect(dbResult[0].BidId).To(Equal("6")) - Expect(dbResult[0].ContractAddress).To(Equal(test_data.KovanFlipperContractAddress)) - }) - - It("rechecks flip deal event", func() { - // transaction: 0x05b5eabac2ace136f0f7e0efc61d7d42abe8e8938cc0f04fbf1a6ba545d59e58 - flipBlockNumber := int64(8958007) - header, err := persistHeader(db, flipBlockNumber, blockChain) - Expect(err).NotTo(HaveOccurred()) - - initializer.Config.StartingBlockNumber = flipBlockNumber - initializer.Config.EndingBlockNumber = flipBlockNumber - - logs, err := fetcher.FetchLogs(addresses, topics, header) - Expect(err).NotTo(HaveOccurred()) - - transformer := initializer.NewLogNoteTransformer(db) - err = transformer.Execute(logs, header, constants.HeaderMissing) - Expect(err).NotTo(HaveOccurred()) - - err = transformer.Execute(logs, header, constants.HeaderRecheck) - Expect(err).NotTo(HaveOccurred()) - - var headerID int64 - err = db.Get(&headerID, `SELECT id FROM public.headers WHERE block_number = $1`, flipBlockNumber) - Expect(err).NotTo(HaveOccurred()) - - var dentChecked []int - err = db.Select(&dentChecked, `SELECT deal_checked FROM public.checked_headers WHERE header_id = $1`, headerID) - Expect(err).NotTo(HaveOccurred()) - }) - - It("persists a flop deal log event", func() { - //TODO: There are currently no Flop.deal events on Kovan - }) - - It("persists a flap deal log event", func() { - flapBlockNumber := int64(9004628) - header, err := persistHeader(db, flapBlockNumber, blockChain) - Expect(err).NotTo(HaveOccurred()) - - initializer.Config.StartingBlockNumber = flapBlockNumber - initializer.Config.EndingBlockNumber = flapBlockNumber - - logs, err := fetcher.FetchLogs(addresses, topics, header) - Expect(err).NotTo(HaveOccurred()) - - transformer := initializer.NewLogNoteTransformer(db) - err = transformer.Execute(logs, header, constants.HeaderMissing) - Expect(err).NotTo(HaveOccurred()) - - var dbResult []deal.DealModel - err = db.Select(&dbResult, `SELECT bid_id, contract_address FROM maker.deal`) - Expect(err).NotTo(HaveOccurred()) - - Expect(len(dbResult)).To(Equal(1)) - Expect(dbResult[0].BidId).To(Equal("1")) - Expect(dbResult[0].ContractAddress).To(Equal(test_data.KovanFlapperContractAddress)) - }) -}) diff --git a/pkg/transformers/integration_tests/dent.go b/pkg/transformers/integration_tests/dent.go deleted file mode 100644 index 70c1aaf0..00000000 --- a/pkg/transformers/integration_tests/dent.go +++ /dev/null @@ -1,124 +0,0 @@ -package integration_tests - -import ( - "github.com/ethereum/go-ethereum/common" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" - "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data" - - shared_t "github.com/vulcanize/vulcanizedb/libraries/shared/transformer" - "github.com/vulcanize/vulcanizedb/pkg/core" - "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" - "github.com/vulcanize/vulcanizedb/pkg/transformers/dent" - "github.com/vulcanize/vulcanizedb/pkg/transformers/factories" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared" - "github.com/vulcanize/vulcanizedb/test_config" -) - -var _ = Describe("Dent transformer", func() { - var ( - db *postgres.DB - blockChain core.BlockChain - fetcher *shared.Fetcher - transformer shared_t.Transformer - config shared_t.TransformerConfig - addresses []common.Address - topics []common.Hash - initializer factories.LogNoteTransformer - ) - - BeforeEach(func() { - rpcClient, ethClient, err := getClients(ipc) - Expect(err).NotTo(HaveOccurred()) - blockChain, err = getBlockChain(rpcClient, ethClient) - Expect(err).NotTo(HaveOccurred()) - db = test_config.NewTestDB(blockChain.Node()) - test_config.CleanTestDB(db) - - config = shared_t.TransformerConfig{ - TransformerName: constants.DentLabel, - ContractAddresses: []string{test_data.KovanFlipperContractAddress, test_data.KovanFlopperContractAddress}, - ContractAbi: test_data.KovanFlipperABI, - Topic: test_data.KovanDentFunctionSignature, - StartingBlockNumber: 0, - EndingBlockNumber: -1, - } - - addresses = shared_t.HexStringsToAddresses(config.ContractAddresses) - topics = []common.Hash{common.HexToHash(config.Topic)} - fetcher = shared.NewFetcher(blockChain) - - initializer = factories.LogNoteTransformer{ - Config: config, - Converter: &dent.DentConverter{}, - Repository: &dent.DentRepository{}, - } - }) - - It("persists a flop dent log event", func() { - blockNumber := int64(8955613) - header, err := persistHeader(db, blockNumber, blockChain) - Expect(err).NotTo(HaveOccurred()) - - initializer.Config.StartingBlockNumber = blockNumber - initializer.Config.EndingBlockNumber = blockNumber - - logs, err := fetcher.FetchLogs(addresses, topics, header) - Expect(err).NotTo(HaveOccurred()) - - transformer = initializer.NewLogNoteTransformer(db) - err = transformer.Execute(logs, header, constants.HeaderMissing) - Expect(err).NotTo(HaveOccurred()) - - var dbResult []dent.DentModel - err = db.Select(&dbResult, `SELECT bid, bid_id, guy, lot FROM maker.dent`) - Expect(err).NotTo(HaveOccurred()) - - Expect(len(dbResult)).To(Equal(1)) - Expect(dbResult[0].Bid).To(Equal("10000000000000000000000")) - Expect(dbResult[0].BidId).To(Equal("2")) - Expect(dbResult[0].Guy).To(Equal("0x0000d8b4147eDa80Fec7122AE16DA2479Cbd7ffB")) - Expect(dbResult[0].Lot).To(Equal("1000000000000000000000000000")) - - var dbTic int64 - err = db.Get(&dbTic, `SELECT tic FROM maker.dent`) - Expect(err).NotTo(HaveOccurred()) - - actualTic := 1538637780 + constants.TTL - Expect(dbTic).To(Equal(actualTic)) - }) - - It("rechecks header for flop dent log event", func() { - blockNumber := int64(8955613) - header, err := persistHeader(db, blockNumber, blockChain) - Expect(err).NotTo(HaveOccurred()) - - initializer.Config.StartingBlockNumber = blockNumber - initializer.Config.EndingBlockNumber = blockNumber - - logs, err := fetcher.FetchLogs(addresses, topics, header) - Expect(err).NotTo(HaveOccurred()) - - transformer = initializer.NewLogNoteTransformer(db) - err = transformer.Execute(logs, header, constants.HeaderMissing) - Expect(err).NotTo(HaveOccurred()) - - err = transformer.Execute(logs, header, constants.HeaderRecheck) - Expect(err).NotTo(HaveOccurred()) - - var headerID int64 - err = db.Get(&headerID, `SELECT id FROM public.headers WHERE block_number = $1`, blockNumber) - Expect(err).NotTo(HaveOccurred()) - - var dentChecked []int - err = db.Select(&dentChecked, `SELECT dent_checked FROM public.checked_headers WHERE header_id = $1`, headerID) - Expect(err).NotTo(HaveOccurred()) - - Expect(dentChecked[0]).To(Equal(2)) - }) - - It("persists a flip dent log event", func() { - //TODO: There are currently no Flip.dent events on Kovan - }) -}) diff --git a/pkg/transformers/integration_tests/drip_file_vow.go b/pkg/transformers/integration_tests/drip_file_vow.go deleted file mode 100644 index 3e522444..00000000 --- a/pkg/transformers/integration_tests/drip_file_vow.go +++ /dev/null @@ -1,135 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package integration_tests - -import ( - "github.com/ethereum/go-ethereum/common" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - - shared_t "github.com/vulcanize/vulcanizedb/libraries/shared/transformer" - "github.com/vulcanize/vulcanizedb/pkg/core" - "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" - "github.com/vulcanize/vulcanizedb/pkg/transformers/drip_file/vow" - "github.com/vulcanize/vulcanizedb/pkg/transformers/factories" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared" - "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data" - - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" - "github.com/vulcanize/vulcanizedb/test_config" -) - -var _ = Describe("Drip File Vow LogNoteTransformer", func() { - var ( - db *postgres.DB - blockChain core.BlockChain - ) - - BeforeEach(func() { - rpcClient, ethClient, err := getClients(ipc) - Expect(err).NotTo(HaveOccurred()) - blockChain, err = getBlockChain(rpcClient, ethClient) - Expect(err).NotTo(HaveOccurred()) - db = test_config.NewTestDB(blockChain.Node()) - test_config.CleanTestDB(db) - }) - - It("transforms DripFileVow log events", func() { - blockNumber := int64(8762197) - config := shared_t.TransformerConfig{ - TransformerName: constants.DripFileVowLabel, - ContractAddresses: []string{test_data.KovanDripContractAddress}, - ContractAbi: test_data.KovanDripABI, - Topic: test_data.KovanDripFileVowSignature, - StartingBlockNumber: blockNumber, - EndingBlockNumber: blockNumber, - } - - header, err := persistHeader(db, blockNumber, blockChain) - Expect(err).NotTo(HaveOccurred()) - - initializer := factories.LogNoteTransformer{ - Config: config, - Converter: &vow.DripFileVowConverter{}, - Repository: &vow.DripFileVowRepository{}, - } - transformer := initializer.NewLogNoteTransformer(db) - - fetcher := shared.NewFetcher(blockChain) - logs, err := fetcher.FetchLogs( - shared_t.HexStringsToAddresses(config.ContractAddresses), - []common.Hash{common.HexToHash(config.Topic)}, - header) - Expect(err).NotTo(HaveOccurred()) - - err = transformer.Execute(logs, header, constants.HeaderMissing) - Expect(err).NotTo(HaveOccurred()) - - var dbResult []vow.DripFileVowModel - err = db.Select(&dbResult, `SELECT what, data FROM maker.drip_file_vow`) - Expect(err).NotTo(HaveOccurred()) - - Expect(len(dbResult)).To(Equal(1)) - Expect(dbResult[0].What).To(Equal("vow")) - Expect(dbResult[0].Data).To(Equal("0x3728e9777B2a0a611ee0F89e00E01044ce4736d1")) - }) - - It("rechecks drip file vow event", func() { - blockNumber := int64(8762197) - config := shared_t.TransformerConfig{ - TransformerName: constants.DripFileVowLabel, - ContractAddresses: []string{test_data.KovanDripContractAddress}, - ContractAbi: test_data.KovanDripABI, - Topic: test_data.KovanDripFileVowSignature, - StartingBlockNumber: blockNumber, - EndingBlockNumber: blockNumber, - } - - header, err := persistHeader(db, blockNumber, blockChain) - Expect(err).NotTo(HaveOccurred()) - - initializer := factories.LogNoteTransformer{ - Config: config, - Converter: &vow.DripFileVowConverter{}, - Repository: &vow.DripFileVowRepository{}, - } - transformer := initializer.NewLogNoteTransformer(db) - - fetcher := shared.NewFetcher(blockChain) - logs, err := fetcher.FetchLogs( - shared_t.HexStringsToAddresses(config.ContractAddresses), - []common.Hash{common.HexToHash(config.Topic)}, - header) - Expect(err).NotTo(HaveOccurred()) - - err = transformer.Execute(logs, header, constants.HeaderMissing) - Expect(err).NotTo(HaveOccurred()) - - err = transformer.Execute(logs, header, constants.HeaderRecheck) - Expect(err).NotTo(HaveOccurred()) - - var headerID int64 - err = db.Get(&headerID, `SELECT id FROM public.headers WHERE block_number = $1`, blockNumber) - Expect(err).NotTo(HaveOccurred()) - - var dripfilevowChecked []int - err = db.Select(&dripfilevowChecked, `SELECT drip_file_vow_checked FROM public.checked_headers WHERE header_id = $1`, headerID) - Expect(err).NotTo(HaveOccurred()) - - Expect(dripfilevowChecked[0]).To(Equal(2)) - }) -}) diff --git a/pkg/transformers/integration_tests/flap_kick.go b/pkg/transformers/integration_tests/flap_kick.go deleted file mode 100644 index f8803533..00000000 --- a/pkg/transformers/integration_tests/flap_kick.go +++ /dev/null @@ -1,137 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package integration_tests - -import ( - "github.com/ethereum/go-ethereum/common" - "github.com/vulcanize/vulcanizedb/pkg/core" - "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" - "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data" - "github.com/vulcanize/vulcanizedb/test_config" - "time" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - - shared_t "github.com/vulcanize/vulcanizedb/libraries/shared/transformer" - "github.com/vulcanize/vulcanizedb/pkg/transformers/factories" - "github.com/vulcanize/vulcanizedb/pkg/transformers/flap_kick" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" -) - -var _ = Describe("FlapKick Transformer", func() { - var ( - db *postgres.DB - blockChain core.BlockChain - ) - - BeforeEach(func() { - rpcClient, ethClient, err := getClients(ipc) - Expect(err).NotTo(HaveOccurred()) - blockChain, err = getBlockChain(rpcClient, ethClient) - Expect(err).NotTo(HaveOccurred()) - db = test_config.NewTestDB(blockChain.Node()) - test_config.CleanTestDB(db) - }) - - It("fetches and transforms a FlapKick event from Kovan chain", func() { - blockNumber := int64(9002933) - config := shared_t.TransformerConfig{ - TransformerName: constants.FlapKickLabel, - ContractAddresses: []string{test_data.KovanFlapperContractAddress}, - ContractAbi: test_data.KovanFlapperABI, - Topic: test_data.KovanFlapKickSignature, - StartingBlockNumber: blockNumber, - EndingBlockNumber: blockNumber, - } - - header, err := persistHeader(db, blockNumber, blockChain) - Expect(err).NotTo(HaveOccurred()) - - transformer := factories.Transformer{ - Config: config, - Converter: &flap_kick.FlapKickConverter{}, - Repository: &flap_kick.FlapKickRepository{}, - }.NewTransformer(db) - - fetcher := shared.NewFetcher(blockChain) - logs, err := fetcher.FetchLogs( - shared_t.HexStringsToAddresses(config.ContractAddresses), - []common.Hash{common.HexToHash(config.Topic)}, - header) - Expect(err).NotTo(HaveOccurred()) - - err = transformer.Execute(logs, header, constants.HeaderMissing) - Expect(err).NotTo(HaveOccurred()) - - var dbResult []flap_kick.FlapKickModel - err = db.Select(&dbResult, `SELECT bid, bid_id, "end", gal, lot FROM maker.flap_kick`) - Expect(err).NotTo(HaveOccurred()) - - Expect(len(dbResult)).To(Equal(1)) - Expect(dbResult[0].Bid).To(Equal("0")) - Expect(dbResult[0].BidId).To(Equal("1")) - Expect(dbResult[0].End.Equal(time.Unix(1539163860, 0))).To(BeTrue()) - Expect(dbResult[0].Gal).To(Equal("0x0000d8b4147eDa80Fec7122AE16DA2479Cbd7ffB")) - Expect(dbResult[0].Lot).To(Equal("1000000000000000000")) - }) - - It("rechecks flap kick transformer", func() { - blockNumber := int64(9002933) - config := shared.TransformerConfig{ - TransformerName: constants.FlapKickLabel, - ContractAddresses: []string{test_data.KovanFlapperContractAddress}, - ContractAbi: test_data.KovanFlapperABI, - Topic: test_data.KovanFlapKickSignature, - StartingBlockNumber: blockNumber, - EndingBlockNumber: blockNumber, - } - - header, err := persistHeader(db, blockNumber, blockChain) - Expect(err).NotTo(HaveOccurred()) - - transformer := factories.Transformer{ - Config: config, - Converter: &flap_kick.FlapKickConverter{}, - Repository: &flap_kick.FlapKickRepository{}, - }.NewTransformer(db) - - fetcher := shared.NewFetcher(blockChain) - logs, err := fetcher.FetchLogs( - shared.HexStringsToAddresses(config.ContractAddresses), - []common.Hash{common.HexToHash(config.Topic)}, - header) - Expect(err).NotTo(HaveOccurred()) - - err = transformer.Execute(logs, header, constants.HeaderMissing) - Expect(err).NotTo(HaveOccurred()) - - err = transformer.Execute(logs, header, constants.HeaderRecheck) - Expect(err).NotTo(HaveOccurred()) - - var headerID int64 - err = db.Get(&headerID, `SELECT id FROM public.headers WHERE block_number = $1`, blockNumber) - Expect(err).NotTo(HaveOccurred()) - - var flapkickChecked []int - err = db.Select(&flapkickChecked, `SELECT flap_kick_checked FROM public.checked_headers WHERE header_id = $1`, headerID) - Expect(err).NotTo(HaveOccurred()) - - Expect(flapkickChecked[0]).To(Equal(2)) - }) -}) diff --git a/pkg/transformers/integration_tests/flip_kick.go b/pkg/transformers/integration_tests/flip_kick.go deleted file mode 100644 index d062faea..00000000 --- a/pkg/transformers/integration_tests/flip_kick.go +++ /dev/null @@ -1,160 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package integration_tests - -import ( - "time" - - "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/common" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - - shared_t "github.com/vulcanize/vulcanizedb/libraries/shared/transformer" - "github.com/vulcanize/vulcanizedb/pkg/geth" - "github.com/vulcanize/vulcanizedb/pkg/transformers/factories" - "github.com/vulcanize/vulcanizedb/pkg/transformers/flip_kick" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" - "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data" - "github.com/vulcanize/vulcanizedb/test_config" -) - -var _ = Describe("FlipKick Transformer", func() { - It("unpacks an event log", func() { - address := common.HexToAddress(test_data.KovanFlipperContractAddress) - abi, err := geth.ParseAbi(test_data.KovanFlipperABI) - Expect(err).NotTo(HaveOccurred()) - - contract := bind.NewBoundContract(address, abi, nil, nil, nil) - entity := &flip_kick.FlipKickEntity{} - - var eventLog = test_data.EthFlipKickLog - - err = contract.UnpackLog(entity, "Kick", eventLog) - Expect(err).NotTo(HaveOccurred()) - - expectedEntity := test_data.FlipKickEntity - Expect(entity.Id).To(Equal(expectedEntity.Id)) - Expect(entity.Lot).To(Equal(expectedEntity.Lot)) - Expect(entity.Bid).To(Equal(expectedEntity.Bid)) - Expect(entity.Gal).To(Equal(expectedEntity.Gal)) - Expect(entity.End).To(Equal(expectedEntity.End)) - Expect(entity.Urn).To(Equal(expectedEntity.Urn)) - Expect(entity.Tab).To(Equal(expectedEntity.Tab)) - }) - - It("fetches and transforms a FlipKick event from Kovan chain", func() { - blockNumber := int64(8956476) - config := shared_t.TransformerConfig{ - TransformerName: constants.FlipKickLabel, - ContractAddresses: []string{test_data.KovanFlipperContractAddress}, - ContractAbi: test_data.KovanFlipperABI, - Topic: test_data.KovanFlipKickSignature, - StartingBlockNumber: blockNumber, - EndingBlockNumber: blockNumber, - } - - rpcClient, ethClient, err := getClients(ipc) - Expect(err).NotTo(HaveOccurred()) - blockChain, err := getBlockChain(rpcClient, ethClient) - Expect(err).NotTo(HaveOccurred()) - db := test_config.NewTestDB(blockChain.Node()) - test_config.CleanTestDB(db) - - header, err := persistHeader(db, blockNumber, blockChain) - Expect(err).NotTo(HaveOccurred()) - - transformer := factories.Transformer{ - Config: config, - Converter: &flip_kick.FlipKickConverter{}, - Repository: &flip_kick.FlipKickRepository{}, - }.NewTransformer(db) - - fetcher := shared.NewFetcher(blockChain) - logs, err := fetcher.FetchLogs( - shared_t.HexStringsToAddresses(config.ContractAddresses), - []common.Hash{common.HexToHash(config.Topic)}, - header) - Expect(err).NotTo(HaveOccurred()) - - err = transformer.Execute(logs, header, constants.HeaderMissing) - Expect(err).NotTo(HaveOccurred()) - - var dbResult []flip_kick.FlipKickModel - err = db.Select(&dbResult, `SELECT bid, bid_id, "end", gal, lot FROM maker.flip_kick`) - Expect(err).NotTo(HaveOccurred()) - - Expect(len(dbResult)).To(Equal(1)) - Expect(dbResult[0].Bid).To(Equal("0")) - Expect(dbResult[0].BidId).To(Equal("6")) - Expect(dbResult[0].End.Equal(time.Unix(1538816904, 0))).To(BeTrue()) - Expect(dbResult[0].Gal).To(Equal("0x3728e9777B2a0a611ee0F89e00E01044ce4736d1")) - Expect(dbResult[0].Lot).To(Equal("1000000000000000000")) - }) - - It("rechecks flip kick event", func() { - blockNumber := int64(8956476) - config := shared.TransformerConfig{ - TransformerName: constants.FlipKickLabel, - ContractAddresses: []string{test_data.KovanFlipperContractAddress}, - ContractAbi: test_data.KovanFlipperABI, - Topic: test_data.KovanFlipKickSignature, - StartingBlockNumber: blockNumber, - EndingBlockNumber: blockNumber, - } - - rpcClient, ethClient, err := getClients(ipc) - Expect(err).NotTo(HaveOccurred()) - blockChain, err := getBlockChain(rpcClient, ethClient) - Expect(err).NotTo(HaveOccurred()) - db := test_config.NewTestDB(blockChain.Node()) - test_config.CleanTestDB(db) - - header, err := persistHeader(db, blockNumber, blockChain) - Expect(err).NotTo(HaveOccurred()) - - transformer := factories.Transformer{ - Config: config, - Converter: &flip_kick.FlipKickConverter{}, - Repository: &flip_kick.FlipKickRepository{}, - }.NewTransformer(db) - - fetcher := shared.NewFetcher(blockChain) - logs, err := fetcher.FetchLogs( - shared.HexStringsToAddresses(config.ContractAddresses), - []common.Hash{common.HexToHash(config.Topic)}, - header) - Expect(err).NotTo(HaveOccurred()) - - err = transformer.Execute(logs, header, constants.HeaderMissing) - Expect(err).NotTo(HaveOccurred()) - - err = transformer.Execute(logs, header, constants.HeaderRecheck) - Expect(err).NotTo(HaveOccurred()) - - var headerID int64 - err = db.Get(&headerID, `SELECT id FROM public.headers WHERE block_number = $1`, blockNumber) - Expect(err).NotTo(HaveOccurred()) - - var flipkickChecked []int - err = db.Select(&flipkickChecked, `SELECT flip_kick_checked FROM public.checked_headers WHERE header_id = $1`, headerID) - Expect(err).NotTo(HaveOccurred()) - - Expect(flipkickChecked[0]).To(Equal(2)) - }) -}) diff --git a/pkg/transformers/integration_tests/flop_kick.go b/pkg/transformers/integration_tests/flop_kick.go deleted file mode 100644 index 7d73217f..00000000 --- a/pkg/transformers/integration_tests/flop_kick.go +++ /dev/null @@ -1,194 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package integration_tests - -import ( - "time" - - "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/common" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - - shared_t "github.com/vulcanize/vulcanizedb/libraries/shared/transformer" - "github.com/vulcanize/vulcanizedb/pkg/core" - "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" - "github.com/vulcanize/vulcanizedb/pkg/geth" - "github.com/vulcanize/vulcanizedb/pkg/transformers/factories" - "github.com/vulcanize/vulcanizedb/pkg/transformers/flop_kick" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" - "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data" - "github.com/vulcanize/vulcanizedb/test_config" -) - -var _ = Describe("FlopKick Transformer", func() { - var ( - db *postgres.DB - blockChain core.BlockChain - config shared_t.TransformerConfig - initializer factories.Transformer - fetcher shared.LogFetcher - addresses []common.Address - topics []common.Hash - ) - - BeforeEach(func() { - rpcClient, ethClient, err := getClients(ipc) - Expect(err).NotTo(HaveOccurred()) - blockChain, err = getBlockChain(rpcClient, ethClient) - Expect(err).NotTo(HaveOccurred()) - db = test_config.NewTestDB(blockChain.Node()) - test_config.CleanTestDB(db) - - config = shared_t.TransformerConfig{ - TransformerName: constants.FlopKickLabel, - ContractAddresses: []string{test_data.KovanFlopperContractAddress}, - ContractAbi: test_data.KovanFlopperABI, - Topic: test_data.KovanFlopKickSignature, - StartingBlockNumber: 0, - EndingBlockNumber: -1, - } - - initializer = factories.Transformer{ - Config: config, - Converter: &flop_kick.FlopKickConverter{}, - Repository: &flop_kick.FlopKickRepository{}, - } - - fetcher = shared.NewFetcher(blockChain) - addresses = shared_t.HexStringsToAddresses(config.ContractAddresses) - topics = []common.Hash{common.HexToHash(config.Topic)} - }) - - It("fetches and transforms a FlopKick event from Kovan chain", func() { - blockNumber := int64(8672119) - initializer.Config.StartingBlockNumber = blockNumber - initializer.Config.EndingBlockNumber = blockNumber - - header, err := persistHeader(db, blockNumber, blockChain) - Expect(err).NotTo(HaveOccurred()) - - logs, err := fetcher.FetchLogs(addresses, topics, header) - Expect(err).NotTo(HaveOccurred()) - - transformer := initializer.NewTransformer(db) - err = transformer.Execute(logs, header, constants.HeaderMissing) - Expect(err).NotTo(HaveOccurred()) - - var dbResult []flop_kick.Model - err = db.Select(&dbResult, `SELECT bid, bid_id, "end", gal, lot FROM maker.flop_kick`) - Expect(err).NotTo(HaveOccurred()) - - Expect(len(dbResult)).To(Equal(1)) - Expect(dbResult[0].Bid).To(Equal("0")) - Expect(dbResult[0].BidId).To(Equal("1")) - Expect(dbResult[0].End.Equal(time.Unix(1536726768, 0))).To(BeTrue()) - Expect(dbResult[0].Gal).To(Equal("0x9B870D55BaAEa9119dBFa71A92c5E26E79C4726d")) - // this very large number appears to be derived from the data including: "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" - Expect(dbResult[0].Lot).To(Equal("115792089237316195423570985008687907853269984665640564039457584007913129639935")) - }) - - It("rechecks flop kick event", func() { - blockNumber := int64(8672119) - initializer.Config.StartingBlockNumber = blockNumber - initializer.Config.EndingBlockNumber = blockNumber - - header, err := persistHeader(db, blockNumber, blockChain) - Expect(err).NotTo(HaveOccurred()) - - logs, err := fetcher.FetchLogs(addresses, topics, header) - Expect(err).NotTo(HaveOccurred()) - - transformer := initializer.NewTransformer(db) - err = transformer.Execute(logs, header, constants.HeaderMissing) - Expect(err).NotTo(HaveOccurred()) - - err = transformer.Execute(logs, header, constants.HeaderRecheck) - Expect(err).NotTo(HaveOccurred()) - - var dbResult []flop_kick.Model - err = db.Select(&dbResult, `SELECT bid, bid_id, "end", gal, lot FROM maker.flop_kick`) - Expect(err).NotTo(HaveOccurred()) - - var headerID int64 - err = db.Get(&headerID, `SELECT id FROM public.headers WHERE block_number = $1`, blockNumber) - Expect(err).NotTo(HaveOccurred()) - - var flopKickChecked []int - err = db.Select(&flopKickChecked, `SELECT flop_kick_checked FROM public.checked_headers WHERE header_id = $1`, headerID) - Expect(err).NotTo(HaveOccurred()) - - Expect(flopKickChecked[0]).To(Equal(2)) - - Expect(len(dbResult)).To(Equal(1)) - Expect(dbResult[0].Bid).To(Equal("0")) - Expect(dbResult[0].BidId).To(Equal("1")) - Expect(dbResult[0].End.Equal(time.Unix(1536726768, 0))).To(BeTrue()) - Expect(dbResult[0].Gal).To(Equal("0x9B870D55BaAEa9119dBFa71A92c5E26E79C4726d")) - // this very large number appears to be derived from the data including: "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" - Expect(dbResult[0].Lot).To(Equal("115792089237316195423570985008687907853269984665640564039457584007913129639935")) - }) - - It("fetches and transforms another FlopKick event from Kovan chain", func() { - blockNumber := int64(8955611) - initializer.Config.StartingBlockNumber = blockNumber - initializer.Config.EndingBlockNumber = blockNumber - - header, err := persistHeader(db, blockNumber, blockChain) - Expect(err).NotTo(HaveOccurred()) - - logs, err := fetcher.FetchLogs(addresses, topics, header) - Expect(err).NotTo(HaveOccurred()) - - transformer := initializer.NewTransformer(db) - err = transformer.Execute(logs, header, constants.HeaderMissing) - Expect(err).NotTo(HaveOccurred()) - - var dbResult []flop_kick.Model - err = db.Select(&dbResult, `SELECT bid, bid_id, "end", gal, lot FROM maker.flop_kick`) - Expect(err).NotTo(HaveOccurred()) - - Expect(len(dbResult)).To(Equal(1)) - Expect(dbResult[0].Bid).To(Equal("10000000000000000000000")) - Expect(dbResult[0].BidId).To(Equal("2")) - Expect(dbResult[0].End.Equal(time.Unix(1538810564, 0))).To(BeTrue()) - Expect(dbResult[0].Gal).To(Equal("0x3728e9777B2a0a611ee0F89e00E01044ce4736d1")) - Expect(dbResult[0].Lot).To(Equal("115792089237316195423570985008687907853269984665640564039457584007913129639935")) - }) - - It("unpacks an flop kick event log", func() { - address := common.HexToAddress(test_data.KovanFlopperContractAddress) - abi, err := geth.ParseAbi(test_data.KovanFlopperABI) - Expect(err).NotTo(HaveOccurred()) - - contract := bind.NewBoundContract(address, abi, nil, nil, nil) - entity := &flop_kick.Entity{} - - var eventLog = test_data.FlopKickLog - - err = contract.UnpackLog(entity, "Kick", eventLog) - Expect(err).NotTo(HaveOccurred()) - - expectedEntity := test_data.FlopKickEntity - Expect(entity.Id).To(Equal(expectedEntity.Id)) - Expect(entity.Lot).To(Equal(expectedEntity.Lot)) - Expect(entity.Bid).To(Equal(expectedEntity.Bid)) - Expect(entity.Gal).To(Equal(expectedEntity.Gal)) - Expect(entity.End).To(Equal(expectedEntity.End)) - }) -}) diff --git a/pkg/transformers/integration_tests/helpers.go b/pkg/transformers/integration_tests/helpers.go deleted file mode 100644 index 8d7681d3..00000000 --- a/pkg/transformers/integration_tests/helpers.go +++ /dev/null @@ -1,59 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package integration_tests - -import ( - "github.com/ethereum/go-ethereum/ethclient" - "github.com/ethereum/go-ethereum/rpc" - "github.com/vulcanize/vulcanizedb/pkg/core" - "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" - "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres/repositories" - "github.com/vulcanize/vulcanizedb/pkg/geth" - "github.com/vulcanize/vulcanizedb/pkg/geth/client" - rpc2 "github.com/vulcanize/vulcanizedb/pkg/geth/converters/rpc" - "github.com/vulcanize/vulcanizedb/pkg/geth/node" -) - -var ipc string - -func getClients(ipc string) (client.RpcClient, *ethclient.Client, error) { - raw, err := rpc.Dial(ipc) - if err != nil { - return client.RpcClient{}, ðclient.Client{}, err - } - return client.NewRpcClient(raw, ipc), ethclient.NewClient(raw), nil -} - -func getBlockChain(rpcClient client.RpcClient, ethClient *ethclient.Client) (core.BlockChain, error) { - client := client.NewEthClient(ethClient) - node := node.MakeNode(rpcClient) - transactionConverter := rpc2.NewRpcTransactionConverter(client) - blockChain := geth.NewBlockChain(client, rpcClient, node, transactionConverter) - return blockChain, nil -} - -// Persist the header for a given block to postgres. Returns the header if successful. -func persistHeader(db *postgres.DB, blockNumber int64, blockChain core.BlockChain) (core.Header, error) { - header, err := blockChain.GetHeaderByNumber(blockNumber) - if err != nil { - return core.Header{}, err - } - headerRepository := repositories.NewHeaderRepository(db) - id, err := headerRepository.CreateOrUpdateHeader(header) - header.Id = id - return header, err -} diff --git a/pkg/transformers/integration_tests/integration_tests_suite_test.go b/pkg/transformers/integration_tests/integration_tests_suite_test.go deleted file mode 100644 index 301e779e..00000000 --- a/pkg/transformers/integration_tests/integration_tests_suite_test.go +++ /dev/null @@ -1,28 +0,0 @@ -package integration_tests - -import ( - log "github.com/sirupsen/logrus" - "testing" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - "github.com/spf13/viper" - "io/ioutil" -) - -func TestIntegrationTests(t *testing.T) { - RegisterFailHandler(Fail) - RunSpecs(t, "IntegrationTests Suite") -} - -var _ = BeforeSuite(func() { - testConfig := viper.New() - testConfig.SetConfigName("staging") - testConfig.AddConfigPath("$GOPATH/src/github.com/vulcanize/vulcanizedb/environments/") - err := testConfig.ReadInConfig() - ipc = testConfig.GetString("client.ipcPath") - if err != nil { - log.Fatal(err) - } - log.SetOutput(ioutil.Discard) -}) diff --git a/pkg/transformers/integration_tests/pit_file_debt_ceiling.go b/pkg/transformers/integration_tests/pit_file_debt_ceiling.go deleted file mode 100644 index 19c49afb..00000000 --- a/pkg/transformers/integration_tests/pit_file_debt_ceiling.go +++ /dev/null @@ -1,142 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package integration_tests - -import ( - "github.com/ethereum/go-ethereum/common" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - "github.com/vulcanize/vulcanizedb/pkg/core" - "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" - "github.com/vulcanize/vulcanizedb/pkg/transformers/factories" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" - "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data" - - shared_t "github.com/vulcanize/vulcanizedb/libraries/shared/transformer" - "github.com/vulcanize/vulcanizedb/pkg/transformers/pit_file/debt_ceiling" - "github.com/vulcanize/vulcanizedb/test_config" -) - -var _ = Describe("PitFileDebtCeiling LogNoteTransformer", func() { - var ( - db *postgres.DB - blockChain core.BlockChain - ) - - BeforeEach(func() { - rpcClient, ethClient, err := getClients(ipc) - Expect(err).NotTo(HaveOccurred()) - blockChain, err = getBlockChain(rpcClient, ethClient) - Expect(err).NotTo(HaveOccurred()) - db = test_config.NewTestDB(blockChain.Node()) - test_config.CleanTestDB(db) - }) - - It("fetches and transforms a PitFileDebtCeiling event from Kovan chain", func() { - blockNumber := int64(8535578) - config := shared_t.TransformerConfig{ - TransformerName: constants.PitFileDebtCeilingLabel, - ContractAddresses: []string{test_data.KovanPitContractAddress}, - ContractAbi: test_data.KovanPitABI, - Topic: test_data.KovanPitFileDebtCeilingSignature, - StartingBlockNumber: blockNumber, - EndingBlockNumber: blockNumber, - } - - header, err := persistHeader(db, blockNumber, blockChain) - Expect(err).NotTo(HaveOccurred()) - - fetcher := shared.NewFetcher(blockChain) - logs, err := fetcher.FetchLogs( - shared_t.HexStringsToAddresses(config.ContractAddresses), - []common.Hash{common.HexToHash(config.Topic)}, - header) - Expect(err).NotTo(HaveOccurred()) - - initializer := factories.LogNoteTransformer{ - Config: config, - Converter: &debt_ceiling.PitFileDebtCeilingConverter{}, - Repository: &debt_ceiling.PitFileDebtCeilingRepository{}, - } - transformer := initializer.NewLogNoteTransformer(db) - - err = transformer.Execute(logs, header, constants.HeaderMissing) - Expect(err).NotTo(HaveOccurred()) - - var dbResult []debt_ceiling.PitFileDebtCeilingModel - err = db.Select(&dbResult, `SELECT what, data from maker.pit_file_debt_ceiling`) - Expect(err).NotTo(HaveOccurred()) - - Expect(len(dbResult)).To(Equal(1)) - Expect(dbResult[0].What).To(Equal("Line")) - Expect(dbResult[0].Data).To(Equal("10000000.000000000000000000")) - }) - - It("rechecks pit file debt ceiling event", func() { - blockNumber := int64(8535578) - config := shared.TransformerConfig{ - TransformerName: constants.PitFileDebtCeilingLabel, - ContractAddresses: []string{test_data.KovanPitContractAddress}, - ContractAbi: test_data.KovanPitABI, - Topic: test_data.KovanPitFileDebtCeilingSignature, - StartingBlockNumber: blockNumber, - EndingBlockNumber: blockNumber, - } - - header, err := persistHeader(db, blockNumber, blockChain) - Expect(err).NotTo(HaveOccurred()) - - fetcher := shared.NewFetcher(blockChain) - logs, err := fetcher.FetchLogs( - shared.HexStringsToAddresses(config.ContractAddresses), - []common.Hash{common.HexToHash(config.Topic)}, - header) - Expect(err).NotTo(HaveOccurred()) - - initializer := factories.LogNoteTransformer{ - Config: config, - Converter: &debt_ceiling.PitFileDebtCeilingConverter{}, - Repository: &debt_ceiling.PitFileDebtCeilingRepository{}, - } - transformer := initializer.NewLogNoteTransformer(db) - - err = transformer.Execute(logs, header, constants.HeaderMissing) - Expect(err).NotTo(HaveOccurred()) - - err = transformer.Execute(logs, header, constants.HeaderRecheck) - Expect(err).NotTo(HaveOccurred()) - - var headerID int64 - err = db.Get(&headerID, `SELECT id FROM public.headers WHERE block_number = $1`, blockNumber) - Expect(err).NotTo(HaveOccurred()) - - var pitFileDebtCeilingChecked []int - err = db.Select(&pitFileDebtCeilingChecked, `SELECT pit_file_debt_ceiling_checked FROM public.checked_headers WHERE header_id = $1`, headerID) - Expect(err).NotTo(HaveOccurred()) - - Expect(pitFileDebtCeilingChecked[0]).To(Equal(2)) - - var dbResult []debt_ceiling.PitFileDebtCeilingModel - err = db.Select(&dbResult, `SELECT what, data from maker.pit_file_debt_ceiling`) - Expect(err).NotTo(HaveOccurred()) - - Expect(len(dbResult)).To(Equal(1)) - Expect(dbResult[0].What).To(Equal("Line")) - Expect(dbResult[0].Data).To(Equal("10000000.000000000000000000")) - }) -}) diff --git a/pkg/transformers/integration_tests/price_feeds.go b/pkg/transformers/integration_tests/price_feeds.go deleted file mode 100644 index 43ce7bd2..00000000 --- a/pkg/transformers/integration_tests/price_feeds.go +++ /dev/null @@ -1,179 +0,0 @@ -// VulcanizeDB // Copyright © 2018 Vulcanize // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Affero General Public License for more details. // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . - -package integration_tests - -import ( - "github.com/ethereum/go-ethereum/common" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" - "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data" - - shared_t "github.com/vulcanize/vulcanizedb/libraries/shared/transformer" - "github.com/vulcanize/vulcanizedb/pkg/core" - "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" - "github.com/vulcanize/vulcanizedb/pkg/transformers/factories" - "github.com/vulcanize/vulcanizedb/pkg/transformers/price_feeds" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared" - "github.com/vulcanize/vulcanizedb/test_config" -) - -var _ = Describe("Price feeds transformer", func() { - var ( - db *postgres.DB - blockChain core.BlockChain - config shared_t.TransformerConfig - fetcher *shared.Fetcher - initializer factories.LogNoteTransformer - topics []common.Hash - ) - - BeforeEach(func() { - rpcClient, ethClient, err := getClients(ipc) - Expect(err).NotTo(HaveOccurred()) - blockChain, err = getBlockChain(rpcClient, ethClient) - Expect(err).NotTo(HaveOccurred()) - db = test_config.NewTestDB(blockChain.Node()) - test_config.CleanTestDB(db) - - config = shared_t.TransformerConfig{ - TransformerName: constants.PriceFeedLabel, - ContractAddresses: []string{ - test_data.KovanPepContractAddress, - test_data.KovanPipContractAddress, - test_data.KovanRepContractAddress, - }, - ContractAbi: test_data.KovanMedianizerABI, - Topic: test_data.KovanLogValueSignature, - StartingBlockNumber: 0, - EndingBlockNumber: -1, - } - - topics = []common.Hash{common.HexToHash(config.Topic)} - - fetcher = shared.NewFetcher(blockChain) - - initializer = factories.LogNoteTransformer{ - Config: config, - Converter: &price_feeds.PriceFeedConverter{}, - Repository: &price_feeds.PriceFeedRepository{}, - } - }) - - It("persists a ETH/USD price feed event", func() { - blockNumber := int64(8763054) - header, err := persistHeader(db, blockNumber, blockChain) - Expect(err).NotTo(HaveOccurred()) - addresses := []string{test_data.KovanPipContractAddress} - initializer.Config.ContractAddresses = addresses - initializer.Config.StartingBlockNumber = blockNumber - initializer.Config.EndingBlockNumber = blockNumber - - logs, err := fetcher.FetchLogs( - shared_t.HexStringsToAddresses(addresses), - topics, - header) - Expect(err).NotTo(HaveOccurred()) - - transformer := initializer.NewLogNoteTransformer(db) - err = transformer.Execute(logs, header, constants.HeaderMissing) - - Expect(err).NotTo(HaveOccurred()) - var model price_feeds.PriceFeedModel - err = db.Get(&model, `SELECT block_number, medianizer_address, usd_value, tx_idx, raw_log FROM maker.price_feeds WHERE block_number = $1`, initializer.Config.StartingBlockNumber) - Expect(err).NotTo(HaveOccurred()) - Expect(model.UsdValue).To(Equal("207.314891143000011198")) - Expect(model.MedianizerAddress).To(Equal(addresses[0])) - }) - - It("rechecks price feed event", func() { - blockNumber := int64(8763054) - header, err := persistHeader(db, blockNumber, blockChain) - Expect(err).NotTo(HaveOccurred()) - addresses := []string{test_data.KovanPipContractAddress} - initializer.Config.ContractAddresses = addresses - initializer.Config.StartingBlockNumber = blockNumber - initializer.Config.EndingBlockNumber = blockNumber - - logs, err := fetcher.FetchLogs( - shared.HexStringsToAddresses(addresses), - topics, - header) - Expect(err).NotTo(HaveOccurred()) - - transformer := initializer.NewLogNoteTransformer(db) - err = transformer.Execute(logs, header, constants.HeaderMissing) - Expect(err).NotTo(HaveOccurred()) - - err = transformer.Execute(logs, header, constants.HeaderRecheck) - Expect(err).NotTo(HaveOccurred()) - - var headerID int64 - err = db.Get(&headerID, `SELECT id FROM public.headers WHERE block_number = $1`, blockNumber) - Expect(err).NotTo(HaveOccurred()) - - var priceFeedChecked []int - err = db.Select(&priceFeedChecked, `SELECT price_feeds_checked FROM public.checked_headers WHERE header_id = $1`, headerID) - Expect(err).NotTo(HaveOccurred()) - - Expect(priceFeedChecked[0]).To(Equal(2)) - - var model price_feeds.PriceFeedModel - err = db.Get(&model, `SELECT block_number, medianizer_address, usd_value, tx_idx, raw_log FROM maker.price_feeds WHERE block_number = $1`, initializer.Config.StartingBlockNumber) - Expect(err).NotTo(HaveOccurred()) - Expect(model.UsdValue).To(Equal("207.314891143000011198")) - Expect(model.MedianizerAddress).To(Equal(addresses[0])) - }) - - It("persists a MKR/USD price feed event", func() { - blockNumber := int64(8763059) - header, err := persistHeader(db, blockNumber, blockChain) - Expect(err).NotTo(HaveOccurred()) - addresses := []string{test_data.KovanPepContractAddress} - initializer.Config.ContractAddresses = addresses - initializer.Config.StartingBlockNumber = blockNumber - initializer.Config.EndingBlockNumber = blockNumber - - logs, err := fetcher.FetchLogs( - shared_t.HexStringsToAddresses(addresses), - topics, - header) - Expect(err).NotTo(HaveOccurred()) - - transformer := initializer.NewLogNoteTransformer(db) - err = transformer.Execute(logs, header, constants.HeaderMissing) - - Expect(err).NotTo(HaveOccurred()) - var model price_feeds.PriceFeedModel - err = db.Get(&model, `SELECT block_number, medianizer_address, usd_value, tx_idx, raw_log FROM maker.price_feeds WHERE block_number = $1`, initializer.Config.StartingBlockNumber) - Expect(err).NotTo(HaveOccurred()) - Expect(model.UsdValue).To(Equal("391.803979212000001553")) - Expect(model.MedianizerAddress).To(Equal(addresses[0])) - }) - - It("persists a REP/USD price feed event", func() { - blockNumber := int64(8763062) - header, err := persistHeader(db, blockNumber, blockChain) - Expect(err).NotTo(HaveOccurred()) - addresses := []string{test_data.KovanRepContractAddress} - initializer.Config.ContractAddresses = addresses - initializer.Config.StartingBlockNumber = blockNumber - initializer.Config.EndingBlockNumber = blockNumber - - logs, err := fetcher.FetchLogs( - shared_t.HexStringsToAddresses(addresses), - topics, - header) - Expect(err).NotTo(HaveOccurred()) - - transformer := initializer.NewLogNoteTransformer(db) - err = transformer.Execute(logs, header, constants.HeaderMissing) - - Expect(err).NotTo(HaveOccurred()) - var model price_feeds.PriceFeedModel - err = db.Get(&model, `SELECT block_number, medianizer_address, usd_value, tx_idx, raw_log FROM maker.price_feeds WHERE block_number = $1`, initializer.Config.StartingBlockNumber) - Expect(err).NotTo(HaveOccurred()) - Expect(model.UsdValue).To(Equal("12.816928482699999847")) - Expect(model.MedianizerAddress).To(Equal(addresses[0])) - }) -}) diff --git a/pkg/transformers/integration_tests/tend.go b/pkg/transformers/integration_tests/tend.go deleted file mode 100644 index 9555e663..00000000 --- a/pkg/transformers/integration_tests/tend.go +++ /dev/null @@ -1,217 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package integration_tests - -import ( - "github.com/ethereum/go-ethereum/common" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - shared_t "github.com/vulcanize/vulcanizedb/libraries/shared/transformer" - "github.com/vulcanize/vulcanizedb/pkg/core" - "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" - "github.com/vulcanize/vulcanizedb/pkg/transformers/factories" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" - "github.com/vulcanize/vulcanizedb/pkg/transformers/tend" - "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data" - "github.com/vulcanize/vulcanizedb/test_config" -) - -var _ = Describe("Tend LogNoteTransformer", func() { - var ( - db *postgres.DB - blockChain core.BlockChain - config shared_t.TransformerConfig - fetcher *shared.Fetcher - initializer factories.LogNoteTransformer - addresses []common.Address - topics []common.Hash - ) - - BeforeEach(func() { - rpcClient, ethClient, err := getClients(ipc) - Expect(err).NotTo(HaveOccurred()) - blockChain, err = getBlockChain(rpcClient, ethClient) - Expect(err).NotTo(HaveOccurred()) - db = test_config.NewTestDB(blockChain.Node()) - test_config.CleanTestDB(db) - - config = shared_t.TransformerConfig{ - TransformerName: constants.TendLabel, - ContractAddresses: []string{test_data.KovanFlapperContractAddress, test_data.KovanFlipperContractAddress}, - ContractAbi: test_data.KovanFlipperABI, - Topic: test_data.KovanTendFunctionSignature, - StartingBlockNumber: 0, - EndingBlockNumber: -1, - } - - fetcher = shared.NewFetcher(blockChain) - addresses = shared_t.HexStringsToAddresses(config.ContractAddresses) - topics = []common.Hash{common.HexToHash(config.Topic)} - - initializer = factories.LogNoteTransformer{ - Config: config, - Converter: &tend.TendConverter{}, - Repository: &tend.TendRepository{}, - } - }) - - It("fetches and transforms a Flip Tend event from Kovan chain", func() { - blockNumber := int64(8935601) - initializer.Config.StartingBlockNumber = blockNumber - initializer.Config.EndingBlockNumber = blockNumber - - header, err := persistHeader(db, blockNumber, blockChain) - Expect(err).NotTo(HaveOccurred()) - - logs, err := fetcher.FetchLogs(addresses, topics, header) - Expect(err).NotTo(HaveOccurred()) - - transformer := initializer.NewLogNoteTransformer(db) - err = transformer.Execute(logs, header, constants.HeaderMissing) - Expect(err).NotTo(HaveOccurred()) - - var dbResult []tend.TendModel - err = db.Select(&dbResult, `SELECT bid, bid_id, guy, lot FROM maker.tend`) - Expect(err).NotTo(HaveOccurred()) - - Expect(len(dbResult)).To(Equal(1)) - Expect(dbResult[0].Bid).To(Equal("4000")) - Expect(dbResult[0].BidId).To(Equal("3")) - Expect(dbResult[0].Guy).To(Equal("0000000000000000000000000000d8b4147eda80fec7122ae16da2479cbd7ffb")) - Expect(dbResult[0].Lot).To(Equal("1000000000000000000")) - - var dbTic int64 - err = db.Get(&dbTic, `SELECT tic FROM maker.tend`) - Expect(err).NotTo(HaveOccurred()) - - actualTic := 1538490276 + constants.TTL - Expect(dbTic).To(Equal(actualTic)) - }) - - It("rechecks tend event", func() { - blockNumber := int64(8935601) - initializer.Config.StartingBlockNumber = blockNumber - initializer.Config.EndingBlockNumber = blockNumber - - header, err := persistHeader(db, blockNumber, blockChain) - Expect(err).NotTo(HaveOccurred()) - - logs, err := fetcher.FetchLogs(addresses, topics, header) - Expect(err).NotTo(HaveOccurred()) - - transformer := initializer.NewLogNoteTransformer(db) - err = transformer.Execute(logs, header, constants.HeaderMissing) - Expect(err).NotTo(HaveOccurred()) - - err = transformer.Execute(logs, header, constants.HeaderRecheck) - Expect(err).NotTo(HaveOccurred()) - - var headerID int64 - err = db.Get(&headerID, `SELECT id FROM public.headers WHERE block_number = $1`, blockNumber) - Expect(err).NotTo(HaveOccurred()) - - var tendChecked []int - err = db.Select(&tendChecked, `SELECT tend_checked FROM public.checked_headers WHERE header_id = $1`, headerID) - Expect(err).NotTo(HaveOccurred()) - - Expect(tendChecked[0]).To(Equal(2)) - - var dbResult []tend.TendModel - err = db.Select(&dbResult, `SELECT bid, bid_id, guy, lot from maker.tend where header_id = $1`, headerID) - Expect(err).NotTo(HaveOccurred()) - - Expect(len(dbResult)).To(Equal(1)) - Expect(dbResult[0].Bid).To(Equal("4000")) - Expect(dbResult[0].BidId).To(Equal("3")) - Expect(dbResult[0].Guy).To(Equal("0000000000000000000000000000d8b4147eda80fec7122ae16da2479cbd7ffb")) - Expect(dbResult[0].Lot).To(Equal("1000000000000000000")) - - var dbTic int64 - err = db.Get(&dbTic, `SELECT tic FROM maker.tend`) - Expect(err).NotTo(HaveOccurred()) - - actualTic := 1538490276 + constants.TTL - Expect(dbTic).To(Equal(actualTic)) - }) - - It("fetches and transforms a subsequent Flip Tend event from Kovan chain for the same auction", func() { - blockNumber := int64(8935731) - initializer.Config.StartingBlockNumber = blockNumber - initializer.Config.EndingBlockNumber = blockNumber - - header, err := persistHeader(db, blockNumber, blockChain) - Expect(err).NotTo(HaveOccurred()) - - logs, err := fetcher.FetchLogs(addresses, topics, header) - Expect(err).NotTo(HaveOccurred()) - - transformer := initializer.NewLogNoteTransformer(db) - err = transformer.Execute(logs, header, constants.HeaderMissing) - Expect(err).NotTo(HaveOccurred()) - - var dbResult []tend.TendModel - err = db.Select(&dbResult, `SELECT bid, bid_id, guy, lot from maker.tend`) - Expect(err).NotTo(HaveOccurred()) - - Expect(len(dbResult)).To(Equal(1)) - Expect(dbResult[0].Bid).To(Equal("4300")) - Expect(dbResult[0].BidId).To(Equal("3")) - Expect(dbResult[0].Guy).To(Equal("0000000000000000000000000000d8b4147eda80fec7122ae16da2479cbd7ffb")) - Expect(dbResult[0].Lot).To(Equal("1000000000000000000")) - - var dbTic int64 - err = db.Get(&dbTic, `SELECT tic FROM maker.tend`) - Expect(err).NotTo(HaveOccurred()) - - actualTic := 1538491224 + constants.TTL - Expect(dbTic).To(Equal(actualTic)) - }) - - It("fetches and transforms a Flap Tend event from the Kovan chain", func() { - blockNumber := int64(9003177) - initializer.Config.StartingBlockNumber = blockNumber - initializer.Config.EndingBlockNumber = blockNumber - - header, err := persistHeader(db, blockNumber, blockChain) - Expect(err).NotTo(HaveOccurred()) - - logs, err := fetcher.FetchLogs(addresses, topics, header) - Expect(err).NotTo(HaveOccurred()) - - transformer := initializer.NewLogNoteTransformer(db) - err = transformer.Execute(logs, header, constants.HeaderMissing) - Expect(err).NotTo(HaveOccurred()) - - var dbResult []tend.TendModel - err = db.Select(&dbResult, `SELECT bid, bid_id, guy, lot from maker.tend`) - Expect(err).NotTo(HaveOccurred()) - - Expect(len(dbResult)).To(Equal(1)) - Expect(dbResult[0].Bid).To(Equal("1000000000000000")) - Expect(dbResult[0].BidId).To(Equal("1")) - Expect(dbResult[0].Guy).To(Equal("0000000000000000000000000000d8b4147eda80fec7122ae16da2479cbd7ffb")) - Expect(dbResult[0].Lot).To(Equal("1000000000000000000")) - - var dbTic int64 - err = db.Get(&dbTic, `SELECT tic FROM maker.tend`) - Expect(err).NotTo(HaveOccurred()) - - actualTic := 1538992860 + constants.TTL - Expect(dbTic).To(Equal(actualTic)) - }) -}) diff --git a/pkg/transformers/integration_tests/vat_heal.go b/pkg/transformers/integration_tests/vat_heal.go deleted file mode 100644 index 54d0ab5c..00000000 --- a/pkg/transformers/integration_tests/vat_heal.go +++ /dev/null @@ -1,143 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package integration_tests - -import ( - "github.com/ethereum/go-ethereum/common" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" - "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data" - - shared_t "github.com/vulcanize/vulcanizedb/libraries/shared/transformer" - "github.com/vulcanize/vulcanizedb/pkg/transformers/factories" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared" - "github.com/vulcanize/vulcanizedb/pkg/transformers/vat_heal" - "github.com/vulcanize/vulcanizedb/test_config" -) - -var _ = Describe("VatHeal Transformer", func() { - It("transforms VatHeal log events", func() { - blockNumber := int64(8935578) - config := shared_t.TransformerConfig{ - TransformerName: constants.VatHealLabel, - ContractAddresses: []string{test_data.KovanVatContractAddress}, - ContractAbi: test_data.KovanVatABI, - Topic: test_data.KovanVatHealSignature, - StartingBlockNumber: blockNumber, - EndingBlockNumber: blockNumber, - } - - rpcClient, ethClient, err := getClients(ipc) - Expect(err).NotTo(HaveOccurred()) - blockChain, err := getBlockChain(rpcClient, ethClient) - Expect(err).NotTo(HaveOccurred()) - - db := test_config.NewTestDB(blockChain.Node()) - test_config.CleanTestDB(db) - - header, err := persistHeader(db, blockNumber, blockChain) - Expect(err).NotTo(HaveOccurred()) - - fetcher := shared.NewFetcher(blockChain) - logs, err := fetcher.FetchLogs( - shared_t.HexStringsToAddresses(config.ContractAddresses), - []common.Hash{common.HexToHash(config.Topic)}, - header) - Expect(err).NotTo(HaveOccurred()) - - transformer := factories.LogNoteTransformer{ - Config: config, - Converter: &vat_heal.VatHealConverter{}, - Repository: &vat_heal.VatHealRepository{}, - }.NewLogNoteTransformer(db) - - err = transformer.Execute(logs, header, constants.HeaderMissing) - Expect(err).NotTo(HaveOccurred()) - - var dbResults []vat_heal.VatHealModel - err = db.Select(&dbResults, `SELECT urn, v, rad from maker.vat_heal`) - Expect(err).NotTo(HaveOccurred()) - - Expect(len(dbResults)).To(Equal(1)) - dbResult := dbResults[0] - Expect(dbResult.Urn).To(Equal("0000000000000000000000003728e9777b2a0a611ee0f89e00e01044ce4736d1")) - Expect(dbResult.V).To(Equal("0000000000000000000000003728e9777b2a0a611ee0f89e00e01044ce4736d1")) - Expect(dbResult.Rad).To(Equal("1000000000000000000000000000")) - }) - - It("rechecks vat heal event", func() { - blockNumber := int64(8935578) - config := shared.TransformerConfig{ - TransformerName: constants.VatHealLabel, - ContractAddresses: []string{test_data.KovanVatContractAddress}, - ContractAbi: test_data.KovanVatABI, - Topic: test_data.KovanVatHealSignature, - StartingBlockNumber: blockNumber, - EndingBlockNumber: blockNumber, - } - - rpcClient, ethClient, err := getClients(ipc) - Expect(err).NotTo(HaveOccurred()) - blockChain, err := getBlockChain(rpcClient, ethClient) - Expect(err).NotTo(HaveOccurred()) - - db := test_config.NewTestDB(blockChain.Node()) - test_config.CleanTestDB(db) - - header, err := persistHeader(db, blockNumber, blockChain) - Expect(err).NotTo(HaveOccurred()) - - fetcher := shared.NewFetcher(blockChain) - logs, err := fetcher.FetchLogs( - shared.HexStringsToAddresses(config.ContractAddresses), - []common.Hash{common.HexToHash(config.Topic)}, - header) - Expect(err).NotTo(HaveOccurred()) - - transformer := factories.LogNoteTransformer{ - Config: config, - Converter: &vat_heal.VatHealConverter{}, - Repository: &vat_heal.VatHealRepository{}, - }.NewLogNoteTransformer(db) - - err = transformer.Execute(logs, header, constants.HeaderMissing) - Expect(err).NotTo(HaveOccurred()) - - err = transformer.Execute(logs, header, constants.HeaderRecheck) - Expect(err).NotTo(HaveOccurred()) - var headerID int64 - err = db.Get(&headerID, `SELECT id FROM public.headers WHERE block_number = $1`, blockNumber) - Expect(err).NotTo(HaveOccurred()) - - var vatHealChecked []int - err = db.Select(&vatHealChecked, `SELECT vat_heal_checked FROM public.checked_headers WHERE header_id = $1`, headerID) - Expect(err).NotTo(HaveOccurred()) - - Expect(vatHealChecked[0]).To(Equal(2)) - - var dbResults []vat_heal.VatHealModel - err = db.Select(&dbResults, `SELECT urn, v, rad from maker.vat_heal`) - Expect(err).NotTo(HaveOccurred()) - - Expect(len(dbResults)).To(Equal(1)) - dbResult := dbResults[0] - Expect(dbResult.Urn).To(Equal("0000000000000000000000003728e9777b2a0a611ee0f89e00e01044ce4736d1")) - Expect(dbResult.V).To(Equal("0000000000000000000000003728e9777b2a0a611ee0f89e00e01044ce4736d1")) - Expect(dbResult.Rad).To(Equal("1000000000000000000000000000")) - }) -}) diff --git a/pkg/transformers/integration_tests/vat_move.go b/pkg/transformers/integration_tests/vat_move.go deleted file mode 100644 index 6a1c7517..00000000 --- a/pkg/transformers/integration_tests/vat_move.go +++ /dev/null @@ -1,144 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package integration_tests - -import ( - "github.com/ethereum/go-ethereum/common" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - "github.com/vulcanize/vulcanizedb/pkg/transformers/factories" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" - "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data" - - shared_t "github.com/vulcanize/vulcanizedb/libraries/shared/transformer" - "github.com/vulcanize/vulcanizedb/pkg/transformers/vat_move" - "github.com/vulcanize/vulcanizedb/test_config" -) - -var _ = Describe("VatMove LogNoteTransformer", func() { - It("transforms VatMove log events", func() { - blockNumber := int64(9004628) - config := shared_t.TransformerConfig{ - TransformerName: constants.VatMoveLabel, - ContractAddresses: []string{test_data.KovanVatContractAddress}, - ContractAbi: test_data.KovanVatABI, - Topic: test_data.KovanVatMoveSignature, - StartingBlockNumber: blockNumber, - EndingBlockNumber: blockNumber, - } - - rpcClient, ethClient, err := getClients(ipc) - Expect(err).NotTo(HaveOccurred()) - blockChain, err := getBlockChain(rpcClient, ethClient) - Expect(err).NotTo(HaveOccurred()) - - db := test_config.NewTestDB(blockChain.Node()) - test_config.CleanTestDB(db) - - header, err := persistHeader(db, blockNumber, blockChain) - Expect(err).NotTo(HaveOccurred()) - - fetcher := shared.NewFetcher(blockChain) - logs, err := fetcher.FetchLogs( - shared_t.HexStringsToAddresses(config.ContractAddresses), - []common.Hash{common.HexToHash(config.Topic)}, - header) - Expect(err).NotTo(HaveOccurred()) - - transformer := factories.LogNoteTransformer{ - Config: config, - Converter: &vat_move.VatMoveConverter{}, - Repository: &vat_move.VatMoveRepository{}, - }.NewLogNoteTransformer(db) - - err = transformer.Execute(logs, header, constants.HeaderMissing) - Expect(err).NotTo(HaveOccurred()) - - var dbResults []vat_move.VatMoveModel - err = db.Select(&dbResults, `SELECT src, dst, rad from maker.vat_move`) - Expect(err).NotTo(HaveOccurred()) - - Expect(len(dbResults)).To(Equal(1)) - dbResult := dbResults[0] - Expect(dbResult.Src).To(Equal("0000000000000000000000008868bad8e74fca4505676d1b5b21ecc23328d132")) - Expect(dbResult.Dst).To(Equal("0000000000000000000000000000d8b4147eda80fec7122ae16da2479cbd7ffb")) - Expect(dbResult.Rad).To(Equal("1000000000000000000000000000000000000000000000")) - }) - - It("rechecks vat move event", func() { - blockNumber := int64(9004628) - config := shared.TransformerConfig{ - TransformerName: constants.VatMoveLabel, - ContractAddresses: []string{test_data.KovanVatContractAddress}, - ContractAbi: test_data.KovanVatABI, - Topic: test_data.KovanVatMoveSignature, - StartingBlockNumber: blockNumber, - EndingBlockNumber: blockNumber, - } - - rpcClient, ethClient, err := getClients(ipc) - Expect(err).NotTo(HaveOccurred()) - blockChain, err := getBlockChain(rpcClient, ethClient) - Expect(err).NotTo(HaveOccurred()) - - db := test_config.NewTestDB(blockChain.Node()) - test_config.CleanTestDB(db) - - header, err := persistHeader(db, blockNumber, blockChain) - Expect(err).NotTo(HaveOccurred()) - - fetcher := shared.NewFetcher(blockChain) - logs, err := fetcher.FetchLogs( - shared.HexStringsToAddresses(config.ContractAddresses), - []common.Hash{common.HexToHash(config.Topic)}, - header) - Expect(err).NotTo(HaveOccurred()) - - transformer := factories.LogNoteTransformer{ - Config: config, - Converter: &vat_move.VatMoveConverter{}, - Repository: &vat_move.VatMoveRepository{}, - }.NewLogNoteTransformer(db) - - err = transformer.Execute(logs, header, constants.HeaderMissing) - Expect(err).NotTo(HaveOccurred()) - - err = transformer.Execute(logs, header, constants.HeaderRecheck) - Expect(err).NotTo(HaveOccurred()) - - var headerID int64 - err = db.Get(&headerID, `SELECT id FROM public.headers WHERE block_number = $1`, blockNumber) - Expect(err).NotTo(HaveOccurred()) - - var vatMoveChecked []int - err = db.Select(&vatMoveChecked, `SELECT vat_move_checked FROM public.checked_headers WHERE header_id = $1`, headerID) - Expect(err).NotTo(HaveOccurred()) - - Expect(vatMoveChecked[0]).To(Equal(2)) - - var dbResults []vat_move.VatMoveModel - err = db.Select(&dbResults, `SELECT src, dst, rad from maker.vat_move`) - Expect(err).NotTo(HaveOccurred()) - - Expect(len(dbResults)).To(Equal(1)) - dbResult := dbResults[0] - Expect(dbResult.Src).To(Equal("0000000000000000000000008868bad8e74fca4505676d1b5b21ecc23328d132")) - Expect(dbResult.Dst).To(Equal("0000000000000000000000000000d8b4147eda80fec7122ae16da2479cbd7ffb")) - Expect(dbResult.Rad).To(Equal("1000000000000000000000000000000000000000000000")) - }) -}) diff --git a/pkg/transformers/integration_tests/vow_flog.go b/pkg/transformers/integration_tests/vow_flog.go deleted file mode 100644 index e8aedb3f..00000000 --- a/pkg/transformers/integration_tests/vow_flog.go +++ /dev/null @@ -1,139 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package integration_tests - -import ( - "github.com/ethereum/go-ethereum/common" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - "github.com/vulcanize/vulcanizedb/pkg/core" - "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" - "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data" - - shared_t "github.com/vulcanize/vulcanizedb/libraries/shared/transformer" - "github.com/vulcanize/vulcanizedb/pkg/transformers/factories" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared" - "github.com/vulcanize/vulcanizedb/pkg/transformers/vow_flog" - "github.com/vulcanize/vulcanizedb/test_config" -) - -var _ = Describe("VowFlog LogNoteTransformer", func() { - var ( - db *postgres.DB - blockChain core.BlockChain - ) - - BeforeEach(func() { - rpcClient, ethClient, err := getClients(ipc) - Expect(err).NotTo(HaveOccurred()) - blockChain, err = getBlockChain(rpcClient, ethClient) - Expect(err).NotTo(HaveOccurred()) - db = test_config.NewTestDB(blockChain.Node()) - test_config.CleanTestDB(db) - }) - - It("transforms VowFlog log events", func() { - blockNumber := int64(8946819) - config := shared_t.TransformerConfig{ - TransformerName: constants.VowFlogLabel, - ContractAddresses: []string{test_data.KovanVowContractAddress}, - ContractAbi: test_data.KovanVowABI, - Topic: test_data.KovanVowFlogSignature, - StartingBlockNumber: blockNumber, - EndingBlockNumber: blockNumber, - } - - header, err := persistHeader(db, blockNumber, blockChain) - Expect(err).NotTo(HaveOccurred()) - - fetcher := shared.NewFetcher(blockChain) - logs, err := fetcher.FetchLogs( - shared_t.HexStringsToAddresses(config.ContractAddresses), - []common.Hash{common.HexToHash(config.Topic)}, - header) - Expect(err).NotTo(HaveOccurred()) - - transformer := factories.LogNoteTransformer{ - Config: config, - Converter: &vow_flog.VowFlogConverter{}, - Repository: &vow_flog.VowFlogRepository{}, - }.NewLogNoteTransformer(db) - - err = transformer.Execute(logs, header, constants.HeaderMissing) - Expect(err).NotTo(HaveOccurred()) - - var dbResult []vow_flog.VowFlogModel - err = db.Select(&dbResult, `SELECT era, log_idx, tx_idx from maker.vow_flog`) - Expect(err).NotTo(HaveOccurred()) - - Expect(dbResult[0].Era).To(Equal("1538558052")) - Expect(dbResult[0].LogIndex).To(Equal(uint(2))) - Expect(dbResult[0].TransactionIndex).To(Equal(uint(2))) - }) - - It("rechecks vow flog event", func() { - blockNumber := int64(8946819) - config := shared.TransformerConfig{ - TransformerName: constants.VowFlogLabel, - ContractAddresses: []string{test_data.KovanVowContractAddress}, - ContractAbi: test_data.KovanVowABI, - Topic: test_data.KovanVowFlogSignature, - StartingBlockNumber: blockNumber, - EndingBlockNumber: blockNumber, - } - - header, err := persistHeader(db, blockNumber, blockChain) - Expect(err).NotTo(HaveOccurred()) - - fetcher := shared.NewFetcher(blockChain) - logs, err := fetcher.FetchLogs( - shared.HexStringsToAddresses(config.ContractAddresses), - []common.Hash{common.HexToHash(config.Topic)}, - header) - Expect(err).NotTo(HaveOccurred()) - transformer := factories.LogNoteTransformer{ - Config: config, - Converter: &vow_flog.VowFlogConverter{}, - Repository: &vow_flog.VowFlogRepository{}, - }.NewLogNoteTransformer(db) - - err = transformer.Execute(logs, header, constants.HeaderMissing) - Expect(err).NotTo(HaveOccurred()) - - err = transformer.Execute(logs, header, constants.HeaderRecheck) - Expect(err).NotTo(HaveOccurred()) - - var headerID int64 - err = db.Get(&headerID, `SELECT id FROM public.headers WHERE block_number = $1`, blockNumber) - Expect(err).NotTo(HaveOccurred()) - - var vowFlogChecked []int - err = db.Select(&vowFlogChecked, `SELECT vow_flog_checked FROM public.checked_headers WHERE header_id = $1`, headerID) - Expect(err).NotTo(HaveOccurred()) - - Expect(vowFlogChecked[0]).To(Equal(2)) - - var dbResult []vow_flog.VowFlogModel - err = db.Select(&dbResult, `SELECT era, log_idx, tx_idx from maker.vow_flog`) - Expect(err).NotTo(HaveOccurred()) - - Expect(dbResult[0].Era).To(Equal("1538558052")) - Expect(dbResult[0].LogIndex).To(Equal(uint(2))) - Expect(dbResult[0].TransactionIndex).To(Equal(uint(2))) - }) -}) diff --git a/pkg/transformers/pit_file/debt_ceiling/config.go b/pkg/transformers/pit_file/debt_ceiling/config.go deleted file mode 100644 index 356432be..00000000 --- a/pkg/transformers/pit_file/debt_ceiling/config.go +++ /dev/null @@ -1,33 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package debt_ceiling - -import ( - shared_t "github.com/vulcanize/vulcanizedb/libraries/shared/transformer" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" -) - -func GetDebtCeilingFileConfig() shared_t.TransformerConfig { - return shared_t.TransformerConfig{ - TransformerName: constants.PitFileDebtCeilingLabel, - ContractAddresses: []string{constants.PitContractAddress()}, - ContractAbi: constants.PitABI(), - Topic: constants.GetPitFileDebtCeilingSignature(), - StartingBlockNumber: constants.PitDeploymentBlock(), - EndingBlockNumber: -1, - } -} diff --git a/pkg/transformers/pit_file/debt_ceiling/converter.go b/pkg/transformers/pit_file/debt_ceiling/converter.go deleted file mode 100644 index 4a8c0f41..00000000 --- a/pkg/transformers/pit_file/debt_ceiling/converter.go +++ /dev/null @@ -1,64 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package debt_ceiling - -import ( - "bytes" - "encoding/json" - "errors" - "github.com/ethereum/go-ethereum/core/types" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" -) - -type PitFileDebtCeilingConverter struct{} - -func (PitFileDebtCeilingConverter) ToModels(ethLogs []types.Log) ([]interface{}, error) { - var models []interface{} - for _, ethLog := range ethLogs { - err := verifyLog(ethLog) - if err != nil { - return nil, err - } - what := string(bytes.Trim(ethLog.Topics[2].Bytes(), "\x00")) - data := shared.ConvertToWad(ethLog.Topics[3].Big().String()) - - raw, err := json.Marshal(ethLog) - if err != nil { - return nil, err - } - model := PitFileDebtCeilingModel{ - What: what, - Data: data, - LogIndex: ethLog.Index, - TransactionIndex: ethLog.TxIndex, - Raw: raw, - } - models = append(models, model) - } - return models, nil -} - -func verifyLog(log types.Log) error { - if len(log.Topics) < 2 { - return errors.New("log missing topics") - } - if len(log.Data) < constants.DataItemLength { - return errors.New("log missing data") - } - return nil -} diff --git a/pkg/transformers/pit_file/debt_ceiling/converter_test.go b/pkg/transformers/pit_file/debt_ceiling/converter_test.go deleted file mode 100644 index 1c2c7ee7..00000000 --- a/pkg/transformers/pit_file/debt_ceiling/converter_test.go +++ /dev/null @@ -1,61 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package debt_ceiling_test - -import ( - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - "github.com/vulcanize/vulcanizedb/pkg/transformers/pit_file/debt_ceiling" - - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/types" - "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data" -) - -var _ = Describe("Pit file debt ceiling converter", func() { - It("returns err if log is missing topics", func() { - converter := debt_ceiling.PitFileDebtCeilingConverter{} - badLog := types.Log{ - Data: []byte{1, 1, 1, 1, 1}, - } - - _, err := converter.ToModels([]types.Log{badLog}) - - Expect(err).To(HaveOccurred()) - }) - - It("returns err if log is missing data", func() { - converter := debt_ceiling.PitFileDebtCeilingConverter{} - badLog := types.Log{ - Topics: []common.Hash{{}, {}, {}, {}}, - } - - _, err := converter.ToModels([]types.Log{badLog}) - - Expect(err).To(HaveOccurred()) - }) - - It("converts a log to an model", func() { - converter := debt_ceiling.PitFileDebtCeilingConverter{} - - models, err := converter.ToModels([]types.Log{test_data.EthPitFileDebtCeilingLog}) - - Expect(err).NotTo(HaveOccurred()) - Expect(len(models)).To(Equal(1)) - Expect(models[0].(debt_ceiling.PitFileDebtCeilingModel)).To(Equal(test_data.PitFileDebtCeilingModel)) - }) -}) diff --git a/pkg/transformers/pit_file/debt_ceiling/debt_ceiling_suite_test.go b/pkg/transformers/pit_file/debt_ceiling/debt_ceiling_suite_test.go deleted file mode 100644 index 8bece7ec..00000000 --- a/pkg/transformers/pit_file/debt_ceiling/debt_ceiling_suite_test.go +++ /dev/null @@ -1,35 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package debt_ceiling_test - -import ( - log "github.com/sirupsen/logrus" - "io/ioutil" - "testing" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -func TestDebtCeiling(t *testing.T) { - RegisterFailHandler(Fail) - RunSpecs(t, "DebtCeiling Suite") -} - -var _ = BeforeSuite(func() { - log.SetOutput(ioutil.Discard) -}) diff --git a/pkg/transformers/pit_file/debt_ceiling/model.go b/pkg/transformers/pit_file/debt_ceiling/model.go deleted file mode 100644 index 3639a3e6..00000000 --- a/pkg/transformers/pit_file/debt_ceiling/model.go +++ /dev/null @@ -1,25 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package debt_ceiling - -type PitFileDebtCeilingModel struct { - What string - Data string - LogIndex uint `db:"log_idx"` - TransactionIndex uint `db:"tx_idx"` - Raw []byte `db:"raw_log"` -} diff --git a/pkg/transformers/pit_file/debt_ceiling/repository.go b/pkg/transformers/pit_file/debt_ceiling/repository.go deleted file mode 100644 index eff9703a..00000000 --- a/pkg/transformers/pit_file/debt_ceiling/repository.go +++ /dev/null @@ -1,92 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package debt_ceiling - -import ( - "fmt" - - log "github.com/sirupsen/logrus" - - "github.com/vulcanize/vulcanizedb/pkg/core" - "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" -) - -type PitFileDebtCeilingRepository struct { - db *postgres.DB -} - -func (repository PitFileDebtCeilingRepository) Create(headerID int64, models []interface{}) error { - tx, dBaseErr := repository.db.Begin() - if dBaseErr != nil { - return dBaseErr - } - - for _, model := range models { - pitFileDC, ok := model.(PitFileDebtCeilingModel) - if !ok { - rollbackErr := tx.Rollback() - if rollbackErr != nil { - log.Error("failed to rollback ", rollbackErr) - } - return fmt.Errorf("model of type %T, not %T", model, PitFileDebtCeilingModel{}) - } - - _, execErr := tx.Exec( - `INSERT into maker.pit_file_debt_ceiling (header_id, what, data, log_idx, tx_idx, raw_log) - VALUES($1, $2, $3::NUMERIC, $4, $5, $6) - ON CONFLICT (header_id, tx_idx, log_idx) DO UPDATE SET what = $2, data = $3, raw_log = $6;`, - headerID, pitFileDC.What, pitFileDC.Data, pitFileDC.LogIndex, pitFileDC.TransactionIndex, pitFileDC.Raw, - ) - - if execErr != nil { - rollbackErr := tx.Rollback() - if rollbackErr != nil { - log.Error("failed to rollback ", rollbackErr) - } - return execErr - } - } - - checkHeaderErr := shared.MarkHeaderCheckedInTransaction(headerID, tx, constants.PitFileDebtCeilingChecked) - if checkHeaderErr != nil { - rollbackErr := tx.Rollback() - if rollbackErr != nil { - log.Error("failed to rollback ", rollbackErr) - } - return checkHeaderErr - } - - return tx.Commit() -} - -func (repository PitFileDebtCeilingRepository) MarkHeaderChecked(headerID int64) error { - return shared.MarkHeaderChecked(headerID, repository.db, constants.PitFileDebtCeilingChecked) -} - -func (repository PitFileDebtCeilingRepository) MissingHeaders(startingBlockNumber, endingBlockNumber int64) ([]core.Header, error) { - return shared.MissingHeaders(startingBlockNumber, endingBlockNumber, repository.db, constants.PitFileDebtCeilingChecked) -} - -func (repository PitFileDebtCeilingRepository) RecheckHeaders(startingBlockNumber, endingBlockNumber int64) ([]core.Header, error) { - return shared.RecheckHeaders(startingBlockNumber, endingBlockNumber, repository.db, constants.PitFileDebtCeilingChecked) -} - -func (repository *PitFileDebtCeilingRepository) SetDB(db *postgres.DB) { - repository.db = db -} diff --git a/pkg/transformers/pit_file/debt_ceiling/repository_test.go b/pkg/transformers/pit_file/debt_ceiling/repository_test.go deleted file mode 100644 index de06cc78..00000000 --- a/pkg/transformers/pit_file/debt_ceiling/repository_test.go +++ /dev/null @@ -1,86 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package debt_ceiling_test - -import ( - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - - "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" - "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres/repositories" - "github.com/vulcanize/vulcanizedb/pkg/fakes" - "github.com/vulcanize/vulcanizedb/pkg/transformers/pit_file/debt_ceiling" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" - "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data" - "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data/shared_behaviors" - "github.com/vulcanize/vulcanizedb/test_config" -) - -var _ = Describe("Pit file debt ceiling repository", func() { - var ( - db *postgres.DB - pitFileDebtCeilingRepository debt_ceiling.PitFileDebtCeilingRepository - headerRepository repositories.HeaderRepository - ) - - BeforeEach(func() { - db = test_config.NewTestDB(test_config.NewTestNode()) - test_config.CleanTestDB(db) - pitFileDebtCeilingRepository = debt_ceiling.PitFileDebtCeilingRepository{} - pitFileDebtCeilingRepository.SetDB(db) - headerRepository = repositories.NewHeaderRepository(db) - }) - - Describe("Create", func() { - modelWithDifferentLogIdx := test_data.PitFileDebtCeilingModel - modelWithDifferentLogIdx.LogIndex = modelWithDifferentLogIdx.LogIndex + 1 - inputs := shared_behaviors.CreateBehaviorInputs{ - CheckedHeaderColumnName: constants.PitFileDebtCeilingChecked, - LogEventTableName: "maker.pit_file_debt_ceiling", - TestModel: test_data.PitFileDebtCeilingModel, - ModelWithDifferentLogIdx: modelWithDifferentLogIdx, - Repository: &pitFileDebtCeilingRepository, - } - - shared_behaviors.SharedRepositoryCreateBehaviors(&inputs) - - It("adds a pit file debt ceiling event", func() { - headerID, err := headerRepository.CreateOrUpdateHeader(fakes.FakeHeader) - Expect(err).NotTo(HaveOccurred()) - err = pitFileDebtCeilingRepository.Create(headerID, []interface{}{test_data.PitFileDebtCeilingModel}) - - Expect(err).NotTo(HaveOccurred()) - var dbPitFile debt_ceiling.PitFileDebtCeilingModel - err = db.Get(&dbPitFile, `SELECT what, data, log_idx, tx_idx, raw_log FROM maker.pit_file_debt_ceiling WHERE header_id = $1`, headerID) - Expect(err).NotTo(HaveOccurred()) - Expect(dbPitFile.What).To(Equal(test_data.PitFileDebtCeilingModel.What)) - Expect(dbPitFile.Data).To(Equal(test_data.PitFileDebtCeilingModel.Data)) - Expect(dbPitFile.LogIndex).To(Equal(test_data.PitFileDebtCeilingModel.LogIndex)) - Expect(dbPitFile.TransactionIndex).To(Equal(test_data.PitFileDebtCeilingModel.TransactionIndex)) - Expect(dbPitFile.Raw).To(MatchJSON(test_data.PitFileDebtCeilingModel.Raw)) - }) - }) - - Describe("MarkHeaderChecked", func() { - inputs := shared_behaviors.MarkedHeaderCheckedBehaviorInputs{ - CheckedHeaderColumnName: constants.PitFileDebtCeilingChecked, - Repository: &pitFileDebtCeilingRepository, - } - - shared_behaviors.SharedRepositoryMarkHeaderCheckedBehaviors(&inputs) - }) -}) diff --git a/pkg/transformers/pit_file/ilk/config.go b/pkg/transformers/pit_file/ilk/config.go deleted file mode 100644 index 4b29caaf..00000000 --- a/pkg/transformers/pit_file/ilk/config.go +++ /dev/null @@ -1,33 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package ilk - -import ( - shared_t "github.com/vulcanize/vulcanizedb/libraries/shared/transformer" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" -) - -func GetIlkFileConfig() shared_t.TransformerConfig { - return shared_t.TransformerConfig{ - TransformerName: constants.PitFileIlkLabel, - ContractAddresses: []string{constants.PitContractAddress()}, - ContractAbi: constants.PitABI(), - Topic: constants.GetPitFileIlkSignature(), - StartingBlockNumber: constants.PitDeploymentBlock(), - EndingBlockNumber: -1, - } -} diff --git a/pkg/transformers/pit_file/ilk/converter_test.go b/pkg/transformers/pit_file/ilk/converter_test.go deleted file mode 100644 index 3b15d50a..00000000 --- a/pkg/transformers/pit_file/ilk/converter_test.go +++ /dev/null @@ -1,97 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package ilk_test - -import ( - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/types" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - - "github.com/vulcanize/vulcanizedb/pkg/transformers/pit_file/ilk" - "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data" -) - -var _ = Describe("Pit file ilk converter", func() { - It("returns err if log is missing topics", func() { - converter := ilk.PitFileIlkConverter{} - badLog := types.Log{ - Data: []byte{1, 1, 1, 1, 1}, - } - - _, err := converter.ToModels([]types.Log{badLog}) - - Expect(err).To(HaveOccurred()) - }) - - It("returns err if log is missing data", func() { - converter := ilk.PitFileIlkConverter{} - badLog := types.Log{ - Topics: []common.Hash{{}, {}, {}, {}}, - } - - _, err := converter.ToModels([]types.Log{badLog}) - - Expect(err).To(HaveOccurred()) - }) - - It("returns error if 'what' field is unknown", func() { - log := types.Log{ - Address: test_data.EthPitFileIlkLineLog.Address, - Topics: []common.Hash{ - test_data.EthPitFileIlkLineLog.Topics[0], - test_data.EthPitFileIlkLineLog.Topics[1], - test_data.EthPitFileIlkLineLog.Topics[2], - common.HexToHash("0x1111111100000000000000000000000000000000000000000000000000000000"), - }, - Data: test_data.EthPitFileIlkLineLog.Data, - BlockNumber: test_data.EthPitFileIlkLineLog.BlockNumber, - TxHash: test_data.EthPitFileIlkLineLog.TxHash, - TxIndex: test_data.EthPitFileIlkLineLog.TxIndex, - BlockHash: test_data.EthPitFileIlkLineLog.BlockHash, - Index: test_data.EthPitFileIlkLineLog.Index, - } - converter := ilk.PitFileIlkConverter{} - - _, err := converter.ToModels([]types.Log{log}) - - Expect(err).To(HaveOccurred()) - }) - - Describe("when log is valid", func() { - It("converts to model with data converted to ray when what is 'spot'", func() { - converter := ilk.PitFileIlkConverter{} - - models, err := converter.ToModels([]types.Log{test_data.EthPitFileIlkSpotLog}) - - Expect(err).NotTo(HaveOccurred()) - Expect(len(models)).To(Equal(1)) - Expect(models[0].(ilk.PitFileIlkModel)).To(Equal(test_data.PitFileIlkSpotModel)) - }) - - It("converts to model with data converted to wad when what is 'line'", func() { - converter := ilk.PitFileIlkConverter{} - - models, err := converter.ToModels([]types.Log{test_data.EthPitFileIlkLineLog}) - - Expect(err).NotTo(HaveOccurred()) - Expect(len(models)).To(Equal(1)) - Expect(models[0].(ilk.PitFileIlkModel)).To(Equal(test_data.PitFileIlkLineModel)) - }) - }) - -}) diff --git a/pkg/transformers/pit_file/ilk/ilk_suite_test.go b/pkg/transformers/pit_file/ilk/ilk_suite_test.go deleted file mode 100644 index 469bede6..00000000 --- a/pkg/transformers/pit_file/ilk/ilk_suite_test.go +++ /dev/null @@ -1,35 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package ilk_test - -import ( - log "github.com/sirupsen/logrus" - "io/ioutil" - "testing" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -func TestIlk(t *testing.T) { - RegisterFailHandler(Fail) - RunSpecs(t, "Ilk Suite") -} - -var _ = BeforeSuite(func() { - log.SetOutput(ioutil.Discard) -}) diff --git a/pkg/transformers/pit_file/ilk/model.go b/pkg/transformers/pit_file/ilk/model.go deleted file mode 100644 index 7c73ab98..00000000 --- a/pkg/transformers/pit_file/ilk/model.go +++ /dev/null @@ -1,26 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package ilk - -type PitFileIlkModel struct { - Ilk string - What string - Data string - LogIndex uint `db:"log_idx"` - TransactionIndex uint `db:"tx_idx"` - Raw []byte `db:"raw_log"` -} diff --git a/pkg/transformers/price_feeds/config.go b/pkg/transformers/price_feeds/config.go deleted file mode 100644 index 437ba879..00000000 --- a/pkg/transformers/price_feeds/config.go +++ /dev/null @@ -1,38 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package price_feeds - -import ( - shared_t "github.com/vulcanize/vulcanizedb/libraries/shared/transformer" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" -) - -func GetPriceFeedConfig() shared_t.TransformerConfig { - return shared_t.TransformerConfig{ - TransformerName: constants.PriceFeedLabel, - ContractAddresses: []string{ - constants.PepContractAddress(), constants.PipContractAddress(), constants.RepContractAddress(), - }, - ContractAbi: constants.MedianizerABI(), - Topic: constants.GetLogValueSignature(), - StartingBlockNumber: shared.MinInt64([]int64{ - constants.PepDeploymentBlock(), constants.PipDeploymentBlock(), constants.RepDeploymentBlock(), - }), - EndingBlockNumber: -1, - } -} diff --git a/pkg/transformers/price_feeds/converter.go b/pkg/transformers/price_feeds/converter.go deleted file mode 100644 index c36e4c46..00000000 --- a/pkg/transformers/price_feeds/converter.go +++ /dev/null @@ -1,46 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package price_feeds - -import ( - "encoding/json" - "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/ethereum/go-ethereum/core/types" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared" -) - -type PriceFeedConverter struct{} - -func (converter PriceFeedConverter) ToModels(ethLogs []types.Log) ([]interface{}, error) { - var results []interface{} - for _, log := range ethLogs { - raw, err := json.Marshal(log) - if err != nil { - return nil, err - } - model := PriceFeedModel{ - BlockNumber: log.BlockNumber, - MedianizerAddress: log.Address.String(), - UsdValue: shared.ConvertToWad(hexutil.Encode(log.Data)), - LogIndex: log.Index, - TransactionIndex: log.TxIndex, - Raw: raw, - } - results = append(results, model) - } - return results, nil -} diff --git a/pkg/transformers/price_feeds/converter_test.go b/pkg/transformers/price_feeds/converter_test.go deleted file mode 100644 index 36931d21..00000000 --- a/pkg/transformers/price_feeds/converter_test.go +++ /dev/null @@ -1,38 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package price_feeds_test - -import ( - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - - "github.com/ethereum/go-ethereum/core/types" - "github.com/vulcanize/vulcanizedb/pkg/transformers/price_feeds" - "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data" -) - -var _ = Describe("Price feed Converter", func() { - It("converts a log to a price feed model", func() { - converter := price_feeds.PriceFeedConverter{} - - models, err := converter.ToModels([]types.Log{test_data.EthPriceFeedLog}) - - Expect(err).NotTo(HaveOccurred()) - Expect(len(models)).To(Equal(1)) - Expect(models[0]).To(Equal(test_data.PriceFeedModel)) - }) -}) diff --git a/pkg/transformers/price_feeds/price_feeds_suite_test.go b/pkg/transformers/price_feeds/price_feeds_suite_test.go deleted file mode 100644 index 04417f29..00000000 --- a/pkg/transformers/price_feeds/price_feeds_suite_test.go +++ /dev/null @@ -1,35 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package price_feeds_test - -import ( - log "github.com/sirupsen/logrus" - "io/ioutil" - "testing" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -func TestPriceFeeds(t *testing.T) { - RegisterFailHandler(Fail) - RunSpecs(t, "PriceFeeds Suite") -} - -var _ = BeforeSuite(func() { - log.SetOutput(ioutil.Discard) -}) diff --git a/pkg/transformers/price_feeds/repository.go b/pkg/transformers/price_feeds/repository.go deleted file mode 100644 index ed776e73..00000000 --- a/pkg/transformers/price_feeds/repository.go +++ /dev/null @@ -1,84 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package price_feeds - -import ( - "fmt" - - log "github.com/sirupsen/logrus" - - "github.com/vulcanize/vulcanizedb/pkg/core" - "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" -) - -type PriceFeedRepository struct { - db *postgres.DB -} - -func (repository PriceFeedRepository) Create(headerID int64, models []interface{}) error { - tx, dBaseErr := repository.db.Begin() - if dBaseErr != nil { - return dBaseErr - } - for _, model := range models { - priceUpdate, ok := model.(PriceFeedModel) - if !ok { - rollbackErr := tx.Rollback() - if rollbackErr != nil { - log.Error("failed to rollback ", rollbackErr) - } - return fmt.Errorf("model of type %T, not %T", model, PriceFeedModel{}) - } - - _, err := tx.Exec(`INSERT INTO maker.price_feeds (block_number, header_id, medianizer_address, usd_value, log_idx, tx_idx, raw_log) - VALUES ($1, $2, $3, $4::NUMERIC, $5, $6, $7) - ON CONFLICT (header_id, medianizer_address, tx_idx, log_idx) DO UPDATE SET block_number = $1, usd_value = $4, raw_log = $7;`, - priceUpdate.BlockNumber, headerID, priceUpdate.MedianizerAddress, priceUpdate.UsdValue, priceUpdate.LogIndex, priceUpdate.TransactionIndex, priceUpdate.Raw) - if err != nil { - tx.Rollback() - return err - } - } - - checkHeaderErr := shared.MarkHeaderCheckedInTransaction(headerID, tx, constants.PriceFeedsChecked) - if checkHeaderErr != nil { - rollbackErr := tx.Rollback() - if rollbackErr != nil { - log.Error("failed to rollback ", rollbackErr) - } - return checkHeaderErr - } - return tx.Commit() -} - -func (repository PriceFeedRepository) MarkHeaderChecked(headerID int64) error { - return shared.MarkHeaderChecked(headerID, repository.db, constants.PriceFeedsChecked) -} - -func (repository PriceFeedRepository) MissingHeaders(startingBlockNumber, endingBlockNumber int64) ([]core.Header, error) { - return shared.MissingHeaders(startingBlockNumber, endingBlockNumber, repository.db, constants.PriceFeedsChecked) -} - -func (repository PriceFeedRepository) RecheckHeaders(startingBlockNumber, endingBlockNumber int64) ([]core.Header, error) { - return shared.RecheckHeaders(startingBlockNumber, endingBlockNumber, repository.db, constants.PriceFeedsChecked) -} - -func (repository *PriceFeedRepository) SetDB(db *postgres.DB) { - repository.db = db -} diff --git a/pkg/transformers/price_feeds/repository_test.go b/pkg/transformers/price_feeds/repository_test.go deleted file mode 100644 index 41c86359..00000000 --- a/pkg/transformers/price_feeds/repository_test.go +++ /dev/null @@ -1,87 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package price_feeds_test - -import ( - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - - "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" - "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres/repositories" - "github.com/vulcanize/vulcanizedb/pkg/fakes" - "github.com/vulcanize/vulcanizedb/pkg/transformers/price_feeds" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" - "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data" - "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data/shared_behaviors" - "github.com/vulcanize/vulcanizedb/test_config" -) - -var _ = Describe("Price feeds repository", func() { - var ( - db *postgres.DB - priceFeedRepository price_feeds.PriceFeedRepository - headerRepository repositories.HeaderRepository - ) - - BeforeEach(func() { - db = test_config.NewTestDB(test_config.NewTestNode()) - test_config.CleanTestDB(db) - priceFeedRepository = price_feeds.PriceFeedRepository{} - priceFeedRepository.SetDB(db) - headerRepository = repositories.NewHeaderRepository(db) - }) - - Describe("Create", func() { - modelWithDifferentLogIdx := test_data.PriceFeedModel - modelWithDifferentLogIdx.LogIndex = modelWithDifferentLogIdx.LogIndex + 1 - inputs := shared_behaviors.CreateBehaviorInputs{ - CheckedHeaderColumnName: constants.PriceFeedsChecked, - LogEventTableName: "maker.price_feeds", - TestModel: test_data.PriceFeedModel, - ModelWithDifferentLogIdx: modelWithDifferentLogIdx, - Repository: &priceFeedRepository, - } - - shared_behaviors.SharedRepositoryCreateBehaviors(&inputs) - - It("persists a price feed update", func() { - headerID, err := headerRepository.CreateOrUpdateHeader(fakes.FakeHeader) - Expect(err).NotTo(HaveOccurred()) - err = priceFeedRepository.Create(headerID, []interface{}{test_data.PriceFeedModel}) - - Expect(err).NotTo(HaveOccurred()) - var dbPriceFeedUpdate price_feeds.PriceFeedModel - err = db.Get(&dbPriceFeedUpdate, `SELECT block_number, medianizer_address, usd_value, log_idx, tx_idx, raw_log FROM maker.price_feeds WHERE header_id = $1`, headerID) - Expect(err).NotTo(HaveOccurred()) - Expect(dbPriceFeedUpdate.BlockNumber).To(Equal(test_data.PriceFeedModel.BlockNumber)) - Expect(dbPriceFeedUpdate.MedianizerAddress).To(Equal(test_data.PriceFeedModel.MedianizerAddress)) - Expect(dbPriceFeedUpdate.UsdValue).To(Equal(test_data.PriceFeedModel.UsdValue)) - Expect(dbPriceFeedUpdate.LogIndex).To(Equal(test_data.PriceFeedModel.LogIndex)) - Expect(dbPriceFeedUpdate.TransactionIndex).To(Equal(test_data.PriceFeedModel.TransactionIndex)) - Expect(dbPriceFeedUpdate.Raw).To(MatchJSON(test_data.PriceFeedModel.Raw)) - }) - }) - - Describe("MarkHeaderChecked", func() { - inputs := shared_behaviors.MarkedHeaderCheckedBehaviorInputs{ - CheckedHeaderColumnName: constants.PriceFeedsChecked, - Repository: &priceFeedRepository, - } - - shared_behaviors.SharedRepositoryMarkHeaderCheckedBehaviors(&inputs) - }) -}) diff --git a/pkg/transformers/shared/TransformerREADME.md b/pkg/transformers/shared/TransformerREADME.md deleted file mode 100644 index 1049f271..00000000 --- a/pkg/transformers/shared/TransformerREADME.md +++ /dev/null @@ -1,27 +0,0 @@ -# Transformers - -## Description -Transformers must be defined in order to define what events should trigger data updates and how those are performed. - -## Interface - -### Initializer -Accepts DB and Blockchain from Vulcanize and returns a new transformer. E.g. for a new object "Cup": -`func NewCupTransformer(db *postgres.DB, blockchain core.ContractDataFetcher) transformers.Transformer` - -### Execute -Triggers operations to take in response to a given log event. -Can persist data from logs, fetch and persist arbitrary data from outside services (e.g. contract state), or take any number of other actions. E.g.: -`func (cupTransformer *CupTransformer) Execute() error` - -## Additional Requirements -Transformers must define log filters and create them so that relevant watched events can be identified and retrieved. E.g.: -```$xslt - { - Name: "CupsBite", - FromBlock: 0, - ToBlock: -1, - Address: "0x448a5065aebb8e423f0896e6c5d525c040f59af3", - Topics: core.Topics{"0x40cc885400000000000000000000000000000000000000000000000000000000"}, - }, -``` \ No newline at end of file diff --git a/pkg/transformers/shared/constants/checked_headers.go b/pkg/transformers/shared/constants/checked_headers.go deleted file mode 100644 index ccbd250e..00000000 --- a/pkg/transformers/shared/constants/checked_headers.go +++ /dev/null @@ -1,40 +0,0 @@ -package constants - -type TransformerExecution bool - -const ( - HeaderRecheck TransformerExecution = true - HeaderMissing TransformerExecution = false - RecheckHeaderCap = "4" -) - -var ( - BiteChecked = "bite_checked" - CatFileChopLumpChecked = "cat_file_chop_lump_checked" - CatFileFlipChecked = "cat_file_flip_checked" - CatFilePitVowChecked = "cat_file_pit_vow_checked" - DealChecked = "deal_checked" - DentChecked = "dent_checked" - DripDripChecked = "drip_drip_checked" - DripFileIlkChecked = "drip_file_ilk_checked" - DripFileRepoChecked = "drip_file_repo_checked" - DripFileVowChecked = "drip_file_vow_checked" - FlapKickChecked = "flap_kick_checked" - FlipKickChecked = "flip_kick_checked" - FlopKickChecked = "flop_kick_checked" - FrobChecked = "frob_checked" - PitFileDebtCeilingChecked = "pit_file_debt_ceiling_checked" - PitFileIlkChecked = "pit_file_ilk_checked" - PriceFeedsChecked = "price_feeds_checked" - TendChecked = "tend_checked" - VatFluxChecked = "vat_flux_checked" - VatFoldChecked = "vat_fold_checked" - VatGrabChecked = "vat_grab_checked" - VatHealChecked = "vat_heal_checked" - VatInitChecked = "vat_init_checked" - VatMoveChecked = "vat_move_checked" - VatSlipChecked = "vat_slip_checked" - VatTollChecked = "vat_toll_checked" - VatTuneChecked = "vat_tune_checked" - VowFlogChecked = "vow_flog_checked" -) diff --git a/pkg/transformers/shared/constants/constants_suite_test.go b/pkg/transformers/shared/constants/constants_suite_test.go deleted file mode 100644 index 4aae199f..00000000 --- a/pkg/transformers/shared/constants/constants_suite_test.go +++ /dev/null @@ -1,13 +0,0 @@ -package constants_test - -import ( - "testing" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -func TestConstants(t *testing.T) { - RegisterFailHandler(Fail) - RunSpecs(t, "Constants Suite") -} diff --git a/pkg/transformers/shared/constants/data.go b/pkg/transformers/shared/constants/data.go deleted file mode 100644 index 001952ba..00000000 --- a/pkg/transformers/shared/constants/data.go +++ /dev/null @@ -1,6 +0,0 @@ -package constants - -var DataItemLength = 32 - -// TODO Grab this from DB, since it can change through governance -var TTL = int64(10800) // 60 * 60 * 3 == 10800 seconds == 3 hours diff --git a/pkg/transformers/shared/constants/event_signature_generator.go b/pkg/transformers/shared/constants/event_signature_generator.go deleted file mode 100644 index aa288094..00000000 --- a/pkg/transformers/shared/constants/event_signature_generator.go +++ /dev/null @@ -1,59 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package constants - -import ( - "fmt" - "strings" - - "github.com/ethereum/go-ethereum/accounts/abi" - "github.com/ethereum/go-ethereum/crypto" - - "github.com/vulcanize/vulcanizedb/pkg/geth" -) - -func GetEventSignature(solidityMethodSignature string) string { - eventSignature := []byte(solidityMethodSignature) - hash := crypto.Keccak256Hash(eventSignature) - return hash.Hex() -} - -func GetLogNoteSignature(solidityMethodSignature string) string { - rawSignature := GetEventSignature(solidityMethodSignature) - return rawSignature[:10] + "00000000000000000000000000000000000000000000000000000000" -} - -func GetSolidityMethodSignature(abi, name string) string { - parsedAbi, _ := geth.ParseAbi(abi) - - if method, ok := parsedAbi.Methods[name]; ok { - return method.Sig() - } else if event, ok := parsedAbi.Events[name]; ok { - return getEventSignature(event) - } - panic("Error: could not get Solidity method signature for: " + name) -} - -func getEventSignature(event abi.Event) string { - types := make([]string, len(event.Inputs)) - for i, input := range event.Inputs { - types[i] = input.Type.String() - i++ - } - - return fmt.Sprintf("%v(%v)", event.Name, strings.Join(types, ",")) -} diff --git a/pkg/transformers/shared/constants/event_signature_generator_test.go b/pkg/transformers/shared/constants/event_signature_generator_test.go deleted file mode 100644 index 54a15d85..00000000 --- a/pkg/transformers/shared/constants/event_signature_generator_test.go +++ /dev/null @@ -1,272 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package constants_test - -import ( - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" - "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data" -) - -var _ = Describe("Event signature generator", func() { - Describe("generating non-anonymous event signatures", func() { - It("generates bite event signature", func() { - expected := "0x99b5620489b6ef926d4518936cfec15d305452712b88bd59da2d9c10fb0953e8" - actual := constants.GetEventSignature("Bite(bytes32,bytes32,uint256,uint256,uint256,uint256,uint256)") - - Expect(expected).To(Equal(actual)) - }) - - It("generates frob event signature", func() { - expected := "0xb2afa28318bcc689926b52835d844de174ef8de97e982a85c0199d584920791b" - actual := constants.GetEventSignature("Frob(bytes32,bytes32,uint256,uint256,int256,int256,uint256)") - - Expect(expected).To(Equal(actual)) - }) - - It("generates the flap kick event signature", func() { - expected := "0xefa52d9342a199cb30efd2692463f2c2bef63cd7186b50382d4fb94ad207880e" - actual := constants.GetEventSignature("Kick(uint256,uint256,uint256,address,uint48)") - - Expect(expected).To(Equal(actual)) - }) - - It("generates flip kick event signature", func() { - expected := "0xbac86238bdba81d21995024470425ecb370078fa62b7271b90cf28cbd1e3e87e" - actual := constants.GetEventSignature("Kick(uint256,uint256,uint256,address,uint48,bytes32,uint256)") - - Expect(expected).To(Equal(actual)) - }) - - It("generates log value event signature", func() { - expected := "0x296ba4ca62c6c21c95e828080cb8aec7481b71390585605300a8a76f9e95b527" - actual := constants.GetEventSignature("LogValue(bytes32)") - - Expect(expected).To(Equal(actual)) - }) - }) - - Describe("generating LogNote event signatures", func() { - It("generates flip tend event signature", func() { - expected := "0x4b43ed1200000000000000000000000000000000000000000000000000000000" - actual := constants.GetLogNoteSignature("tend(uint256,uint256,uint256)") - - Expect(expected).To(Equal(actual)) - }) - - It("generates pit file event signature for overloaded function with three arguments", func() { - expected := "0x1a0b287e00000000000000000000000000000000000000000000000000000000" - actual := constants.GetLogNoteSignature("file(bytes32,bytes32,uint256)") - - Expect(expected).To(Equal(actual)) - }) - - It("generates pit file event signature for overloaded function with two arguments", func() { - expected := "0x29ae811400000000000000000000000000000000000000000000000000000000" - actual := constants.GetLogNoteSignature("file(bytes32,uint256)") - - Expect(expected).To(Equal(actual)) - }) - - It("generates pit file event signature for overloaded function with two different arguments", func() { - expected := "0xd4e8be8300000000000000000000000000000000000000000000000000000000" - actual := constants.GetLogNoteSignature("file(bytes32,address)") - - Expect(expected).To(Equal(actual)) - }) - }) - - Describe("getting the solidity method/event signature from the abi", func() { - Describe("it handles methods", func() { - Describe("from the cat contract", func() { - It("gets the file method signature", func() { - expected := "file(bytes32,bytes32,address)" - actual := constants.GetSolidityMethodSignature(test_data.KovanCatABI, "file") - - Expect(expected).To(Equal(actual)) - }) - }) - - Describe("from the drip contract", func() { - It("gets the drip method signature", func() { - expected := "drip(bytes32)" - actual := constants.GetSolidityMethodSignature(test_data.KovanDripABI, "drip") - - Expect(expected).To(Equal(actual)) - }) - - It("gets the file method signature", func() { - expected := "file(bytes32,uint256)" - actual := constants.GetSolidityMethodSignature(test_data.KovanDripABI, "file") - - Expect(expected).To(Equal(actual)) - }) - }) - - Describe("from the flipper contract", func() { - It("gets the deal method signature", func() { - expected := "deal(uint256)" - actual := constants.GetSolidityMethodSignature(test_data.KovanFlipperABI, "deal") - - Expect(expected).To(Equal(actual)) - }) - - It("gets the dent method signature", func() { - expected := "dent(uint256,uint256,uint256)" - actual := constants.GetSolidityMethodSignature(test_data.KovanFlipperABI, "dent") - - Expect(expected).To(Equal(actual)) - }) - - It("gets the tend method signature", func() { - expected := "tend(uint256,uint256,uint256)" - actual := constants.GetSolidityMethodSignature(test_data.KovanFlipperABI, "tend") - - Expect(expected).To(Equal(actual)) - }) - }) - - Describe("from the pit contract", func() { - It("gets the file method signature", func() { - expected := "file(bytes32,address)" - actual := constants.GetSolidityMethodSignature(test_data.KovanPitABI, "file") - - Expect(expected).To(Equal(actual)) - }) - }) - - Describe("from the vat contract", func() { - It("gets the init method signature", func() { - expected := "init(bytes32)" - actual := constants.GetSolidityMethodSignature(test_data.KovanVatABI, "init") - - Expect(expected).To(Equal(actual)) - }) - - It("gets the heal method signature", func() { - expected := "heal(bytes32,bytes32,int256)" - actual := constants.GetSolidityMethodSignature(test_data.KovanVatABI, "heal") - - Expect(expected).To(Equal(actual)) - }) - - It("gets the fold method signature", func() { - expected := "fold(bytes32,bytes32,int256)" - actual := constants.GetSolidityMethodSignature(test_data.KovanVatABI, "fold") - - Expect(expected).To(Equal(actual)) - }) - - It("gets the flux method signature", func() { - expected := "flux(bytes32,bytes32,bytes32,int256)" - actual := constants.GetSolidityMethodSignature(test_data.KovanVatABI, "flux") - - Expect(expected).To(Equal(actual)) - }) - - It("gets the grab method signature", func() { - expected := "grab(bytes32,bytes32,bytes32,bytes32,int256,int256)" - actual := constants.GetSolidityMethodSignature(test_data.KovanVatABI, "grab") - - Expect(expected).To(Equal(actual)) - }) - - It("gets the move method signature", func() { - expected := "move(bytes32,bytes32,int256)" - actual := constants.GetSolidityMethodSignature(test_data.KovanVatABI, "move") - - Expect(expected).To(Equal(actual)) - }) - - It("gets the slip method signature", func() { - expected := "slip(bytes32,bytes32,int256)" - actual := constants.GetSolidityMethodSignature(test_data.KovanVatABI, "slip") - - Expect(expected).To(Equal(actual)) - }) - - It("gets the toll method signature", func() { - expected := "toll(bytes32,bytes32,int256)" - actual := constants.GetSolidityMethodSignature(test_data.KovanVatABI, "toll") - - Expect(expected).To(Equal(actual)) - }) - - It("gets the tune method signature", func() { - expected := "tune(bytes32,bytes32,bytes32,bytes32,int256,int256)" - actual := constants.GetSolidityMethodSignature(test_data.KovanVatABI, "tune") - - Expect(expected).To(Equal(actual)) - }) - }) - - Describe("from the vow contract", func() { - It("gets the flog method signature", func() { - expected := "flog(uint48)" - actual := constants.GetSolidityMethodSignature(test_data.KovanVowABI, "flog") - - Expect(expected).To(Equal(actual)) - }) - }) - }) - - Describe("it handles events", func() { - It("gets the Bite event signature", func() { - expected := "Bite(bytes32,bytes32,uint256,uint256,uint256,uint256,uint256)" - actual := constants.GetSolidityMethodSignature(test_data.KovanCatABI, "Bite") - - Expect(expected).To(Equal(actual)) - }) - - It("gets the flap Kick event signature", func() { - expected := "Kick(uint256,uint256,uint256,address,uint48)" - actual := constants.GetSolidityMethodSignature(test_data.KovanFlapperABI, "Kick") - - Expect(expected).To(Equal(actual)) - }) - - It("gets the flip Kick event signature", func() { - expected := "Kick(uint256,uint256,uint256,address,uint48,bytes32,uint256)" - actual := constants.GetSolidityMethodSignature(test_data.KovanFlipperABI, "Kick") - - Expect(expected).To(Equal(actual)) - }) - - It("gets the flop Kick event signature", func() { - expected := "Kick(uint256,uint256,uint256,address,uint48)" - actual := constants.GetSolidityMethodSignature(test_data.KovanFlopperABI, "Kick") - - Expect(expected).To(Equal(actual)) - }) - - It("gets the pit frob event signature", func() { - expected := "Frob(bytes32,bytes32,uint256,uint256,int256,int256,uint256)" - actual := constants.GetSolidityMethodSignature(test_data.KovanPitABI, "Frob") - - Expect(expected).To(Equal(actual)) - }) - - It("gets the log value method signature", func() { - expected := "LogValue(bytes32)" - actual := constants.GetSolidityMethodSignature(test_data.KovanMedianizerABI, "LogValue") - - Expect(expected).To(Equal(actual)) - }) - }) - }) -}) diff --git a/pkg/transformers/shared/constants/external.go b/pkg/transformers/shared/constants/external.go deleted file mode 100644 index 5b14d435..00000000 --- a/pkg/transformers/shared/constants/external.go +++ /dev/null @@ -1,62 +0,0 @@ -package constants - -import ( - "fmt" - - "github.com/spf13/viper" -) - -func getEnvironmentString(key string) string { - value := viper.GetString(key) - if value == "" { - panic(fmt.Sprintf("No environment configuration variable set for key: \"%v\"", key)) - } - return value -} - -// Returns an int from the environment, defaulting to 0 if it does not exist -func getEnvironmentInt64(key string) int64 { - value := viper.GetInt64(key) - if value == -1 { - return 0 - } - return value -} - -// Getters for contract addresses from environment files -func CatContractAddress() string { return getEnvironmentString("contract.address.cat") } -func DripContractAddress() string { return getEnvironmentString("contract.address.drip") } -func FlapperContractAddress() string { return getEnvironmentString("contract.address.mcd_flap") } -func FlipperContractAddress() string { return getEnvironmentString("contract.address.eth_flip") } -func FlopperContractAddress() string { return getEnvironmentString("contract.address.mcd_flop") } -func PepContractAddress() string { return getEnvironmentString("contract.address.pep") } -func PipContractAddress() string { return getEnvironmentString("contract.address.pip") } -func PitContractAddress() string { return getEnvironmentString("contract.address.pit") } -func RepContractAddress() string { return getEnvironmentString("contract.address.rep") } -func VatContractAddress() string { return getEnvironmentString("contract.address.vat") } -func VowContractAddress() string { return getEnvironmentString("contract.address.vow") } - -func CatABI() string { return getEnvironmentString("contract.abi.cat") } -func DripABI() string { return getEnvironmentString("contract.abi.drip") } -func FlapperABI() string { return getEnvironmentString("contract.abi.mcd_flap") } -func FlipperABI() string { return getEnvironmentString("contract.abi.eth_flip") } -func FlopperABI() string { return getEnvironmentString("contract.abi.mcd_flop") } -func MedianizerABI() string { return getEnvironmentString("contract.abi.medianizer") } -func PitABI() string { return getEnvironmentString("contract.abi.pit") } -func VatABI() string { return getEnvironmentString("contract.abi.vat") } -func VowABI() string { return getEnvironmentString("contract.abi.vow") } - -func CatDeploymentBlock() int64 { return getEnvironmentInt64("contract.deployment-block.cat") } -func DripDeploymentBlock() int64 { return getEnvironmentInt64("contract.deployment-block.drip") } -func FlapperDeploymentBlock() int64 { return getEnvironmentInt64("contract.deployment-block.mcd_flap") } -func FlipperDeploymentBlock() int64 { return getEnvironmentInt64("contract.deployment-block.eth_flip") } -func FlopperDeploymentBlock() int64 { return getEnvironmentInt64("contract.deployment-block.mcd_flop") } -func PepDeploymentBlock() int64 { return getEnvironmentInt64("contract.deployment-block.pep") } -func PipDeploymentBlock() int64 { return getEnvironmentInt64("contract.deployment-block.pip") } -func PitDeploymentBlock() int64 { return getEnvironmentInt64("contract.deployment-block.pit") } -func RepDeploymentBlock() int64 { return getEnvironmentInt64("contract.deployment-block.rep") } -func VatDeploymentBlock() int64 { return getEnvironmentInt64("contract.deployment-block.vat") } -func VowDeploymentBlock() int64 { return getEnvironmentInt64("contract.deployment-block.vow") } -func MedianizerDeploymentBlock() int64 { - return getEnvironmentInt64("contract.deployment-block.medianizer") -} diff --git a/pkg/transformers/shared/constants/label.go b/pkg/transformers/shared/constants/label.go deleted file mode 100644 index ffee43eb..00000000 --- a/pkg/transformers/shared/constants/label.go +++ /dev/null @@ -1,65 +0,0 @@ -package constants - -const ( - BiteLabel = "bite" - CatFileChopLumpLabel = "catFileChopLump" - CatFileFlipLabel = "catFileFlip" - CatFilePitVowLabel = "catFilePitVow" - DealLabel = "deal" - DentLabel = "dent" - DripDripLabel = "dripDrip" - DripFileIlkLabel = "dripFileIlk" - DripFileRepoLabel = "dripFileRepo" - DripFileVowLabel = "dripFileVow" - FlapKickLabel = "flapKick" - FlipKickLabel = "flipKick" - FlopKickLabel = "flopKick" - FrobLabel = "frob" - PitFileDebtCeilingLabel = "pitFileDebtCeiling" - PitFileIlkLabel = "pitFileIlk" - PriceFeedLabel = "priceFeed" - TendLabel = "tend" - VatFluxLabel = "vatFlux" - VatFoldLabel = "vatFold" - VatGrabLabel = "vatGrab" - VatHealLabel = "vatHeal" - VatInitLabel = "vatInit" - VatMoveLabel = "vatMove" - VatSlipLabel = "vatSlip" - VatTollLabel = "vatToll" - VatTuneLabel = "vatTune" - VowFlogLabel = "vowFlog" -) - -func AllTransformerLabels() []string { - return []string{ - BiteLabel, - CatFileChopLumpLabel, - CatFileFlipLabel, - CatFilePitVowLabel, - DealLabel, - DentLabel, - DripDripLabel, - DripFileIlkLabel, - DripFileRepoLabel, - DripFileVowLabel, - FlapKickLabel, - FlipKickLabel, - FlopKickLabel, - FrobLabel, - PitFileDebtCeilingLabel, - PitFileIlkLabel, - PriceFeedLabel, - TendLabel, - VatFluxLabel, - VatFoldLabel, - VatGrabLabel, - VatHealLabel, - VatInitLabel, - VatMoveLabel, - VatSlipLabel, - VatTollLabel, - VatTuneLabel, - VowFlogLabel, - } -} diff --git a/pkg/transformers/shared/constants/method.go b/pkg/transformers/shared/constants/method.go deleted file mode 100644 index b6d658cf..00000000 --- a/pkg/transformers/shared/constants/method.go +++ /dev/null @@ -1,31 +0,0 @@ -package constants - -//TODO: get cat, pit, and drip file method signatures directly from the ABI -func biteMethod() string { return GetSolidityMethodSignature(CatABI(), "Bite") } -func catFileChopLumpMethod() string { return "file(bytes32,bytes32,uint256)" } -func catFileFlipMethod() string { return GetSolidityMethodSignature(CatABI(), "file") } -func catFilePitVowMethod() string { return "file(bytes32,address)" } -func dealMethod() string { return GetSolidityMethodSignature(FlipperABI(), "deal") } -func dentMethod() string { return GetSolidityMethodSignature(FlipperABI(), "dent") } -func dripDripMethod() string { return GetSolidityMethodSignature(DripABI(), "drip") } -func dripFileIlkMethod() string { return "file(bytes32,bytes32,uint256)" } -func dripFileRepoMethod() string { return GetSolidityMethodSignature(DripABI(), "file") } -func dripFileVowMethod() string { return "file(bytes32,bytes32)" } -func flapKickMethod() string { return GetSolidityMethodSignature(FlapperABI(), "Kick") } -func flipKickMethod() string { return GetSolidityMethodSignature(FlipperABI(), "Kick") } -func flopKickMethod() string { return GetSolidityMethodSignature(FlopperABI(), "Kick") } -func frobMethod() string { return GetSolidityMethodSignature(PitABI(), "Frob") } -func logValueMethod() string { return GetSolidityMethodSignature(MedianizerABI(), "LogValue") } -func pitFileDebtCeilingMethod() string { return "file(bytes32,uint256)" } -func pitFileIlkMethod() string { return "file(bytes32,bytes32,uint256)" } -func tendMethod() string { return GetSolidityMethodSignature(FlipperABI(), "tend") } -func vatFluxMethod() string { return GetSolidityMethodSignature(VatABI(), "flux") } -func vatFoldMethod() string { return GetSolidityMethodSignature(VatABI(), "fold") } -func vatGrabMethod() string { return GetSolidityMethodSignature(VatABI(), "grab") } -func vatHealMethod() string { return GetSolidityMethodSignature(VatABI(), "heal") } -func vatInitMethod() string { return GetSolidityMethodSignature(VatABI(), "init") } -func vatMoveMethod() string { return GetSolidityMethodSignature(VatABI(), "move") } -func vatSlipMethod() string { return GetSolidityMethodSignature(VatABI(), "slip") } -func vatTollMethod() string { return GetSolidityMethodSignature(VatABI(), "toll") } -func vatTuneMethod() string { return GetSolidityMethodSignature(VatABI(), "tune") } -func vowFlogMethod() string { return GetSolidityMethodSignature(VowABI(), "flog") } diff --git a/pkg/transformers/shared/constants/signature.go b/pkg/transformers/shared/constants/signature.go deleted file mode 100644 index baa10d5f..00000000 --- a/pkg/transformers/shared/constants/signature.go +++ /dev/null @@ -1,30 +0,0 @@ -package constants - -func GetBiteSignature() string { return GetEventSignature(biteMethod()) } -func GetCatFileChopLumpSignature() string { return GetLogNoteSignature(catFileChopLumpMethod()) } -func GetCatFileFlipSignature() string { return GetLogNoteSignature(catFileFlipMethod()) } -func GetCatFilePitVowSignature() string { return GetLogNoteSignature(catFilePitVowMethod()) } -func GetDealSignature() string { return GetLogNoteSignature(dealMethod()) } -func GetDentFunctionSignature() string { return GetLogNoteSignature(dentMethod()) } -func GetDripDripSignature() string { return GetLogNoteSignature(dripDripMethod()) } -func GetDripFileIlkSignature() string { return GetLogNoteSignature(dripFileIlkMethod()) } -func GetDripFileRepoSignature() string { return GetLogNoteSignature(dripFileRepoMethod()) } -func GetDripFileVowSignature() string { return GetLogNoteSignature(dripFileVowMethod()) } -func GetFlapKickSignature() string { return GetEventSignature(flapKickMethod()) } -func GetFlipKickSignature() string { return GetEventSignature(flipKickMethod()) } -func GetFlopKickSignature() string { return GetEventSignature(flopKickMethod()) } -func GetFrobSignature() string { return GetEventSignature(frobMethod()) } -func GetLogValueSignature() string { return GetEventSignature(logValueMethod()) } -func GetPitFileDebtCeilingSignature() string { return GetLogNoteSignature(pitFileDebtCeilingMethod()) } -func GetPitFileIlkSignature() string { return GetLogNoteSignature(pitFileIlkMethod()) } -func GetTendFunctionSignature() string { return GetLogNoteSignature(tendMethod()) } -func GetVatFluxSignature() string { return GetLogNoteSignature(vatFluxMethod()) } -func GetVatFoldSignature() string { return GetLogNoteSignature(vatFoldMethod()) } -func GetVatGrabSignature() string { return GetLogNoteSignature(vatGrabMethod()) } -func GetVatHealSignature() string { return GetLogNoteSignature(vatHealMethod()) } -func GetVatInitSignature() string { return GetLogNoteSignature(vatInitMethod()) } -func GetVatMoveSignature() string { return GetLogNoteSignature(vatMoveMethod()) } -func GetVatSlipSignature() string { return GetLogNoteSignature(vatSlipMethod()) } -func GetVatTollSignature() string { return GetLogNoteSignature(vatTollMethod()) } -func GetVatTuneSignature() string { return GetLogNoteSignature(vatTuneMethod()) } -func GetVowFlogSignature() string { return GetLogNoteSignature(vowFlogMethod()) } diff --git a/pkg/transformers/shared/storage/transformer.go b/pkg/transformers/shared/storage/transformer.go deleted file mode 100644 index 240f8ca1..00000000 --- a/pkg/transformers/shared/storage/transformer.go +++ /dev/null @@ -1,14 +0,0 @@ -package storage - -import ( - "github.com/ethereum/go-ethereum/common" - "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" - "github.com/vulcanize/vulcanizedb/pkg/transformers/storage_diffs/shared" -) - -type Transformer interface { - Execute(row shared.StorageDiffRow) error - ContractAddress() common.Address -} - -type TransformerInitializer func(db *postgres.DB) Transformer diff --git a/pkg/transformers/shared/utilities.go b/pkg/transformers/shared/utilities.go deleted file mode 100644 index a33587ae..00000000 --- a/pkg/transformers/shared/utilities.go +++ /dev/null @@ -1,100 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package shared - -import ( - "github.com/ethereum/go-ethereum/common" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" - "math/big" -) - -var ( - rayBase = big.NewFloat(1e27) - wadBase = big.NewFloat(1e18) - rayPrecision = 27 - wadPrecision = 18 - ray = "ray" - wad = "wad" -) - -func BigIntToInt64(value *big.Int) int64 { - if value == nil { - return int64(0) - } else { - return value.Int64() - } -} - -func BigIntToString(value *big.Int) string { - result := value.String() - if result == "" { - return "" - } else { - return result - } -} - -func GetDataBytesAtIndex(n int, logData []byte) []byte { - switch { - case n == -1: - return logData[len(logData)-constants.DataItemLength:] - case n == -2: - return logData[len(logData)-(2*constants.DataItemLength) : len(logData)-constants.DataItemLength] - case n == -3: - return logData[len(logData)-(3*constants.DataItemLength) : len(logData)-(2*constants.DataItemLength)] - } - return []byte{} -} - -func GetHexWithoutPrefix(raw []byte) string { - return common.Bytes2Hex(raw) -} - -func ConvertToRay(value string) string { - return convert(ray, value, rayPrecision) -} - -func ConvertToWad(value string) string { - return convert(wad, value, wadPrecision) -} - -func convert(conversion string, value string, precision int) string { - result := big.NewFloat(0.0) - bigFloat := big.NewFloat(0.0) - bigFloat.SetString(value) - - switch conversion { - case ray: - result.Quo(bigFloat, rayBase) - case wad: - result.Quo(bigFloat, wadBase) - } - return result.Text('f', precision) -} - -func MinInt64(ints []int64) (min int64) { - if len(ints) == 0 { - return 0 - } - min = ints[0] - for _, i := range ints { - if i < min { - min = i - } - } - return -} diff --git a/pkg/transformers/shared/utilities_test.go b/pkg/transformers/shared/utilities_test.go deleted file mode 100644 index 56a02e95..00000000 --- a/pkg/transformers/shared/utilities_test.go +++ /dev/null @@ -1,73 +0,0 @@ -package shared_test - -import ( - "github.com/ethereum/go-ethereum/common/hexutil" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - - "github.com/ethereum/go-ethereum/common" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared" - "math/big" -) - -var _ = Describe("Shared utilities", func() { - Describe("getting data at index", func() { - It("gets bytes for the last index in log data", func() { - logData := hexutil.MustDecode("0x000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000c45dd6471a66616b6520696c6b0000000000000000000000000000000000000000000000007d7bee5fcfd8028cf7b00876c5b1421c800561a6000000000000000000000000a3e37186e017747dba34042e83e3f76ad3cce9b00000000000000000000000000f243e26db94b5426032e6dfa6007802dea2a61400000000000000000000000000000000000000000000000000000000000000000000000000000000075bcd15000000000000000000000000000000000000000000000000000000003ade68b1") - bigIntBytes := big.NewInt(987654321).Bytes() - // big.Int.Bytes() does not include zero padding, but bytes in data index are of fixed length and include zero padding - expected := []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} - expected = append(expected, bigIntBytes...) - - actual := shared.GetDataBytesAtIndex(-1, logData) - - Expect(expected[:]).To(Equal(actual)) - }) - - It("gets bytes for the second-to-last index in log data", func() { - logData := hexutil.MustDecode("0x000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000c45dd6471a66616b6520696c6b0000000000000000000000000000000000000000000000007d7bee5fcfd8028cf7b00876c5b1421c800561a6000000000000000000000000a3e37186e017747dba34042e83e3f76ad3cce9b00000000000000000000000000f243e26db94b5426032e6dfa6007802dea2a61400000000000000000000000000000000000000000000000000000000000000000000000000000000075bcd15000000000000000000000000000000000000000000000000000000003ade68b1") - bigIntBytes := big.NewInt(123456789).Bytes() - expected := []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} - expected = append(expected, bigIntBytes...) - - actual := shared.GetDataBytesAtIndex(-2, logData) - - Expect(expected[:]).To(Equal(actual)) - }) - - It("gets bytes for the third-to-last index in log data", func() { - logData := hexutil.MustDecode("0x000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000c45dd6471a66616b6520696c6b0000000000000000000000000000000000000000000000007d7bee5fcfd8028cf7b00876c5b1421c800561a6000000000000000000000000a3e37186e017747dba34042e83e3f76ad3cce9b00000000000000000000000000f243e26db94b5426032e6dfa6007802dea2a61400000000000000000000000000000000000000000000000000000000000000000000000000000000075bcd15000000000000000000000000000000000000000000000000000000003ade68b1") - addressBytes := common.HexToAddress("0x0F243E26db94B5426032E6DFA6007802Dea2a614").Bytes() - // common.address.Bytes() returns [20]byte{}, need [32]byte{} - expected := append(addressBytes, []byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}...) - - actual := shared.GetDataBytesAtIndex(-3, logData) - - Expect(expected[:]).To(Equal(actual)) - }) - - It("converts values to rays", func() { - rayOne := shared.ConvertToRay("123456789012345678901234567890") - Expect(rayOne).To(Equal("123.456789012345680589533003513")) - - rayTwo := shared.ConvertToRay("1234567890123456790123567890") - Expect(rayTwo).To(Equal("1.234567890123456912476740399")) - }) - - It("converts values to wads", func() { - wadOne := shared.ConvertToWad("12345678901234567890123") - Expect(wadOne).To(Equal("12345.678901234567092615")) - - wadTwo := shared.ConvertToWad("1234567890123456789") - Expect(wadTwo).To(Equal("1.234567890123456690")) - }) - }) - - Describe("getting hex without prefix", func() { - It("returns bytes as hex without 0x prefix", func() { - raw := common.HexToHash("0x4554480000000000000000000000000000000000000000000000000000000000").Bytes() - result := shared.GetHexWithoutPrefix(raw) - Expect(result).To(Equal("4554480000000000000000000000000000000000000000000000000000000000")) - }) - }) -}) diff --git a/pkg/transformers/storage_diffs/maker/pit/mappings.go b/pkg/transformers/storage_diffs/maker/pit/mappings.go deleted file mode 100644 index 46e5938c..00000000 --- a/pkg/transformers/storage_diffs/maker/pit/mappings.go +++ /dev/null @@ -1,134 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package pit - -import ( - "github.com/ethereum/go-ethereum/common" - "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" - "github.com/vulcanize/vulcanizedb/pkg/transformers/storage_diffs" - "github.com/vulcanize/vulcanizedb/pkg/transformers/storage_diffs/maker" - "github.com/vulcanize/vulcanizedb/pkg/transformers/storage_diffs/shared" -) - -const ( - IlkLine = "line" - IlkSpot = "spot" - PitDrip = "drip" - PitLine = "Line" - PitLive = "live" - PitVat = "vat" -) - -var ( - // storage key and value metadata for "drip" on the Pit contract - DripKey = common.HexToHash(storage_diffs.IndexFive) - DripMetadata = shared.StorageValueMetadata{ - Name: PitDrip, - Keys: nil, - Type: shared.Address, - } - - IlkSpotIndex = storage_diffs.IndexOne - - // storage key and value metadata for "Spot" on the Pit contract - LineKey = common.HexToHash(storage_diffs.IndexThree) - LineMetadata = shared.StorageValueMetadata{ - Name: PitLine, - Keys: nil, - Type: shared.Uint256, - } - - // storage key and value metadata for "live" on the Pit contract - LiveKey = common.HexToHash(storage_diffs.IndexTwo) - LiveMetadata = shared.StorageValueMetadata{ - Name: PitLive, - Keys: nil, - Type: shared.Uint256, - } - - // storage key and value metadata for "vat" on the Pit contract - VatKey = common.HexToHash(storage_diffs.IndexFour) - VatMetadata = shared.StorageValueMetadata{ - Name: PitVat, - Keys: nil, - Type: shared.Address, - } -) - -type PitMappings struct { - StorageRepository maker.IMakerStorageRepository - mappings map[common.Hash]shared.StorageValueMetadata -} - -func (mappings *PitMappings) SetDB(db *postgres.DB) { - mappings.StorageRepository.SetDB(db) -} - -func (mappings *PitMappings) Lookup(key common.Hash) (shared.StorageValueMetadata, error) { - metadata, ok := mappings.mappings[key] - if !ok { - err := mappings.loadMappings() - if err != nil { - return metadata, err - } - metadata, ok = mappings.mappings[key] - if !ok { - return metadata, shared.ErrStorageKeyNotFound{Key: key.Hex()} - } - } - return metadata, nil -} - -func (mappings *PitMappings) loadMappings() error { - mappings.mappings = getStaticMappings() - ilks, err := mappings.StorageRepository.GetIlks() - if err != nil { - return err - } - for _, ilk := range ilks { - mappings.mappings[getSpotKey(ilk)] = getSpotMetadata(ilk) - mappings.mappings[getLineKey(ilk)] = getLineMetadata(ilk) - } - return nil -} - -func getStaticMappings() map[common.Hash]shared.StorageValueMetadata { - mappings := make(map[common.Hash]shared.StorageValueMetadata) - mappings[DripKey] = DripMetadata - mappings[LineKey] = LineMetadata - mappings[LiveKey] = LiveMetadata - mappings[VatKey] = VatMetadata - return mappings -} - -func getSpotKey(ilk string) common.Hash { - return storage_diffs.GetMapping(IlkSpotIndex, ilk) -} - -func getSpotMetadata(ilk string) shared.StorageValueMetadata { - keys := map[shared.Key]string{shared.Ilk: ilk} - return shared.GetStorageValueMetadata(IlkSpot, keys, shared.Uint256) -} - -func getLineKey(ilk string) common.Hash { - return storage_diffs.GetIncrementedKey(getSpotKey(ilk), 1) -} - -func getLineMetadata(ilk string) shared.StorageValueMetadata { - keys := map[shared.Key]string{shared.Ilk: ilk} - return shared.GetStorageValueMetadata(IlkLine, keys, shared.Uint256) -} diff --git a/pkg/transformers/storage_diffs/maker/pit/mappings_test.go b/pkg/transformers/storage_diffs/maker/pit/mappings_test.go deleted file mode 100644 index 7097a029..00000000 --- a/pkg/transformers/storage_diffs/maker/pit/mappings_test.go +++ /dev/null @@ -1,90 +0,0 @@ -package pit_test - -import ( - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/crypto" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - "github.com/vulcanize/vulcanizedb/pkg/fakes" - "github.com/vulcanize/vulcanizedb/pkg/transformers/storage_diffs/maker/pit" - "github.com/vulcanize/vulcanizedb/pkg/transformers/storage_diffs/maker/test_helpers" - "github.com/vulcanize/vulcanizedb/pkg/transformers/storage_diffs/shared" - "math/big" -) - -var _ = Describe("Pit storage mappings", func() { - Describe("looking up static keys", func() { - It("returns value metadata if key exists", func() { - storageRepository := &test_helpers.MockMakerStorageRepository{} - mappings := pit.PitMappings{StorageRepository: storageRepository} - - Expect(mappings.Lookup(pit.DripKey)).To(Equal(pit.DripMetadata)) - Expect(mappings.Lookup(pit.LineKey)).To(Equal(pit.LineMetadata)) - Expect(mappings.Lookup(pit.LiveKey)).To(Equal(pit.LiveMetadata)) - Expect(mappings.Lookup(pit.VatKey)).To(Equal(pit.VatMetadata)) - }) - - It("returns error if key does not exist", func() { - mappings := pit.PitMappings{StorageRepository: &test_helpers.MockMakerStorageRepository{}} - - _, err := mappings.Lookup(common.HexToHash(fakes.FakeHash.Hex())) - - Expect(err).To(HaveOccurred()) - Expect(err).To(MatchError(shared.ErrStorageKeyNotFound{Key: fakes.FakeHash.Hex()})) - }) - }) - - Describe("looking up dynamic keys", func() { - It("refreshes mappings from repository if key not found", func() { - storageRepository := &test_helpers.MockMakerStorageRepository{} - mappings := pit.PitMappings{StorageRepository: storageRepository} - - mappings.Lookup(fakes.FakeHash) - - Expect(storageRepository.GetIlksCalled).To(BeTrue()) - }) - - It("returns value metadata for spot when ilk in the DB", func() { - storageRepository := &test_helpers.MockMakerStorageRepository{} - fakeIlk := "fakeIlk" - storageRepository.Ilks = []string{fakeIlk} - mappings := pit.PitMappings{StorageRepository: storageRepository} - ilkSpotKey := common.BytesToHash(crypto.Keccak256(common.FromHex("0x" + fakeIlk + pit.IlkSpotIndex))) - expectedMetadata := shared.StorageValueMetadata{ - Name: pit.IlkSpot, - Keys: map[shared.Key]string{shared.Ilk: fakeIlk}, - Type: shared.Uint256, - } - - Expect(mappings.Lookup(ilkSpotKey)).To(Equal(expectedMetadata)) - }) - - It("returns value metadata for line when ilk in the DB", func() { - storageRepository := &test_helpers.MockMakerStorageRepository{} - fakeIlk := "fakeIlk" - storageRepository.Ilks = []string{fakeIlk} - mappings := pit.PitMappings{StorageRepository: storageRepository} - ilkSpotKeyBytes := crypto.Keccak256(common.FromHex("0x" + fakeIlk + pit.IlkSpotIndex)) - ilkSpotAsInt := big.NewInt(0).SetBytes(ilkSpotKeyBytes) - incrementedIlkSpot := big.NewInt(0).Add(ilkSpotAsInt, big.NewInt(1)) - ilkLineKey := common.BytesToHash(incrementedIlkSpot.Bytes()) - expectedMetadata := shared.StorageValueMetadata{ - Name: pit.IlkLine, - Keys: map[shared.Key]string{shared.Ilk: fakeIlk}, - Type: shared.Uint256, - } - - Expect(mappings.Lookup(ilkLineKey)).To(Equal(expectedMetadata)) - }) - - It("returns error if key not found", func() { - storageRepository := &test_helpers.MockMakerStorageRepository{} - mappings := pit.PitMappings{StorageRepository: storageRepository} - - _, err := mappings.Lookup(fakes.FakeHash) - - Expect(err).To(HaveOccurred()) - Expect(err).To(MatchError(shared.ErrStorageKeyNotFound{Key: fakes.FakeHash.Hex()})) - }) - }) -}) diff --git a/pkg/transformers/storage_diffs/maker/vat/mappings.go b/pkg/transformers/storage_diffs/maker/vat/mappings.go deleted file mode 100644 index 58e2bf6a..00000000 --- a/pkg/transformers/storage_diffs/maker/vat/mappings.go +++ /dev/null @@ -1,241 +0,0 @@ -package vat - -import ( - "github.com/ethereum/go-ethereum/common" - "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" - "github.com/vulcanize/vulcanizedb/pkg/transformers/storage_diffs" - "github.com/vulcanize/vulcanizedb/pkg/transformers/storage_diffs/maker" - "github.com/vulcanize/vulcanizedb/pkg/transformers/storage_diffs/shared" -) - -const ( - Dai = "dai" - Gem = "gem" - IlkArt = "Art" - IlkInk = "Ink" - IlkRate = "rate" - IlkTake = "take" - Sin = "sin" - UrnArt = "art" - UrnInk = "ink" - VatDebt = "debt" - VatVice = "vice" -) - -var ( - DebtKey = common.HexToHash(storage_diffs.IndexSix) - DebtMetadata = shared.StorageValueMetadata{ - Name: VatDebt, - Keys: nil, - Type: 0, - } - - IlksMappingIndex = storage_diffs.IndexOne - UrnsMappingIndex = storage_diffs.IndexTwo - GemsMappingIndex = storage_diffs.IndexThree - DaiMappingIndex = storage_diffs.IndexFour - SinMappingIndex = storage_diffs.IndexFive - - ViceKey = common.HexToHash(storage_diffs.IndexSeven) - ViceMetadata = shared.StorageValueMetadata{ - Name: VatVice, - Keys: nil, - Type: 0, - } -) - -type VatMappings struct { - StorageRepository maker.IMakerStorageRepository - mappings map[common.Hash]shared.StorageValueMetadata -} - -func (mappings VatMappings) Lookup(key common.Hash) (shared.StorageValueMetadata, error) { - metadata, ok := mappings.mappings[key] - if !ok { - err := mappings.loadMappings() - if err != nil { - return metadata, err - } - metadata, ok = mappings.mappings[key] - if !ok { - return metadata, shared.ErrStorageKeyNotFound{Key: key.Hex()} - } - } - return metadata, nil -} - -func (mappings *VatMappings) SetDB(db *postgres.DB) { - mappings.StorageRepository.SetDB(db) -} - -func (mappings *VatMappings) loadMappings() error { - mappings.mappings = loadStaticMappings() - daiErr := mappings.loadDaiKeys() - if daiErr != nil { - return daiErr - } - gemErr := mappings.loadGemKeys() - if gemErr != nil { - return gemErr - } - ilkErr := mappings.loadIlkKeys() - if ilkErr != nil { - return ilkErr - } - sinErr := mappings.loadSinKeys() - if sinErr != nil { - return sinErr - } - urnErr := mappings.loadUrnKeys() - if urnErr != nil { - return urnErr - } - return nil -} - -func loadStaticMappings() map[common.Hash]shared.StorageValueMetadata { - mappings := make(map[common.Hash]shared.StorageValueMetadata) - mappings[DebtKey] = DebtMetadata - mappings[ViceKey] = ViceMetadata - return mappings -} - -func (mappings *VatMappings) loadDaiKeys() error { - daiKeys, err := mappings.StorageRepository.GetDaiKeys() - if err != nil { - return err - } - for _, d := range daiKeys { - mappings.mappings[getDaiKey(d)] = getDaiMetadata(d) - } - return nil -} - -func (mappings *VatMappings) loadGemKeys() error { - gemKeys, err := mappings.StorageRepository.GetGemKeys() - if err != nil { - return err - } - for _, gem := range gemKeys { - mappings.mappings[getGemKey(gem.Ilk, gem.Guy)] = getGemMetadata(gem.Ilk, gem.Guy) - } - return nil -} - -func (mappings *VatMappings) loadIlkKeys() error { - ilks, err := mappings.StorageRepository.GetIlks() - if err != nil { - return err - } - for _, ilk := range ilks { - mappings.mappings[getIlkTakeKey(ilk)] = getIlkTakeMetadata(ilk) - mappings.mappings[getIlkRateKey(ilk)] = getIlkRateMetadata(ilk) - mappings.mappings[getIlkInkKey(ilk)] = getIlkInkMetadata(ilk) - mappings.mappings[getIlkArtKey(ilk)] = getIlkArtMetadata(ilk) - } - return nil -} - -func (mappings *VatMappings) loadSinKeys() error { - sinKeys, err := mappings.StorageRepository.GetSinKeys() - if err != nil { - return err - } - for _, s := range sinKeys { - mappings.mappings[getSinKey(s)] = getSinMetadata(s) - } - return nil -} - -func (mappings *VatMappings) loadUrnKeys() error { - urns, err := mappings.StorageRepository.GetUrns() - if err != nil { - return err - } - for _, urn := range urns { - mappings.mappings[getUrnInkKey(urn.Ilk, urn.Guy)] = getUrnInkMetadata(urn.Ilk, urn.Guy) - mappings.mappings[getUrnArtKey(urn.Ilk, urn.Guy)] = getUrnArtMetadata(urn.Ilk, urn.Guy) - } - return nil -} - -func getIlkTakeKey(ilk string) common.Hash { - return storage_diffs.GetMapping(IlksMappingIndex, ilk) -} - -func getIlkTakeMetadata(ilk string) shared.StorageValueMetadata { - keys := map[shared.Key]string{shared.Ilk: ilk} - return shared.GetStorageValueMetadata(IlkTake, keys, shared.Uint256) -} - -func getIlkRateKey(ilk string) common.Hash { - return storage_diffs.GetIncrementedKey(getIlkTakeKey(ilk), 1) -} - -func getIlkRateMetadata(ilk string) shared.StorageValueMetadata { - keys := map[shared.Key]string{shared.Ilk: ilk} - return shared.GetStorageValueMetadata(IlkRate, keys, shared.Uint256) -} - -func getIlkInkKey(ilk string) common.Hash { - return storage_diffs.GetIncrementedKey(getIlkTakeKey(ilk), 2) -} - -func getIlkInkMetadata(ilk string) shared.StorageValueMetadata { - keys := map[shared.Key]string{shared.Ilk: ilk} - return shared.GetStorageValueMetadata(IlkInk, keys, shared.Uint256) -} - -func getIlkArtKey(ilk string) common.Hash { - return storage_diffs.GetIncrementedKey(getIlkTakeKey(ilk), 3) -} - -func getIlkArtMetadata(ilk string) shared.StorageValueMetadata { - keys := map[shared.Key]string{shared.Ilk: ilk} - return shared.GetStorageValueMetadata(IlkArt, keys, shared.Uint256) -} - -func getUrnInkKey(ilk, guy string) common.Hash { - return storage_diffs.GetNestedMapping(UrnsMappingIndex, ilk, guy) -} - -func getUrnInkMetadata(ilk, guy string) shared.StorageValueMetadata { - keys := map[shared.Key]string{shared.Ilk: ilk, shared.Guy: guy} - return shared.GetStorageValueMetadata(UrnInk, keys, shared.Uint256) -} - -func getUrnArtKey(ilk, guy string) common.Hash { - return storage_diffs.GetIncrementedKey(getUrnInkKey(ilk, guy), 1) -} - -func getUrnArtMetadata(ilk, guy string) shared.StorageValueMetadata { - keys := map[shared.Key]string{shared.Ilk: ilk, shared.Guy: guy} - return shared.GetStorageValueMetadata(UrnArt, keys, shared.Uint256) -} - -func getGemKey(ilk, guy string) common.Hash { - return storage_diffs.GetNestedMapping(GemsMappingIndex, ilk, guy) -} - -func getGemMetadata(ilk, guy string) shared.StorageValueMetadata { - keys := map[shared.Key]string{shared.Ilk: ilk, shared.Guy: guy} - return shared.GetStorageValueMetadata(Gem, keys, shared.Uint256) -} - -func getDaiKey(guy string) common.Hash { - return storage_diffs.GetMapping(DaiMappingIndex, guy) -} - -func getDaiMetadata(guy string) shared.StorageValueMetadata { - keys := map[shared.Key]string{shared.Guy: guy} - return shared.GetStorageValueMetadata(Dai, keys, shared.Uint256) -} - -func getSinKey(guy string) common.Hash { - return storage_diffs.GetMapping(SinMappingIndex, guy) -} - -func getSinMetadata(guy string) shared.StorageValueMetadata { - keys := map[shared.Key]string{shared.Guy: guy} - return shared.GetStorageValueMetadata(Sin, keys, shared.Uint256) -} diff --git a/pkg/transformers/storage_diffs/maker/vat/mappings_test.go b/pkg/transformers/storage_diffs/maker/vat/mappings_test.go deleted file mode 100644 index 06f7a052..00000000 --- a/pkg/transformers/storage_diffs/maker/vat/mappings_test.go +++ /dev/null @@ -1,233 +0,0 @@ -package vat_test - -import ( - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/crypto" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - "github.com/vulcanize/vulcanizedb/pkg/fakes" - "github.com/vulcanize/vulcanizedb/pkg/transformers/storage_diffs/maker" - "github.com/vulcanize/vulcanizedb/pkg/transformers/storage_diffs/maker/test_helpers" - "github.com/vulcanize/vulcanizedb/pkg/transformers/storage_diffs/maker/vat" - "github.com/vulcanize/vulcanizedb/pkg/transformers/storage_diffs/shared" - "math/big" -) - -var _ = Describe("Vat storage mappings", func() { - var ( - fakeIlk = "fakeIlk" - fakeGuy = "fakeGuy" - storageRepository *test_helpers.MockMakerStorageRepository - mappings vat.VatMappings - ) - - BeforeEach(func() { - storageRepository = &test_helpers.MockMakerStorageRepository{} - mappings = vat.VatMappings{StorageRepository: storageRepository} - }) - - Describe("looking up static keys", func() { - It("returns value metadata if key exists", func() { - Expect(mappings.Lookup(vat.DebtKey)).To(Equal(vat.DebtMetadata)) - Expect(mappings.Lookup(vat.ViceKey)).To(Equal(vat.ViceMetadata)) - }) - - It("returns error if key does not exist", func() { - _, err := mappings.Lookup(common.HexToHash(fakes.FakeHash.Hex())) - - Expect(err).To(HaveOccurred()) - Expect(err).To(MatchError(shared.ErrStorageKeyNotFound{Key: fakes.FakeHash.Hex()})) - }) - }) - - Describe("looking up dynamic keys", func() { - It("refreshes mappings from repository if key not found", func() { - mappings.Lookup(fakes.FakeHash) - - Expect(storageRepository.GetDaiKeysCalled).To(BeTrue()) - Expect(storageRepository.GetGemKeysCalled).To(BeTrue()) - Expect(storageRepository.GetIlksCalled).To(BeTrue()) - Expect(storageRepository.GetSinKeysCalled).To(BeTrue()) - Expect(storageRepository.GetUrnsCalled).To(BeTrue()) - }) - - It("returns error if dai keys lookup fails", func() { - storageRepository.GetDaiKeysError = fakes.FakeError - - _, err := mappings.Lookup(fakes.FakeHash) - - Expect(err).To(HaveOccurred()) - Expect(err).To(MatchError(fakes.FakeError)) - }) - - It("returns error if gem keys lookup fails", func() { - storageRepository.GetGemKeysError = fakes.FakeError - - _, err := mappings.Lookup(fakes.FakeHash) - - Expect(err).To(HaveOccurred()) - Expect(err).To(MatchError(fakes.FakeError)) - }) - - It("returns error if ilks lookup fails", func() { - storageRepository.GetIlksError = fakes.FakeError - - _, err := mappings.Lookup(fakes.FakeHash) - - Expect(err).To(HaveOccurred()) - Expect(err).To(MatchError(fakes.FakeError)) - }) - - It("returns error if sin keys lookup fails", func() { - storageRepository.GetSinKeysError = fakes.FakeError - - _, err := mappings.Lookup(fakes.FakeHash) - - Expect(err).To(HaveOccurred()) - Expect(err).To(MatchError(fakes.FakeError)) - }) - - It("returns error if urns lookup fails", func() { - storageRepository.GetUrnsError = fakes.FakeError - - _, err := mappings.Lookup(fakes.FakeHash) - - Expect(err).To(HaveOccurred()) - Expect(err).To(MatchError(fakes.FakeError)) - }) - - Describe("ilk", func() { - It("returns value metadata for ilk take", func() { - storageRepository.Ilks = []string{fakeIlk} - ilkTakeKey := common.BytesToHash(crypto.Keccak256(common.FromHex("0x" + fakeIlk + vat.IlksMappingIndex))) - expectedMetadata := shared.StorageValueMetadata{ - Name: vat.IlkTake, - Keys: map[shared.Key]string{shared.Ilk: fakeIlk}, - Type: shared.Uint256, - } - - Expect(mappings.Lookup(ilkTakeKey)).To(Equal(expectedMetadata)) - }) - - It("returns value metadata for ilk rate", func() { - storageRepository.Ilks = []string{fakeIlk} - ilkTakeBytes := crypto.Keccak256(common.FromHex("0x" + fakeIlk + vat.IlksMappingIndex)) - ilkTakeAsInt := big.NewInt(0).SetBytes(ilkTakeBytes) - incrementedIlkTake := big.NewInt(0).Add(ilkTakeAsInt, big.NewInt(1)) - ilkRateKey := common.BytesToHash(incrementedIlkTake.Bytes()) - expectedMetadata := shared.StorageValueMetadata{ - Name: vat.IlkRate, - Keys: map[shared.Key]string{shared.Ilk: fakeIlk}, - Type: shared.Uint256, - } - - Expect(mappings.Lookup(ilkRateKey)).To(Equal(expectedMetadata)) - }) - - It("returns value metadata for ilk Ink", func() { - storageRepository.Ilks = []string{fakeIlk} - ilkTakeBytes := crypto.Keccak256(common.FromHex("0x" + fakeIlk + vat.IlksMappingIndex)) - ilkTakeAsInt := big.NewInt(0).SetBytes(ilkTakeBytes) - doubleIncrementedIlkTake := big.NewInt(0).Add(ilkTakeAsInt, big.NewInt(2)) - ilkInkKey := common.BytesToHash(doubleIncrementedIlkTake.Bytes()) - expectedMetadata := shared.StorageValueMetadata{ - Name: vat.IlkInk, - Keys: map[shared.Key]string{shared.Ilk: fakeIlk}, - Type: shared.Uint256, - } - - Expect(mappings.Lookup(ilkInkKey)).To(Equal(expectedMetadata)) - }) - - It("returns value metadata for ilk Art", func() { - storageRepository.Ilks = []string{fakeIlk} - ilkTakeBytes := crypto.Keccak256(common.FromHex("0x" + fakeIlk + vat.IlksMappingIndex)) - ilkTakeAsInt := big.NewInt(0).SetBytes(ilkTakeBytes) - tripleIncrementedIlkTake := big.NewInt(0).Add(ilkTakeAsInt, big.NewInt(3)) - ilkArtKey := common.BytesToHash(tripleIncrementedIlkTake.Bytes()) - expectedMetadata := shared.StorageValueMetadata{ - Name: vat.IlkArt, - Keys: map[shared.Key]string{shared.Ilk: fakeIlk}, - Type: shared.Uint256, - } - - Expect(mappings.Lookup(ilkArtKey)).To(Equal(expectedMetadata)) - }) - }) - - Describe("urn", func() { - It("returns value metadata for urn ink", func() { - storageRepository.Urns = []maker.Urn{{Ilk: fakeIlk, Guy: fakeGuy}} - encodedPrimaryMapIndex := crypto.Keccak256(common.FromHex("0x" + fakeIlk + vat.UrnsMappingIndex)) - encodedSecondaryMapIndex := crypto.Keccak256(common.FromHex(fakeGuy), encodedPrimaryMapIndex) - urnInkKey := common.BytesToHash(encodedSecondaryMapIndex) - expectedMetadata := shared.StorageValueMetadata{ - Name: vat.UrnInk, - Keys: map[shared.Key]string{shared.Ilk: fakeIlk, shared.Guy: fakeGuy}, - Type: shared.Uint256, - } - - Expect(mappings.Lookup(urnInkKey)).To(Equal(expectedMetadata)) - }) - - It("returns value metadata for urn art", func() { - storageRepository.Urns = []maker.Urn{{Ilk: fakeIlk, Guy: fakeGuy}} - encodedPrimaryMapIndex := crypto.Keccak256(common.FromHex("0x" + fakeIlk + vat.UrnsMappingIndex)) - urnInkAsInt := big.NewInt(0).SetBytes(crypto.Keccak256(common.FromHex(fakeGuy), encodedPrimaryMapIndex)) - incrementedUrnInk := big.NewInt(0).Add(urnInkAsInt, big.NewInt(1)) - urnArtKey := common.BytesToHash(incrementedUrnInk.Bytes()) - expectedMetadata := shared.StorageValueMetadata{ - Name: vat.UrnArt, - Keys: map[shared.Key]string{shared.Ilk: fakeIlk, shared.Guy: fakeGuy}, - Type: shared.Uint256, - } - - Expect(mappings.Lookup(urnArtKey)).To(Equal(expectedMetadata)) - }) - }) - - Describe("gem", func() { - It("returns value metadata for gem", func() { - storageRepository.GemKeys = []maker.Urn{{Ilk: fakeIlk, Guy: fakeGuy}} - encodedPrimaryMapIndex := crypto.Keccak256(common.FromHex("0x" + fakeIlk + vat.GemsMappingIndex)) - encodedSecondaryMapIndex := crypto.Keccak256(common.FromHex(fakeGuy), encodedPrimaryMapIndex) - gemKey := common.BytesToHash(encodedSecondaryMapIndex) - expectedMetadata := shared.StorageValueMetadata{ - Name: vat.Gem, - Keys: map[shared.Key]string{shared.Ilk: fakeIlk, shared.Guy: fakeGuy}, - Type: shared.Uint256, - } - - Expect(mappings.Lookup(gemKey)).To(Equal(expectedMetadata)) - }) - }) - - Describe("dai", func() { - It("returns value metadata for dai", func() { - storageRepository.DaiKeys = []string{fakeGuy} - daiKey := common.BytesToHash(crypto.Keccak256(common.FromHex("0x" + fakeGuy + vat.DaiMappingIndex))) - expectedMetadata := shared.StorageValueMetadata{ - Name: vat.Dai, - Keys: map[shared.Key]string{shared.Guy: fakeGuy}, - Type: shared.Uint256, - } - - Expect(mappings.Lookup(daiKey)).To(Equal(expectedMetadata)) - }) - }) - - Describe("when sin key exists in the db", func() { - It("returns value metadata for sin", func() { - storageRepository.SinKeys = []string{fakeGuy} - sinKey := common.BytesToHash(crypto.Keccak256(common.FromHex("0x" + fakeGuy + vat.SinMappingIndex))) - expectedMetadata := shared.StorageValueMetadata{ - Name: vat.Sin, - Keys: map[shared.Key]string{shared.Guy: fakeGuy}, - Type: shared.Uint256, - } - - Expect(mappings.Lookup(sinKey)).To(Equal(expectedMetadata)) - }) - }) - }) -}) diff --git a/pkg/transformers/tend/config.go b/pkg/transformers/tend/config.go deleted file mode 100644 index 8fc4f0c2..00000000 --- a/pkg/transformers/tend/config.go +++ /dev/null @@ -1,34 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package tend - -import ( - shared_t "github.com/vulcanize/vulcanizedb/libraries/shared/transformer" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" -) - -func GetTendConfig() shared_t.TransformerConfig { - return shared_t.TransformerConfig{ - TransformerName: constants.TendLabel, - ContractAddresses: []string{constants.FlapperContractAddress(), constants.FlipperContractAddress()}, - ContractAbi: constants.FlipperABI(), - Topic: constants.GetTendFunctionSignature(), - StartingBlockNumber: shared.MinInt64([]int64{constants.FlapperDeploymentBlock(), constants.FlipperDeploymentBlock()}), - EndingBlockNumber: -1, - } -} diff --git a/pkg/transformers/tend/converter.go b/pkg/transformers/tend/converter.go deleted file mode 100644 index 3f8602ce..00000000 --- a/pkg/transformers/tend/converter.go +++ /dev/null @@ -1,77 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package tend - -import ( - "encoding/json" - "errors" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared" - "math/big" - - "github.com/ethereum/go-ethereum/core/types" -) - -type TendConverter struct{} - -func (TendConverter) ToModels(ethLogs []types.Log) (results []interface{}, err error) { - for _, ethLog := range ethLogs { - err := validateLog(ethLog) - if err != nil { - return nil, err - } - - bidId := ethLog.Topics[2].Big() - guy := shared.GetHexWithoutPrefix(ethLog.Topics[1].Bytes()) - lot := ethLog.Topics[3].Big().String() - - lastDataItemStartIndex := len(ethLog.Data) - 32 - lastItem := ethLog.Data[lastDataItemStartIndex:] - last := big.NewInt(0).SetBytes(lastItem) - bidValue := last.String() - transactionIndex := ethLog.TxIndex - logIndex := ethLog.Index - - rawLog, err := json.Marshal(ethLog) - if err != nil { - return nil, err - } - - model := TendModel{ - BidId: bidId.String(), - Lot: lot, - Bid: bidValue, - Guy: guy, - LogIndex: logIndex, - TransactionIndex: transactionIndex, - Raw: rawLog, - } - results = append(results, model) - } - return results, err -} - -func validateLog(ethLog types.Log) error { - if len(ethLog.Data) <= 0 { - return errors.New("tend log note data is empty") - } - - if len(ethLog.Topics) < 4 { - return errors.New("tend log does not contain expected topics") - } - - return nil -} diff --git a/pkg/transformers/tend/converter_test.go b/pkg/transformers/tend/converter_test.go deleted file mode 100644 index 2ede2f08..00000000 --- a/pkg/transformers/tend/converter_test.go +++ /dev/null @@ -1,62 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package tend_test - -import ( - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/types" - "github.com/vulcanize/vulcanizedb/pkg/transformers/tend" - "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data" -) - -var _ = Describe("Tend TendConverter", func() { - var converter tend.TendConverter - - BeforeEach(func() { - converter = tend.TendConverter{} - }) - - Describe("ToModels", func() { - It("converts an eth log to a db model", func() { - models, err := converter.ToModels([]types.Log{test_data.TendLogNote}) - - Expect(err).NotTo(HaveOccurred()) - Expect(len(models)).To(Equal(1)) - Expect(models[0]).To(Equal(test_data.TendModel)) - }) - - It("returns an error if the log data is empty", func() { - emptyDataLog := test_data.TendLogNote - emptyDataLog.Data = []byte{} - _, err := converter.ToModels([]types.Log{emptyDataLog}) - - Expect(err).To(HaveOccurred()) - Expect(err).To(MatchError("tend log note data is empty")) - }) - - It("returns an error if the expected amount of topics aren't in the log", func() { - invalidLog := test_data.TendLogNote - invalidLog.Topics = []common.Hash{} - _, err := converter.ToModels([]types.Log{invalidLog}) - - Expect(err).To(MatchError("tend log does not contain expected topics")) - }) - }) -}) diff --git a/pkg/transformers/tend/model.go b/pkg/transformers/tend/model.go deleted file mode 100644 index 4c08ba11..00000000 --- a/pkg/transformers/tend/model.go +++ /dev/null @@ -1,27 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package tend - -type TendModel struct { - BidId string `db:"bid_id"` - Lot string - Bid string - Guy string - LogIndex uint `db:"log_idx"` - TransactionIndex uint `db:"tx_idx"` - Raw []byte `db:"raw_log"` -} diff --git a/pkg/transformers/tend/repository.go b/pkg/transformers/tend/repository.go deleted file mode 100644 index 89e3f08e..00000000 --- a/pkg/transformers/tend/repository.go +++ /dev/null @@ -1,100 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package tend - -import ( - "fmt" - - log "github.com/sirupsen/logrus" - - "github.com/vulcanize/vulcanizedb/pkg/core" - "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" -) - -type TendRepository struct { - db *postgres.DB -} - -func (repository TendRepository) Create(headerID int64, models []interface{}) error { - tx, dBaseErr := repository.db.Begin() - if dBaseErr != nil { - return dBaseErr - } - - tic, getTicErr := shared.GetTicInTx(headerID, tx) - if getTicErr != nil { - rollbackErr := tx.Rollback() - if rollbackErr != nil { - log.Error("failed to rollback ", rollbackErr) - } - return getTicErr - } - - for _, model := range models { - tend, ok := model.(TendModel) - if !ok { - rollbackErr := tx.Rollback() - if rollbackErr != nil { - log.Error("failed to rollback ", rollbackErr) - } - return fmt.Errorf("model of type %T, not %T", model, TendModel{}) - } - - _, execErr := tx.Exec( - `INSERT into maker.tend (header_id, bid_id, lot, bid, guy, tic, log_idx, tx_idx, raw_log) - VALUES($1, $2, $3::NUMERIC, $4::NUMERIC, $5, $6, $7, $8, $9) - ON CONFLICT (header_id, tx_idx, log_idx) DO UPDATE SET bid_id = $2, lot = $3, bid = $4, guy = $5, tic = $6, raw_log = $9;`, - headerID, tend.BidId, tend.Lot, tend.Bid, tend.Guy, tic, tend.LogIndex, tend.TransactionIndex, tend.Raw, - ) - - if execErr != nil { - rollbackErr := tx.Rollback() - if rollbackErr != nil { - log.Error("failed to rollback ", rollbackErr) - } - return execErr - } - } - - checkHeaderErr := shared.MarkHeaderCheckedInTransaction(headerID, tx, constants.TendChecked) - if checkHeaderErr != nil { - rollbackErr := tx.Rollback() - if rollbackErr != nil { - log.Error("failed to rollback ", rollbackErr) - } - return checkHeaderErr - } - return tx.Commit() -} - -func (repository TendRepository) MarkHeaderChecked(headerId int64) error { - return shared.MarkHeaderChecked(headerId, repository.db, constants.TendChecked) -} - -func (repository TendRepository) MissingHeaders(startingBlockNumber, endingBlockNumber int64) ([]core.Header, error) { - return shared.MissingHeaders(startingBlockNumber, endingBlockNumber, repository.db, constants.TendChecked) -} - -func (repository TendRepository) RecheckHeaders(startingBlockNumber, endingBlockNumber int64) ([]core.Header, error) { - return shared.RecheckHeaders(startingBlockNumber, endingBlockNumber, repository.db, constants.TendChecked) -} - -func (repository *TendRepository) SetDB(db *postgres.DB) { - repository.db = db -} diff --git a/pkg/transformers/tend/repository_test.go b/pkg/transformers/tend/repository_test.go deleted file mode 100644 index e8d3da73..00000000 --- a/pkg/transformers/tend/repository_test.go +++ /dev/null @@ -1,99 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package tend_test - -import ( - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - - "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" - "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres/repositories" - "github.com/vulcanize/vulcanizedb/pkg/fakes" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" - "github.com/vulcanize/vulcanizedb/pkg/transformers/tend" - "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data" - "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data/shared_behaviors" - "github.com/vulcanize/vulcanizedb/test_config" -) - -var _ = Describe("TendRepository", func() { - var ( - db *postgres.DB - tendRepository tend.TendRepository - headerRepository repositories.HeaderRepository - ) - - BeforeEach(func() { - db = test_config.NewTestDB(test_config.NewTestNode()) - test_config.CleanTestDB(db) - headerRepository = repositories.NewHeaderRepository(db) - tendRepository = tend.TendRepository{} - tendRepository.SetDB(db) - }) - - Describe("Create", func() { - modelWithDifferentLogIdx := test_data.TendModel - modelWithDifferentLogIdx.LogIndex = modelWithDifferentLogIdx.LogIndex + 1 - inputs := shared_behaviors.CreateBehaviorInputs{ - CheckedHeaderColumnName: constants.TendChecked, - LogEventTableName: "maker.tend", - TestModel: test_data.TendModel, - ModelWithDifferentLogIdx: modelWithDifferentLogIdx, - Repository: &tendRepository, - } - - shared_behaviors.SharedRepositoryCreateBehaviors(&inputs) - - It("persists a tend record", func() { - headerID, err := headerRepository.CreateOrUpdateHeader(fakes.FakeHeader) - Expect(err).NotTo(HaveOccurred()) - err = tendRepository.Create(headerID, []interface{}{test_data.TendModel}) - - Expect(err).NotTo(HaveOccurred()) - var count int - err = db.QueryRow(`SELECT count(*) from maker.tend`).Scan(&count) - Expect(err).NotTo(HaveOccurred()) - Expect(count).To(Equal(1)) - - dbResult := tend.TendModel{} - err = db.Get(&dbResult, `SELECT bid_id, lot, bid, guy, log_idx, tx_idx, raw_log FROM maker.tend WHERE header_id = $1`, headerID) - Expect(err).NotTo(HaveOccurred()) - - Expect(dbResult.BidId).To(Equal(test_data.TendModel.BidId)) - Expect(dbResult.Lot).To(Equal(test_data.TendModel.Lot)) - Expect(dbResult.Bid).To(Equal(test_data.TendModel.Bid)) - Expect(dbResult.Guy).To(Equal(test_data.TendModel.Guy)) - Expect(dbResult.LogIndex).To(Equal(test_data.TendModel.LogIndex)) - Expect(dbResult.TransactionIndex).To(Equal(test_data.TendModel.TransactionIndex)) - Expect(dbResult.Raw).To(MatchJSON(test_data.TendModel.Raw)) - - var dbTic int64 - err = db.Get(&dbTic, `SELECT tic FROM maker.tend WHERE header_id = $1`, headerID) - Expect(err).NotTo(HaveOccurred()) - Expect(dbTic).To(Equal(fakes.FakeHeaderTic)) - }) - }) - - Describe("MarkHeaderChecked", func() { - inputs := shared_behaviors.MarkedHeaderCheckedBehaviorInputs{ - CheckedHeaderColumnName: constants.TendChecked, - Repository: &tendRepository, - } - - shared_behaviors.SharedRepositoryMarkHeaderCheckedBehaviors(&inputs) - }) -}) diff --git a/pkg/transformers/tend/tend_suite_test.go b/pkg/transformers/tend/tend_suite_test.go deleted file mode 100644 index 828d2d10..00000000 --- a/pkg/transformers/tend/tend_suite_test.go +++ /dev/null @@ -1,19 +0,0 @@ -package tend_test - -import ( - log "github.com/sirupsen/logrus" - "io/ioutil" - "testing" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -func TestTend(t *testing.T) { - RegisterFailHandler(Fail) - RunSpecs(t, "Tend Suite") -} - -var _ = BeforeSuite(func() { - log.SetOutput(ioutil.Discard) -}) diff --git a/pkg/transformers/test_data/abi.go b/pkg/transformers/test_data/abi.go deleted file mode 100644 index 5bc04c28..00000000 --- a/pkg/transformers/test_data/abi.go +++ /dev/null @@ -1,14 +0,0 @@ -package test_data - -const ( - KovanCatABI = `[{"constant":true,"inputs":[],"name":"vat","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function","signature":"0x36569e77"},{"constant":true,"inputs":[],"name":"vow","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function","signature":"0x626cb3c5"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"flips","outputs":[{"name":"ilk","type":"bytes32"},{"name":"urn","type":"bytes32"},{"name":"ink","type":"uint256"},{"name":"tab","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function","signature":"0x70d9235a"},{"constant":true,"inputs":[],"name":"nflip","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function","signature":"0x76181a51"},{"constant":true,"inputs":[],"name":"live","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function","signature":"0x957aa58c"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"wards","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function","signature":"0xbf353dbb"},{"constant":true,"inputs":[{"name":"","type":"bytes32"}],"name":"ilks","outputs":[{"name":"flip","type":"address"},{"name":"chop","type":"uint256"},{"name":"lump","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function","signature":"0xd9638d36"},{"constant":true,"inputs":[],"name":"pit","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function","signature":"0xf03c7c6e"},{"inputs":[{"name":"vat_","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor","signature":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"ilk","type":"bytes32"},{"indexed":true,"name":"urn","type":"bytes32"},{"indexed":false,"name":"ink","type":"uint256"},{"indexed":false,"name":"art","type":"uint256"},{"indexed":false,"name":"tab","type":"uint256"},{"indexed":false,"name":"flip","type":"uint256"},{"indexed":false,"name":"iArt","type":"uint256"}],"name":"Bite","type":"event","signature":"0x99b5620489b6ef926d4518936cfec15d305452712b88bd59da2d9c10fb0953e8"},{"anonymous":true,"inputs":[{"indexed":true,"name":"sig","type":"bytes4"},{"indexed":true,"name":"guy","type":"address"},{"indexed":true,"name":"foo","type":"bytes32"},{"indexed":true,"name":"bar","type":"bytes32"},{"indexed":false,"name":"wad","type":"uint256"},{"indexed":false,"name":"fax","type":"bytes"}],"name":"LogNote","type":"event","signature":"0x644843f351d3fba4abcd60109eaff9f54bac8fb8ccf0bab941009c21df21cf31"},{"constant":false,"inputs":[{"name":"guy","type":"address"}],"name":"rely","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function","signature":"0x65fae35e"},{"constant":false,"inputs":[{"name":"guy","type":"address"}],"name":"deny","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function","signature":"0x9c52a7f1"},{"constant":false,"inputs":[{"name":"ilk","type":"bytes32"},{"name":"what","type":"bytes32"},{"name":"data","type":"uint256"}],"name":"file","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function","signature":"0x1a0b287e"},{"constant":false,"inputs":[{"name":"what","type":"bytes32"},{"name":"data","type":"address"}],"name":"file","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function","signature":"0xd4e8be83"},{"constant":false,"inputs":[{"name":"ilk","type":"bytes32"},{"name":"what","type":"bytes32"},{"name":"flip","type":"address"}],"name":"file","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function","signature":"0xebecb39d"},{"constant":false,"inputs":[{"name":"ilk","type":"bytes32"},{"name":"urn","type":"bytes32"}],"name":"bite","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function","signature":"0x72f7b593"},{"constant":false,"inputs":[{"name":"n","type":"uint256"},{"name":"wad","type":"uint256"}],"name":"flip","outputs":[{"name":"id","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function","signature":"0xe6f95917"}]` - KovanDripABI = `[{"constant":true,"inputs":[],"name":"vat","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function","signature":"0x36569e77"},{"constant":true,"inputs":[],"name":"repo","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function","signature":"0x56ff3122"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"wards","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function","signature":"0xbf353dbb"},{"constant":true,"inputs":[{"name":"","type":"bytes32"}],"name":"ilks","outputs":[{"name":"vow","type":"bytes32"},{"name":"tax","type":"uint256"},{"name":"rho","type":"uint48"}],"payable":false,"stateMutability":"view","type":"function","signature":"0xd9638d36"},{"inputs":[{"name":"vat_","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor","signature":"constructor"},{"anonymous":true,"inputs":[{"indexed":true,"name":"sig","type":"bytes4"},{"indexed":true,"name":"guy","type":"address"},{"indexed":true,"name":"foo","type":"bytes32"},{"indexed":true,"name":"bar","type":"bytes32"},{"indexed":false,"name":"wad","type":"uint256"},{"indexed":false,"name":"fax","type":"bytes"}],"name":"LogNote","type":"event","signature":"0x644843f351d3fba4abcd60109eaff9f54bac8fb8ccf0bab941009c21df21cf31"},{"constant":false,"inputs":[{"name":"guy","type":"address"}],"name":"rely","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function","signature":"0x65fae35e"},{"constant":false,"inputs":[{"name":"guy","type":"address"}],"name":"deny","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function","signature":"0x9c52a7f1"},{"constant":true,"inputs":[],"name":"era","outputs":[{"name":"","type":"uint48"}],"payable":false,"stateMutability":"view","type":"function","signature":"0x143e55e0"},{"constant":false,"inputs":[{"name":"ilk","type":"bytes32"},{"name":"vow","type":"bytes32"},{"name":"tax","type":"uint256"}],"name":"file","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function","signature":"0x1a0b287e"},{"constant":false,"inputs":[{"name":"what","type":"bytes32"},{"name":"data","type":"uint256"}],"name":"file","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function","signature":"0x29ae8114"},{"constant":false,"inputs":[{"name":"ilk","type":"bytes32"}],"name":"drip","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function","signature":"0x44e2a5a8"}]` - KovanFlapperABI = `[{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"bids","outputs":[{"name":"bid","type":"uint256"},{"name":"lot","type":"uint256"},{"name":"guy","type":"address"},{"name":"tic","type":"uint48"},{"name":"end","type":"uint48"},{"name":"gal","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"ttl","outputs":[{"name":"","type":"uint48"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"gem","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"beg","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"tau","outputs":[{"name":"","type":"uint48"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"kicks","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"dai","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[{"name":"dai_","type":"address"},{"name":"gem_","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"id","type":"uint256"},{"indexed":false,"name":"lot","type":"uint256"},{"indexed":false,"name":"bid","type":"uint256"},{"indexed":false,"name":"gal","type":"address"},{"indexed":false,"name":"end","type":"uint48"}],"name":"Kick","type":"event"},{"anonymous":true,"inputs":[{"indexed":true,"name":"sig","type":"bytes4"},{"indexed":true,"name":"guy","type":"address"},{"indexed":true,"name":"foo","type":"bytes32"},{"indexed":true,"name":"bar","type":"bytes32"},{"indexed":false,"name":"wad","type":"uint256"},{"indexed":false,"name":"fax","type":"bytes"}],"name":"LogNote","type":"event"},{"constant":false,"inputs":[{"name":"gal","type":"address"},{"name":"lot","type":"uint256"},{"name":"bid","type":"uint256"}],"name":"kick","outputs":[{"name":"id","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"id","type":"uint256"},{"name":"lot","type":"uint256"},{"name":"bid","type":"uint256"}],"name":"tend","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"id","type":"uint256"}],"name":"deal","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}]` - KovanFlipperABI = `[{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"bids","outputs":[{"name":"bid","type":"uint256"},{"name":"lot","type":"uint256"},{"name":"guy","type":"address"},{"name":"tic","type":"uint48"},{"name":"end","type":"uint48"},{"name":"urn","type":"bytes32"},{"name":"gal","type":"address"},{"name":"tab","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function","signature":"0x4423c5f1"},{"constant":true,"inputs":[],"name":"ttl","outputs":[{"name":"","type":"uint48"}],"payable":false,"stateMutability":"view","type":"function","signature":"0x4e8b1dd5"},{"constant":true,"inputs":[],"name":"gem","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function","signature":"0x7bd2bea7"},{"constant":true,"inputs":[],"name":"beg","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function","signature":"0x7d780d82"},{"constant":true,"inputs":[],"name":"tau","outputs":[{"name":"","type":"uint48"}],"payable":false,"stateMutability":"view","type":"function","signature":"0xcfc4af55"},{"constant":true,"inputs":[],"name":"kicks","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function","signature":"0xcfdd3302"},{"constant":true,"inputs":[],"name":"dai","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function","signature":"0xf4b9fa75"},{"inputs":[{"name":"dai_","type":"address"},{"name":"gem_","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor","signature":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"id","type":"uint256"},{"indexed":false,"name":"lot","type":"uint256"},{"indexed":false,"name":"bid","type":"uint256"},{"indexed":false,"name":"gal","type":"address"},{"indexed":false,"name":"end","type":"uint48"},{"indexed":true,"name":"urn","type":"bytes32"},{"indexed":false,"name":"tab","type":"uint256"}],"name":"Kick","type":"event","signature":"0xbac86238bdba81d21995024470425ecb370078fa62b7271b90cf28cbd1e3e87e"},{"anonymous":true,"inputs":[{"indexed":true,"name":"sig","type":"bytes4"},{"indexed":true,"name":"guy","type":"address"},{"indexed":true,"name":"foo","type":"bytes32"},{"indexed":true,"name":"bar","type":"bytes32"},{"indexed":false,"name":"wad","type":"uint256"},{"indexed":false,"name":"fax","type":"bytes"}],"name":"LogNote","type":"event","signature":"0x644843f351d3fba4abcd60109eaff9f54bac8fb8ccf0bab941009c21df21cf31"},{"constant":true,"inputs":[],"name":"era","outputs":[{"name":"","type":"uint48"}],"payable":false,"stateMutability":"view","type":"function","signature":"0x143e55e0"},{"constant":false,"inputs":[{"name":"urn","type":"bytes32"},{"name":"gal","type":"address"},{"name":"tab","type":"uint256"},{"name":"lot","type":"uint256"},{"name":"bid","type":"uint256"}],"name":"kick","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function","signature":"0xeae19d9e"},{"constant":false,"inputs":[{"name":"id","type":"uint256"}],"name":"tick","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function","signature":"0xfc7b6aee"},{"constant":false,"inputs":[{"name":"id","type":"uint256"},{"name":"lot","type":"uint256"},{"name":"bid","type":"uint256"}],"name":"tend","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function","signature":"0x4b43ed12"},{"constant":false,"inputs":[{"name":"id","type":"uint256"},{"name":"lot","type":"uint256"},{"name":"bid","type":"uint256"}],"name":"dent","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function","signature":"0x5ff3a382"},{"constant":false,"inputs":[{"name":"id","type":"uint256"}],"name":"deal","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function","signature":"0xc959c42b"}]` - KovanFlopperABI = `[{"constant":true,"inputs":[],"name":"era","outputs":[{"name":"","type":"uint48"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"bids","outputs":[{"name":"bid","type":"uint256"},{"name":"lot","type":"uint256"},{"name":"guy","type":"address"},{"name":"tic","type":"uint48"},{"name":"end","type":"uint48"},{"name":"vow","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"ttl","outputs":[{"name":"","type":"uint48"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"id","type":"uint256"},{"name":"lot","type":"uint256"},{"name":"bid","type":"uint256"}],"name":"dent","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"guy","type":"address"}],"name":"rely","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"gem","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"beg","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"guy","type":"address"}],"name":"deny","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"gal","type":"address"},{"name":"lot","type":"uint256"},{"name":"bid","type":"uint256"}],"name":"kick","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"wards","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"id","type":"uint256"}],"name":"deal","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"tau","outputs":[{"name":"","type":"uint48"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"kicks","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"dai","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[{"name":"dai_","type":"address"},{"name":"gem_","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"id","type":"uint256"},{"indexed":false,"name":"lot","type":"uint256"},{"indexed":false,"name":"bid","type":"uint256"},{"indexed":false,"name":"gal","type":"address"},{"indexed":false,"name":"end","type":"uint48"}],"name":"Kick","type":"event"},{"anonymous":true,"inputs":[{"indexed":true,"name":"sig","type":"bytes4"},{"indexed":true,"name":"guy","type":"address"},{"indexed":true,"name":"foo","type":"bytes32"},{"indexed":true,"name":"bar","type":"bytes32"},{"indexed":false,"name":"wad","type":"uint256"},{"indexed":false,"name":"fax","type":"bytes"}],"name":"LogNote","type":"event"}]` - KovanMedianizerABI = `[{"constant":false,"inputs":[{"name":"owner_","type":"address"}],"name":"setOwner","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"","type":"bytes32"}],"name":"poke","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"poke","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"compute","outputs":[{"name":"","type":"bytes32"},{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"wat","type":"address"}],"name":"set","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"wat","type":"address"}],"name":"unset","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"indexes","outputs":[{"name":"","type":"bytes12"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"next","outputs":[{"name":"","type":"bytes12"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"read","outputs":[{"name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"peek","outputs":[{"name":"","type":"bytes32"},{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"bytes12"}],"name":"values","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"min_","type":"uint96"}],"name":"setMin","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"authority_","type":"address"}],"name":"setAuthority","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"void","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"pos","type":"bytes12"},{"name":"wat","type":"address"}],"name":"set","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"authority","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"pos","type":"bytes12"}],"name":"unset","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"next_","type":"bytes12"}],"name":"setNext","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"min","outputs":[{"name":"","type":"uint96"}],"payable":false,"stateMutability":"view","type":"function"},{"anonymous":false,"inputs":[{"indexed":false,"name":"val","type":"bytes32"}],"name":"LogValue","type":"event"},{"anonymous":true,"inputs":[{"indexed":true,"name":"sig","type":"bytes4"},{"indexed":true,"name":"guy","type":"address"},{"indexed":true,"name":"foo","type":"bytes32"},{"indexed":true,"name":"bar","type":"bytes32"},{"indexed":false,"name":"wad","type":"uint256"},{"indexed":false,"name":"fax","type":"bytes"}],"name":"LogNote","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"authority","type":"address"}],"name":"LogSetAuthority","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"owner","type":"address"}],"name":"LogSetOwner","type":"event"}]]` - // TODO: replace with updated ABI when contract is deployed (with no pit file stability fee method + modified Frob event) - KovanPitABI = `[{"constant":true,"inputs":[],"name":"vat","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function","signature":"0x36569e77"},{"constant":true,"inputs":[],"name":"live","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function","signature":"0x957aa58c"},{"constant":true,"inputs":[],"name":"drip","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function","signature":"0x9f678cca"},{"constant":true,"inputs":[],"name":"Line","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function","signature":"0xbabe8a3f"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"wards","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function","signature":"0xbf353dbb"},{"constant":true,"inputs":[{"name":"","type":"bytes32"}],"name":"ilks","outputs":[{"name":"spot","type":"uint256"},{"name":"line","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function","signature":"0xd9638d36"},{"inputs":[{"name":"vat_","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor","signature":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"ilk","type":"bytes32"},{"indexed":true,"name":"urn","type":"bytes32"},{"indexed":false,"name":"ink","type":"uint256"},{"indexed":false,"name":"art","type":"uint256"},{"indexed":false,"name":"dink","type":"int256"},{"indexed":false,"name":"dart","type":"int256"},{"indexed":false,"name":"iArt","type":"uint256"}],"name":"Frob","type":"event","signature":"0xb2afa28318bcc689926b52835d844de174ef8de97e982a85c0199d584920791b"},{"anonymous":true,"inputs":[{"indexed":true,"name":"sig","type":"bytes4"},{"indexed":true,"name":"guy","type":"address"},{"indexed":true,"name":"foo","type":"bytes32"},{"indexed":true,"name":"bar","type":"bytes32"},{"indexed":false,"name":"wad","type":"uint256"},{"indexed":false,"name":"fax","type":"bytes"}],"name":"LogNote","type":"event","signature":"0x644843f351d3fba4abcd60109eaff9f54bac8fb8ccf0bab941009c21df21cf31"},{"constant":false,"inputs":[{"name":"guy","type":"address"}],"name":"rely","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function","signature":"0x65fae35e"},{"constant":false,"inputs":[{"name":"guy","type":"address"}],"name":"deny","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function","signature":"0x9c52a7f1"},{"constant":false,"inputs":[{"name":"ilk","type":"bytes32"},{"name":"what","type":"bytes32"},{"name":"data","type":"uint256"}],"name":"file","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function","signature":"0x1a0b287e"},{"constant":false,"inputs":[{"name":"what","type":"bytes32"},{"name":"data","type":"uint256"}],"name":"file","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function","signature":"0x29ae8114"},{"constant":false,"inputs":[{"name":"what","type":"bytes32"},{"name":"data","type":"address"}],"name":"file","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function","signature":"0xd4e8be83"},{"constant":false,"inputs":[{"name":"ilk","type":"bytes32"},{"name":"dink","type":"int256"},{"name":"dart","type":"int256"}],"name":"frob","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function","signature":"0x5a984ded"}]` - KovanVatABI = `[{"constant":true,"inputs":[],"name":"debt","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function","signature":"0x0dca59c1"},{"constant":true,"inputs":[{"name":"","type":"bytes32"},{"name":"","type":"bytes32"}],"name":"urns","outputs":[{"name":"ink","type":"uint256"},{"name":"art","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function","signature":"0x26e27482"},{"constant":true,"inputs":[],"name":"vice","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function","signature":"0x2d61a355"},{"constant":true,"inputs":[{"name":"","type":"bytes32"}],"name":"sin","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function","signature":"0xa60f1d3e"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"wards","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function","signature":"0xbf353dbb"},{"constant":true,"inputs":[{"name":"","type":"bytes32"},{"name":"","type":"bytes32"}],"name":"gem","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function","signature":"0xc0912683"},{"constant":true,"inputs":[{"name":"","type":"bytes32"}],"name":"ilks","outputs":[{"name":"take","type":"uint256"},{"name":"rate","type":"uint256"},{"name":"Ink","type":"uint256"},{"name":"Art","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function","signature":"0xd9638d36"},{"constant":true,"inputs":[{"name":"","type":"bytes32"}],"name":"dai","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function","signature":"0xf53e4e69"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor","signature":"constructor"},{"anonymous":true,"inputs":[{"indexed":true,"name":"sig","type":"bytes4"},{"indexed":true,"name":"foo","type":"bytes32"},{"indexed":true,"name":"bar","type":"bytes32"},{"indexed":true,"name":"too","type":"bytes32"},{"indexed":false,"name":"fax","type":"bytes"}],"name":"Note","type":"event","signature":"0x8c2dbbc2b33ffaa77c104b777e574a8a4ff79829dfee8b66f4dc63e3f8067152"},{"constant":false,"inputs":[{"name":"guy","type":"address"}],"name":"rely","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function","signature":"0x65fae35e"},{"constant":false,"inputs":[{"name":"guy","type":"address"}],"name":"deny","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function","signature":"0x9c52a7f1"},{"constant":false,"inputs":[{"name":"ilk","type":"bytes32"}],"name":"init","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function","signature":"0x3b663195"},{"constant":false,"inputs":[{"name":"ilk","type":"bytes32"},{"name":"guy","type":"bytes32"},{"name":"rad","type":"int256"}],"name":"slip","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function","signature":"0x42066cbb"},{"constant":false,"inputs":[{"name":"ilk","type":"bytes32"},{"name":"src","type":"bytes32"},{"name":"dst","type":"bytes32"},{"name":"rad","type":"int256"}],"name":"flux","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function","signature":"0xa6e41821"},{"constant":false,"inputs":[{"name":"src","type":"bytes32"},{"name":"dst","type":"bytes32"},{"name":"rad","type":"int256"}],"name":"move","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function","signature":"0x78f19470"},{"constant":false,"inputs":[{"name":"i","type":"bytes32"},{"name":"u","type":"bytes32"},{"name":"v","type":"bytes32"},{"name":"w","type":"bytes32"},{"name":"dink","type":"int256"},{"name":"dart","type":"int256"}],"name":"tune","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function","signature":"0x5dd6471a"},{"constant":false,"inputs":[{"name":"i","type":"bytes32"},{"name":"u","type":"bytes32"},{"name":"v","type":"bytes32"},{"name":"w","type":"bytes32"},{"name":"dink","type":"int256"},{"name":"dart","type":"int256"}],"name":"grab","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function","signature":"0x3690ae4c"},{"constant":false,"inputs":[{"name":"u","type":"bytes32"},{"name":"v","type":"bytes32"},{"name":"rad","type":"int256"}],"name":"heal","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function","signature":"0x990a5f63"},{"constant":false,"inputs":[{"name":"i","type":"bytes32"},{"name":"u","type":"bytes32"},{"name":"rate","type":"int256"}],"name":"fold","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function","signature":"0xe6a6a64d"},{"constant":false,"inputs":[{"name":"i","type":"bytes32"},{"name":"u","type":"bytes32"},{"name":"take","type":"int256"}],"name":"toll","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function","signature":"0x09b7a0b5"}]` - KovanVowABI = `[{"constant":true,"inputs":[],"name":"Awe","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"Joy","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"flap","outputs":[{"name":"id","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"hump","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"wad","type":"uint256"}],"name":"kiss","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"what","type":"bytes32"},{"name":"data","type":"uint256"}],"name":"file","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"Ash","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"era","type":"uint48"}],"name":"flog","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"vat","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"Woe","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"wait","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"guy","type":"address"}],"name":"rely","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"bump","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"tab","type":"uint256"}],"name":"fess","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"row","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint48"}],"name":"sin","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"guy","type":"address"}],"name":"deny","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"flop","outputs":[{"name":"id","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"wards","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"sump","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"Sin","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"what","type":"bytes32"},{"name":"addr","type":"address"}],"name":"file","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"cow","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"wad","type":"uint256"}],"name":"heal","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":true,"inputs":[{"indexed":true,"name":"sig","type":"bytes4"},{"indexed":true,"name":"guy","type":"address"},{"indexed":true,"name":"foo","type":"bytes32"},{"indexed":true,"name":"bar","type":"bytes32"},{"indexed":false,"name":"wad","type":"uint256"},{"indexed":false,"name":"fax","type":"bytes"}],"name":"LogNote","type":"event"}]` -) diff --git a/pkg/transformers/test_data/addresses.go b/pkg/transformers/test_data/addresses.go deleted file mode 100644 index 67c8e582..00000000 --- a/pkg/transformers/test_data/addresses.go +++ /dev/null @@ -1,15 +0,0 @@ -package test_data - -const ( - KovanCatContractAddress = "0x2f34f22a00ee4b7a8f8bbc4eaee1658774c624e0" - KovanDripContractAddress = "0x891c04639a5edcae088e546fa125b5d7fb6a2b9d" - KovanFlapperContractAddress = "0x8868BAd8e74FcA4505676D1B5B21EcC23328d132" - KovanFlipperContractAddress = "0x32D496Ad866D110060866B7125981C73642cc509" - KovanFlopperContractAddress = "0x6191C9b0086c2eBF92300cC507009b53996FbFFa" - KovanPepContractAddress = "0xB1997239Cfc3d15578A3a09730f7f84A90BB4975" - KovanPipContractAddress = "0x9FfFE440258B79c5d6604001674A4722FfC0f7Bc" - KovanPitContractAddress = "0xe7cf3198787c9a4daac73371a38f29aaeeced87e" - KovanRepContractAddress = "0xf88bBDc1E2718F8857F30A180076ec38d53cf296" - KovanVatContractAddress = "0xcd726790550afcd77e9a7a47e86a3f9010af126b" - KovanVowContractAddress = "0x3728e9777B2a0a611ee0F89e00E01044ce4736d1" -) diff --git a/pkg/transformers/test_data/bite.go b/pkg/transformers/test_data/bite.go deleted file mode 100644 index 7456684e..00000000 --- a/pkg/transformers/test_data/bite.go +++ /dev/null @@ -1,88 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package test_data - -import ( - "encoding/json" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/ethereum/go-ethereum/core/types" - "github.com/vulcanize/vulcanizedb/pkg/fakes" - "github.com/vulcanize/vulcanizedb/pkg/transformers/bite" - "math/big" -) - -const ( - TemporaryBiteBlockNumber = int64(26) - TemporaryBiteData = "0x00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000300000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000005" - TemporaryBiteTransaction = "0x5c698f13940a2153440c6d19660878bc90219d9298fdcf37365aa8d88d40fc42" -) - -var ( - biteInk = big.NewInt(1) - biteArt = big.NewInt(2) - biteTab = big.NewInt(3) - biteFlip = big.NewInt(4) - biteIArt = big.NewInt(5) - biteRawJson, _ = json.Marshal(EthBiteLog) - biteIlk = [32]byte{69, 84, 72, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} - biteLad = [32]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 216, 180, 20, 126, 218, 128, 254, 199, 18, 42, 225, 109, 162, 71, 156, 189, 127, 251} - biteIlkString = "4554480000000000000000000000000000000000000000000000000000000000" - biteLadString = "0000000000000000000000000000d8b4147eda80fec7122ae16da2479cbd7ffb" -) - -var EthBiteLog = types.Log{ - Address: common.HexToAddress("0x2f34f22a00ee4b7a8f8bbc4eaee1658774c624e0"), - Topics: []common.Hash{ - common.HexToHash("0x99b5620489b6ef926d4518936cfec15d305452712b88bd59da2d9c10fb0953e8"), - common.HexToHash("0x4554480000000000000000000000000000000000000000000000000000000000"), - common.HexToHash("0x0000000000000000000000000000d8b4147eda80fec7122ae16da2479cbd7ffb"), - }, - Data: hexutil.MustDecode(TemporaryBiteData), - BlockNumber: uint64(TemporaryBiteBlockNumber), - TxHash: common.HexToHash(TemporaryBiteTransaction), - TxIndex: 111, - BlockHash: fakes.FakeHash, - Index: 7, - Removed: false, -} - -var BiteEntity = bite.BiteEntity{ - Ilk: biteIlk, - Urn: biteLad, - Ink: biteInk, - Art: biteArt, - Tab: biteTab, - Flip: biteFlip, - IArt: biteIArt, - LogIndex: EthBiteLog.Index, - TransactionIndex: EthBiteLog.TxIndex, - Raw: EthBiteLog, -} - -var BiteModel = bite.BiteModel{ - Ilk: biteIlkString, - Urn: biteLadString, - Ink: biteInk.String(), - Art: biteArt.String(), - IArt: biteIArt.String(), - Tab: biteTab.String(), - NFlip: biteFlip.String(), - LogIndex: EthBiteLog.Index, - TransactionIndex: EthBiteLog.TxIndex, - Raw: biteRawJson, -} diff --git a/pkg/transformers/test_data/cat_file.go b/pkg/transformers/test_data/cat_file.go deleted file mode 100644 index 180262a6..00000000 --- a/pkg/transformers/test_data/cat_file.go +++ /dev/null @@ -1,133 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package test_data - -import ( - "encoding/json" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/ethereum/go-ethereum/core/types" - "github.com/vulcanize/vulcanizedb/pkg/fakes" - "github.com/vulcanize/vulcanizedb/pkg/transformers/cat_file/chop_lump" - "github.com/vulcanize/vulcanizedb/pkg/transformers/cat_file/flip" - "github.com/vulcanize/vulcanizedb/pkg/transformers/cat_file/pit_vow" -) - -var EthCatFileChopLog = types.Log{ - Address: common.HexToAddress(KovanCatContractAddress), - Topics: []common.Hash{ - common.HexToHash("0x1a0b287e00000000000000000000000000000000000000000000000000000000"), - common.HexToHash("0x00000000000000000000000064d922894153be9eef7b7218dc565d1d0ce2a092"), - common.HexToHash("0x66616b6520696c6b000000000000000000000000000000000000000000000000"), - common.HexToHash("0x63686f7000000000000000000000000000000000000000000000000000000000"), - }, - Data: hexutil.MustDecode("0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000641a0b287e66616b6520696c6b00000000000000000000000000000000000000000000000063686f700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000018EE90FF6C373E0EE4E3F0AD2"), - BlockNumber: 110, - TxHash: common.HexToHash("0xe32dfe6afd7ea28475569756fc30f0eea6ad4cfd32f67436ff1d1c805e4382df"), - TxIndex: 13, - BlockHash: fakes.FakeHash, - Index: 1, - Removed: false, -} -var rawCatFileChopLog, _ = json.Marshal(EthCatFileChopLog) -var CatFileChopModel = chop_lump.CatFileChopLumpModel{ - Ilk: "66616b6520696c6b000000000000000000000000000000000000000000000000", - What: "chop", - Data: "123.456789012345680589533003513", - TransactionIndex: EthCatFileChopLog.TxIndex, - LogIndex: EthCatFileChopLog.Index, - Raw: rawCatFileChopLog, -} - -var EthCatFileLumpLog = types.Log{ - Address: common.HexToAddress(KovanCatContractAddress), - Topics: []common.Hash{ - common.HexToHash("0x1a0b287e00000000000000000000000000000000000000000000000000000000"), - common.HexToHash("0x00000000000000000000000064d922894153be9eef7b7218dc565d1d0ce2a092"), - common.HexToHash("0x66616b6520696c6b000000000000000000000000000000000000000000000000"), - common.HexToHash("0x6c756d7000000000000000000000000000000000000000000000000000000000"), - }, - Data: hexutil.MustDecode("0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000641a0b287e66616b6520696c6b00000000000000000000000000000000000000000000000063686f700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000029D42B64E76714244CB"), - BlockNumber: 110, - TxHash: common.HexToHash("0xe32dfe6afd7ea28475569756fc30f0eea6ad4cfd32f67436ff1d1c805e4382df"), - TxIndex: 15, - BlockHash: fakes.FakeHash, - Index: 3, - Removed: false, -} -var rawCatFileLumpLog, _ = json.Marshal(EthCatFileLumpLog) -var CatFileLumpModel = chop_lump.CatFileChopLumpModel{ - Ilk: "66616b6520696c6b000000000000000000000000000000000000000000000000", - What: "lump", - Data: "12345.678901234567092615", - TransactionIndex: EthCatFileLumpLog.TxIndex, - LogIndex: EthCatFileLumpLog.Index, - Raw: rawCatFileLumpLog, -} - -var EthCatFileFlipLog = types.Log{ - Address: common.HexToAddress(KovanCatContractAddress), - Topics: []common.Hash{ - common.HexToHash("0xebecb39d00000000000000000000000000000000000000000000000000000000"), - common.HexToHash("0x00000000000000000000000064d922894153be9eef7b7218dc565d1d0ce2a092"), - common.HexToHash("0x66616b6520696c6b000000000000000000000000000000000000000000000000"), - common.HexToHash("0x666c697000000000000000000000000000000000000000000000000000000000"), - }, - Data: hexutil.MustDecode("0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000064ebecb39d66616b6520696c6b000000000000000000000000000000000000000000000000666c69700000000000000000000000000000000000000000000000000000000000000000000000000000000007fa9ef6609ca7921112231f8f195138ebba2977"), - BlockNumber: 88, - TxHash: common.HexToHash("0xc71ef3e9999595913d31e89446cab35319bd4289520e55611a1b42fc2a8463b6"), - TxIndex: 12, - BlockHash: fakes.FakeHash, - Index: 1, - Removed: false, -} - -var rawCatFileFlipLog, _ = json.Marshal(EthCatFileFlipLog) -var CatFileFlipModel = flip.CatFileFlipModel{ - Ilk: "66616b6520696c6b000000000000000000000000000000000000000000000000", - What: "flip", - Flip: "0x07Fa9eF6609cA7921112231F8f195138ebbA2977", - TransactionIndex: EthCatFileFlipLog.TxIndex, - LogIndex: EthCatFileFlipLog.Index, - Raw: rawCatFileFlipLog, -} - -var EthCatFilePitVowLog = types.Log{ - Address: common.HexToAddress(KovanCatContractAddress), - Topics: []common.Hash{ - common.HexToHash("0xd4e8be8300000000000000000000000000000000000000000000000000000000"), - common.HexToHash("0x00000000000000000000000064d922894153be9eef7b7218dc565d1d0ce2a092"), - common.HexToHash("0x7069740000000000000000000000000000000000000000000000000000000000"), - common.HexToHash("0x0000000000000000000000008e84a1e068d77059cbe263c43ad0cdc130863313"), - }, - Data: hexutil.MustDecode("0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000044d4e8be8370697400000000000000000000000000000000000000000000000000000000000000000000000000000000008e84a1e068d77059cbe263c43ad0cdc130863313"), - BlockNumber: 87, - TxHash: common.HexToHash("0x6515c7dfe53f0ad83ce1173fa99032c24a07cfd8b5d5a1c1f80486c99dd52800"), - TxIndex: 11, - BlockHash: fakes.FakeHash, - Index: 2, - Removed: false, -} - -var rawCatFilePitVowLog, _ = json.Marshal(EthCatFilePitVowLog) -var CatFilePitVowModel = pit_vow.CatFilePitVowModel{ - What: "pit", - Data: "0x8E84a1e068d77059Cbe263C43AD0cDc130863313", - TransactionIndex: EthCatFilePitVowLog.TxIndex, - LogIndex: EthCatFilePitVowLog.Index, - Raw: rawCatFilePitVowLog, -} diff --git a/pkg/transformers/test_data/deal.go b/pkg/transformers/test_data/deal.go deleted file mode 100644 index ab1e64cf..00000000 --- a/pkg/transformers/test_data/deal.go +++ /dev/null @@ -1,52 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package test_data - -import ( - "encoding/json" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/ethereum/go-ethereum/core/types" - "github.com/vulcanize/vulcanizedb/pkg/fakes" - "github.com/vulcanize/vulcanizedb/pkg/transformers/deal" -) - -var DealLogNote = types.Log{ - Address: common.HexToAddress(KovanFlipperContractAddress), - Topics: []common.Hash{ - common.HexToHash("0xc959c42b00000000000000000000000000000000000000000000000000000000"), - common.HexToHash("0x00000000000000000000000064d922894153be9eef7b7218dc565d1d0ce2a092"), - common.HexToHash("0x000000000000000000000000000000000000000000000000000000000000007b"), - common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000000"), - }, - Data: hexutil.MustDecode("0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000024c959c42b000000000000000000000000000000000000000000000000000000000000007b"), - BlockNumber: 16, - TxHash: common.HexToHash("0xc6ff19de9299e5b290ba2d52fdb4662360ca86376613d78ee546244866a0be2d"), - TxIndex: 74, - BlockHash: fakes.FakeHash, - Index: 75, - Removed: false, -} -var dealRawJson, _ = json.Marshal(DealLogNote) - -var DealModel = deal.DealModel{ - BidId: "123", - ContractAddress: KovanFlipperContractAddress, - LogIndex: DealLogNote.Index, - TransactionIndex: DealLogNote.TxIndex, - Raw: dealRawJson, -} diff --git a/pkg/transformers/test_data/dent.go b/pkg/transformers/test_data/dent.go deleted file mode 100644 index 027bf0be..00000000 --- a/pkg/transformers/test_data/dent.go +++ /dev/null @@ -1,64 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package test_data - -import ( - "encoding/json" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/ethereum/go-ethereum/core/types" - "github.com/vulcanize/vulcanizedb/pkg/fakes" - "github.com/vulcanize/vulcanizedb/pkg/transformers/dent" - "strconv" -) - -var ( - DentData = "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000645ff3a382000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000098a7d9b8314c000000000000000000000000000000000000000000000000000029a2241af62c0000" - DentTransactionHash = "0x5a210319fcd31eea5959fedb4a1b20881c21a21976e23ff19dff3b44cc1c71e8" - dentBidId = int64(1) - dentLot = "11000000000000000000" - dentBid = "3000000000000000000" - dentGuy = "0x64d922894153BE9EEf7b7218dc565d1D0Ce2a092" - dentRawJson, _ = json.Marshal(DentLog) -) - -var DentLog = types.Log{ - Address: common.HexToAddress(KovanFlipperContractAddress), - Topics: []common.Hash{ - common.HexToHash("0x5ff3a38200000000000000000000000000000000000000000000000000000000"), - common.HexToHash("0x00000000000000000000000064d922894153be9eef7b7218dc565d1d0ce2a092"), - common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000001"), - common.HexToHash("0x00000000000000000000000000000000000000000000000098a7d9b8314c0000"), - }, - Data: hexutil.MustDecode(DentData), - BlockNumber: 15, - TxHash: common.HexToHash(DentTransactionHash), - TxIndex: 5, - BlockHash: fakes.FakeHash, - Index: 2, - Removed: false, -} - -var DentModel = dent.DentModel{ - BidId: strconv.FormatInt(dentBidId, 10), - Lot: dentLot, - Bid: dentBid, - Guy: dentGuy, - LogIndex: DentLog.Index, - TransactionIndex: DentLog.TxIndex, - Raw: dentRawJson, -} diff --git a/pkg/transformers/test_data/drip_drip.go b/pkg/transformers/test_data/drip_drip.go deleted file mode 100644 index f87382e0..00000000 --- a/pkg/transformers/test_data/drip_drip.go +++ /dev/null @@ -1,51 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package test_data - -import ( - "encoding/json" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/ethereum/go-ethereum/core/types" - "github.com/vulcanize/vulcanizedb/pkg/fakes" - "github.com/vulcanize/vulcanizedb/pkg/transformers/drip_drip" -) - -var EthDripDripLog = types.Log{ - Address: common.HexToAddress(KovanDripContractAddress), - Topics: []common.Hash{ - common.HexToHash("0x44e2a5a800000000000000000000000000000000000000000000000000000000"), - common.HexToHash("0x00000000000000000000000064d922894153be9eef7b7218dc565d1d0ce2a092"), - common.HexToHash("0x66616b6520696c6b000000000000000000000000000000000000000000000000"), - common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000000"), - }, - Data: hexutil.MustDecode("0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000002444e2a5a866616b6520696c6b000000000000000000000000000000000000000000000000"), - BlockNumber: 62, - TxHash: common.HexToHash("0xa34fd5cfcb125ebfc81d33633495701b531753669712092bdb8aa6159a240040"), - TxIndex: 10, - BlockHash: fakes.FakeHash, - Index: 11, - Removed: false, -} - -var rawDripDripLog, _ = json.Marshal(EthDripDripLog) -var DripDripModel = drip_drip.DripDripModel{ - Ilk: "66616b6520696c6b000000000000000000000000000000000000000000000000", - LogIndex: EthDripDripLog.Index, - TransactionIndex: EthDripDripLog.TxIndex, - Raw: rawDripDripLog, -} diff --git a/pkg/transformers/test_data/drip_file.go b/pkg/transformers/test_data/drip_file.go deleted file mode 100644 index bc393128..00000000 --- a/pkg/transformers/test_data/drip_file.go +++ /dev/null @@ -1,108 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package test_data - -import ( - "encoding/json" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/ethereum/go-ethereum/core/types" - "github.com/vulcanize/vulcanizedb/pkg/fakes" - ilk2 "github.com/vulcanize/vulcanizedb/pkg/transformers/drip_file/ilk" - "github.com/vulcanize/vulcanizedb/pkg/transformers/drip_file/repo" - "github.com/vulcanize/vulcanizedb/pkg/transformers/drip_file/vow" - "math/big" -) - -var EthDripFileIlkLog = types.Log{ - Address: common.HexToAddress(KovanDripContractAddress), - Topics: []common.Hash{ - common.HexToHash("0x1a0b287e00000000000000000000000000000000000000000000000000000000"), - common.HexToHash("0x00000000000000000000000064d922894153be9eef7b7218dc565d1d0ce2a092"), - common.HexToHash("0x66616b6520696c6b000000000000000000000000000000000000000000000000"), - common.HexToHash("0x66616b6520766f77000000000000000000000000000000000000000000000000"), - }, - Data: hexutil.MustDecode("0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000641a0b287e66616b6520696c6b00000000000000000000000000000000000000000000000066616b6520766f77000000000000000000000000000000000000000000000000000000000000000000000000000000000000009B3F7188CE95D16E5AE0000000"), - BlockNumber: 35, - TxHash: common.HexToHash("0xa1c31b7e6389470902237161263558615e60b40f2e63060b2f4aeafe92d57e5f"), - TxIndex: 12, - BlockHash: fakes.FakeHash, - Index: 15, - Removed: false, -} - -var rawDripFileIlkLog, _ = json.Marshal(EthDripFileIlkLog) -var DripFileIlkModel = ilk2.DripFileIlkModel{ - Ilk: "66616b6520696c6b000000000000000000000000000000000000000000000000", - Vow: "66616b6520766f77000000000000000000000000000000000000000000000000", - Tax: "12300.000000000000000000000000000", - LogIndex: EthDripFileIlkLog.Index, - TransactionIndex: EthDripFileIlkLog.TxIndex, - Raw: rawDripFileIlkLog, -} - -var EthDripFileRepoLog = types.Log{ - Address: common.HexToAddress(KovanDripContractAddress), - Topics: []common.Hash{ - common.HexToHash("0x29ae811400000000000000000000000000000000000000000000000000000000"), - common.HexToHash("0x00000000000000000000000064d922894153be9eef7b7218dc565d1d0ce2a092"), - common.HexToHash("0x66616b6520776861740000000000000000000000000000000000000000000000"), - common.HexToHash("0x000000000000000000000000000000000000000000000000000000000000007b"), - }, - Data: hexutil.MustDecode("0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000004429ae811466616b6520776861740000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007b"), - BlockNumber: 36, - TxHash: common.HexToHash("0xeeaa16de1d91c239b66773e8c2116a26cfeaaf5d962b31466c9bf047a5caa20f"), - TxIndex: 13, - BlockHash: fakes.FakeHash, - Index: 16, - Removed: false, -} - -var rawDripFileRepoLog, _ = json.Marshal(EthDripFileRepoLog) -var DripFileRepoModel = repo.DripFileRepoModel{ - What: "fake what", - Data: big.NewInt(123).String(), - LogIndex: EthDripFileRepoLog.Index, - TransactionIndex: EthDripFileRepoLog.TxIndex, - Raw: rawDripFileRepoLog, -} - -var EthDripFileVowLog = types.Log{ - Address: common.HexToAddress(KovanDripContractAddress), - Topics: []common.Hash{ - common.HexToHash("0xe9b674b900000000000000000000000000000000000000000000000000000000"), - common.HexToHash("0x00000000000000000000000064d922894153be9eef7b7218dc565d1d0ce2a092"), - common.HexToHash("0x766f770000000000000000000000000000000000000000000000000000000000"), - common.HexToHash("0x0000000000000000000000003728e9777b2a0a611ee0f89e00e01044ce4736d1"), - }, - Data: hexutil.MustDecode("0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000044e9b674b966616b652077686174000000000000000000000000000000000000000000000066616b6520646174610000000000000000000000000000000000000000000000"), - BlockNumber: 51, - TxHash: common.HexToHash("0x586e26b71b41fcd6905044dbe8f0cca300517542278f74a9b925c4f800fed85c"), - TxIndex: 14, - BlockHash: fakes.FakeHash, - Index: 17, - Removed: false, -} - -var rawDripFileVowLog, _ = json.Marshal(EthDripFileVowLog) -var DripFileVowModel = vow.DripFileVowModel{ - What: "vow", - Data: "0x3728e9777B2a0a611ee0F89e00E01044ce4736d1", - LogIndex: EthDripFileVowLog.Index, - TransactionIndex: EthDripFileVowLog.TxIndex, - Raw: rawDripFileVowLog, -} diff --git a/pkg/transformers/test_data/flap_kick.go b/pkg/transformers/test_data/flap_kick.go deleted file mode 100644 index d8d87201..00000000 --- a/pkg/transformers/test_data/flap_kick.go +++ /dev/null @@ -1,50 +0,0 @@ -package test_data - -import ( - "encoding/json" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/ethereum/go-ethereum/core/types" - "github.com/vulcanize/vulcanizedb/pkg/fakes" - "github.com/vulcanize/vulcanizedb/pkg/transformers/flap_kick" - "math/big" - "time" -) - -var EthFlapKickLog = types.Log{ - Address: common.HexToAddress(KovanFlapperContractAddress), - Topics: []common.Hash{ - common.HexToHash("0xefa52d9342a199cb30efd2692463f2c2bef63cd7186b50382d4fb94ad207880e"), - common.HexToHash("0x00000000000000000000000000000000000000000000000000000000069f6bc7"), - }, - Data: hexutil.MustDecode("0x000000000000000000000000000000000000000000000000000000003ade68b100000000000000000000000000000000000000000000000000000000075bcd150000000000000000000000007d7bee5fcfd8028cf7b00876c5b1421c800561a6000000000000000000000000000000000000000000000000000000005be469c5"), - BlockNumber: 65, - TxHash: common.HexToHash("0xee7930b76b6e93974bd3f37824644ae42a89a3887a1131a7bcb3267ab4dc0169"), - TxIndex: 66, - BlockHash: fakes.FakeHash, - Index: 67, - Removed: false, -} - -var FlapKickEntity = flap_kick.FlapKickEntity{ - Id: big.NewInt(111111111), - Lot: big.NewInt(987654321), - Bid: big.NewInt(123456789), - Gal: common.HexToAddress("0x7d7bEe5fCfD8028cf7b00876C5b1421c800561A6"), - End: big.NewInt(1541695941), - Raw: EthFlapKickLog, - TransactionIndex: EthFlapKickLog.TxIndex, - LogIndex: EthFlapKickLog.Index, -} - -var rawFlapKickLog, _ = json.Marshal(EthFlapKickLog) -var FlapKickModel = flap_kick.FlapKickModel{ - BidId: FlapKickEntity.Id.String(), - Lot: FlapKickEntity.Lot.String(), - Bid: FlapKickEntity.Bid.String(), - Gal: FlapKickEntity.Gal.String(), - End: time.Unix(1541695941, 0), - Raw: rawFlapKickLog, - TransactionIndex: EthFlapKickLog.TxIndex, - LogIndex: EthFlapKickLog.Index, -} diff --git a/pkg/transformers/test_data/flip_kick.go b/pkg/transformers/test_data/flip_kick.go deleted file mode 100644 index 16d62d50..00000000 --- a/pkg/transformers/test_data/flip_kick.go +++ /dev/null @@ -1,100 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package test_data - -import ( - "encoding/json" - "github.com/vulcanize/vulcanizedb/pkg/fakes" - "math/big" - "time" - - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/ethereum/go-ethereum/core/types" - - "github.com/vulcanize/vulcanizedb/pkg/transformers/flip_kick" -) - -var ( - idString = "1" - id, _ = new(big.Int).SetString(idString, 10) - lotString = "100" - lot, _ = new(big.Int).SetString(lotString, 10) - bidString = "0" - bid = new(big.Int).SetBytes([]byte{0}) - gal = "0x07Fa9eF6609cA7921112231F8f195138ebbA2977" - end = int64(1535991025) - urnBytes = [32]byte{115, 64, 224, 6, 244, 19, 91, 166, 151, 13, 67, 191, 67, 216, 141, 202, 212, 231, 168, 202, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} - urnString = "0x7340e006f4135BA6970D43bf43d88DCAD4e7a8CA" - tabString = "50" - tab, _ = new(big.Int).SetString(tabString, 10) - rawLog, _ = json.Marshal(EthFlipKickLog) -) - -var ( - flipKickTransactionHash = "0xd11ab35cfb1ad71f790d3dd488cc1a2046080e765b150e8997aa0200947d4a9b" - flipKickData = "0x0000000000000000000000000000000000000000000000000000000000000064000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007fa9ef6609ca7921112231f8f195138ebba2977000000000000000000000000000000000000000000000000000000005b8d5cf10000000000000000000000000000000000000000000000000000000000000032" - FlipKickBlockNumber = int64(10) -) - -var EthFlipKickLog = types.Log{ - Address: common.HexToAddress(KovanFlipperContractAddress), - Topics: []common.Hash{ - common.HexToHash("0xbac86238bdba81d21995024470425ecb370078fa62b7271b90cf28cbd1e3e87e"), - common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000001"), - common.HexToHash("0x7340e006f4135ba6970d43bf43d88dcad4e7a8ca000000000000000000000000"), - }, - Data: hexutil.MustDecode(flipKickData), - BlockNumber: uint64(FlipKickBlockNumber), - TxHash: common.HexToHash(flipKickTransactionHash), - TxIndex: 999, - BlockHash: fakes.FakeHash, - Index: 1, - Removed: false, -} - -var FlipKickEntity = flip_kick.FlipKickEntity{ - Id: id, - Lot: lot, - Bid: bid, - Gal: common.HexToAddress(gal), - End: big.NewInt(end), - Urn: urnBytes, - Tab: tab, - TransactionIndex: EthFlipKickLog.TxIndex, - LogIndex: EthFlipKickLog.Index, - Raw: EthFlipKickLog, -} - -var FlipKickModel = flip_kick.FlipKickModel{ - BidId: idString, - Lot: lotString, - Bid: bidString, - Gal: gal, - End: time.Unix(end, 0), - Urn: urnString, - Tab: tabString, - TransactionIndex: EthFlipKickLog.TxIndex, - LogIndex: EthFlipKickLog.Index, - Raw: rawLog, -} - -type FlipKickDBRow struct { - ID int64 - HeaderId int64 `db:"header_id"` - flip_kick.FlipKickModel -} diff --git a/pkg/transformers/test_data/flop_kick.go b/pkg/transformers/test_data/flop_kick.go deleted file mode 100644 index a573e271..00000000 --- a/pkg/transformers/test_data/flop_kick.go +++ /dev/null @@ -1,82 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package test_data - -import ( - "encoding/json" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/ethereum/go-ethereum/core/types" - "github.com/vulcanize/vulcanizedb/pkg/fakes" - "github.com/vulcanize/vulcanizedb/pkg/transformers/flop_kick" - "math/big" - "strconv" - "time" -) - -var ( - FlopKickLog = types.Log{ - Address: common.HexToAddress(KovanFlopperContractAddress), - Topics: []common.Hash{ - common.HexToHash("0xefa52d9342a199cb30efd2692463f2c2bef63cd7186b50382d4fb94ad207880e"), - common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000005"), - }, - Data: hexutil.MustDecode("0x000000000000000000000000000000000000000000000000000000000000000f00000000000000000000000000000000000000000000000000000000000000020000000000000000000000007d7bee5fcfd8028cf7b00876c5b1421c800561a6000000000000000000000000000000000000000000000000000000000002a300"), - BlockNumber: 19, - TxHash: common.HexToHash("0xd8fd67b37a6aa64a3cef4937204765183b180d8dc92eecd0d233f445526d31b5"), - TxIndex: flopTxIndex, - BlockHash: fakes.FakeHash, - Index: 32, - Removed: false, - } - - flopTxIndex = uint(33) - flopBidId = int64(5) - flopLot = int64(15) - flopBid = int64(2) - flopGal = "0x7d7bEe5fCfD8028cf7b00876C5b1421c800561A6" - rawFlopLogJson, _ = json.Marshal(FlopKickLog) - flopEnd = int64(172800) - - FlopKickEntity = flop_kick.Entity{ - Id: big.NewInt(flopBidId), - Lot: big.NewInt(flopLot), - Bid: big.NewInt(flopBid), - Gal: common.HexToAddress(flopGal), - End: big.NewInt(flopEnd), - TransactionIndex: flopTxIndex, - LogIndex: FlopKickLog.Index, - Raw: FlopKickLog, - } - - FlopKickModel = flop_kick.Model{ - BidId: strconv.FormatInt(flopBidId, 10), - Lot: strconv.FormatInt(flopLot, 10), - Bid: strconv.FormatInt(flopBid, 10), - Gal: flopGal, - End: time.Unix(flopEnd, 0), - TransactionIndex: flopTxIndex, - LogIndex: FlopKickLog.Index, - Raw: rawFlopLogJson, - } -) - -type FlopKickDBResult struct { - Id int64 - HeaderId int64 `db:"header_id"` - flop_kick.Model -} diff --git a/pkg/transformers/test_data/frob.go b/pkg/transformers/test_data/frob.go deleted file mode 100644 index 9b0aad05..00000000 --- a/pkg/transformers/test_data/frob.go +++ /dev/null @@ -1,89 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package test_data - -import ( - "encoding/json" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/ethereum/go-ethereum/core/types" - "github.com/vulcanize/vulcanizedb/pkg/fakes" - "github.com/vulcanize/vulcanizedb/pkg/transformers/frob" - "math/big" -) - -var ( - TemporaryFrobBlockNumber = int64(13) - TemporaryFrobData = "0x000000000000000000000000000000000000000000000000000000000000000f0000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000019" - TemporaryFrobTransaction = "0xbcff98316acb5732891d1a7e02f23ec12fbf8c231ca4b5530fa7a21c1e9b6aa9" -) - -var ( - // need to set bytes as 0 or else the big Int 0 evaluates differently from the one unpacked by the abi - art = big.NewInt(20) - dink = big.NewInt(10) - dart = big.NewInt(0).SetBytes([]byte{0}) - iArt = big.NewInt(25) - frobLad = [32]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 100, 217, 34, 137, 65, 83, 190, 158, 239, 123, 114, 24, 220, 86, 93, 29, 12, 226, 160, 146} - ink = big.NewInt(15) - ilk = [32]byte{102, 97, 107, 101, 32, 105, 108, 107, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} - frobIlkString = "66616b6520696c6b000000000000000000000000000000000000000000000000" - frobUrnString = "00000000000000000000000064d922894153be9eef7b7218dc565d1d0ce2a092" -) - -var EthFrobLog = types.Log{ - Address: common.HexToAddress(KovanPitContractAddress), - Topics: []common.Hash{ - common.HexToHash("0xb2afa28318bcc689926b52835d844de174ef8de97e982a85c0199d584920791b"), - common.HexToHash("0x66616b6520696c6b000000000000000000000000000000000000000000000000"), - common.HexToHash("0x00000000000000000000000064d922894153be9eef7b7218dc565d1d0ce2a092"), - }, - Data: hexutil.MustDecode(TemporaryFrobData), - BlockNumber: uint64(TemporaryFrobBlockNumber), - TxHash: common.HexToHash(TemporaryFrobTransaction), - TxIndex: 123, - BlockHash: fakes.FakeHash, - Index: 7, - Removed: false, -} - -var FrobEntity = frob.FrobEntity{ - Ilk: ilk, - Urn: frobLad, - Ink: ink, - Art: art, - Dink: dink, - Dart: dart, - IArt: iArt, - LogIndex: EthFrobLog.Index, - TransactionIndex: EthFrobLog.TxIndex, - Raw: EthFrobLog, -} - -var rawFrobLog, _ = json.Marshal(EthFrobLog) -var FrobModel = frob.FrobModel{ - Ilk: frobIlkString, - Urn: frobUrnString, - Ink: ink.String(), - Art: art.String(), - Dink: dink.String(), - Dart: dart.String(), - IArt: iArt.String(), - LogIndex: EthFrobLog.Index, - TransactionIndex: EthFrobLog.TxIndex, - Raw: rawFrobLog, -} diff --git a/pkg/transformers/test_data/generic.go b/pkg/transformers/test_data/generic.go deleted file mode 100644 index d373dd6c..00000000 --- a/pkg/transformers/test_data/generic.go +++ /dev/null @@ -1,60 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package test_data - -import ( - "math/rand" - "time" - - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/types" - shared_t "github.com/vulcanize/vulcanizedb/libraries/shared/transformer" -) - -type GenericModel struct{} -type GenericEntity struct{} - -var startingBlockNumber = rand.Int63() -var topic = "0x" + randomString(64) -var address = "0x" + randomString(38) - -var GenericTestLogs = []types.Log{{ - Address: common.HexToAddress(address), - Topics: []common.Hash{common.HexToHash(topic)}, - BlockNumber: uint64(startingBlockNumber), -}} - -var GenericTestConfig = shared_t.TransformerConfig{ - TransformerName: "generic-test-transformer", - ContractAddresses: []string{address}, - ContractAbi: randomString(100), - Topic: topic, - StartingBlockNumber: startingBlockNumber, - EndingBlockNumber: startingBlockNumber + 1, -} - -func randomString(length int) string { - var seededRand *rand.Rand = rand.New( - rand.NewSource(time.Now().UnixNano())) - charset := "abcdefghijklmnopqrstuvwxyz1234567890" - b := make([]byte, length) - for i := range b { - b[i] = charset[seededRand.Intn(len(charset))] - } - - return string(b) -} diff --git a/pkg/transformers/test_data/mocks/converter.go b/pkg/transformers/test_data/mocks/converter.go deleted file mode 100644 index fae4302d..00000000 --- a/pkg/transformers/test_data/mocks/converter.go +++ /dev/null @@ -1,42 +0,0 @@ -package mocks - -import ( - "github.com/ethereum/go-ethereum/core/types" -) - -type MockConverter struct { - ToEntitiesError error - PassedContractAddresses []string - ToModelsError error - entityConverterError error - modelConverterError error - ContractAbi string - LogsToConvert []types.Log - EntitiesToConvert []interface{} - EntitiesToReturn []interface{} - ModelsToReturn []interface{} - ToEntitiesCalledCounter int - ToModelsCalledCounter int -} - -func (converter *MockConverter) ToEntities(contractAbi string, ethLogs []types.Log) ([]interface{}, error) { - for _, log := range ethLogs { - converter.PassedContractAddresses = append(converter.PassedContractAddresses, log.Address.Hex()) - } - converter.ContractAbi = contractAbi - converter.LogsToConvert = ethLogs - return converter.EntitiesToReturn, converter.ToEntitiesError -} - -func (converter *MockConverter) ToModels(entities []interface{}) ([]interface{}, error) { - converter.EntitiesToConvert = entities - return converter.ModelsToReturn, converter.ToModelsError -} - -func (converter *MockConverter) SetToEntityConverterError(err error) { - converter.entityConverterError = err -} - -func (c *MockConverter) SetToModelConverterError(err error) { - c.modelConverterError = err -} diff --git a/pkg/transformers/test_data/mocks/log_fetcher.go b/pkg/transformers/test_data/mocks/log_fetcher.go deleted file mode 100644 index bd73276c..00000000 --- a/pkg/transformers/test_data/mocks/log_fetcher.go +++ /dev/null @@ -1,54 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package mocks - -import ( - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/types" - "github.com/vulcanize/vulcanizedb/pkg/core" -) - -type MockLogFetcher struct { - FetchedContractAddresses [][]common.Address - FetchedTopics [][]common.Hash - FetchedBlocks []int64 - fetcherError error - FetchedLogs []types.Log - SetBcCalled bool - FetchLogsCalled bool -} - -func (mlf *MockLogFetcher) FetchLogs(contractAddresses []common.Address, topics []common.Hash, header core.Header) ([]types.Log, error) { - mlf.FetchedContractAddresses = append(mlf.FetchedContractAddresses, contractAddresses) - mlf.FetchedTopics = [][]common.Hash{topics} - mlf.FetchedBlocks = append(mlf.FetchedBlocks, header.BlockNumber) - mlf.FetchLogsCalled = true - - return mlf.FetchedLogs, mlf.fetcherError -} - -func (mlf *MockLogFetcher) SetBC(bc core.BlockChain) { - mlf.SetBcCalled = true -} - -func (mlf *MockLogFetcher) SetFetcherError(err error) { - mlf.fetcherError = err -} - -func (mlf *MockLogFetcher) SetFetchedLogs(logs []types.Log) { - mlf.FetchedLogs = logs -} diff --git a/pkg/transformers/test_data/mocks/log_note_converter.go b/pkg/transformers/test_data/mocks/log_note_converter.go deleted file mode 100644 index 9a43434e..00000000 --- a/pkg/transformers/test_data/mocks/log_note_converter.go +++ /dev/null @@ -1,26 +0,0 @@ -package mocks - -import ( - "github.com/ethereum/go-ethereum/core/types" -) - -type MockLogNoteConverter struct { - err error - returnModels []interface{} - PassedLogs []types.Log - ToModelsCalledCounter int -} - -func (converter *MockLogNoteConverter) ToModels(ethLogs []types.Log) ([]interface{}, error) { - converter.PassedLogs = ethLogs - converter.ToModelsCalledCounter++ - return converter.returnModels, converter.err -} - -func (converter *MockLogNoteConverter) SetConverterError(e error) { - converter.err = e -} - -func (converter *MockLogNoteConverter) SetReturnModels(models []interface{}) { - converter.returnModels = models -} diff --git a/pkg/transformers/test_data/mocks/mappings.go b/pkg/transformers/test_data/mocks/mappings.go deleted file mode 100644 index 18ab4a08..00000000 --- a/pkg/transformers/test_data/mocks/mappings.go +++ /dev/null @@ -1,22 +0,0 @@ -package mocks - -import ( - "github.com/ethereum/go-ethereum/common" - "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" - "github.com/vulcanize/vulcanizedb/pkg/transformers/storage_diffs/shared" -) - -type MockMappings struct { - Metadata shared.StorageValueMetadata - LookupCalled bool - LookupErr error -} - -func (mappings *MockMappings) Lookup(key common.Hash) (shared.StorageValueMetadata, error) { - mappings.LookupCalled = true - return mappings.Metadata, mappings.LookupErr -} - -func (*MockMappings) SetDB(db *postgres.DB) { - panic("implement me") -} diff --git a/pkg/transformers/test_data/mocks/repository.go b/pkg/transformers/test_data/mocks/repository.go deleted file mode 100644 index a19e7f86..00000000 --- a/pkg/transformers/test_data/mocks/repository.go +++ /dev/null @@ -1,82 +0,0 @@ -package mocks - -import ( - . "github.com/onsi/gomega" - - "github.com/vulcanize/vulcanizedb/pkg/core" - "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" -) - -type MockRepository struct { - createError error - markHeaderCheckedError error - MarkHeaderCheckedPassedHeaderIDs []int64 - CreatedHeaderIds []int64 - missingHeaders []core.Header - allHeaders []core.Header - missingHeadersError error - PassedStartingBlockNumber int64 - PassedEndingBlockNumber int64 - PassedHeaderID int64 - PassedModels []interface{} - SetDbCalled bool - CreateCalledCounter int -} - -func (repository *MockRepository) Create(headerID int64, models []interface{}) error { - repository.PassedHeaderID = headerID - repository.PassedModels = models - repository.CreatedHeaderIds = append(repository.CreatedHeaderIds, headerID) - repository.CreateCalledCounter++ - - return repository.createError -} - -func (repository *MockRepository) MarkHeaderChecked(headerID int64) error { - repository.MarkHeaderCheckedPassedHeaderIDs = append(repository.MarkHeaderCheckedPassedHeaderIDs, headerID) - return repository.markHeaderCheckedError -} - -func (repository *MockRepository) MissingHeaders(startingBlockNumber, endingBlockNumber int64) ([]core.Header, error) { - repository.PassedStartingBlockNumber = startingBlockNumber - repository.PassedEndingBlockNumber = endingBlockNumber - return repository.missingHeaders, repository.missingHeadersError -} - -func (repository *MockRepository) RecheckHeaders(startingBlockNumber, endingBlockNumber int64) ([]core.Header, error) { - repository.PassedStartingBlockNumber = startingBlockNumber - repository.PassedEndingBlockNumber = endingBlockNumber - return repository.allHeaders, nil -} - -func (repository *MockRepository) SetDB(db *postgres.DB) { - repository.SetDbCalled = true -} - -func (repository *MockRepository) SetMissingHeadersError(e error) { - repository.missingHeadersError = e -} - -func (repository *MockRepository) SetAllHeaders(headers []core.Header) { - repository.allHeaders = headers -} - -func (repository *MockRepository) SetMissingHeaders(headers []core.Header) { - repository.missingHeaders = headers -} - -func (repository *MockRepository) SetMarkHeaderCheckedError(e error) { - repository.markHeaderCheckedError = e -} - -func (repository *MockRepository) SetCreateError(e error) { - repository.createError = e -} - -func (repository *MockRepository) AssertMarkHeaderCheckedCalledWith(i int64) { - Expect(repository.MarkHeaderCheckedPassedHeaderIDs).To(ContainElement(i)) -} - -func (repository *MockRepository) AssertMarkHeaderCheckedNotCalled() { - Expect(len(repository.MarkHeaderCheckedPassedHeaderIDs)).To(Equal(0)) -} diff --git a/pkg/transformers/test_data/mocks/storage_repository.go b/pkg/transformers/test_data/mocks/storage_repository.go deleted file mode 100644 index 62e88186..00000000 --- a/pkg/transformers/test_data/mocks/storage_repository.go +++ /dev/null @@ -1,26 +0,0 @@ -package mocks - -import ( - "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" - "github.com/vulcanize/vulcanizedb/pkg/transformers/storage_diffs/shared" -) - -type MockStorageRepository struct { - CreateErr error - PassedBlockNumber int - PassedBlockHash string - PassedMetadata shared.StorageValueMetadata - PassedValue interface{} -} - -func (repository *MockStorageRepository) Create(blockNumber int, blockHash string, metadata shared.StorageValueMetadata, value interface{}) error { - repository.PassedBlockNumber = blockNumber - repository.PassedBlockHash = blockHash - repository.PassedMetadata = metadata - repository.PassedValue = value - return repository.CreateErr -} - -func (*MockStorageRepository) SetDB(db *postgres.DB) { - panic("implement me") -} diff --git a/pkg/transformers/test_data/mocks/storage_transformer.go b/pkg/transformers/test_data/mocks/storage_transformer.go deleted file mode 100644 index 34c00007..00000000 --- a/pkg/transformers/test_data/mocks/storage_transformer.go +++ /dev/null @@ -1,27 +0,0 @@ -package mocks - -import ( - "github.com/ethereum/go-ethereum/common" - "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/storage" - "github.com/vulcanize/vulcanizedb/pkg/transformers/storage_diffs/shared" -) - -type MockStorageTransformer struct { - Address common.Address - ExecuteErr error - PassedRow shared.StorageDiffRow -} - -func (transformer *MockStorageTransformer) Execute(row shared.StorageDiffRow) error { - transformer.PassedRow = row - return transformer.ExecuteErr -} - -func (transformer *MockStorageTransformer) ContractAddress() common.Address { - return transformer.Address -} - -func (transformer *MockStorageTransformer) FakeTransformerInitializer(db *postgres.DB) storage.Transformer { - return transformer -} diff --git a/pkg/transformers/test_data/price_feed.go b/pkg/transformers/test_data/price_feed.go deleted file mode 100644 index c9f59739..00000000 --- a/pkg/transformers/test_data/price_feed.go +++ /dev/null @@ -1,54 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package test_data - -import ( - "encoding/json" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/types" - "github.com/vulcanize/vulcanizedb/pkg/fakes" - "github.com/vulcanize/vulcanizedb/pkg/transformers/price_feeds" -) - -var ( - medianizerAddress = common.HexToAddress("0x99041f808d598b782d5a3e498681c2452a31da08") - blockNumber = uint64(6147230) - txIndex = uint(119) -) - -// https://etherscan.io/tx/0xa51a50a2adbfba4e2ab3d72dfd67a21c769f1bc8d2b180663a15500a56cde58f -var EthPriceFeedLog = types.Log{ - Address: medianizerAddress, - Topics: []common.Hash{common.HexToHash("0x296ba4ca62c6c21c95e828080cb8aec7481b71390585605300a8a76f9e95b527")}, - Data: common.FromHex("00000000000000000000000000000000000000000000001486f658319fb0c100"), - BlockNumber: blockNumber, - TxHash: common.HexToHash("0xa51a50a2adbfba4e2ab3d72dfd67a21c769f1bc8d2b180663a15500a56cde58f"), - TxIndex: txIndex, - BlockHash: fakes.FakeHash, - Index: 8, - Removed: false, -} - -var rawPriceFeedLog, _ = json.Marshal(EthPriceFeedLog) -var PriceFeedModel = price_feeds.PriceFeedModel{ - BlockNumber: blockNumber, - MedianizerAddress: EthPriceFeedLog.Address.String(), - UsdValue: "378.659938889700015352", - LogIndex: EthPriceFeedLog.Index, - TransactionIndex: EthPriceFeedLog.TxIndex, - Raw: rawPriceFeedLog, -} diff --git a/pkg/transformers/test_data/shared_behaviors/repository_behaviors.go b/pkg/transformers/test_data/shared_behaviors/repository_behaviors.go deleted file mode 100644 index d12008fa..00000000 --- a/pkg/transformers/test_data/shared_behaviors/repository_behaviors.go +++ /dev/null @@ -1,187 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package shared_behaviors - -import ( - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - "github.com/vulcanize/vulcanizedb/pkg/datastore" - "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" - "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres/repositories" - "github.com/vulcanize/vulcanizedb/pkg/fakes" - "github.com/vulcanize/vulcanizedb/pkg/transformers/factories" - "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data" - "github.com/vulcanize/vulcanizedb/test_config" -) - -var ( - db *postgres.DB - headerRepository datastore.HeaderRepository - err error - headerId int64 -) - -type CreateBehaviorInputs struct { - CheckedHeaderColumnName string - LogEventTableName string - TestModel interface{} - RecheckTestModel interface{} - ModelWithDifferentLogIdx interface{} - Repository factories.Repository -} - -type MarkedHeaderCheckedBehaviorInputs struct { - CheckedHeaderColumnName string - Repository factories.Repository -} - -type MissingHeadersBehaviorInputs struct { - Repository factories.Repository - RepositoryTwo factories.Repository -} - -func SharedRepositoryCreateBehaviors(inputs *CreateBehaviorInputs) { - Describe("Create", func() { - var headerID int64 - var repository = inputs.Repository - var checkedHeaderColumn = inputs.CheckedHeaderColumnName - var logEventModel = inputs.TestModel - - BeforeEach(func() { - headerRepository = getHeaderRepository() - headerID, err = headerRepository.CreateOrUpdateHeader(fakes.FakeHeader) - Expect(err).NotTo(HaveOccurred()) - }) - - It("marks header as checked for logs", func() { - err = repository.Create(headerID, []interface{}{logEventModel}) - - Expect(err).NotTo(HaveOccurred()) - var headerChecked int - query := `SELECT ` + checkedHeaderColumn + ` FROM public.checked_headers WHERE header_id = $1` - err = db.Get(&headerChecked, query, headerID) - Expect(err).NotTo(HaveOccurred()) - Expect(headerChecked).To(Equal(1)) - }) - - It("updates the header to checked if checked headers row already exists", func() { - _, err := db.Exec(`INSERT INTO public.checked_headers (header_id) VALUES ($1)`, headerID) - Expect(err).NotTo(HaveOccurred()) - - err = repository.Create(headerID, []interface{}{logEventModel}) - - Expect(err).NotTo(HaveOccurred()) - var headerChecked int - query := `SELECT ` + checkedHeaderColumn + ` FROM public.checked_headers WHERE header_id = $1` - err = db.Get(&headerChecked, query, headerID) - Expect(err).NotTo(HaveOccurred()) - Expect(headerChecked).To(Equal(1)) - }) - - It("allows for multiple log events of the same type in one transaction if they have different log indexes", func() { - err = repository.Create(headerID, []interface{}{logEventModel}) - Expect(err).NotTo(HaveOccurred()) - - err = repository.Create(headerID, []interface{}{inputs.ModelWithDifferentLogIdx}) - Expect(err).NotTo(HaveOccurred()) - }) - - It("removes the log event record if the corresponding header is deleted", func() { - err = repository.Create(headerID, []interface{}{logEventModel}) - Expect(err).NotTo(HaveOccurred()) - - _, err = db.Exec(`DELETE FROM headers WHERE id = $1`, headerID) - Expect(err).NotTo(HaveOccurred()) - - var count int - query := `SELECT count(*) from ` + inputs.LogEventTableName - err = db.QueryRow(query).Scan(&count) - Expect(err).NotTo(HaveOccurred()) - Expect(count).To(Equal(0)) - }) - - It("returns an error if model is of wrong type", func() { - err = repository.Create(headerID, []interface{}{test_data.WrongModel{}}) - - Expect(err).To(HaveOccurred()) - Expect(err.Error()).To(ContainSubstring("model of type")) - }) - }) -} - -func SharedRepositoryMarkHeaderCheckedBehaviors(inputs *MarkedHeaderCheckedBehaviorInputs) { - var repository = inputs.Repository - var checkedHeaderColumn = inputs.CheckedHeaderColumnName - - Describe("MarkHeaderChecked", func() { - BeforeEach(func() { - headerRepository = getHeaderRepository() - headerId, err = headerRepository.CreateOrUpdateHeader(fakes.FakeHeader) - Expect(err).NotTo(HaveOccurred()) - }) - - It("creates a row for a new headerId", func() { - err = repository.MarkHeaderChecked(headerId) - - Expect(err).NotTo(HaveOccurred()) - var headerChecked int - query := `SELECT ` + checkedHeaderColumn + ` FROM public.checked_headers WHERE header_id = $1` - err = db.Get(&headerChecked, query, headerId) - Expect(err).NotTo(HaveOccurred()) - Expect(headerChecked).To(Equal(1)) - }) - - It("updates row when headerID already exists", func() { - _, err = db.Exec(`INSERT INTO public.checked_headers (header_id) VALUES ($1)`, headerId) - - err = repository.MarkHeaderChecked(headerId) - - Expect(err).NotTo(HaveOccurred()) - var headerChecked int - query := `SELECT ` + checkedHeaderColumn + ` FROM public.checked_headers WHERE header_id = $1` - err = db.Get(&headerChecked, query, headerId) - Expect(err).NotTo(HaveOccurred()) - Expect(headerChecked).To(Equal(1)) - }) - - It("returns an error if upserting a record fails", func() { - err = repository.MarkHeaderChecked(0) - - Expect(err).To(HaveOccurred()) - Expect(err.Error()).To(ContainSubstring("violates foreign key constraint")) - }) - - It("increments header checked", func() { - err = repository.MarkHeaderChecked(headerId) - err = repository.MarkHeaderChecked(headerId) - - Expect(err).NotTo(HaveOccurred()) - var headerChecked int - query := `SELECT ` + checkedHeaderColumn + ` FROM public.checked_headers WHERE header_id = $1` - err = db.Get(&headerChecked, query, headerId) - Expect(err).NotTo(HaveOccurred()) - Expect(headerChecked).To(Equal(2)) - }) - }) -} - -func getHeaderRepository() repositories.HeaderRepository { - db = test_config.NewTestDB(test_config.NewTestNode()) - test_config.CleanTestDB(db) - - return repositories.NewHeaderRepository(db) -} diff --git a/pkg/transformers/test_data/signatures.go b/pkg/transformers/test_data/signatures.go deleted file mode 100644 index ffa60c2d..00000000 --- a/pkg/transformers/test_data/signatures.go +++ /dev/null @@ -1,32 +0,0 @@ -package test_data - -const ( - KovanVatSlipSignature = "0x42066cbb00000000000000000000000000000000000000000000000000000000" - KovanVatTuneSignature = "0x5dd6471a00000000000000000000000000000000000000000000000000000000" - KovanBiteSignature = "0x99b5620489b6ef926d4518936cfec15d305452712b88bd59da2d9c10fb0953e8" - KovanCatFileFlipSignature = "0xebecb39d00000000000000000000000000000000000000000000000000000000" - KovanDripFileRepoSignature = "0x29ae811400000000000000000000000000000000000000000000000000000000" - KovanPitFileDebtCeilingSignature = "0x29ae811400000000000000000000000000000000000000000000000000000000" - KovanDentFunctionSignature = "0x5ff3a38200000000000000000000000000000000000000000000000000000000" - KovanFlopKickSignature = "0xefa52d9342a199cb30efd2692463f2c2bef63cd7186b50382d4fb94ad207880e" - KovanTendFunctionSignature = "0x4b43ed1200000000000000000000000000000000000000000000000000000000" - KovanVatGrabSignature = "0x3690ae4c00000000000000000000000000000000000000000000000000000000" - KovanPitFileIlkSignature = "0x1a0b287e00000000000000000000000000000000000000000000000000000000" - KovanVatFluxSignature = "0xa6e4182100000000000000000000000000000000000000000000000000000000" - KovanVatMoveSignature = "0x78f1947000000000000000000000000000000000000000000000000000000000" - KovanDripFileIlkSignature = "0x1a0b287e00000000000000000000000000000000000000000000000000000000" - KovanFlapKickSignature = "0xefa52d9342a199cb30efd2692463f2c2bef63cd7186b50382d4fb94ad207880e" - KovanDealSignature = "0xc959c42b00000000000000000000000000000000000000000000000000000000" - KovanVatFoldSignature = "0xe6a6a64d00000000000000000000000000000000000000000000000000000000" - KovanVatHealSignature = "0x990a5f6300000000000000000000000000000000000000000000000000000000" - KovanCatFileChopLumpSignature = "0x1a0b287e00000000000000000000000000000000000000000000000000000000" - KovanFlipKickSignature = "0xbac86238bdba81d21995024470425ecb370078fa62b7271b90cf28cbd1e3e87e" - KovanVatInitSignature = "0x3b66319500000000000000000000000000000000000000000000000000000000" - KovanCatFilePitVowSignature = "0xd4e8be8300000000000000000000000000000000000000000000000000000000" - KovanDripDripSignature = "0x44e2a5a800000000000000000000000000000000000000000000000000000000" - KovanDripFileVowSignature = "0xe9b674b900000000000000000000000000000000000000000000000000000000" - KovanFrobSignature = "0xb2afa28318bcc689926b52835d844de174ef8de97e982a85c0199d584920791b" - KovanLogValueSignature = "0x296ba4ca62c6c21c95e828080cb8aec7481b71390585605300a8a76f9e95b527" - KovanVatTollSignature = "0x09b7a0b500000000000000000000000000000000000000000000000000000000" - KovanVowFlogSignature = "0x35aee16f00000000000000000000000000000000000000000000000000000000" -) diff --git a/pkg/transformers/test_data/tend.go b/pkg/transformers/test_data/tend.go deleted file mode 100644 index 13dadc62..00000000 --- a/pkg/transformers/test_data/tend.go +++ /dev/null @@ -1,67 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package test_data - -import ( - "encoding/json" - "strconv" - - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/ethereum/go-ethereum/core/types" - - "github.com/vulcanize/vulcanizedb/pkg/fakes" - "github.com/vulcanize/vulcanizedb/pkg/transformers/tend" -) - -var ( - tendBidId = int64(10) - tendLot = "85000000000000000000" - tendBid = "1000000000000000000" - tendGuy = "0000000000000000000000007d7bee5fcfd8028cf7b00876c5b1421c800561a6" - tendData = "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000644b43ed12000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000049b9ca9a6943400000000000000000000000000000000000000000000000000000de0b6b3a7640000" - tendTransactionHash = "0x7909c8793ded2b8348f5db623044fbc26bb7ab78ad5792897abdf68ddc1df63d" - tendBlockHash = "0xa8ea87147c0a68daeb6b1d9f8c0937ba975a650809cab80d19c969e8d0df452c" -) - -var TendLogNote = types.Log{ - Address: common.HexToAddress(KovanFlipperContractAddress), - Topics: []common.Hash{ - common.HexToHash("0x4b43ed1200000000000000000000000000000000000000000000000000000000"), //abbreviated tend function signature - common.HexToHash("0x0000000000000000000000007d7bee5fcfd8028cf7b00876c5b1421c800561a6"), //msg caller address - common.HexToHash("0x000000000000000000000000000000000000000000000000000000000000000a"), //first param of the function called (i.e. flip kick id) - common.HexToHash("0x0000000000000000000000000000000000000000000000049b9ca9a694340000"), //second param of the function called (i.e. lot) - }, - Data: hexutil.MustDecode(tendData), - BlockNumber: 11, - TxHash: common.HexToHash(tendTransactionHash), - TxIndex: 10, - BlockHash: fakes.FakeHash, - Index: 1, - Removed: false, -} - -var rawTendLog, _ = json.Marshal(TendLogNote) -var TendModel = tend.TendModel{ - BidId: strconv.FormatInt(tendBidId, 10), - Lot: tendLot, - Bid: tendBid, - Guy: tendGuy, - LogIndex: TendLogNote.Index, - TransactionIndex: TendLogNote.TxIndex, - Raw: rawTendLog, -} diff --git a/pkg/transformers/test_data/vat_flux.go b/pkg/transformers/test_data/vat_flux.go deleted file mode 100644 index 9c4aab0a..00000000 --- a/pkg/transformers/test_data/vat_flux.go +++ /dev/null @@ -1,54 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package test_data - -import ( - "encoding/json" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/ethereum/go-ethereum/core/types" - "github.com/vulcanize/vulcanizedb/pkg/fakes" - "github.com/vulcanize/vulcanizedb/pkg/transformers/vat_flux" -) - -var VatFluxLog = types.Log{ - Address: common.HexToAddress(KovanVatContractAddress), - Topics: []common.Hash{ - common.HexToHash("0xa6e4182100000000000000000000000000000000000000000000000000000000"), - common.HexToHash("0x5245500000000000000000000000000000000000000000000000000000000000"), - common.HexToHash("0x0000000000000000000000007FA9EF6609Ca7921112231f8f195138ebba29770"), - common.HexToHash("0x00000000000000000000000093086347c52a8878af71bb818509d484c6a2e1bf"), - }, - Data: hexutil.MustDecode("0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000084a6e418217340e006f4135ba6970d43bf43d88dcad4e7a8ca00000000000000000000000007fa9ef6609ca7921112231f8f195138ebba297700000000000000000000000093086347c52a8878af71bb818509d484c6a2e1bf000000000000000000000000000000000000000000000000000000000000000000000000000000000000007b"), - BlockNumber: 23, - TxHash: common.HexToHash("0xf98681bab9b8c75bd8aa4a7d0a8142ff527c5ea8fa54f3c2835d4533838b2e6f"), - TxIndex: 0, - BlockHash: fakes.FakeHash, - Index: 3, - Removed: false, -} - -var rawFluxLog, _ = json.Marshal(VatFluxLog) -var VatFluxModel = vat_flux.VatFluxModel{ - Ilk: "5245500000000000000000000000000000000000000000000000000000000000", - Src: "0000000000000000000000007fa9ef6609ca7921112231f8f195138ebba29770", - Dst: "00000000000000000000000093086347c52a8878af71bb818509d484c6a2e1bf", - Rad: "123", - TransactionIndex: VatFluxLog.TxIndex, - LogIndex: VatFluxLog.Index, - Raw: rawFluxLog, -} diff --git a/pkg/transformers/test_data/vat_fold.go b/pkg/transformers/test_data/vat_fold.go deleted file mode 100644 index c2f80320..00000000 --- a/pkg/transformers/test_data/vat_fold.go +++ /dev/null @@ -1,55 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package test_data - -import ( - "encoding/json" - - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/ethereum/go-ethereum/core/types" - - "github.com/vulcanize/vulcanizedb/pkg/fakes" - "github.com/vulcanize/vulcanizedb/pkg/transformers/vat_fold" -) - -var EthVatFoldLog = types.Log{ - Address: common.HexToAddress(KovanVatContractAddress), - Topics: []common.Hash{ - common.HexToHash("0xe6a6a64d00000000000000000000000000000000000000000000000000000000"), - common.HexToHash("0x5245500000000000000000000000000000000000000000000000000000000000"), - common.HexToHash("0x0000000000000000000000003728e9777b2a0a611ee0f89e00e01044ce4736d1"), - common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000002"), - }, - Data: hexutil.MustDecode("0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000064e6a6a64d45544800000000000000000000000000000000000000000000000000000000000000000000000000000000003728e9777b2a0a611ee0f89e00e01044ce4736d10000000000000000000000000000000000000000000000000000000000000000"), - BlockNumber: 8940380, - TxHash: common.HexToHash("0xfb37b7a88aa8ad14538d1e244a55939fa07c1828e5ca8168bf4edd56f5fc4d57"), - TxIndex: 8, - BlockHash: fakes.FakeHash, - Index: 5, - Removed: false, -} - -var rawVatFoldLog, _ = json.Marshal(EthVatFoldLog) -var VatFoldModel = vat_fold.VatFoldModel{ - Ilk: "5245500000000000000000000000000000000000000000000000000000000000", - Urn: "0000000000000000000000003728e9777b2a0a611ee0f89e00e01044ce4736d1", - Rate: "0.000000000000000000000000002", - LogIndex: EthVatFoldLog.Index, - TransactionIndex: EthVatFoldLog.TxIndex, - Raw: rawVatFoldLog, -} diff --git a/pkg/transformers/test_data/vat_grab.go b/pkg/transformers/test_data/vat_grab.go deleted file mode 100644 index 4a7aef70..00000000 --- a/pkg/transformers/test_data/vat_grab.go +++ /dev/null @@ -1,40 +0,0 @@ -package test_data - -import ( - "encoding/json" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/ethereum/go-ethereum/core/types" - "github.com/vulcanize/vulcanizedb/pkg/fakes" - "github.com/vulcanize/vulcanizedb/pkg/transformers/vat_grab" -) - -var EthVatGrabLog = types.Log{ - Address: common.HexToAddress(KovanVatContractAddress), - Topics: []common.Hash{ - common.HexToHash("0x3690ae4c00000000000000000000000000000000000000000000000000000000"), - common.HexToHash("0x5245500000000000000000000000000000000000000000000000000000000000"), - common.HexToHash("0x0000000000000000000000006a3ae20c315e845b2e398e68effe39139ec6060c"), - common.HexToHash("0x0000000000000000000000002f34f22a00ee4b7a8f8bbc4eaee1658774c624e0"), - }, - Data: hexutil.MustDecode("0x000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000c43690ae4c52455000000000000000000000000000000000000000000000000000000000000000000000000000000000006a3ae20c315e845b2e398e68effe39139ec6060c0000000000000000000000002f34f22a00ee4b7a8f8bbc4eaee1658774c624e00000000000000000000000003728e9777b2a0a611ee0f89e00e01044ce4736d1ffffffffffffffffffffffffffffffffffffffffffffffffe43e9298b1380000ffffffffffffffffffffffffffffffffffffffffffffffff24fea01c7f8f8000"), - BlockNumber: 23, - TxHash: common.HexToHash("0x7cb84c750ce4985f7811abf641d52ffcb35306d943081475226484cf1470c6fa"), - TxIndex: 4, - BlockHash: fakes.FakeHash, - Index: 5, - Removed: false, -} - -var rawVatGrabLog, _ = json.Marshal(EthVatGrabLog) -var VatGrabModel = vat_grab.VatGrabModel{ - Ilk: "5245500000000000000000000000000000000000000000000000000000000000", - Urn: "0000000000000000000000006a3ae20c315e845b2e398e68effe39139ec6060c", - V: "0000000000000000000000002f34f22a00ee4b7a8f8bbc4eaee1658774c624e0", - W: "0000000000000000000000003728e9777b2a0a611ee0f89e00e01044ce4736d1", - Dink: "115792089237316195423570985008687907853269984665640564039455584007913129639936", - Dart: "115792089237316195423570985008687907853269984665640564039441803007913129639936", - LogIndex: EthVatGrabLog.Index, - TransactionIndex: EthVatGrabLog.TxIndex, - Raw: rawVatGrabLog, -} diff --git a/pkg/transformers/test_data/vat_heal.go b/pkg/transformers/test_data/vat_heal.go deleted file mode 100644 index 01ff4bb1..00000000 --- a/pkg/transformers/test_data/vat_heal.go +++ /dev/null @@ -1,53 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package test_data - -import ( - "encoding/json" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/ethereum/go-ethereum/core/types" - "github.com/vulcanize/vulcanizedb/pkg/fakes" - "github.com/vulcanize/vulcanizedb/pkg/transformers/vat_heal" -) - -var VatHealLog = types.Log{ - Address: common.HexToAddress(KovanVatContractAddress), - Topics: []common.Hash{ - common.HexToHash("0x990a5f6300000000000000000000000000000000000000000000000000000000"), - common.HexToHash("0x0000000000000000000000007d7bee5fcfd8028cf7b00876c5b1421c800561a6"), - common.HexToHash("0x0000000000000000000000007340e006f4135ba6970d43bf43d88dcad4e7a8ca"), - common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000078"), - }, - Data: hexutil.MustDecode("0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000064990a5f637d7bee5fcfd8028cf7b00876c5b1421c800561a600000000000000000000000074686520762076616c75650000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000078"), - BlockNumber: 10, - TxHash: common.HexToHash("0x991b8079b1333024000dcaf2b00c24c5db0315e112a4ac4d912aa96a602e12b9"), - TxIndex: 2, - BlockHash: fakes.FakeHash, - Index: 3, - Removed: false, -} - -var rawHealLog, _ = json.Marshal(VatHealLog) -var VatHealModel = vat_heal.VatHealModel{ - Urn: "0000000000000000000000007d7bee5fcfd8028cf7b00876c5b1421c800561a6", - V: "0000000000000000000000007340e006f4135ba6970d43bf43d88dcad4e7a8ca", - Rad: "120", - LogIndex: VatHealLog.Index, - TransactionIndex: VatHealLog.TxIndex, - Raw: rawHealLog, -} diff --git a/pkg/transformers/test_data/vat_init.go b/pkg/transformers/test_data/vat_init.go deleted file mode 100644 index bc566d24..00000000 --- a/pkg/transformers/test_data/vat_init.go +++ /dev/null @@ -1,53 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package test_data - -import ( - "encoding/json" - - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/ethereum/go-ethereum/core/types" - - "github.com/vulcanize/vulcanizedb/pkg/fakes" - "github.com/vulcanize/vulcanizedb/pkg/transformers/vat_init" -) - -var EthVatInitLog = types.Log{ - Address: common.HexToAddress(KovanVatContractAddress), - Topics: []common.Hash{ - common.HexToHash("0x3b66319500000000000000000000000000000000000000000000000000000000"), - common.HexToHash("0x66616b6520696c6b000000000000000000000000000000000000000000000000"), - common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000000"), - common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000000"), - }, - Data: hexutil.MustDecode("0x000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000243b66319566616b6520696c6b000000000000000000000000000000000000000000000000"), - BlockNumber: 24, - TxHash: common.HexToHash("0xe8f39fbb7fea3621f543868f19b1114e305aff6a063a30d32835ff1012526f91"), - TxIndex: 7, - BlockHash: fakes.FakeHash, - Index: 8, - Removed: false, -} - -var rawVatInitLog, _ = json.Marshal(EthVatInitLog) -var VatInitModel = vat_init.VatInitModel{ - Ilk: "66616b6520696c6b000000000000000000000000000000000000000000000000", - LogIndex: EthVatInitLog.Index, - TransactionIndex: EthVatInitLog.TxIndex, - Raw: rawVatInitLog, -} diff --git a/pkg/transformers/test_data/vat_move.go b/pkg/transformers/test_data/vat_move.go deleted file mode 100644 index 4b09dd45..00000000 --- a/pkg/transformers/test_data/vat_move.go +++ /dev/null @@ -1,55 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package test_data - -import ( - "encoding/json" - - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/ethereum/go-ethereum/core/types" - - "github.com/vulcanize/vulcanizedb/pkg/fakes" - "github.com/vulcanize/vulcanizedb/pkg/transformers/vat_move" -) - -var EthVatMoveLog = types.Log{ - Address: common.HexToAddress(KovanVatContractAddress), - Topics: []common.Hash{ - common.HexToHash("0x78f1947000000000000000000000000000000000000000000000000000000000"), - common.HexToHash("0x000000000000000000000000a730d1ff8b6bc74a26d54c20a9dda539909bab0e"), - common.HexToHash("0x000000000000000000000000b730d1ff8b6bc74a26d54c20a9dda539909bab0e"), - common.HexToHash("0x000000000000000000000000000000000000000000000000000000000000002a"), - }, - Data: hexutil.MustDecode("0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000006478f19470a730d1ff8b6bc74a26d54c20a9dda539909bab0e000000000000000000000000b730d1ff8b6bc74a26d54c20a9dda539909bab0e000000000000000000000000000000000000000000000000000000000000000000000000000000000000002a"), - BlockNumber: 10, - TxHash: common.HexToHash("0xe8f39fbb7fea3621f543868f19b1114e305aff6a063a30d32835ff1012526f91"), - TxIndex: 7, - BlockHash: fakes.FakeHash, - Index: 8, - Removed: false, -} - -var rawVatMoveLog, _ = json.Marshal(EthVatMoveLog) -var VatMoveModel = vat_move.VatMoveModel{ - Src: "000000000000000000000000a730d1ff8b6bc74a26d54c20a9dda539909bab0e", - Dst: "000000000000000000000000b730d1ff8b6bc74a26d54c20a9dda539909bab0e", - Rad: "42", - LogIndex: EthVatMoveLog.Index, - TransactionIndex: EthVatMoveLog.TxIndex, - Raw: rawVatMoveLog, -} diff --git a/pkg/transformers/test_data/vat_slip.go b/pkg/transformers/test_data/vat_slip.go deleted file mode 100644 index fd717c61..00000000 --- a/pkg/transformers/test_data/vat_slip.go +++ /dev/null @@ -1,55 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package test_data - -import ( - "encoding/json" - - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/ethereum/go-ethereum/core/types" - - "github.com/vulcanize/vulcanizedb/pkg/fakes" - "github.com/vulcanize/vulcanizedb/pkg/transformers/vat_slip" -) - -var EthVatSlipLog = types.Log{ - Address: common.HexToAddress(KovanVatContractAddress), - Topics: []common.Hash{ - common.HexToHash("0x42066cbb00000000000000000000000000000000000000000000000000000000"), - common.HexToHash("0x66616b6520696c6b000000000000000000000000000000000000000000000000"), - common.HexToHash("0x0000000000000000000000007d7bee5fcfd8028cf7b00876c5b1421c800561a6"), - common.HexToHash("0x000000000000000000000000000000000000000000000000000000003ade68b1"), - }, - Data: hexutil.MustDecode("0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000006442066cbb66616b6520696c6b0000000000000000000000000000000000000000000000000000000000000000000000007d7bee5fcfd8028cf7b00876c5b1421c800561a6000000000000000000000000000000000000000000000000000000003ade68b1"), - BlockNumber: 10, - TxHash: common.HexToHash("0xb114ba306c80c86d51bdbf4a5ac8ed151020cd81b70cfa1dc9822f4a1f73930b"), - TxIndex: 3, - BlockHash: fakes.FakeHash, - Index: 2, - Removed: false, -} - -var rawVatSlipLog, _ = json.Marshal(EthVatSlipLog) -var VatSlipModel = vat_slip.VatSlipModel{ - Ilk: "66616b6520696c6b000000000000000000000000000000000000000000000000", - Guy: "0000000000000000000000007d7bee5fcfd8028cf7b00876c5b1421c800561a6", - Rad: "987654321", - TransactionIndex: EthVatSlipLog.TxIndex, - LogIndex: EthVatSlipLog.Index, - Raw: rawVatSlipLog, -} diff --git a/pkg/transformers/test_data/vat_toll.go b/pkg/transformers/test_data/vat_toll.go deleted file mode 100644 index e37b303a..00000000 --- a/pkg/transformers/test_data/vat_toll.go +++ /dev/null @@ -1,38 +0,0 @@ -package test_data - -import ( - "encoding/json" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/ethereum/go-ethereum/core/types" - "github.com/vulcanize/vulcanizedb/pkg/fakes" - "github.com/vulcanize/vulcanizedb/pkg/transformers/vat_toll" - "math/big" -) - -var EthVatTollLog = types.Log{ - Address: common.HexToAddress(KovanVatContractAddress), - Topics: []common.Hash{ - common.HexToHash("0x09b7a0b500000000000000000000000000000000000000000000000000000000"), - common.HexToHash("0x66616b6520696c6b000000000000000000000000000000000000000000000000"), - common.HexToHash("0x0000000000000000000000000a3e37186e017747dba34042e83e3f76ad3cce9b"), - common.HexToHash("0x00000000000000000000000000000000000000000000000000000000075bcd15"), - }, - Data: hexutil.MustDecode("0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000006409b7a0b566616b6520696c6b000000000000000000000000000000000000000000000000a3e37186e017747dba34042e83e3f76ad3cce9b000000000000000000000000000000000000000000000000000000000000000000000000000000000075bcd15"), - BlockNumber: 21, - TxHash: common.HexToHash("0x0d59cb158b033ffdfb9a021d1e80bfbbcd99594c62c501897ccee446bcd33828"), - TxIndex: 2, - BlockHash: fakes.FakeHash, - Index: 4, - Removed: false, -} - -var rawVatTollLog, _ = json.Marshal(EthVatTollLog) -var VatTollModel = vat_toll.VatTollModel{ - Ilk: "66616b6520696c6b000000000000000000000000000000000000000000000000", - Urn: "0000000000000000000000000a3e37186e017747dba34042e83e3f76ad3cce9b", - Take: big.NewInt(123456789).String(), - TransactionIndex: EthVatTollLog.TxIndex, - LogIndex: EthVatTollLog.Index, - Raw: rawVatTollLog, -} diff --git a/pkg/transformers/test_data/vat_tune.go b/pkg/transformers/test_data/vat_tune.go deleted file mode 100644 index 2269e917..00000000 --- a/pkg/transformers/test_data/vat_tune.go +++ /dev/null @@ -1,46 +0,0 @@ -package test_data - -import ( - "encoding/json" - "math/big" - - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/ethereum/go-ethereum/core/types" - - "github.com/vulcanize/vulcanizedb/pkg/fakes" - "github.com/vulcanize/vulcanizedb/pkg/transformers/vat_tune" -) - -var EthVatTuneLog = types.Log{ - Address: common.HexToAddress(KovanVatContractAddress), - Topics: []common.Hash{ - common.HexToHash("0x5dd6471a00000000000000000000000000000000000000000000000000000000"), - common.HexToHash("0x4554480000000000000000000000000000000000000000000000000000000000"), - common.HexToHash("0x0000000000000000000000004f26ffbe5f04ed43630fdc30a87638d53d0b0876"), - common.HexToHash("0x0000000000000000000000004f26ffbe5f04ed43630fdc30a87638d53d0b0876"), - }, - Data: hexutil.MustDecode("0x000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000c45dd6471a45544800000000000000000000000000000000000000000000000000000000000000000000000000000000004f26ffbe5f04ed43630fdc30a87638d53d0b08760000000000000000000000004f26ffbe5f04ed43630fdc30a87638d53d0b08760000000000000000000000004f26ffbe5f04ed43630fdc30a87638d53d0b08760000000000000000000000000000000000000000000000000000000000000000ffffffffffffffffffffffffffffffffffffffffffffffffe43e9298b1380000"), - BlockNumber: 8761670, - TxHash: common.HexToHash("0x95eb3d6cbd83032efa29714d4a391ce163d7d215db668aadd7d33dd5c20b1ec7"), - TxIndex: 0, - BlockHash: fakes.FakeHash, - Index: 6, - Removed: false, -} - -var rawVatTuneLog, _ = json.Marshal(EthVatTuneLog) -var dartString = "115792089237316195423570985008687907853269984665640564039455584007913129639936" -var vatTuneDart, _ = new(big.Int).SetString(dartString, 10) -var urn = "0000000000000000000000004f26ffbe5f04ed43630fdc30a87638d53d0b0876" -var VatTuneModel = vat_tune.VatTuneModel{ - Ilk: "4554480000000000000000000000000000000000000000000000000000000000", - Urn: urn, - V: urn, - W: urn, - Dink: big.NewInt(0).String(), - Dart: vatTuneDart.String(), - TransactionIndex: EthVatTuneLog.TxIndex, - LogIndex: EthVatTuneLog.Index, - Raw: rawVatTuneLog, -} diff --git a/pkg/transformers/test_data/vow_flog.go b/pkg/transformers/test_data/vow_flog.go deleted file mode 100644 index 7f73cf75..00000000 --- a/pkg/transformers/test_data/vow_flog.go +++ /dev/null @@ -1,51 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package test_data - -import ( - "encoding/json" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/ethereum/go-ethereum/core/types" - "github.com/vulcanize/vulcanizedb/pkg/fakes" - "github.com/vulcanize/vulcanizedb/pkg/transformers/vow_flog" -) - -var EthVowFlogLog = types.Log{ - Address: common.HexToAddress(KovanVowContractAddress), - Topics: []common.Hash{ - common.HexToHash("0x35aee16f00000000000000000000000000000000000000000000000000000000"), - common.HexToHash("0x0000000000000000000000008e84a1e068d77059cbe263c43ad0cdc130863313"), - common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000539"), - common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000000"), - }, - Data: hexutil.MustDecode("0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000002435aee16f0000000000000000000000000000000000000000000000000000000000000539"), - BlockNumber: 11, - TxHash: common.HexToHash("0x47ffd75c1cda1d5c08219755743663a3790e4f5ae9e1fcb85bb3fe0d74bb7109"), - TxIndex: 4, - BlockHash: fakes.FakeHash, - Index: 3, - Removed: false, -} - -var rawVowFlogLog, _ = json.Marshal(EthVowFlogLog) -var VowFlogModel = vow_flog.VowFlogModel{ - Era: "1337", - LogIndex: EthVowFlogLog.Index, - TransactionIndex: EthVowFlogLog.TxIndex, - Raw: rawVowFlogLog, -} diff --git a/pkg/transformers/test_data/wrong_types.go b/pkg/transformers/test_data/wrong_types.go deleted file mode 100644 index 30aa69e1..00000000 --- a/pkg/transformers/test_data/wrong_types.go +++ /dev/null @@ -1,20 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package test_data - -type WrongEntity struct{} -type WrongModel struct{} diff --git a/pkg/transformers/transformers.go b/pkg/transformers/transformers.go deleted file mode 100644 index 04acc76e..00000000 --- a/pkg/transformers/transformers.go +++ /dev/null @@ -1,327 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package transformers - -import ( - shared_t "github.com/vulcanize/vulcanizedb/libraries/shared/transformer" - "github.com/vulcanize/vulcanizedb/pkg/transformers/bite" - "github.com/vulcanize/vulcanizedb/pkg/transformers/cat_file/chop_lump" - "github.com/vulcanize/vulcanizedb/pkg/transformers/cat_file/flip" - "github.com/vulcanize/vulcanizedb/pkg/transformers/cat_file/pit_vow" - "github.com/vulcanize/vulcanizedb/pkg/transformers/deal" - "github.com/vulcanize/vulcanizedb/pkg/transformers/dent" - "github.com/vulcanize/vulcanizedb/pkg/transformers/drip_drip" - ilk2 "github.com/vulcanize/vulcanizedb/pkg/transformers/drip_file/ilk" - "github.com/vulcanize/vulcanizedb/pkg/transformers/drip_file/repo" - "github.com/vulcanize/vulcanizedb/pkg/transformers/drip_file/vow" - "github.com/vulcanize/vulcanizedb/pkg/transformers/factories" - "github.com/vulcanize/vulcanizedb/pkg/transformers/flap_kick" - "github.com/vulcanize/vulcanizedb/pkg/transformers/flip_kick" - "github.com/vulcanize/vulcanizedb/pkg/transformers/flop_kick" - "github.com/vulcanize/vulcanizedb/pkg/transformers/frob" - "github.com/vulcanize/vulcanizedb/pkg/transformers/pit_file/debt_ceiling" - "github.com/vulcanize/vulcanizedb/pkg/transformers/pit_file/ilk" - "github.com/vulcanize/vulcanizedb/pkg/transformers/price_feeds" - "github.com/vulcanize/vulcanizedb/pkg/transformers/tend" - "github.com/vulcanize/vulcanizedb/pkg/transformers/vat_flux" - "github.com/vulcanize/vulcanizedb/pkg/transformers/vat_fold" - "github.com/vulcanize/vulcanizedb/pkg/transformers/vat_grab" - "github.com/vulcanize/vulcanizedb/pkg/transformers/vat_heal" - "github.com/vulcanize/vulcanizedb/pkg/transformers/vat_init" - "github.com/vulcanize/vulcanizedb/pkg/transformers/vat_move" - "github.com/vulcanize/vulcanizedb/pkg/transformers/vat_slip" - "github.com/vulcanize/vulcanizedb/pkg/transformers/vat_toll" - "github.com/vulcanize/vulcanizedb/pkg/transformers/vat_tune" - "github.com/vulcanize/vulcanizedb/pkg/transformers/vow_flog" -) - -// Custom event transformers -func GetBiteTransformer() factories.Transformer { - return factories.Transformer{ - Config: bite.GetBiteConfig(), - Converter: &bite.BiteConverter{}, - Repository: &bite.BiteRepository{}, - } -} - -func GetFlapKickTransformer() factories.Transformer { - return factories.Transformer{ - Config: flap_kick.GetFlapKickConfig(), - Converter: &flap_kick.FlapKickConverter{}, - Repository: &flap_kick.FlapKickRepository{}, - } -} - -func GetFlipKickTransformer() factories.Transformer { - return factories.Transformer{ - Config: flip_kick.GetFlipKickConfig(), - Converter: &flip_kick.FlipKickConverter{}, - Repository: &flip_kick.FlipKickRepository{}, - } -} - -func GetFrobTransformer() factories.Transformer { - return factories.Transformer{ - Config: frob.GetFrobConfig(), - Converter: &frob.FrobConverter{}, - Repository: &frob.FrobRepository{}, - } -} - -func GetFlopKickTransformer() factories.Transformer { - return factories.Transformer{ - Config: flop_kick.GetFlopKickConfig(), - Converter: &flop_kick.FlopKickConverter{}, - Repository: &flop_kick.FlopKickRepository{}, - } -} - -func getCustomEventTransformers() []factories.Transformer { - return []factories.Transformer{ - GetBiteTransformer(), - GetFlapKickTransformer(), - GetFlipKickTransformer(), - GetFrobTransformer(), - GetFlopKickTransformer(), - } -} - -// LogNote transformers -func GetCatFileChopLumpTransformer() factories.LogNoteTransformer { - return factories.LogNoteTransformer{ - Config: chop_lump.GetCatFileChopLumpConfig(), - Converter: &chop_lump.CatFileChopLumpConverter{}, - Repository: &chop_lump.CatFileChopLumpRepository{}, - } -} - -func GetCatFileFlipTransformer() factories.LogNoteTransformer { - return factories.LogNoteTransformer{ - Config: flip.GetCatFileFlipConfig(), - Converter: &flip.CatFileFlipConverter{}, - Repository: &flip.CatFileFlipRepository{}, - } -} - -func GetCatFilePitVowTransformer() factories.LogNoteTransformer { - return factories.LogNoteTransformer{ - Config: pit_vow.GetCatFilePitVowConfig(), - Converter: &pit_vow.CatFilePitVowConverter{}, - Repository: &pit_vow.CatFilePitVowRepository{}, - } -} - -func GetDealTransformer() factories.LogNoteTransformer { - return factories.LogNoteTransformer{ - Config: deal.GetDealConfig(), - Converter: &deal.DealConverter{}, - Repository: &deal.DealRepository{}, - } -} - -func GetDentTransformer() factories.LogNoteTransformer { - return factories.LogNoteTransformer{ - Config: dent.GetDentConfig(), - Converter: &dent.DentConverter{}, - Repository: &dent.DentRepository{}, - } -} - -func GetDripDripTransformer() factories.LogNoteTransformer { - return factories.LogNoteTransformer{ - Config: drip_drip.GetDripDripConfig(), - Converter: &drip_drip.DripDripConverter{}, - Repository: &drip_drip.DripDripRepository{}, - } -} - -func GetDripFileIlkTransformer() factories.LogNoteTransformer { - return factories.LogNoteTransformer{ - Config: ilk2.GetDripFileIlkConfig(), - Converter: &ilk2.DripFileIlkConverter{}, - Repository: &ilk2.DripFileIlkRepository{}, - } -} - -func GetDripFileRepoTransformer() factories.LogNoteTransformer { - return factories.LogNoteTransformer{ - Config: repo.GetDripFileRepoConfig(), - Converter: &repo.DripFileRepoConverter{}, - Repository: &repo.DripFileRepoRepository{}, - } -} - -func GetDripFileVowTransformer() factories.LogNoteTransformer { - return factories.LogNoteTransformer{ - Config: vow.GetDripFileVowConfig(), - Converter: &vow.DripFileVowConverter{}, - Repository: &vow.DripFileVowRepository{}, - } -} - -func GetFlogTransformer() factories.LogNoteTransformer { - return factories.LogNoteTransformer{ - Config: vow_flog.GetVowFlogConfig(), - Converter: &vow_flog.VowFlogConverter{}, - Repository: &vow_flog.VowFlogRepository{}, - } -} - -func GetPitFileDebtCeilingTransformer() factories.LogNoteTransformer { - return factories.LogNoteTransformer{ - Config: debt_ceiling.GetDebtCeilingFileConfig(), - Converter: &debt_ceiling.PitFileDebtCeilingConverter{}, - Repository: &debt_ceiling.PitFileDebtCeilingRepository{}, - } -} - -func GetPitFileIlkTransformer() factories.LogNoteTransformer { - return factories.LogNoteTransformer{ - Config: ilk.GetIlkFileConfig(), - Converter: &ilk.PitFileIlkConverter{}, - Repository: &ilk.PitFileIlkRepository{}, - } -} - -func GetPriceFeedTransformer() factories.LogNoteTransformer { - return factories.LogNoteTransformer{ - Config: price_feeds.GetPriceFeedConfig(), - Converter: &price_feeds.PriceFeedConverter{}, - Repository: &price_feeds.PriceFeedRepository{}, - } -} - -func GetTendTransformer() factories.LogNoteTransformer { - return factories.LogNoteTransformer{ - Config: tend.GetTendConfig(), - Converter: &tend.TendConverter{}, - Repository: &tend.TendRepository{}, - } -} - -func GetVatInitTransformer() factories.LogNoteTransformer { - return factories.LogNoteTransformer{ - Config: vat_init.GetVatInitConfig(), - Converter: &vat_init.VatInitConverter{}, - Repository: &vat_init.VatInitRepository{}, - } -} - -func GetVatGrabTransformer() factories.LogNoteTransformer { - return factories.LogNoteTransformer{ - Config: vat_grab.GetVatGrabConfig(), - Converter: &vat_grab.VatGrabConverter{}, - Repository: &vat_grab.VatGrabRepository{}, - } -} - -func GetVatFoldTransformer() factories.LogNoteTransformer { - return factories.LogNoteTransformer{ - Config: vat_fold.GetVatFoldConfig(), - Converter: &vat_fold.VatFoldConverter{}, - Repository: &vat_fold.VatFoldRepository{}, - } -} - -func GetVatHealTransformer() factories.LogNoteTransformer { - return factories.LogNoteTransformer{ - Config: vat_heal.GetVatHealConfig(), - Converter: &vat_heal.VatHealConverter{}, - Repository: &vat_heal.VatHealRepository{}, - } -} - -func GetVatMoveTransformer() factories.LogNoteTransformer { - return factories.LogNoteTransformer{ - Config: vat_move.GetVatMoveConfig(), - Converter: &vat_move.VatMoveConverter{}, - Repository: &vat_move.VatMoveRepository{}, - } -} - -func GetVatSlipTransformer() factories.LogNoteTransformer { - return factories.LogNoteTransformer{ - Config: vat_slip.GetVatSlipConfig(), - Converter: &vat_slip.VatSlipConverter{}, - Repository: &vat_slip.VatSlipRepository{}, - } -} - -func GetVatTollTransformer() factories.LogNoteTransformer { - return factories.LogNoteTransformer{ - Config: vat_toll.GetVatTollConfig(), - Converter: &vat_toll.VatTollConverter{}, - Repository: &vat_toll.VatTollRepository{}, - } -} - -func GetVatTuneTransformer() factories.LogNoteTransformer { - return factories.LogNoteTransformer{ - Config: vat_tune.GetVatTuneConfig(), - Converter: &vat_tune.VatTuneConverter{}, - Repository: &vat_tune.VatTuneRepository{}, - } -} - -func GetVatFluxTransformer() factories.LogNoteTransformer { - return factories.LogNoteTransformer{ - Config: vat_flux.GetVatFluxConfig(), - Converter: &vat_flux.VatFluxConverter{}, - Repository: &vat_flux.VatFluxRepository{}, - } -} - -func getLogNoteTransformers() []factories.LogNoteTransformer { - return []factories.LogNoteTransformer{ - GetCatFileChopLumpTransformer(), - GetCatFileFlipTransformer(), - GetCatFilePitVowTransformer(), - GetDealTransformer(), - GetDentTransformer(), - GetDripDripTransformer(), - GetDripFileIlkTransformer(), - GetDripFileRepoTransformer(), - GetDripFileVowTransformer(), - GetFlogTransformer(), - GetPitFileDebtCeilingTransformer(), - GetPitFileIlkTransformer(), - GetPriceFeedTransformer(), - GetTendTransformer(), - GetVatInitTransformer(), - GetVatGrabTransformer(), - GetVatFoldTransformer(), - GetVatHealTransformer(), - GetVatMoveTransformer(), - GetVatSlipTransformer(), - GetVatTollTransformer(), - GetVatTuneTransformer(), - GetVatFluxTransformer(), - } -} - -// `TransformerInitializers` returns a list of functions, that given a db pointer -// will return a `shared.Transformer` -func TransformerInitializers() (initializers []shared_t.TransformerInitializer) { - for _, transformer := range getLogNoteTransformers() { - initializers = append(initializers, transformer.NewLogNoteTransformer) - } - - for _, transformer := range getCustomEventTransformers() { - initializers = append(initializers, transformer.NewTransformer) - } - return -} diff --git a/pkg/transformers/vat_flux/config.go b/pkg/transformers/vat_flux/config.go deleted file mode 100644 index f4b347eb..00000000 --- a/pkg/transformers/vat_flux/config.go +++ /dev/null @@ -1,17 +0,0 @@ -package vat_flux - -import ( - shared_t "github.com/vulcanize/vulcanizedb/libraries/shared/transformer" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" -) - -func GetVatFluxConfig() shared_t.TransformerConfig { - return shared_t.TransformerConfig{ - TransformerName: constants.VatFluxLabel, - ContractAddresses: []string{constants.VatContractAddress()}, - ContractAbi: constants.VatABI(), - Topic: constants.GetVatFluxSignature(), - StartingBlockNumber: constants.VatDeploymentBlock(), - EndingBlockNumber: -1, - } -} diff --git a/pkg/transformers/vat_flux/converter.go b/pkg/transformers/vat_flux/converter.go deleted file mode 100644 index cc22867a..00000000 --- a/pkg/transformers/vat_flux/converter.go +++ /dev/null @@ -1,73 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package vat_flux - -import ( - "encoding/json" - "errors" - "github.com/ethereum/go-ethereum/core/types" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared" - "math/big" -) - -type VatFluxConverter struct{} - -func (VatFluxConverter) ToModels(ethLogs []types.Log) ([]interface{}, error) { - var models []interface{} - for _, ethLog := range ethLogs { - err := verifyLog(ethLog) - if err != nil { - return nil, err - } - - ilk := shared.GetHexWithoutPrefix(ethLog.Topics[1].Bytes()) - src := shared.GetHexWithoutPrefix(ethLog.Topics[2].Bytes()) - dst := shared.GetHexWithoutPrefix(ethLog.Topics[3].Bytes()) - radBytes := shared.GetDataBytesAtIndex(-1, ethLog.Data) - rad := big.NewInt(0).SetBytes(radBytes).String() - - if err != nil { - return nil, err - } - - rawLogJson, err := json.Marshal(ethLog) - if err != nil { - return nil, err - } - - model := VatFluxModel{ - Ilk: ilk, - Src: src, - Dst: dst, - Rad: rad, - TransactionIndex: ethLog.TxIndex, - LogIndex: ethLog.Index, - Raw: rawLogJson, - } - - models = append(models, model) - } - - return models, nil -} - -func verifyLog(log types.Log) error { - if len(log.Topics) < 4 { - return errors.New("log missing topics") - } - return nil -} diff --git a/pkg/transformers/vat_flux/converter_test.go b/pkg/transformers/vat_flux/converter_test.go deleted file mode 100644 index 7b8727ce..00000000 --- a/pkg/transformers/vat_flux/converter_test.go +++ /dev/null @@ -1,52 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package vat_flux_test - -import ( - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/types" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - - "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data" - "github.com/vulcanize/vulcanizedb/pkg/transformers/vat_flux" -) - -var _ = Describe("VatFlux converter", func() { - It("Converts logs to models", func() { - converter := vat_flux.VatFluxConverter{} - models, err := converter.ToModels([]types.Log{test_data.VatFluxLog}) - - Expect(err).NotTo(HaveOccurred()) - Expect(len(models)).To(Equal(1)) - Expect(models[0]).To(Equal(test_data.VatFluxModel)) - }) - - It("Returns an error there are missing topics", func() { - converter := vat_flux.VatFluxConverter{} - badLog := types.Log{ - Topics: []common.Hash{ - common.HexToHash("0x"), - common.HexToHash("0x"), - common.HexToHash("0x"), - }, - } - _, err := converter.ToModels([]types.Log{badLog}) - - Expect(err).To(HaveOccurred()) - }) -}) diff --git a/pkg/transformers/vat_flux/model.go b/pkg/transformers/vat_flux/model.go deleted file mode 100644 index ce3e2aa2..00000000 --- a/pkg/transformers/vat_flux/model.go +++ /dev/null @@ -1,27 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package vat_flux - -type VatFluxModel struct { - Ilk string - Src string - Dst string - Rad string - TransactionIndex uint `db:"tx_idx"` - LogIndex uint `db:"log_idx"` - Raw []byte `db:"raw_log"` -} diff --git a/pkg/transformers/vat_flux/vat_flux_suite_test.go b/pkg/transformers/vat_flux/vat_flux_suite_test.go deleted file mode 100644 index 6703caa9..00000000 --- a/pkg/transformers/vat_flux/vat_flux_suite_test.go +++ /dev/null @@ -1,19 +0,0 @@ -package vat_flux_test - -import ( - log "github.com/sirupsen/logrus" - "io/ioutil" - "testing" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -func TestVatFlux(t *testing.T) { - RegisterFailHandler(Fail) - RunSpecs(t, "VatFlux Suite") -} - -var _ = BeforeSuite(func() { - log.SetOutput(ioutil.Discard) -}) diff --git a/pkg/transformers/vat_fold/config.go b/pkg/transformers/vat_fold/config.go deleted file mode 100644 index 27fd3427..00000000 --- a/pkg/transformers/vat_fold/config.go +++ /dev/null @@ -1,33 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package vat_fold - -import ( - shared_t "github.com/vulcanize/vulcanizedb/libraries/shared/transformer" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" -) - -func GetVatFoldConfig() shared_t.TransformerConfig { - return shared_t.TransformerConfig{ - TransformerName: constants.VatFoldLabel, - ContractAddresses: []string{constants.VatContractAddress()}, - ContractAbi: constants.VatABI(), - Topic: constants.GetVatFoldSignature(), - StartingBlockNumber: constants.VatDeploymentBlock(), - EndingBlockNumber: -1, - } -} diff --git a/pkg/transformers/vat_fold/converter.go b/pkg/transformers/vat_fold/converter.go deleted file mode 100644 index 3f58094f..00000000 --- a/pkg/transformers/vat_fold/converter.go +++ /dev/null @@ -1,64 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package vat_fold - -import ( - "encoding/json" - "errors" - "github.com/ethereum/go-ethereum/core/types" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared" -) - -type VatFoldConverter struct{} - -func (VatFoldConverter) ToModels(ethLogs []types.Log) ([]interface{}, error) { - var models []interface{} - for _, ethLog := range ethLogs { - err := verifyLog(ethLog) - if err != nil { - return nil, err - } - - ilk := shared.GetHexWithoutPrefix(ethLog.Topics[1].Bytes()) - urn := shared.GetHexWithoutPrefix(ethLog.Topics[2].Bytes()) - rate := shared.ConvertToRay(ethLog.Topics[3].Big().String()) - raw, err := json.Marshal(ethLog) - - if err != nil { - return models, err - } - - model := VatFoldModel{ - Ilk: ilk, - Urn: urn, - Rate: rate, - LogIndex: ethLog.Index, - TransactionIndex: ethLog.TxIndex, - Raw: raw, - } - - models = append(models, model) - } - return models, nil -} - -func verifyLog(log types.Log) error { - if len(log.Topics) < 4 { - return errors.New("log missing topics") - } - return nil -} diff --git a/pkg/transformers/vat_fold/converter_test.go b/pkg/transformers/vat_fold/converter_test.go deleted file mode 100644 index 9966a503..00000000 --- a/pkg/transformers/vat_fold/converter_test.go +++ /dev/null @@ -1,46 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package vat_fold_test - -import ( - "github.com/ethereum/go-ethereum/core/types" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - - "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data" - "github.com/vulcanize/vulcanizedb/pkg/transformers/vat_fold" -) - -var _ = Describe("Vat fold converter", func() { - It("returns err if log missing topics", func() { - converter := vat_fold.VatFoldConverter{} - badLog := types.Log{} - - _, err := converter.ToModels([]types.Log{badLog}) - - Expect(err).To(HaveOccurred()) - }) - - It("converts a log to an model", func() { - converter := vat_fold.VatFoldConverter{} - - model, err := converter.ToModels([]types.Log{test_data.EthVatFoldLog}) - - Expect(err).NotTo(HaveOccurred()) - Expect(model).To(Equal([]interface{}{test_data.VatFoldModel})) - }) -}) diff --git a/pkg/transformers/vat_fold/model.go b/pkg/transformers/vat_fold/model.go deleted file mode 100644 index 10ccc35a..00000000 --- a/pkg/transformers/vat_fold/model.go +++ /dev/null @@ -1,10 +0,0 @@ -package vat_fold - -type VatFoldModel struct { - Ilk string - Urn string - Rate string - LogIndex uint `db:"log_idx"` - TransactionIndex uint `db:"tx_idx"` - Raw []byte `db:"raw_log"` -} diff --git a/pkg/transformers/vat_fold/vat_fold_suite_test.go b/pkg/transformers/vat_fold/vat_fold_suite_test.go deleted file mode 100644 index e3ee0832..00000000 --- a/pkg/transformers/vat_fold/vat_fold_suite_test.go +++ /dev/null @@ -1,19 +0,0 @@ -package vat_fold_test - -import ( - log "github.com/sirupsen/logrus" - "io/ioutil" - "testing" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -func TestVatFold(t *testing.T) { - RegisterFailHandler(Fail) - RunSpecs(t, "VatFold Suite") -} - -var _ = BeforeSuite(func() { - log.SetOutput(ioutil.Discard) -}) diff --git a/pkg/transformers/vat_grab/config.go b/pkg/transformers/vat_grab/config.go deleted file mode 100644 index ce653677..00000000 --- a/pkg/transformers/vat_grab/config.go +++ /dev/null @@ -1,17 +0,0 @@ -package vat_grab - -import ( - shared_t "github.com/vulcanize/vulcanizedb/libraries/shared/transformer" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" -) - -func GetVatGrabConfig() shared_t.TransformerConfig { - return shared_t.TransformerConfig{ - TransformerName: constants.VatGrabLabel, - ContractAddresses: []string{constants.VatContractAddress()}, - ContractAbi: constants.VatABI(), - Topic: constants.GetVatGrabSignature(), - StartingBlockNumber: constants.VatDeploymentBlock(), - EndingBlockNumber: -1, - } -} diff --git a/pkg/transformers/vat_grab/converter.go b/pkg/transformers/vat_grab/converter.go deleted file mode 100644 index 592b3171..00000000 --- a/pkg/transformers/vat_grab/converter.go +++ /dev/null @@ -1,59 +0,0 @@ -package vat_grab - -import ( - "encoding/json" - "errors" - "github.com/ethereum/go-ethereum/core/types" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" - "math/big" -) - -type VatGrabConverter struct{} - -func (VatGrabConverter) ToModels(ethLogs []types.Log) ([]interface{}, error) { - var models []interface{} - for _, ethLog := range ethLogs { - err := verifyLog(ethLog) - if err != nil { - return nil, err - } - ilk := shared.GetHexWithoutPrefix(ethLog.Topics[1].Bytes()) - urn := shared.GetHexWithoutPrefix(ethLog.Topics[2].Bytes()) - v := shared.GetHexWithoutPrefix(ethLog.Topics[3].Bytes()) - wBytes := shared.GetDataBytesAtIndex(-3, ethLog.Data) - w := shared.GetHexWithoutPrefix(wBytes) - dinkBytes := shared.GetDataBytesAtIndex(-2, ethLog.Data) - dink := big.NewInt(0).SetBytes(dinkBytes).String() - dartBytes := shared.GetDataBytesAtIndex(-1, ethLog.Data) - dart := big.NewInt(0).SetBytes(dartBytes).String() - - raw, err := json.Marshal(ethLog) - if err != nil { - return nil, err - } - model := VatGrabModel{ - Ilk: ilk, - Urn: urn, - V: v, - W: w, - Dink: dink, - Dart: dart, - LogIndex: ethLog.Index, - TransactionIndex: ethLog.TxIndex, - Raw: raw, - } - models = append(models, model) - } - return models, nil -} - -func verifyLog(log types.Log) error { - if len(log.Topics) < 4 { - return errors.New("log missing topics") - } - if len(log.Data) < constants.DataItemLength { - return errors.New("log missing data") - } - return nil -} diff --git a/pkg/transformers/vat_grab/converter_test.go b/pkg/transformers/vat_grab/converter_test.go deleted file mode 100644 index ee3f5fcc..00000000 --- a/pkg/transformers/vat_grab/converter_test.go +++ /dev/null @@ -1,47 +0,0 @@ -package vat_grab_test - -import ( - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/types" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - - "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data" - "github.com/vulcanize/vulcanizedb/pkg/transformers/vat_grab" -) - -var _ = Describe("Vat grab converter", func() { - var converter vat_grab.VatGrabConverter - - BeforeEach(func() { - converter = vat_grab.VatGrabConverter{} - }) - - It("returns err if log is missing topics", func() { - badLog := types.Log{ - Data: []byte{1, 1, 1, 1, 1}, - } - - _, err := converter.ToModels([]types.Log{badLog}) - - Expect(err).To(HaveOccurred()) - }) - - It("returns err if log is missing data", func() { - badLog := types.Log{ - Topics: []common.Hash{{}, {}, {}, {}}, - } - - _, err := converter.ToModels([]types.Log{badLog}) - - Expect(err).To(HaveOccurred()) - }) - - It("converts a log to an model", func() { - models, err := converter.ToModels([]types.Log{test_data.EthVatGrabLog}) - - Expect(err).NotTo(HaveOccurred()) - Expect(len(models)).To(Equal(1)) - Expect(models[0]).To(Equal(test_data.VatGrabModel)) - }) -}) diff --git a/pkg/transformers/vat_grab/model.go b/pkg/transformers/vat_grab/model.go deleted file mode 100644 index a8a8aa20..00000000 --- a/pkg/transformers/vat_grab/model.go +++ /dev/null @@ -1,13 +0,0 @@ -package vat_grab - -type VatGrabModel struct { - Ilk string - Urn string - V string - W string - Dink string - Dart string - LogIndex uint `db:"log_idx"` - TransactionIndex uint `db:"tx_idx"` - Raw []byte `db:"raw_log"` -} diff --git a/pkg/transformers/vat_grab/vat_grab_suite_test.go b/pkg/transformers/vat_grab/vat_grab_suite_test.go deleted file mode 100644 index 428078fe..00000000 --- a/pkg/transformers/vat_grab/vat_grab_suite_test.go +++ /dev/null @@ -1,19 +0,0 @@ -package vat_grab_test - -import ( - log "github.com/sirupsen/logrus" - "io/ioutil" - "testing" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -func TestVatGrab(t *testing.T) { - RegisterFailHandler(Fail) - RunSpecs(t, "VatGrab Suite") -} - -var _ = BeforeSuite(func() { - log.SetOutput(ioutil.Discard) -}) diff --git a/pkg/transformers/vat_heal/config.go b/pkg/transformers/vat_heal/config.go deleted file mode 100644 index 2e4ec56f..00000000 --- a/pkg/transformers/vat_heal/config.go +++ /dev/null @@ -1,33 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package vat_heal - -import ( - shared_t "github.com/vulcanize/vulcanizedb/libraries/shared/transformer" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" -) - -func GetVatHealConfig() shared_t.TransformerConfig { - return shared_t.TransformerConfig{ - TransformerName: constants.VatHealLabel, - ContractAddresses: []string{constants.VatContractAddress()}, - ContractAbi: constants.VatABI(), - Topic: constants.GetVatHealSignature(), - StartingBlockNumber: constants.VatDeploymentBlock(), - EndingBlockNumber: -1, - } -} diff --git a/pkg/transformers/vat_heal/converter.go b/pkg/transformers/vat_heal/converter.go deleted file mode 100644 index b5192084..00000000 --- a/pkg/transformers/vat_heal/converter.go +++ /dev/null @@ -1,69 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package vat_heal - -import ( - "encoding/json" - "errors" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared" - - "github.com/ethereum/go-ethereum/core/types" -) - -type VatHealConverter struct{} - -func (VatHealConverter) ToModels(ethLogs []types.Log) ([]interface{}, error) { - var models []interface{} - for _, ethLog := range ethLogs { - err := verifyLog(ethLog) - if err != nil { - return nil, err - } - - urn := shared.GetHexWithoutPrefix(ethLog.Topics[1].Bytes()) - v := shared.GetHexWithoutPrefix(ethLog.Topics[2].Bytes()) - radInt := ethLog.Topics[3].Big() - if err != nil { - return nil, err - } - - rawLogJson, err := json.Marshal(ethLog) - if err != nil { - return nil, err - } - - model := VatHealModel{ - Urn: urn, - V: v, - Rad: radInt.String(), - LogIndex: ethLog.Index, - TransactionIndex: ethLog.TxIndex, - Raw: rawLogJson, - } - - models = append(models, model) - } - - return models, nil -} - -func verifyLog(log types.Log) error { - if len(log.Topics) < 4 { - return errors.New("log missing topics") - } - return nil -} diff --git a/pkg/transformers/vat_heal/converter_test.go b/pkg/transformers/vat_heal/converter_test.go deleted file mode 100644 index e4364897..00000000 --- a/pkg/transformers/vat_heal/converter_test.go +++ /dev/null @@ -1,52 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package vat_heal_test - -import ( - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/types" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - - "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data" - "github.com/vulcanize/vulcanizedb/pkg/transformers/vat_heal" -) - -var _ = Describe("VatHeal converter", func() { - It("Converts logs to models", func() { - converter := vat_heal.VatHealConverter{} - models, err := converter.ToModels([]types.Log{test_data.VatHealLog}) - - Expect(err).NotTo(HaveOccurred()) - Expect(len(models)).To(Equal(1)) - Expect(models[0]).To(Equal(test_data.VatHealModel)) - }) - - It("Returns an error there are missing topics", func() { - converter := vat_heal.VatHealConverter{} - badLog := types.Log{ - Topics: []common.Hash{ - common.HexToHash("0x"), - common.HexToHash("0x"), - common.HexToHash("0x"), - }, - } - _, err := converter.ToModels([]types.Log{badLog}) - - Expect(err).To(HaveOccurred()) - }) -}) diff --git a/pkg/transformers/vat_heal/model.go b/pkg/transformers/vat_heal/model.go deleted file mode 100644 index 675f610c..00000000 --- a/pkg/transformers/vat_heal/model.go +++ /dev/null @@ -1,26 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package vat_heal - -type VatHealModel struct { - Urn string - V string - Rad string - LogIndex uint `db:"log_idx"` - TransactionIndex uint `db:"tx_idx"` - Raw []byte `db:"raw_log"` -} diff --git a/pkg/transformers/vat_heal/repository.go b/pkg/transformers/vat_heal/repository.go deleted file mode 100644 index 59d567de..00000000 --- a/pkg/transformers/vat_heal/repository.go +++ /dev/null @@ -1,87 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package vat_heal - -import ( - "fmt" - log "github.com/sirupsen/logrus" - - "github.com/vulcanize/vulcanizedb/pkg/core" - "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" -) - -type VatHealRepository struct { - db *postgres.DB -} - -func (repository *VatHealRepository) SetDB(db *postgres.DB) { - repository.db = db -} - -func (repository VatHealRepository) Create(headerID int64, models []interface{}) error { - tx, dBaseErr := repository.db.Begin() - if dBaseErr != nil { - return dBaseErr - } - - for _, model := range models { - vatHeal, ok := model.(VatHealModel) - if !ok { - rollbackErr := tx.Rollback() - if rollbackErr != nil { - log.Error("failed to rollback ", rollbackErr) - } - return fmt.Errorf("model of type %T, not %T", model, VatHealModel{}) - } - - _, execErr := tx.Exec(`INSERT INTO maker.vat_heal (header_id, urn, v, rad, log_idx, tx_idx, raw_log) - VALUES($1, $2, $3, $4::NUMERIC, $5, $6, $7) - ON CONFlICT (header_id, tx_idx, log_idx) DO UPDATE SET urn = $2, v = $3, rad = $4, raw_log = $7;`, - headerID, vatHeal.Urn, vatHeal.V, vatHeal.Rad, vatHeal.LogIndex, vatHeal.TransactionIndex, vatHeal.Raw) - if execErr != nil { - rollbackErr := tx.Rollback() - if rollbackErr != nil { - log.Error("failed to rollback ", rollbackErr) - } - return execErr - } - } - - checkHeaderErr := shared.MarkHeaderCheckedInTransaction(headerID, tx, constants.VatHealChecked) - if checkHeaderErr != nil { - rollbackErr := tx.Rollback() - if rollbackErr != nil { - log.Error("failed to rollback ", rollbackErr) - } - return checkHeaderErr - } - return tx.Commit() -} - -func (repository VatHealRepository) MissingHeaders(startingBlock, endingBlock int64) ([]core.Header, error) { - return shared.MissingHeaders(startingBlock, endingBlock, repository.db, constants.VatHealChecked) -} - -func (repository VatHealRepository) RecheckHeaders(startingBlock, endingBlock int64) ([]core.Header, error) { - return shared.RecheckHeaders(startingBlock, endingBlock, repository.db, constants.VatHealChecked) -} - -func (repository VatHealRepository) MarkHeaderChecked(headerId int64) error { - return shared.MarkHeaderChecked(headerId, repository.db, constants.VatHealChecked) -} diff --git a/pkg/transformers/vat_heal/repository_test.go b/pkg/transformers/vat_heal/repository_test.go deleted file mode 100644 index ff5292fe..00000000 --- a/pkg/transformers/vat_heal/repository_test.go +++ /dev/null @@ -1,96 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package vat_heal_test - -import ( - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - - "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" - "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres/repositories" - "github.com/vulcanize/vulcanizedb/pkg/fakes" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" - "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data" - "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data/shared_behaviors" - "github.com/vulcanize/vulcanizedb/pkg/transformers/vat_heal" - "github.com/vulcanize/vulcanizedb/test_config" -) - -var _ = Describe("VatHeal Repository", func() { - var ( - db *postgres.DB - repository vat_heal.VatHealRepository - ) - - BeforeEach(func() { - db = test_config.NewTestDB(test_config.NewTestNode()) - test_config.CleanTestDB(db) - repository = vat_heal.VatHealRepository{} - repository.SetDB(db) - }) - - type VatHealDBResult struct { - vat_heal.VatHealModel - Id int - HeaderId int64 `db:"header_id"` - } - - Describe("Create", func() { - modelWithDifferentLogIdx := test_data.VatHealModel - modelWithDifferentLogIdx.LogIndex++ - inputs := shared_behaviors.CreateBehaviorInputs{ - CheckedHeaderColumnName: constants.VatHealChecked, - LogEventTableName: "maker.vat_heal", - TestModel: test_data.VatHealModel, - ModelWithDifferentLogIdx: modelWithDifferentLogIdx, - Repository: &repository, - } - - shared_behaviors.SharedRepositoryCreateBehaviors(&inputs) - - It("persists vat heal records", func() { - headerRepository := repositories.NewHeaderRepository(db) - headerId, err := headerRepository.CreateOrUpdateHeader(fakes.FakeHeader) - Expect(err).NotTo(HaveOccurred()) - anotherVatHeal := test_data.VatHealModel - anotherVatHeal.LogIndex = test_data.VatHealModel.LogIndex + 1 - err = repository.Create(headerId, []interface{}{test_data.VatHealModel, anotherVatHeal}) - - var dbResult []VatHealDBResult - err = db.Select(&dbResult, `SELECT * from maker.vat_heal where header_id = $1`, headerId) - Expect(err).NotTo(HaveOccurred()) - Expect(len(dbResult)).To(Equal(2)) - Expect(dbResult[0].Urn).To(Equal(test_data.VatHealModel.Urn)) - Expect(dbResult[0].V).To(Equal(test_data.VatHealModel.V)) - Expect(dbResult[0].Rad).To(Equal(test_data.VatHealModel.Rad)) - Expect(dbResult[0].LogIndex).To(Equal(test_data.VatHealModel.LogIndex)) - Expect(dbResult[1].LogIndex).To(Equal(test_data.VatHealModel.LogIndex + 1)) - Expect(dbResult[0].TransactionIndex).To(Equal(test_data.VatHealModel.TransactionIndex)) - Expect(dbResult[0].Raw).To(MatchJSON(test_data.VatHealModel.Raw)) - Expect(dbResult[0].HeaderId).To(Equal(headerId)) - }) - }) - - Describe("MarkCheckedHeader", func() { - inputs := shared_behaviors.MarkedHeaderCheckedBehaviorInputs{ - CheckedHeaderColumnName: constants.VatHealChecked, - Repository: &repository, - } - - shared_behaviors.SharedRepositoryMarkHeaderCheckedBehaviors(&inputs) - }) -}) diff --git a/pkg/transformers/vat_heal/vat_heal_suite_test.go b/pkg/transformers/vat_heal/vat_heal_suite_test.go deleted file mode 100644 index 047019ea..00000000 --- a/pkg/transformers/vat_heal/vat_heal_suite_test.go +++ /dev/null @@ -1,19 +0,0 @@ -package vat_heal_test - -import ( - log "github.com/sirupsen/logrus" - "io/ioutil" - "testing" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -func TestVatHeal(t *testing.T) { - RegisterFailHandler(Fail) - RunSpecs(t, "VatHeal Suite") -} - -var _ = BeforeSuite(func() { - log.SetOutput(ioutil.Discard) -}) diff --git a/pkg/transformers/vat_init/config.go b/pkg/transformers/vat_init/config.go deleted file mode 100644 index 95a4a2f9..00000000 --- a/pkg/transformers/vat_init/config.go +++ /dev/null @@ -1,33 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package vat_init - -import ( - shared_t "github.com/vulcanize/vulcanizedb/libraries/shared/transformer" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" -) - -func GetVatInitConfig() shared_t.TransformerConfig { - return shared_t.TransformerConfig{ - TransformerName: constants.VatInitLabel, - ContractAddresses: []string{constants.VatContractAddress()}, - ContractAbi: constants.VatABI(), - Topic: constants.GetVatInitSignature(), - StartingBlockNumber: constants.VatDeploymentBlock(), - EndingBlockNumber: -1, - } -} diff --git a/pkg/transformers/vat_init/converter.go b/pkg/transformers/vat_init/converter.go deleted file mode 100644 index 1b59c2c8..00000000 --- a/pkg/transformers/vat_init/converter.go +++ /dev/null @@ -1,56 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package vat_init - -import ( - "encoding/json" - "errors" - "github.com/ethereum/go-ethereum/core/types" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared" -) - -type VatInitConverter struct{} - -func (VatInitConverter) ToModels(ethLogs []types.Log) ([]interface{}, error) { - var models []interface{} - for _, ethLog := range ethLogs { - err := verifyLog(ethLog) - if err != nil { - return nil, err - } - ilk := shared.GetHexWithoutPrefix(ethLog.Topics[1].Bytes()) - raw, err := json.Marshal(ethLog) - if err != nil { - return nil, err - } - model := VatInitModel{ - Ilk: ilk, - LogIndex: ethLog.Index, - TransactionIndex: ethLog.TxIndex, - Raw: raw, - } - models = append(models, model) - } - return models, nil -} - -func verifyLog(log types.Log) error { - if len(log.Topics) < 2 { - return errors.New("log missing topics") - } - return nil -} diff --git a/pkg/transformers/vat_init/converter_test.go b/pkg/transformers/vat_init/converter_test.go deleted file mode 100644 index 8a2fbf12..00000000 --- a/pkg/transformers/vat_init/converter_test.go +++ /dev/null @@ -1,49 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package vat_init_test - -import ( - "github.com/ethereum/go-ethereum/core/types" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - - "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data" - "github.com/vulcanize/vulcanizedb/pkg/transformers/vat_init" -) - -var _ = Describe("Vat init converter", func() { - var converter vat_init.VatInitConverter - - BeforeEach(func() { - converter = vat_init.VatInitConverter{} - }) - - It("returns err if log missing topics", func() { - badLog := types.Log{} - _, err := converter.ToModels([]types.Log{badLog}) - - Expect(err).To(HaveOccurred()) - }) - - It("converts a log to a model", func() { - models, err := converter.ToModels([]types.Log{test_data.EthVatInitLog}) - - Expect(err).NotTo(HaveOccurred()) - Expect(len(models)).To(Equal(1)) - Expect(models[0]).To(Equal(test_data.VatInitModel)) - }) -}) diff --git a/pkg/transformers/vat_init/model.go b/pkg/transformers/vat_init/model.go deleted file mode 100644 index a23422ad..00000000 --- a/pkg/transformers/vat_init/model.go +++ /dev/null @@ -1,24 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package vat_init - -type VatInitModel struct { - Ilk string - LogIndex uint `db:"log_idx"` - TransactionIndex uint `db:"tx_idx"` - Raw []byte `db:"raw_log"` -} diff --git a/pkg/transformers/vat_init/vat_init_suite_test.go b/pkg/transformers/vat_init/vat_init_suite_test.go deleted file mode 100644 index b5e75fe4..00000000 --- a/pkg/transformers/vat_init/vat_init_suite_test.go +++ /dev/null @@ -1,35 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package vat_init_test - -import ( - log "github.com/sirupsen/logrus" - "io/ioutil" - "testing" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -func TestVatInit(t *testing.T) { - RegisterFailHandler(Fail) - RunSpecs(t, "VatInit Suite") -} - -var _ = BeforeSuite(func() { - log.SetOutput(ioutil.Discard) -}) diff --git a/pkg/transformers/vat_move/config.go b/pkg/transformers/vat_move/config.go deleted file mode 100644 index 03c990bd..00000000 --- a/pkg/transformers/vat_move/config.go +++ /dev/null @@ -1,33 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package vat_move - -import ( - shared_t "github.com/vulcanize/vulcanizedb/libraries/shared/transformer" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" -) - -func GetVatMoveConfig() shared_t.TransformerConfig { - return shared_t.TransformerConfig{ - TransformerName: constants.VatMoveLabel, - ContractAddresses: []string{constants.VatContractAddress()}, - ContractAbi: constants.VatABI(), - Topic: constants.GetVatMoveSignature(), - StartingBlockNumber: constants.VatDeploymentBlock(), - EndingBlockNumber: -1, - } -} diff --git a/pkg/transformers/vat_move/converter.go b/pkg/transformers/vat_move/converter.go deleted file mode 100644 index 4a129bb9..00000000 --- a/pkg/transformers/vat_move/converter.go +++ /dev/null @@ -1,65 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package vat_move - -import ( - "encoding/json" - "errors" - "github.com/ethereum/go-ethereum/core/types" - shared2 "github.com/vulcanize/vulcanizedb/pkg/transformers/shared" -) - -type VatMoveConverter struct{} - -func (VatMoveConverter) ToModels(ethLogs []types.Log) ([]interface{}, error) { - var models []interface{} - for _, ethLog := range ethLogs { - err := verifyLog(ethLog) - if err != nil { - return []interface{}{}, err - } - - src := shared2.GetHexWithoutPrefix(ethLog.Topics[1].Bytes()) - dst := shared2.GetHexWithoutPrefix(ethLog.Topics[2].Bytes()) - rad := ethLog.Topics[3].Big() - raw, err := json.Marshal(ethLog) - if err != nil { - return []interface{}{}, err - } - - models = append(models, VatMoveModel{ - Src: src, - Dst: dst, - Rad: rad.String(), - LogIndex: ethLog.Index, - TransactionIndex: ethLog.TxIndex, - Raw: raw, - }) - } - - return models, nil -} - -func verifyLog(ethLog types.Log) error { - if len(ethLog.Data) <= 0 { - return errors.New("log data is empty") - } - if len(ethLog.Topics) < 4 { - return errors.New("log missing topics") - } - return nil -} diff --git a/pkg/transformers/vat_move/converter_test.go b/pkg/transformers/vat_move/converter_test.go deleted file mode 100644 index 5e3313f7..00000000 --- a/pkg/transformers/vat_move/converter_test.go +++ /dev/null @@ -1,49 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package vat_move_test - -import ( - "github.com/ethereum/go-ethereum/core/types" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - - "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data" - "github.com/vulcanize/vulcanizedb/pkg/transformers/vat_move" -) - -var _ = Describe("Vat move converter", func() { - var converter vat_move.VatMoveConverter - - BeforeEach(func() { - converter = vat_move.VatMoveConverter{} - }) - - It("returns err if logs are missing topics", func() { - badLog := types.Log{} - _, err := converter.ToModels([]types.Log{badLog}) - - Expect(err).To(HaveOccurred()) - }) - - It("converts a log to a model", func() { - models, err := converter.ToModels([]types.Log{test_data.EthVatMoveLog}) - - Expect(err).NotTo(HaveOccurred()) - Expect(len(models)).To(Equal(1)) - Expect(models[0]).To(Equal(test_data.VatMoveModel)) - }) -}) diff --git a/pkg/transformers/vat_move/model.go b/pkg/transformers/vat_move/model.go deleted file mode 100644 index 80c37852..00000000 --- a/pkg/transformers/vat_move/model.go +++ /dev/null @@ -1,26 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package vat_move - -type VatMoveModel struct { - Src string - Dst string - Rad string - LogIndex uint `db:"log_idx"` - TransactionIndex uint `db:"tx_idx"` - Raw []byte `db:"raw_log"` -} diff --git a/pkg/transformers/vat_move/repository.go b/pkg/transformers/vat_move/repository.go deleted file mode 100644 index 4bd2c26b..00000000 --- a/pkg/transformers/vat_move/repository.go +++ /dev/null @@ -1,92 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package vat_move - -import ( - "fmt" - - log "github.com/sirupsen/logrus" - - "github.com/vulcanize/vulcanizedb/pkg/core" - "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" -) - -type VatMoveRepository struct { - db *postgres.DB -} - -func (repository VatMoveRepository) Create(headerID int64, models []interface{}) error { - tx, dBaseErr := repository.db.Begin() - if dBaseErr != nil { - return dBaseErr - } - - for _, model := range models { - vatMove, ok := model.(VatMoveModel) - if !ok { - rollbackErr := tx.Rollback() - if rollbackErr != nil { - log.Error("failed to rollback ", rollbackErr) - } - return fmt.Errorf("model of type %T, not %T", model, VatMoveModel{}) - } - - _, execErr := tx.Exec( - `INSERT INTO maker.vat_move (header_id, src, dst, rad, log_idx, tx_idx, raw_log) - VALUES ($1, $2, $3, $4::NUMERIC, $5, $6, $7) - ON CONFLICT (header_id, tx_idx, log_idx) DO UPDATE SET src = $2, dst = $3, rad = $4, raw_log = $7;`, - headerID, vatMove.Src, vatMove.Dst, vatMove.Rad, vatMove.LogIndex, vatMove.TransactionIndex, vatMove.Raw, - ) - - if execErr != nil { - rollbackErr := tx.Rollback() - if rollbackErr != nil { - log.Error("failed to rollback ", rollbackErr) - } - return execErr - } - } - - checkHeaderErr := shared.MarkHeaderCheckedInTransaction(headerID, tx, constants.VatMoveChecked) - if checkHeaderErr != nil { - rollbackErr := tx.Rollback() - if rollbackErr != nil { - log.Error("failed to rollback ", rollbackErr) - } - return checkHeaderErr - } - - return tx.Commit() -} - -func (repository VatMoveRepository) MissingHeaders(startingBlockNumber, endingBlockNumber int64) ([]core.Header, error) { - return shared.MissingHeaders(startingBlockNumber, endingBlockNumber, repository.db, constants.VatMoveChecked) -} - -func (repository VatMoveRepository) RecheckHeaders(startingBlockNumber, endingBlockNumber int64) ([]core.Header, error) { - return shared.RecheckHeaders(startingBlockNumber, endingBlockNumber, repository.db, constants.VatMoveChecked) -} - -func (repository VatMoveRepository) MarkHeaderChecked(headerID int64) error { - return shared.MarkHeaderChecked(headerID, repository.db, constants.VatMoveChecked) -} - -func (repository *VatMoveRepository) SetDB(db *postgres.DB) { - repository.db = db -} diff --git a/pkg/transformers/vat_move/repository_test.go b/pkg/transformers/vat_move/repository_test.go deleted file mode 100644 index 905559dc..00000000 --- a/pkg/transformers/vat_move/repository_test.go +++ /dev/null @@ -1,84 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package vat_move_test - -import ( - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" - "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres/repositories" - "github.com/vulcanize/vulcanizedb/pkg/fakes" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" - "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data" - "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data/shared_behaviors" - "github.com/vulcanize/vulcanizedb/pkg/transformers/vat_move" - "github.com/vulcanize/vulcanizedb/test_config" -) - -var _ = Describe("Vat Move", func() { - var db *postgres.DB - var repository vat_move.VatMoveRepository - - BeforeEach(func() { - db = test_config.NewTestDB(test_config.NewTestNode()) - test_config.CleanTestDB(db) - repository = vat_move.VatMoveRepository{} - repository.SetDB(db) - }) - - Describe("Create", func() { - modelWithDifferentLogIdx := test_data.VatMoveModel - modelWithDifferentLogIdx.LogIndex++ - inputs := shared_behaviors.CreateBehaviorInputs{ - CheckedHeaderColumnName: constants.VatMoveChecked, - LogEventTableName: "maker.vat_move", - TestModel: test_data.VatMoveModel, - ModelWithDifferentLogIdx: modelWithDifferentLogIdx, - Repository: &repository, - } - - shared_behaviors.SharedRepositoryCreateBehaviors(&inputs) - - It("persists vat move records", func() { - headerRepository := repositories.NewHeaderRepository(db) - headerID, err := headerRepository.CreateOrUpdateHeader(fakes.FakeHeader) - Expect(err).NotTo(HaveOccurred()) - - err = repository.Create(headerID, []interface{}{test_data.VatMoveModel}) - - Expect(err).NotTo(HaveOccurred()) - var dbVatMove vat_move.VatMoveModel - err = db.Get(&dbVatMove, `SELECT src, dst, rad, log_idx, tx_idx, raw_log FROM maker.vat_move WHERE header_id = $1`, headerID) - Expect(err).NotTo(HaveOccurred()) - Expect(dbVatMove.Src).To(Equal(test_data.VatMoveModel.Src)) - Expect(dbVatMove.Dst).To(Equal(test_data.VatMoveModel.Dst)) - Expect(dbVatMove.Rad).To(Equal(test_data.VatMoveModel.Rad)) - Expect(dbVatMove.LogIndex).To(Equal(test_data.VatMoveModel.LogIndex)) - Expect(dbVatMove.TransactionIndex).To(Equal(test_data.VatMoveModel.TransactionIndex)) - Expect(dbVatMove.Raw).To(MatchJSON(test_data.VatMoveModel.Raw)) - }) - }) - - Describe("MarkHeaderChecked", func() { - inputs := shared_behaviors.MarkedHeaderCheckedBehaviorInputs{ - CheckedHeaderColumnName: constants.VatMoveChecked, - Repository: &repository, - } - - shared_behaviors.SharedRepositoryMarkHeaderCheckedBehaviors(&inputs) - }) -}) diff --git a/pkg/transformers/vat_move/vat_move_suite_test.go b/pkg/transformers/vat_move/vat_move_suite_test.go deleted file mode 100644 index e42b8919..00000000 --- a/pkg/transformers/vat_move/vat_move_suite_test.go +++ /dev/null @@ -1,35 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package vat_move_test - -import ( - log "github.com/sirupsen/logrus" - "io/ioutil" - "testing" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -func TestVatMove(t *testing.T) { - RegisterFailHandler(Fail) - RunSpecs(t, "VatMove Suite") -} - -var _ = BeforeSuite(func() { - log.SetOutput(ioutil.Discard) -}) diff --git a/pkg/transformers/vat_slip/config.go b/pkg/transformers/vat_slip/config.go deleted file mode 100644 index d095b8c1..00000000 --- a/pkg/transformers/vat_slip/config.go +++ /dev/null @@ -1,17 +0,0 @@ -package vat_slip - -import ( - shared_t "github.com/vulcanize/vulcanizedb/libraries/shared/transformer" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" -) - -func GetVatSlipConfig() shared_t.TransformerConfig { - return shared_t.TransformerConfig{ - TransformerName: constants.VatSlipLabel, - ContractAddresses: []string{constants.VatContractAddress()}, - ContractAbi: constants.VatABI(), - Topic: constants.GetVatSlipSignature(), - StartingBlockNumber: constants.VatDeploymentBlock(), - EndingBlockNumber: -1, - } -} diff --git a/pkg/transformers/vat_slip/converter.go b/pkg/transformers/vat_slip/converter.go deleted file mode 100644 index d40311e0..00000000 --- a/pkg/transformers/vat_slip/converter.go +++ /dev/null @@ -1,62 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package vat_slip - -import ( - "encoding/json" - "errors" - "github.com/ethereum/go-ethereum/core/types" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared" -) - -type VatSlipConverter struct{} - -func (VatSlipConverter) ToModels(ethLogs []types.Log) ([]interface{}, error) { - var models []interface{} - for _, ethLog := range ethLogs { - err := verifyLog(ethLog) - if err != nil { - return nil, err - } - ilk := shared.GetHexWithoutPrefix(ethLog.Topics[1].Bytes()) - guy := shared.GetHexWithoutPrefix(ethLog.Topics[2].Bytes()) - rad := ethLog.Topics[3].Big() - - raw, err := json.Marshal(ethLog) - if err != nil { - return nil, err - } - model := VatSlipModel{ - Ilk: ilk, - Guy: guy, - Rad: rad.String(), - TransactionIndex: ethLog.TxIndex, - LogIndex: ethLog.Index, - Raw: raw, - } - models = append(models, model) - } - return models, nil -} - -func verifyLog(log types.Log) error { - numTopicInValidLog := 4 - if len(log.Topics) < numTopicInValidLog { - return errors.New("log missing topics") - } - return nil -} diff --git a/pkg/transformers/vat_slip/converter_test.go b/pkg/transformers/vat_slip/converter_test.go deleted file mode 100644 index 24107eb0..00000000 --- a/pkg/transformers/vat_slip/converter_test.go +++ /dev/null @@ -1,49 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package vat_slip_test - -import ( - "github.com/ethereum/go-ethereum/core/types" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - - "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data" - "github.com/vulcanize/vulcanizedb/pkg/transformers/vat_slip" -) - -var _ = Describe("Vat slip converter", func() { - It("returns err if log is missing topics", func() { - converter := vat_slip.VatSlipConverter{} - badLog := types.Log{ - Data: []byte{1, 1, 1, 1, 1}, - } - - _, err := converter.ToModels([]types.Log{badLog}) - - Expect(err).To(HaveOccurred()) - }) - - It("converts a log to a model", func() { - converter := vat_slip.VatSlipConverter{} - - models, err := converter.ToModels([]types.Log{test_data.EthVatSlipLog}) - - Expect(err).NotTo(HaveOccurred()) - Expect(len(models)).To(Equal(1)) - Expect(models[0]).To(Equal(test_data.VatSlipModel)) - }) -}) diff --git a/pkg/transformers/vat_slip/model.go b/pkg/transformers/vat_slip/model.go deleted file mode 100644 index adb69417..00000000 --- a/pkg/transformers/vat_slip/model.go +++ /dev/null @@ -1,26 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package vat_slip - -type VatSlipModel struct { - Ilk string - Guy string - Rad string - TransactionIndex uint `db:"tx_idx"` - LogIndex uint `db:"log_idx"` - Raw []byte `db:"raw_log"` -} diff --git a/pkg/transformers/vat_slip/vat_slip_suite_test.go b/pkg/transformers/vat_slip/vat_slip_suite_test.go deleted file mode 100644 index 643ccd4f..00000000 --- a/pkg/transformers/vat_slip/vat_slip_suite_test.go +++ /dev/null @@ -1,35 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package vat_slip_test - -import ( - "testing" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - log "github.com/sirupsen/logrus" - "io/ioutil" -) - -func TestVatSlip(t *testing.T) { - RegisterFailHandler(Fail) - RunSpecs(t, "VatSlip Suite") -} - -var _ = BeforeSuite(func() { - log.SetOutput(ioutil.Discard) -}) diff --git a/pkg/transformers/vat_toll/config.go b/pkg/transformers/vat_toll/config.go deleted file mode 100644 index 998026d4..00000000 --- a/pkg/transformers/vat_toll/config.go +++ /dev/null @@ -1,17 +0,0 @@ -package vat_toll - -import ( - shared_t "github.com/vulcanize/vulcanizedb/libraries/shared/transformer" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" -) - -func GetVatTollConfig() shared_t.TransformerConfig { - return shared_t.TransformerConfig{ - TransformerName: constants.VatTollLabel, - ContractAddresses: []string{constants.VatContractAddress()}, - ContractAbi: constants.VatABI(), - Topic: constants.GetVatTollSignature(), - StartingBlockNumber: constants.VatDeploymentBlock(), - EndingBlockNumber: -1, - } -} diff --git a/pkg/transformers/vat_toll/converter.go b/pkg/transformers/vat_toll/converter.go deleted file mode 100644 index fce8b7b7..00000000 --- a/pkg/transformers/vat_toll/converter.go +++ /dev/null @@ -1,47 +0,0 @@ -package vat_toll - -import ( - "encoding/json" - "errors" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared" - - "github.com/ethereum/go-ethereum/core/types" -) - -type VatTollConverter struct{} - -func (VatTollConverter) ToModels(ethLogs []types.Log) ([]interface{}, error) { - var models []interface{} - for _, ethLog := range ethLogs { - err := verifyLog(ethLog) - if err != nil { - return nil, err - } - ilk := shared.GetHexWithoutPrefix(ethLog.Topics[1].Bytes()) - urn := shared.GetHexWithoutPrefix(ethLog.Topics[2].Bytes()) - take := ethLog.Topics[3].Big() - - raw, err := json.Marshal(ethLog) - if err != nil { - return nil, err - } - model := VatTollModel{ - Ilk: ilk, - Urn: urn, - Take: take.String(), - TransactionIndex: ethLog.TxIndex, - LogIndex: ethLog.Index, - Raw: raw, - } - models = append(models, model) - } - return models, nil -} - -func verifyLog(log types.Log) error { - numTopicInValidLog := 4 - if len(log.Topics) < numTopicInValidLog { - return errors.New("log missing topics") - } - return nil -} diff --git a/pkg/transformers/vat_toll/converter_test.go b/pkg/transformers/vat_toll/converter_test.go deleted file mode 100644 index 94b049f3..00000000 --- a/pkg/transformers/vat_toll/converter_test.go +++ /dev/null @@ -1,33 +0,0 @@ -package vat_toll_test - -import ( - "github.com/ethereum/go-ethereum/core/types" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - - "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data" - "github.com/vulcanize/vulcanizedb/pkg/transformers/vat_toll" -) - -var _ = Describe("Vat toll converter", func() { - It("returns err if log is missing topics", func() { - converter := vat_toll.VatTollConverter{} - badLog := types.Log{ - Data: []byte{1, 1, 1, 1, 1}, - } - - _, err := converter.ToModels([]types.Log{badLog}) - - Expect(err).To(HaveOccurred()) - }) - - It("converts a log to an model", func() { - converter := vat_toll.VatTollConverter{} - - models, err := converter.ToModels([]types.Log{test_data.EthVatTollLog}) - - Expect(err).NotTo(HaveOccurred()) - Expect(len(models)).To(Equal(1)) - Expect(models[0]).To(Equal(test_data.VatTollModel)) - }) -}) diff --git a/pkg/transformers/vat_toll/model.go b/pkg/transformers/vat_toll/model.go deleted file mode 100644 index 8f0d1855..00000000 --- a/pkg/transformers/vat_toll/model.go +++ /dev/null @@ -1,10 +0,0 @@ -package vat_toll - -type VatTollModel struct { - Ilk string - Urn string - Take string - TransactionIndex uint `db:"tx_idx"` - LogIndex uint `db:"log_idx"` - Raw []byte `db:"raw_log"` -} diff --git a/pkg/transformers/vat_toll/vat_toll_suite_test.go b/pkg/transformers/vat_toll/vat_toll_suite_test.go deleted file mode 100644 index b5b1e7b0..00000000 --- a/pkg/transformers/vat_toll/vat_toll_suite_test.go +++ /dev/null @@ -1,19 +0,0 @@ -package vat_toll_test - -import ( - "testing" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - log "github.com/sirupsen/logrus" - "io/ioutil" -) - -func TestVatToll(t *testing.T) { - RegisterFailHandler(Fail) - RunSpecs(t, "VatToll Suite") -} - -var _ = BeforeSuite(func() { - log.SetOutput(ioutil.Discard) -}) diff --git a/pkg/transformers/vat_tune/config.go b/pkg/transformers/vat_tune/config.go deleted file mode 100644 index cd3627a6..00000000 --- a/pkg/transformers/vat_tune/config.go +++ /dev/null @@ -1,17 +0,0 @@ -package vat_tune - -import ( - shared_t "github.com/vulcanize/vulcanizedb/libraries/shared/transformer" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" -) - -func GetVatTuneConfig() shared_t.TransformerConfig { - return shared_t.TransformerConfig{ - TransformerName: constants.VatTuneLabel, - ContractAddresses: []string{constants.VatContractAddress()}, - ContractAbi: constants.VatABI(), - Topic: constants.GetVatTuneSignature(), - StartingBlockNumber: constants.VatDeploymentBlock(), - EndingBlockNumber: -1, - } -} diff --git a/pkg/transformers/vat_tune/converter.go b/pkg/transformers/vat_tune/converter.go deleted file mode 100644 index e2627606..00000000 --- a/pkg/transformers/vat_tune/converter.go +++ /dev/null @@ -1,61 +0,0 @@ -package vat_tune - -import ( - "encoding/json" - "errors" - "math/big" - - "github.com/ethereum/go-ethereum/core/types" - - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" -) - -type VatTuneConverter struct{} - -func (VatTuneConverter) ToModels(ethLogs []types.Log) ([]interface{}, error) { - var models []interface{} - for _, ethLog := range ethLogs { - err := verifyLog(ethLog) - if err != nil { - return nil, err - } - ilk := shared.GetHexWithoutPrefix(ethLog.Topics[1].Bytes()) - urn := shared.GetHexWithoutPrefix(ethLog.Topics[2].Bytes()) - v := shared.GetHexWithoutPrefix(ethLog.Topics[3].Bytes()) - wBytes := shared.GetDataBytesAtIndex(-3, ethLog.Data) - w := shared.GetHexWithoutPrefix(wBytes) - dinkBytes := shared.GetDataBytesAtIndex(-2, ethLog.Data) - dink := big.NewInt(0).SetBytes(dinkBytes) - dartBytes := shared.GetDataBytesAtIndex(-1, ethLog.Data) - dart := big.NewInt(0).SetBytes(dartBytes) - - raw, err := json.Marshal(ethLog) - if err != nil { - return nil, err - } - model := VatTuneModel{ - Ilk: ilk, - Urn: urn, - V: v, - W: w, - Dink: dink.String(), - Dart: dart.String(), - TransactionIndex: ethLog.TxIndex, - LogIndex: ethLog.Index, - Raw: raw, - } - models = append(models, model) - } - return models, nil -} - -func verifyLog(log types.Log) error { - if len(log.Topics) < 4 { - return errors.New("log missing topics") - } - if len(log.Data) < constants.DataItemLength { - return errors.New("log missing data") - } - return nil -} diff --git a/pkg/transformers/vat_tune/converter_test.go b/pkg/transformers/vat_tune/converter_test.go deleted file mode 100644 index 6f8c21a3..00000000 --- a/pkg/transformers/vat_tune/converter_test.go +++ /dev/null @@ -1,45 +0,0 @@ -package vat_tune_test - -import ( - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/types" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - - "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data" - "github.com/vulcanize/vulcanizedb/pkg/transformers/vat_tune" -) - -var _ = Describe("Vat tune converter", func() { - It("returns err if log is missing topics", func() { - converter := vat_tune.VatTuneConverter{} - badLog := types.Log{ - Data: []byte{1, 1, 1, 1, 1}, - } - - _, err := converter.ToModels([]types.Log{badLog}) - - Expect(err).To(HaveOccurred()) - }) - - It("returns err if log is missing data", func() { - converter := vat_tune.VatTuneConverter{} - badLog := types.Log{ - Topics: []common.Hash{{}, {}, {}, {}}, - } - - _, err := converter.ToModels([]types.Log{badLog}) - - Expect(err).To(HaveOccurred()) - }) - - It("converts a log to a model", func() { - converter := vat_tune.VatTuneConverter{} - - models, err := converter.ToModels([]types.Log{test_data.EthVatTuneLog}) - - Expect(err).NotTo(HaveOccurred()) - Expect(len(models)).To(Equal(1)) - Expect(models[0]).To(Equal(test_data.VatTuneModel)) - }) -}) diff --git a/pkg/transformers/vat_tune/model.go b/pkg/transformers/vat_tune/model.go deleted file mode 100644 index e32df171..00000000 --- a/pkg/transformers/vat_tune/model.go +++ /dev/null @@ -1,13 +0,0 @@ -package vat_tune - -type VatTuneModel struct { - Ilk string - Urn string - V string - W string - Dink string - Dart string - TransactionIndex uint `db:"tx_idx"` - LogIndex uint `db:"log_idx"` - Raw []byte `db:"raw_log"` -} diff --git a/pkg/transformers/vat_tune/vat_tune_suite_test.go b/pkg/transformers/vat_tune/vat_tune_suite_test.go deleted file mode 100644 index 6dcefa73..00000000 --- a/pkg/transformers/vat_tune/vat_tune_suite_test.go +++ /dev/null @@ -1,19 +0,0 @@ -package vat_tune_test - -import ( - "testing" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - log "github.com/sirupsen/logrus" - "io/ioutil" -) - -func TestVatTune(t *testing.T) { - RegisterFailHandler(Fail) - RunSpecs(t, "VatTune Suite") -} - -var _ = BeforeSuite(func() { - log.SetOutput(ioutil.Discard) -}) diff --git a/pkg/transformers/vow_flog/config.go b/pkg/transformers/vow_flog/config.go deleted file mode 100644 index 5f46ec82..00000000 --- a/pkg/transformers/vow_flog/config.go +++ /dev/null @@ -1,33 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package vow_flog - -import ( - shared_t "github.com/vulcanize/vulcanizedb/libraries/shared/transformer" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" -) - -func GetVowFlogConfig() shared_t.TransformerConfig { - return shared_t.TransformerConfig{ - TransformerName: constants.VowFlogLabel, - ContractAddresses: []string{constants.VowContractAddress()}, - ContractAbi: constants.VowABI(), - Topic: constants.GetVowFlogSignature(), - StartingBlockNumber: constants.VowDeploymentBlock(), - EndingBlockNumber: -1, - } -} diff --git a/pkg/transformers/vow_flog/converter.go b/pkg/transformers/vow_flog/converter.go deleted file mode 100644 index dcabd152..00000000 --- a/pkg/transformers/vow_flog/converter.go +++ /dev/null @@ -1,61 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package vow_flog - -import ( - "encoding/json" - "errors" - "github.com/ethereum/go-ethereum/core/types" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" -) - -type VowFlogConverter struct{} - -func (VowFlogConverter) ToModels(ethLogs []types.Log) ([]interface{}, error) { - var models []interface{} - for _, ethLog := range ethLogs { - err := verifyLog(ethLog) - if err != nil { - return nil, err - } - - era := ethLog.Topics[2].Big() - - raw, err := json.Marshal(ethLog) - if err != nil { - return nil, err - } - model := VowFlogModel{ - Era: era.String(), - LogIndex: ethLog.Index, - TransactionIndex: ethLog.TxIndex, - Raw: raw, - } - models = append(models, model) - } - return models, nil -} - -func verifyLog(log types.Log) error { - if len(log.Topics) < 3 { - return errors.New("log missing topics") - } - if len(log.Data) < constants.DataItemLength { - return errors.New("log missing data") - } - return nil -} diff --git a/pkg/transformers/vow_flog/converter_test.go b/pkg/transformers/vow_flog/converter_test.go deleted file mode 100644 index fd26d573..00000000 --- a/pkg/transformers/vow_flog/converter_test.go +++ /dev/null @@ -1,60 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package vow_flog_test - -import ( - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/types" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - "github.com/vulcanize/vulcanizedb/pkg/transformers/vow_flog" - - "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data" -) - -var _ = Describe("Vow flog converter", func() { - var converter vow_flog.VowFlogConverter - BeforeEach(func() { - converter = vow_flog.VowFlogConverter{} - }) - - It("returns err if log is missing topics", func() { - badLog := types.Log{ - Data: []byte{1, 1, 1, 1, 1}, - } - - _, err := converter.ToModels([]types.Log{badLog}) - Expect(err).To(HaveOccurred()) - }) - - It("returns err if log is missing data", func() { - badLog := types.Log{ - Topics: []common.Hash{{}, {}, {}, {}}, - } - - _, err := converter.ToModels([]types.Log{badLog}) - Expect(err).To(HaveOccurred()) - }) - - It("converts a log to a model", func() { - models, err := converter.ToModels([]types.Log{test_data.EthVowFlogLog}) - - Expect(err).NotTo(HaveOccurred()) - Expect(len(models)).To(Equal(1)) - Expect(models[0].(vow_flog.VowFlogModel)).To(Equal(test_data.VowFlogModel)) - }) -}) diff --git a/pkg/transformers/vow_flog/model.go b/pkg/transformers/vow_flog/model.go deleted file mode 100644 index 4fdbda8d..00000000 --- a/pkg/transformers/vow_flog/model.go +++ /dev/null @@ -1,24 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package vow_flog - -type VowFlogModel struct { - Era string - LogIndex uint `db:"log_idx"` - TransactionIndex uint `db:"tx_idx"` - Raw []byte `db:"raw_log"` -} diff --git a/pkg/transformers/vow_flog/repository.go b/pkg/transformers/vow_flog/repository.go deleted file mode 100644 index 6b1a735d..00000000 --- a/pkg/transformers/vow_flog/repository.go +++ /dev/null @@ -1,92 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package vow_flog - -import ( - "fmt" - - log "github.com/sirupsen/logrus" - - "github.com/vulcanize/vulcanizedb/pkg/core" - "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" -) - -type VowFlogRepository struct { - db *postgres.DB -} - -func (repository VowFlogRepository) Create(headerID int64, models []interface{}) error { - tx, dBaseErr := repository.db.Begin() - if dBaseErr != nil { - return dBaseErr - } - - for _, model := range models { - flog, ok := model.(VowFlogModel) - if !ok { - rollbackErr := tx.Rollback() - if rollbackErr != nil { - log.Error("failed to rollback ", rollbackErr) - } - return fmt.Errorf("model of type %T, not %T", model, VowFlogModel{}) - } - - _, execErr := tx.Exec( - `INSERT into maker.vow_flog (header_id, era, log_idx, tx_idx, raw_log) - VALUES($1, $2::NUMERIC, $3, $4, $5) - ON CONFLICT (header_id, tx_idx, log_idx) DO UPDATE SET era = $2, raw_log = $5;`, - headerID, flog.Era, flog.LogIndex, flog.TransactionIndex, flog.Raw, - ) - - if execErr != nil { - rollbackErr := tx.Rollback() - if rollbackErr != nil { - log.Error("failed to rollback ", rollbackErr) - } - return execErr - } - } - - checkHeaderErr := shared.MarkHeaderCheckedInTransaction(headerID, tx, constants.VowFlogChecked) - if checkHeaderErr != nil { - rollbackErr := tx.Rollback() - if rollbackErr != nil { - log.Error("failed to rollback ", rollbackErr) - } - return checkHeaderErr - } - - return tx.Commit() -} - -func (repository VowFlogRepository) MarkHeaderChecked(headerID int64) error { - return shared.MarkHeaderChecked(headerID, repository.db, constants.VowFlogChecked) -} - -func (repository VowFlogRepository) MissingHeaders(startingBlockNumber, endingBlockNumber int64) ([]core.Header, error) { - return shared.MissingHeaders(startingBlockNumber, endingBlockNumber, repository.db, constants.VowFlogChecked) -} - -func (repository VowFlogRepository) RecheckHeaders(startingBlockNumber, endingBlockNumber int64) ([]core.Header, error) { - return shared.RecheckHeaders(startingBlockNumber, endingBlockNumber, repository.db, constants.VowFlogChecked) -} - -func (repository *VowFlogRepository) SetDB(db *postgres.DB) { - repository.db = db -} diff --git a/pkg/transformers/vow_flog/repository_test.go b/pkg/transformers/vow_flog/repository_test.go deleted file mode 100644 index 5f843c07..00000000 --- a/pkg/transformers/vow_flog/repository_test.go +++ /dev/null @@ -1,85 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package vow_flog_test - -import ( - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" - "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data/shared_behaviors" - - "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" - "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres/repositories" - "github.com/vulcanize/vulcanizedb/pkg/fakes" - "github.com/vulcanize/vulcanizedb/pkg/transformers/test_data" - "github.com/vulcanize/vulcanizedb/pkg/transformers/vow_flog" - "github.com/vulcanize/vulcanizedb/test_config" -) - -var _ = Describe("Vow flog repository", func() { - var ( - db *postgres.DB - repository vow_flog.VowFlogRepository - ) - - BeforeEach(func() { - db = test_config.NewTestDB(test_config.NewTestNode()) - test_config.CleanTestDB(db) - repository = vow_flog.VowFlogRepository{} - repository.SetDB(db) - }) - - Describe("Create", func() { - modelWithDifferentLogIdx := test_data.VowFlogModel - modelWithDifferentLogIdx.LogIndex++ - inputs := shared_behaviors.CreateBehaviorInputs{ - CheckedHeaderColumnName: constants.VowFlogChecked, - LogEventTableName: "maker.vow_flog", - TestModel: test_data.VowFlogModel, - ModelWithDifferentLogIdx: modelWithDifferentLogIdx, - Repository: &repository, - } - - shared_behaviors.SharedRepositoryCreateBehaviors(&inputs) - - It("adds a vow flog event", func() { - headerRepository := repositories.NewHeaderRepository(db) - headerID, err := headerRepository.CreateOrUpdateHeader(fakes.FakeHeader) - Expect(err).NotTo(HaveOccurred()) - - err = repository.Create(headerID, []interface{}{test_data.VowFlogModel}) - Expect(err).NotTo(HaveOccurred()) - - var dbFlog vow_flog.VowFlogModel - err = db.Get(&dbFlog, `SELECT era, log_idx, tx_idx, raw_log FROM maker.vow_flog WHERE header_id = $1`, headerID) - Expect(err).NotTo(HaveOccurred()) - Expect(dbFlog.Era).To(Equal(test_data.VowFlogModel.Era)) - Expect(dbFlog.LogIndex).To(Equal(test_data.VowFlogModel.LogIndex)) - Expect(dbFlog.TransactionIndex).To(Equal(test_data.VowFlogModel.TransactionIndex)) - Expect(dbFlog.Raw).To(MatchJSON(test_data.VowFlogModel.Raw)) - }) - }) - - Describe("MarkHeaderChecked", func() { - inputs := shared_behaviors.MarkedHeaderCheckedBehaviorInputs{ - CheckedHeaderColumnName: constants.VowFlogChecked, - Repository: &repository, - } - - shared_behaviors.SharedRepositoryMarkHeaderCheckedBehaviors(&inputs) - }) -}) diff --git a/pkg/transformers/vow_flog/vow_flog_suite_test.go b/pkg/transformers/vow_flog/vow_flog_suite_test.go deleted file mode 100644 index f5b602d7..00000000 --- a/pkg/transformers/vow_flog/vow_flog_suite_test.go +++ /dev/null @@ -1,35 +0,0 @@ -// VulcanizeDB -// Copyright © 2018 Vulcanize - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. - -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -package vow_flog - -import ( - "testing" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - log "github.com/sirupsen/logrus" - "io/ioutil" -) - -func TestVowFlog(t *testing.T) { - RegisterFailHandler(Fail) - RunSpecs(t, "VowFlog Suite") -} - -var _ = BeforeSuite(func() { - log.SetOutput(ioutil.Discard) -}) diff --git a/plugins/README.md b/plugins/README.md index 0b3b440d..4a1d8983 100644 --- a/plugins/README.md +++ b/plugins/README.md @@ -17,8 +17,7 @@ The config file requires, at a minimum, the below fields: ipcPath = "http://kovan0.vulcanize.io:8545" [exporter] - filePath = "$GOPATH/src/github.com/vulcanize/vulcanizedb/plugins/" - fileName = "exporter" + name = "exporter" [exporter.transformers] transformer1 = "github.com/path/to/transformer1" transformer2 = "github.com/path/to/transformer2" @@ -70,7 +69,9 @@ func (e exporter) Export() []interface1.TransformerInitializer { As such, to plug in an external transformer we need to create a [package](https://github.com/vulcanize/maker-vulcanizedb/blob/compose_and_execute/pkg/autogen/test_helpers/bite/initializer.go) that exports a variable `TransformerInitializer` that is of type [TransformerInitializer](https://github.com/vulcanize/maker-vulcanizedb/blob/compose_and_execute/libraries/shared/transformer/transformer.go#L19) As long as the imported transformers abide by the required interfaces, we can execute over any arbitrary set of them -Note: currently the transformers must also operate using the watcher's [execution mode](https://github.com/vulcanize/maker-vulcanizedb/blob/compose_and_execute/libraries/shared/watcher/watcher.go#L80) +Note: currently the transformers must also operate using this watcher's [execution mode](https://github.com/vulcanize/maker-vulcanizedb/blob/compose_and_execute/libraries/shared/watcher/watcher.go#L80), in the future the watcher will become pluggable as well For each transformer we will also need to create db migrations to run against vulcanizeDB so that we can store the transformed data -The migrations needed for a specific transformer need to be included in the same repository as the transformers that require them, and their relative paths in that repo specified in the config as discussed above \ No newline at end of file +The migrations needed for a specific transformer need to be included in the same repository as the transformer(s) that require them, and their relative paths in that repo must be specified in the config as discussed above + +NOTE: Due to a bug with plugin migrations, currently need to leave the `exporter.migrations` blank and manually run migrations before running composeAndExecute \ No newline at end of file diff --git a/pkg/transformers/start_test_chain.sh b/scripts/start_test_chain.sh similarity index 83% rename from pkg/transformers/start_test_chain.sh rename to scripts/start_test_chain.sh index cd62fab5..58b7707b 100755 --- a/pkg/transformers/start_test_chain.sh +++ b/scripts/start_test_chain.sh @@ -2,7 +2,7 @@ MNEMONIC_PHRASE="whisper ordinary mystery awesome wood fox auction february blind volcano spare soft" PORT=7545 -DATABASE_PATH=pkg/transformers/test_data/test_chain/ +DATABASE_PATH=test_data/test_chain/ echo Starting ganache chain on port $PORT... ganache-cli --port $PORT \ diff --git a/pkg/transformers/stop_test_chain.sh b/scripts/stop_test_chain.sh similarity index 100% rename from pkg/transformers/stop_test_chain.sh rename to scripts/stop_test_chain.sh diff --git a/pkg/transformers/test_data/test_chain/!blockHashes!0x1faae5bf0d78e3d8cc018d2e87db91d0e1e64edc1e69e2ef1dd8caec3afec93c b/test_data/test_chain/!blockHashes!0x1faae5bf0d78e3d8cc018d2e87db91d0e1e64edc1e69e2ef1dd8caec3afec93c similarity index 100% rename from pkg/transformers/test_data/test_chain/!blockHashes!0x1faae5bf0d78e3d8cc018d2e87db91d0e1e64edc1e69e2ef1dd8caec3afec93c rename to test_data/test_chain/!blockHashes!0x1faae5bf0d78e3d8cc018d2e87db91d0e1e64edc1e69e2ef1dd8caec3afec93c diff --git a/pkg/transformers/test_data/test_chain/!blockHashes!0x56ba7ae1c6f7aaa74ae77f9613b43a5a50a7fad09f1fca42888e163fb34f0537 b/test_data/test_chain/!blockHashes!0x56ba7ae1c6f7aaa74ae77f9613b43a5a50a7fad09f1fca42888e163fb34f0537 similarity index 100% rename from pkg/transformers/test_data/test_chain/!blockHashes!0x56ba7ae1c6f7aaa74ae77f9613b43a5a50a7fad09f1fca42888e163fb34f0537 rename to test_data/test_chain/!blockHashes!0x56ba7ae1c6f7aaa74ae77f9613b43a5a50a7fad09f1fca42888e163fb34f0537 diff --git a/pkg/transformers/test_data/test_chain/!blockHashes!0x6151d2ee962c0182b8d259362d9c84a7f11bf0f1f3f9113e88f23cc80e6e5a24 b/test_data/test_chain/!blockHashes!0x6151d2ee962c0182b8d259362d9c84a7f11bf0f1f3f9113e88f23cc80e6e5a24 similarity index 100% rename from pkg/transformers/test_data/test_chain/!blockHashes!0x6151d2ee962c0182b8d259362d9c84a7f11bf0f1f3f9113e88f23cc80e6e5a24 rename to test_data/test_chain/!blockHashes!0x6151d2ee962c0182b8d259362d9c84a7f11bf0f1f3f9113e88f23cc80e6e5a24 diff --git a/pkg/transformers/test_data/test_chain/!blockHashes!0x61c5cb2a574755ca1bb146fe391418c638bb118b74fa456748cebad6f5565dd2 b/test_data/test_chain/!blockHashes!0x61c5cb2a574755ca1bb146fe391418c638bb118b74fa456748cebad6f5565dd2 similarity index 100% rename from pkg/transformers/test_data/test_chain/!blockHashes!0x61c5cb2a574755ca1bb146fe391418c638bb118b74fa456748cebad6f5565dd2 rename to test_data/test_chain/!blockHashes!0x61c5cb2a574755ca1bb146fe391418c638bb118b74fa456748cebad6f5565dd2 diff --git a/pkg/transformers/test_data/test_chain/!blockHashes!0x6803ff793873c6143a8e1734584ea759b2b3fdb8a13a1cb023c6d0822e650aa1 b/test_data/test_chain/!blockHashes!0x6803ff793873c6143a8e1734584ea759b2b3fdb8a13a1cb023c6d0822e650aa1 similarity index 100% rename from pkg/transformers/test_data/test_chain/!blockHashes!0x6803ff793873c6143a8e1734584ea759b2b3fdb8a13a1cb023c6d0822e650aa1 rename to test_data/test_chain/!blockHashes!0x6803ff793873c6143a8e1734584ea759b2b3fdb8a13a1cb023c6d0822e650aa1 diff --git a/pkg/transformers/test_data/test_chain/!blockHashes!0x71f36ea384f3f25e317f6c4b5f889578811b77e710f9e7c1a75ed5e1cff13a65 b/test_data/test_chain/!blockHashes!0x71f36ea384f3f25e317f6c4b5f889578811b77e710f9e7c1a75ed5e1cff13a65 similarity index 100% rename from pkg/transformers/test_data/test_chain/!blockHashes!0x71f36ea384f3f25e317f6c4b5f889578811b77e710f9e7c1a75ed5e1cff13a65 rename to test_data/test_chain/!blockHashes!0x71f36ea384f3f25e317f6c4b5f889578811b77e710f9e7c1a75ed5e1cff13a65 diff --git a/pkg/transformers/test_data/test_chain/!blockHashes!0x876ecbdafaee12440e7619a789e1fcdab1e0252c236b3ec622fb2f565a3f2216 b/test_data/test_chain/!blockHashes!0x876ecbdafaee12440e7619a789e1fcdab1e0252c236b3ec622fb2f565a3f2216 similarity index 100% rename from pkg/transformers/test_data/test_chain/!blockHashes!0x876ecbdafaee12440e7619a789e1fcdab1e0252c236b3ec622fb2f565a3f2216 rename to test_data/test_chain/!blockHashes!0x876ecbdafaee12440e7619a789e1fcdab1e0252c236b3ec622fb2f565a3f2216 diff --git a/pkg/transformers/test_data/test_chain/!blockHashes!0x8fbe0d8442f58c843bd8003e93f2b100c81f2b57e5a339fea6d8de9bee764afa b/test_data/test_chain/!blockHashes!0x8fbe0d8442f58c843bd8003e93f2b100c81f2b57e5a339fea6d8de9bee764afa similarity index 100% rename from pkg/transformers/test_data/test_chain/!blockHashes!0x8fbe0d8442f58c843bd8003e93f2b100c81f2b57e5a339fea6d8de9bee764afa rename to test_data/test_chain/!blockHashes!0x8fbe0d8442f58c843bd8003e93f2b100c81f2b57e5a339fea6d8de9bee764afa diff --git a/pkg/transformers/test_data/test_chain/!blockHashes!0x903a879c68f1485576c44d211ceb42e7dc0ad30e33f08fad8578384c334d9254 b/test_data/test_chain/!blockHashes!0x903a879c68f1485576c44d211ceb42e7dc0ad30e33f08fad8578384c334d9254 similarity index 100% rename from pkg/transformers/test_data/test_chain/!blockHashes!0x903a879c68f1485576c44d211ceb42e7dc0ad30e33f08fad8578384c334d9254 rename to test_data/test_chain/!blockHashes!0x903a879c68f1485576c44d211ceb42e7dc0ad30e33f08fad8578384c334d9254 diff --git a/pkg/transformers/test_data/test_chain/!blockHashes!0x9a97cef69601c548306f2029e3e2059c02716eafa859f0f4eae08c23b5b78903 b/test_data/test_chain/!blockHashes!0x9a97cef69601c548306f2029e3e2059c02716eafa859f0f4eae08c23b5b78903 similarity index 100% rename from pkg/transformers/test_data/test_chain/!blockHashes!0x9a97cef69601c548306f2029e3e2059c02716eafa859f0f4eae08c23b5b78903 rename to test_data/test_chain/!blockHashes!0x9a97cef69601c548306f2029e3e2059c02716eafa859f0f4eae08c23b5b78903 diff --git a/pkg/transformers/test_data/test_chain/!blockHashes!0xa4dc9cf47b1ac951d65d325778b2be463d13e50974d41afc2b5463f5dc6b5550 b/test_data/test_chain/!blockHashes!0xa4dc9cf47b1ac951d65d325778b2be463d13e50974d41afc2b5463f5dc6b5550 similarity index 100% rename from pkg/transformers/test_data/test_chain/!blockHashes!0xa4dc9cf47b1ac951d65d325778b2be463d13e50974d41afc2b5463f5dc6b5550 rename to test_data/test_chain/!blockHashes!0xa4dc9cf47b1ac951d65d325778b2be463d13e50974d41afc2b5463f5dc6b5550 diff --git a/pkg/transformers/test_data/test_chain/!blockHashes!0xc95293bdd8a065d159347c1444656ffe4993ecd8e2108d00ba842f6b98821c1f b/test_data/test_chain/!blockHashes!0xc95293bdd8a065d159347c1444656ffe4993ecd8e2108d00ba842f6b98821c1f similarity index 100% rename from pkg/transformers/test_data/test_chain/!blockHashes!0xc95293bdd8a065d159347c1444656ffe4993ecd8e2108d00ba842f6b98821c1f rename to test_data/test_chain/!blockHashes!0xc95293bdd8a065d159347c1444656ffe4993ecd8e2108d00ba842f6b98821c1f diff --git a/pkg/transformers/test_data/test_chain/!blockHashes!0xe6c87e0c062c3544efe2e9f7d0ed346abd16b0ed27fcfd8dfddab878bc34c085 b/test_data/test_chain/!blockHashes!0xe6c87e0c062c3544efe2e9f7d0ed346abd16b0ed27fcfd8dfddab878bc34c085 similarity index 100% rename from pkg/transformers/test_data/test_chain/!blockHashes!0xe6c87e0c062c3544efe2e9f7d0ed346abd16b0ed27fcfd8dfddab878bc34c085 rename to test_data/test_chain/!blockHashes!0xe6c87e0c062c3544efe2e9f7d0ed346abd16b0ed27fcfd8dfddab878bc34c085 diff --git a/pkg/transformers/test_data/test_chain/!blockLogs!0 b/test_data/test_chain/!blockLogs!0 similarity index 100% rename from pkg/transformers/test_data/test_chain/!blockLogs!0 rename to test_data/test_chain/!blockLogs!0 diff --git a/pkg/transformers/test_data/test_chain/!blockLogs!1 b/test_data/test_chain/!blockLogs!1 similarity index 100% rename from pkg/transformers/test_data/test_chain/!blockLogs!1 rename to test_data/test_chain/!blockLogs!1 diff --git a/pkg/transformers/test_data/test_chain/!blockLogs!10 b/test_data/test_chain/!blockLogs!10 similarity index 100% rename from pkg/transformers/test_data/test_chain/!blockLogs!10 rename to test_data/test_chain/!blockLogs!10 diff --git a/pkg/transformers/test_data/test_chain/!blockLogs!11 b/test_data/test_chain/!blockLogs!11 similarity index 100% rename from pkg/transformers/test_data/test_chain/!blockLogs!11 rename to test_data/test_chain/!blockLogs!11 diff --git a/pkg/transformers/test_data/test_chain/!blockLogs!12 b/test_data/test_chain/!blockLogs!12 similarity index 100% rename from pkg/transformers/test_data/test_chain/!blockLogs!12 rename to test_data/test_chain/!blockLogs!12 diff --git a/pkg/transformers/test_data/test_chain/!blockLogs!2 b/test_data/test_chain/!blockLogs!2 similarity index 100% rename from pkg/transformers/test_data/test_chain/!blockLogs!2 rename to test_data/test_chain/!blockLogs!2 diff --git a/pkg/transformers/test_data/test_chain/!blockLogs!3 b/test_data/test_chain/!blockLogs!3 similarity index 100% rename from pkg/transformers/test_data/test_chain/!blockLogs!3 rename to test_data/test_chain/!blockLogs!3 diff --git a/pkg/transformers/test_data/test_chain/!blockLogs!4 b/test_data/test_chain/!blockLogs!4 similarity index 100% rename from pkg/transformers/test_data/test_chain/!blockLogs!4 rename to test_data/test_chain/!blockLogs!4 diff --git a/pkg/transformers/test_data/test_chain/!blockLogs!5 b/test_data/test_chain/!blockLogs!5 similarity index 100% rename from pkg/transformers/test_data/test_chain/!blockLogs!5 rename to test_data/test_chain/!blockLogs!5 diff --git a/pkg/transformers/test_data/test_chain/!blockLogs!6 b/test_data/test_chain/!blockLogs!6 similarity index 100% rename from pkg/transformers/test_data/test_chain/!blockLogs!6 rename to test_data/test_chain/!blockLogs!6 diff --git a/pkg/transformers/test_data/test_chain/!blockLogs!7 b/test_data/test_chain/!blockLogs!7 similarity index 100% rename from pkg/transformers/test_data/test_chain/!blockLogs!7 rename to test_data/test_chain/!blockLogs!7 diff --git a/pkg/transformers/test_data/test_chain/!blockLogs!8 b/test_data/test_chain/!blockLogs!8 similarity index 100% rename from pkg/transformers/test_data/test_chain/!blockLogs!8 rename to test_data/test_chain/!blockLogs!8 diff --git a/pkg/transformers/test_data/test_chain/!blockLogs!9 b/test_data/test_chain/!blockLogs!9 similarity index 100% rename from pkg/transformers/test_data/test_chain/!blockLogs!9 rename to test_data/test_chain/!blockLogs!9 diff --git a/pkg/transformers/test_data/test_chain/!blockLogs!length b/test_data/test_chain/!blockLogs!length similarity index 100% rename from pkg/transformers/test_data/test_chain/!blockLogs!length rename to test_data/test_chain/!blockLogs!length diff --git a/pkg/transformers/test_data/test_chain/!blocks!0 b/test_data/test_chain/!blocks!0 similarity index 100% rename from pkg/transformers/test_data/test_chain/!blocks!0 rename to test_data/test_chain/!blocks!0 diff --git a/pkg/transformers/test_data/test_chain/!blocks!1 b/test_data/test_chain/!blocks!1 similarity index 100% rename from pkg/transformers/test_data/test_chain/!blocks!1 rename to test_data/test_chain/!blocks!1 diff --git a/pkg/transformers/test_data/test_chain/!blocks!10 b/test_data/test_chain/!blocks!10 similarity index 100% rename from pkg/transformers/test_data/test_chain/!blocks!10 rename to test_data/test_chain/!blocks!10 diff --git a/pkg/transformers/test_data/test_chain/!blocks!11 b/test_data/test_chain/!blocks!11 similarity index 100% rename from pkg/transformers/test_data/test_chain/!blocks!11 rename to test_data/test_chain/!blocks!11 diff --git a/pkg/transformers/test_data/test_chain/!blocks!12 b/test_data/test_chain/!blocks!12 similarity index 100% rename from pkg/transformers/test_data/test_chain/!blocks!12 rename to test_data/test_chain/!blocks!12 diff --git a/pkg/transformers/test_data/test_chain/!blocks!2 b/test_data/test_chain/!blocks!2 similarity index 100% rename from pkg/transformers/test_data/test_chain/!blocks!2 rename to test_data/test_chain/!blocks!2 diff --git a/pkg/transformers/test_data/test_chain/!blocks!3 b/test_data/test_chain/!blocks!3 similarity index 100% rename from pkg/transformers/test_data/test_chain/!blocks!3 rename to test_data/test_chain/!blocks!3 diff --git a/pkg/transformers/test_data/test_chain/!blocks!4 b/test_data/test_chain/!blocks!4 similarity index 100% rename from pkg/transformers/test_data/test_chain/!blocks!4 rename to test_data/test_chain/!blocks!4 diff --git a/pkg/transformers/test_data/test_chain/!blocks!5 b/test_data/test_chain/!blocks!5 similarity index 100% rename from pkg/transformers/test_data/test_chain/!blocks!5 rename to test_data/test_chain/!blocks!5 diff --git a/pkg/transformers/test_data/test_chain/!blocks!6 b/test_data/test_chain/!blocks!6 similarity index 100% rename from pkg/transformers/test_data/test_chain/!blocks!6 rename to test_data/test_chain/!blocks!6 diff --git a/pkg/transformers/test_data/test_chain/!blocks!7 b/test_data/test_chain/!blocks!7 similarity index 100% rename from pkg/transformers/test_data/test_chain/!blocks!7 rename to test_data/test_chain/!blocks!7 diff --git a/pkg/transformers/test_data/test_chain/!blocks!8 b/test_data/test_chain/!blocks!8 similarity index 100% rename from pkg/transformers/test_data/test_chain/!blocks!8 rename to test_data/test_chain/!blocks!8 diff --git a/pkg/transformers/test_data/test_chain/!blocks!9 b/test_data/test_chain/!blocks!9 similarity index 100% rename from pkg/transformers/test_data/test_chain/!blocks!9 rename to test_data/test_chain/!blocks!9 diff --git a/pkg/transformers/test_data/test_chain/!blocks!length b/test_data/test_chain/!blocks!length similarity index 100% rename from pkg/transformers/test_data/test_chain/!blocks!length rename to test_data/test_chain/!blocks!length diff --git a/pkg/transformers/test_data/test_chain/!transactionReceipts!0x001b40cb161afd969df9f958665d25384bb0d3f12b59780458f81f9fe11c4464 b/test_data/test_chain/!transactionReceipts!0x001b40cb161afd969df9f958665d25384bb0d3f12b59780458f81f9fe11c4464 similarity index 100% rename from pkg/transformers/test_data/test_chain/!transactionReceipts!0x001b40cb161afd969df9f958665d25384bb0d3f12b59780458f81f9fe11c4464 rename to test_data/test_chain/!transactionReceipts!0x001b40cb161afd969df9f958665d25384bb0d3f12b59780458f81f9fe11c4464 diff --git a/pkg/transformers/test_data/test_chain/!transactionReceipts!0x2194da14a0d4be36fb809efd3f9f426bf60842dbf244788d0a84b894b3e6bd49 b/test_data/test_chain/!transactionReceipts!0x2194da14a0d4be36fb809efd3f9f426bf60842dbf244788d0a84b894b3e6bd49 similarity index 100% rename from pkg/transformers/test_data/test_chain/!transactionReceipts!0x2194da14a0d4be36fb809efd3f9f426bf60842dbf244788d0a84b894b3e6bd49 rename to test_data/test_chain/!transactionReceipts!0x2194da14a0d4be36fb809efd3f9f426bf60842dbf244788d0a84b894b3e6bd49 diff --git a/pkg/transformers/test_data/test_chain/!transactionReceipts!0x30e1e9cb6ee8d98c1fbe6b7ca89d53034c0607b1298226fcd28f774df6f1b09d b/test_data/test_chain/!transactionReceipts!0x30e1e9cb6ee8d98c1fbe6b7ca89d53034c0607b1298226fcd28f774df6f1b09d similarity index 100% rename from pkg/transformers/test_data/test_chain/!transactionReceipts!0x30e1e9cb6ee8d98c1fbe6b7ca89d53034c0607b1298226fcd28f774df6f1b09d rename to test_data/test_chain/!transactionReceipts!0x30e1e9cb6ee8d98c1fbe6b7ca89d53034c0607b1298226fcd28f774df6f1b09d diff --git a/pkg/transformers/test_data/test_chain/!transactionReceipts!0x5b37b7a5bd08efac0e4bb3ac507761a8f13a87176eabb20301e223c74f587434 b/test_data/test_chain/!transactionReceipts!0x5b37b7a5bd08efac0e4bb3ac507761a8f13a87176eabb20301e223c74f587434 similarity index 100% rename from pkg/transformers/test_data/test_chain/!transactionReceipts!0x5b37b7a5bd08efac0e4bb3ac507761a8f13a87176eabb20301e223c74f587434 rename to test_data/test_chain/!transactionReceipts!0x5b37b7a5bd08efac0e4bb3ac507761a8f13a87176eabb20301e223c74f587434 diff --git a/pkg/transformers/test_data/test_chain/!transactionReceipts!0x6b155a55fd77b751195deeebf7abfd8691ca01ee588817a920f19d5b27f65191 b/test_data/test_chain/!transactionReceipts!0x6b155a55fd77b751195deeebf7abfd8691ca01ee588817a920f19d5b27f65191 similarity index 100% rename from pkg/transformers/test_data/test_chain/!transactionReceipts!0x6b155a55fd77b751195deeebf7abfd8691ca01ee588817a920f19d5b27f65191 rename to test_data/test_chain/!transactionReceipts!0x6b155a55fd77b751195deeebf7abfd8691ca01ee588817a920f19d5b27f65191 diff --git a/pkg/transformers/test_data/test_chain/!transactionReceipts!0x8956d8bdced261516039ea57abcfaaa71bbd770886afa1d3e6ac2e5b65bc6293 b/test_data/test_chain/!transactionReceipts!0x8956d8bdced261516039ea57abcfaaa71bbd770886afa1d3e6ac2e5b65bc6293 similarity index 100% rename from pkg/transformers/test_data/test_chain/!transactionReceipts!0x8956d8bdced261516039ea57abcfaaa71bbd770886afa1d3e6ac2e5b65bc6293 rename to test_data/test_chain/!transactionReceipts!0x8956d8bdced261516039ea57abcfaaa71bbd770886afa1d3e6ac2e5b65bc6293 diff --git a/pkg/transformers/test_data/test_chain/!transactionReceipts!0x99eafa867c60105b21589ad055bd60c567482d9b532b926978236477bb34a1db b/test_data/test_chain/!transactionReceipts!0x99eafa867c60105b21589ad055bd60c567482d9b532b926978236477bb34a1db similarity index 100% rename from pkg/transformers/test_data/test_chain/!transactionReceipts!0x99eafa867c60105b21589ad055bd60c567482d9b532b926978236477bb34a1db rename to test_data/test_chain/!transactionReceipts!0x99eafa867c60105b21589ad055bd60c567482d9b532b926978236477bb34a1db diff --git a/pkg/transformers/test_data/test_chain/!transactionReceipts!0xa04e60c48a756ddb94babf195ae4de2699515f0eb9b70b09221ec74ca7dea343 b/test_data/test_chain/!transactionReceipts!0xa04e60c48a756ddb94babf195ae4de2699515f0eb9b70b09221ec74ca7dea343 similarity index 100% rename from pkg/transformers/test_data/test_chain/!transactionReceipts!0xa04e60c48a756ddb94babf195ae4de2699515f0eb9b70b09221ec74ca7dea343 rename to test_data/test_chain/!transactionReceipts!0xa04e60c48a756ddb94babf195ae4de2699515f0eb9b70b09221ec74ca7dea343 diff --git a/pkg/transformers/test_data/test_chain/!transactionReceipts!0xa18a1a6c0f6dffd28c90aaaf6d822a206797367ee094ebcf0ee003f52c812f02 b/test_data/test_chain/!transactionReceipts!0xa18a1a6c0f6dffd28c90aaaf6d822a206797367ee094ebcf0ee003f52c812f02 similarity index 100% rename from pkg/transformers/test_data/test_chain/!transactionReceipts!0xa18a1a6c0f6dffd28c90aaaf6d822a206797367ee094ebcf0ee003f52c812f02 rename to test_data/test_chain/!transactionReceipts!0xa18a1a6c0f6dffd28c90aaaf6d822a206797367ee094ebcf0ee003f52c812f02 diff --git a/pkg/transformers/test_data/test_chain/!transactionReceipts!0xa8e605dfe8af972342126849910aa42ed1ce7df6b88230375628b48c54dfa146 b/test_data/test_chain/!transactionReceipts!0xa8e605dfe8af972342126849910aa42ed1ce7df6b88230375628b48c54dfa146 similarity index 100% rename from pkg/transformers/test_data/test_chain/!transactionReceipts!0xa8e605dfe8af972342126849910aa42ed1ce7df6b88230375628b48c54dfa146 rename to test_data/test_chain/!transactionReceipts!0xa8e605dfe8af972342126849910aa42ed1ce7df6b88230375628b48c54dfa146 diff --git a/pkg/transformers/test_data/test_chain/!transactionReceipts!0xbcff98316acb5732891d1a7e02f23ec12fbf8c231ca4b5530fa7a21c1e9b6aa9 b/test_data/test_chain/!transactionReceipts!0xbcff98316acb5732891d1a7e02f23ec12fbf8c231ca4b5530fa7a21c1e9b6aa9 similarity index 100% rename from pkg/transformers/test_data/test_chain/!transactionReceipts!0xbcff98316acb5732891d1a7e02f23ec12fbf8c231ca4b5530fa7a21c1e9b6aa9 rename to test_data/test_chain/!transactionReceipts!0xbcff98316acb5732891d1a7e02f23ec12fbf8c231ca4b5530fa7a21c1e9b6aa9 diff --git a/pkg/transformers/test_data/test_chain/!transactionReceipts!0xc0bdfdb15c288d6a7b0af865d953677c4818c6655d26631bd7b840e9cfb2d668 b/test_data/test_chain/!transactionReceipts!0xc0bdfdb15c288d6a7b0af865d953677c4818c6655d26631bd7b840e9cfb2d668 similarity index 100% rename from pkg/transformers/test_data/test_chain/!transactionReceipts!0xc0bdfdb15c288d6a7b0af865d953677c4818c6655d26631bd7b840e9cfb2d668 rename to test_data/test_chain/!transactionReceipts!0xc0bdfdb15c288d6a7b0af865d953677c4818c6655d26631bd7b840e9cfb2d668 diff --git a/pkg/transformers/test_data/test_chain/!transactions!0x001b40cb161afd969df9f958665d25384bb0d3f12b59780458f81f9fe11c4464 b/test_data/test_chain/!transactions!0x001b40cb161afd969df9f958665d25384bb0d3f12b59780458f81f9fe11c4464 similarity index 100% rename from pkg/transformers/test_data/test_chain/!transactions!0x001b40cb161afd969df9f958665d25384bb0d3f12b59780458f81f9fe11c4464 rename to test_data/test_chain/!transactions!0x001b40cb161afd969df9f958665d25384bb0d3f12b59780458f81f9fe11c4464 diff --git a/pkg/transformers/test_data/test_chain/!transactions!0x2194da14a0d4be36fb809efd3f9f426bf60842dbf244788d0a84b894b3e6bd49 b/test_data/test_chain/!transactions!0x2194da14a0d4be36fb809efd3f9f426bf60842dbf244788d0a84b894b3e6bd49 similarity index 100% rename from pkg/transformers/test_data/test_chain/!transactions!0x2194da14a0d4be36fb809efd3f9f426bf60842dbf244788d0a84b894b3e6bd49 rename to test_data/test_chain/!transactions!0x2194da14a0d4be36fb809efd3f9f426bf60842dbf244788d0a84b894b3e6bd49 diff --git a/pkg/transformers/test_data/test_chain/!transactions!0x30e1e9cb6ee8d98c1fbe6b7ca89d53034c0607b1298226fcd28f774df6f1b09d b/test_data/test_chain/!transactions!0x30e1e9cb6ee8d98c1fbe6b7ca89d53034c0607b1298226fcd28f774df6f1b09d similarity index 100% rename from pkg/transformers/test_data/test_chain/!transactions!0x30e1e9cb6ee8d98c1fbe6b7ca89d53034c0607b1298226fcd28f774df6f1b09d rename to test_data/test_chain/!transactions!0x30e1e9cb6ee8d98c1fbe6b7ca89d53034c0607b1298226fcd28f774df6f1b09d diff --git a/pkg/transformers/test_data/test_chain/!transactions!0x5b37b7a5bd08efac0e4bb3ac507761a8f13a87176eabb20301e223c74f587434 b/test_data/test_chain/!transactions!0x5b37b7a5bd08efac0e4bb3ac507761a8f13a87176eabb20301e223c74f587434 similarity index 100% rename from pkg/transformers/test_data/test_chain/!transactions!0x5b37b7a5bd08efac0e4bb3ac507761a8f13a87176eabb20301e223c74f587434 rename to test_data/test_chain/!transactions!0x5b37b7a5bd08efac0e4bb3ac507761a8f13a87176eabb20301e223c74f587434 diff --git a/pkg/transformers/test_data/test_chain/!transactions!0x6b155a55fd77b751195deeebf7abfd8691ca01ee588817a920f19d5b27f65191 b/test_data/test_chain/!transactions!0x6b155a55fd77b751195deeebf7abfd8691ca01ee588817a920f19d5b27f65191 similarity index 100% rename from pkg/transformers/test_data/test_chain/!transactions!0x6b155a55fd77b751195deeebf7abfd8691ca01ee588817a920f19d5b27f65191 rename to test_data/test_chain/!transactions!0x6b155a55fd77b751195deeebf7abfd8691ca01ee588817a920f19d5b27f65191 diff --git a/pkg/transformers/test_data/test_chain/!transactions!0x8956d8bdced261516039ea57abcfaaa71bbd770886afa1d3e6ac2e5b65bc6293 b/test_data/test_chain/!transactions!0x8956d8bdced261516039ea57abcfaaa71bbd770886afa1d3e6ac2e5b65bc6293 similarity index 100% rename from pkg/transformers/test_data/test_chain/!transactions!0x8956d8bdced261516039ea57abcfaaa71bbd770886afa1d3e6ac2e5b65bc6293 rename to test_data/test_chain/!transactions!0x8956d8bdced261516039ea57abcfaaa71bbd770886afa1d3e6ac2e5b65bc6293 diff --git a/pkg/transformers/test_data/test_chain/!transactions!0x99eafa867c60105b21589ad055bd60c567482d9b532b926978236477bb34a1db b/test_data/test_chain/!transactions!0x99eafa867c60105b21589ad055bd60c567482d9b532b926978236477bb34a1db similarity index 100% rename from pkg/transformers/test_data/test_chain/!transactions!0x99eafa867c60105b21589ad055bd60c567482d9b532b926978236477bb34a1db rename to test_data/test_chain/!transactions!0x99eafa867c60105b21589ad055bd60c567482d9b532b926978236477bb34a1db diff --git a/pkg/transformers/test_data/test_chain/!transactions!0xa04e60c48a756ddb94babf195ae4de2699515f0eb9b70b09221ec74ca7dea343 b/test_data/test_chain/!transactions!0xa04e60c48a756ddb94babf195ae4de2699515f0eb9b70b09221ec74ca7dea343 similarity index 100% rename from pkg/transformers/test_data/test_chain/!transactions!0xa04e60c48a756ddb94babf195ae4de2699515f0eb9b70b09221ec74ca7dea343 rename to test_data/test_chain/!transactions!0xa04e60c48a756ddb94babf195ae4de2699515f0eb9b70b09221ec74ca7dea343 diff --git a/pkg/transformers/test_data/test_chain/!transactions!0xa18a1a6c0f6dffd28c90aaaf6d822a206797367ee094ebcf0ee003f52c812f02 b/test_data/test_chain/!transactions!0xa18a1a6c0f6dffd28c90aaaf6d822a206797367ee094ebcf0ee003f52c812f02 similarity index 100% rename from pkg/transformers/test_data/test_chain/!transactions!0xa18a1a6c0f6dffd28c90aaaf6d822a206797367ee094ebcf0ee003f52c812f02 rename to test_data/test_chain/!transactions!0xa18a1a6c0f6dffd28c90aaaf6d822a206797367ee094ebcf0ee003f52c812f02 diff --git a/pkg/transformers/test_data/test_chain/!transactions!0xa8e605dfe8af972342126849910aa42ed1ce7df6b88230375628b48c54dfa146 b/test_data/test_chain/!transactions!0xa8e605dfe8af972342126849910aa42ed1ce7df6b88230375628b48c54dfa146 similarity index 100% rename from pkg/transformers/test_data/test_chain/!transactions!0xa8e605dfe8af972342126849910aa42ed1ce7df6b88230375628b48c54dfa146 rename to test_data/test_chain/!transactions!0xa8e605dfe8af972342126849910aa42ed1ce7df6b88230375628b48c54dfa146 diff --git a/pkg/transformers/test_data/test_chain/!transactions!0xbcff98316acb5732891d1a7e02f23ec12fbf8c231ca4b5530fa7a21c1e9b6aa9 b/test_data/test_chain/!transactions!0xbcff98316acb5732891d1a7e02f23ec12fbf8c231ca4b5530fa7a21c1e9b6aa9 similarity index 100% rename from pkg/transformers/test_data/test_chain/!transactions!0xbcff98316acb5732891d1a7e02f23ec12fbf8c231ca4b5530fa7a21c1e9b6aa9 rename to test_data/test_chain/!transactions!0xbcff98316acb5732891d1a7e02f23ec12fbf8c231ca4b5530fa7a21c1e9b6aa9 diff --git a/pkg/transformers/test_data/test_chain/!transactions!0xc0bdfdb15c288d6a7b0af865d953677c4818c6655d26631bd7b840e9cfb2d668 b/test_data/test_chain/!transactions!0xc0bdfdb15c288d6a7b0af865d953677c4818c6655d26631bd7b840e9cfb2d668 similarity index 100% rename from pkg/transformers/test_data/test_chain/!transactions!0xc0bdfdb15c288d6a7b0af865d953677c4818c6655d26631bd7b840e9cfb2d668 rename to test_data/test_chain/!transactions!0xc0bdfdb15c288d6a7b0af865d953677c4818c6655d26631bd7b840e9cfb2d668 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x018307e454fab3317e51ac01fcb6c49b6204ae6e1e11a768a52ad80fef5c45de b/test_data/test_chain/!trie_db!0x018307e454fab3317e51ac01fcb6c49b6204ae6e1e11a768a52ad80fef5c45de similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x018307e454fab3317e51ac01fcb6c49b6204ae6e1e11a768a52ad80fef5c45de rename to test_data/test_chain/!trie_db!0x018307e454fab3317e51ac01fcb6c49b6204ae6e1e11a768a52ad80fef5c45de diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x03a6152e38d112bbb90b47ce492c6f8c7719668be7d71faedd55c522e8a756c7 b/test_data/test_chain/!trie_db!0x03a6152e38d112bbb90b47ce492c6f8c7719668be7d71faedd55c522e8a756c7 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x03a6152e38d112bbb90b47ce492c6f8c7719668be7d71faedd55c522e8a756c7 rename to test_data/test_chain/!trie_db!0x03a6152e38d112bbb90b47ce492c6f8c7719668be7d71faedd55c522e8a756c7 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x0580883480974cf8d76b4a4d6eb1a04a3080df15d235779a7318839acd4ec0bb b/test_data/test_chain/!trie_db!0x0580883480974cf8d76b4a4d6eb1a04a3080df15d235779a7318839acd4ec0bb similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x0580883480974cf8d76b4a4d6eb1a04a3080df15d235779a7318839acd4ec0bb rename to test_data/test_chain/!trie_db!0x0580883480974cf8d76b4a4d6eb1a04a3080df15d235779a7318839acd4ec0bb diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x0669e99db03fadf7104f6fce6f5dee43e3082eea0a429e7bc05c0aa06937a1b4 b/test_data/test_chain/!trie_db!0x0669e99db03fadf7104f6fce6f5dee43e3082eea0a429e7bc05c0aa06937a1b4 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x0669e99db03fadf7104f6fce6f5dee43e3082eea0a429e7bc05c0aa06937a1b4 rename to test_data/test_chain/!trie_db!0x0669e99db03fadf7104f6fce6f5dee43e3082eea0a429e7bc05c0aa06937a1b4 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x070abfdf0f48e22d8997a1da98af511067fa17d3472bb7b2053e26663154e6b5 b/test_data/test_chain/!trie_db!0x070abfdf0f48e22d8997a1da98af511067fa17d3472bb7b2053e26663154e6b5 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x070abfdf0f48e22d8997a1da98af511067fa17d3472bb7b2053e26663154e6b5 rename to test_data/test_chain/!trie_db!0x070abfdf0f48e22d8997a1da98af511067fa17d3472bb7b2053e26663154e6b5 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x08cb51ef4d2a0a75ebaf16e59652f0a909bf9a461c2916e8b600f7e0b4c03624 b/test_data/test_chain/!trie_db!0x08cb51ef4d2a0a75ebaf16e59652f0a909bf9a461c2916e8b600f7e0b4c03624 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x08cb51ef4d2a0a75ebaf16e59652f0a909bf9a461c2916e8b600f7e0b4c03624 rename to test_data/test_chain/!trie_db!0x08cb51ef4d2a0a75ebaf16e59652f0a909bf9a461c2916e8b600f7e0b4c03624 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x08fc4b6336e7757c3d89b620ecf6f1b5a7fbee90374484591347ac658909505b b/test_data/test_chain/!trie_db!0x08fc4b6336e7757c3d89b620ecf6f1b5a7fbee90374484591347ac658909505b similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x08fc4b6336e7757c3d89b620ecf6f1b5a7fbee90374484591347ac658909505b rename to test_data/test_chain/!trie_db!0x08fc4b6336e7757c3d89b620ecf6f1b5a7fbee90374484591347ac658909505b diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x0e1adb36bae65d3155a1a7f0ab1f18cb8bd59db49e62cdebf6705b13116e15ca b/test_data/test_chain/!trie_db!0x0e1adb36bae65d3155a1a7f0ab1f18cb8bd59db49e62cdebf6705b13116e15ca similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x0e1adb36bae65d3155a1a7f0ab1f18cb8bd59db49e62cdebf6705b13116e15ca rename to test_data/test_chain/!trie_db!0x0e1adb36bae65d3155a1a7f0ab1f18cb8bd59db49e62cdebf6705b13116e15ca diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x0e90d9cbe0bf11f02708860522fb09308ce0db17ba249df1a4aa8802824f374e b/test_data/test_chain/!trie_db!0x0e90d9cbe0bf11f02708860522fb09308ce0db17ba249df1a4aa8802824f374e similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x0e90d9cbe0bf11f02708860522fb09308ce0db17ba249df1a4aa8802824f374e rename to test_data/test_chain/!trie_db!0x0e90d9cbe0bf11f02708860522fb09308ce0db17ba249df1a4aa8802824f374e diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x126fe799e67c134d54afc67d5aeee9fc376ab1d87f435750ae382befc5bd3926 b/test_data/test_chain/!trie_db!0x126fe799e67c134d54afc67d5aeee9fc376ab1d87f435750ae382befc5bd3926 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x126fe799e67c134d54afc67d5aeee9fc376ab1d87f435750ae382befc5bd3926 rename to test_data/test_chain/!trie_db!0x126fe799e67c134d54afc67d5aeee9fc376ab1d87f435750ae382befc5bd3926 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x14a96b69c2eef02d5e6634d7934993c4b23d133a8f96001f6a03a9664c02f758 b/test_data/test_chain/!trie_db!0x14a96b69c2eef02d5e6634d7934993c4b23d133a8f96001f6a03a9664c02f758 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x14a96b69c2eef02d5e6634d7934993c4b23d133a8f96001f6a03a9664c02f758 rename to test_data/test_chain/!trie_db!0x14a96b69c2eef02d5e6634d7934993c4b23d133a8f96001f6a03a9664c02f758 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x151e5297e1c821d226d7df4a96b11752d522dcfd50b08d2cc58b38af68ce67c5 b/test_data/test_chain/!trie_db!0x151e5297e1c821d226d7df4a96b11752d522dcfd50b08d2cc58b38af68ce67c5 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x151e5297e1c821d226d7df4a96b11752d522dcfd50b08d2cc58b38af68ce67c5 rename to test_data/test_chain/!trie_db!0x151e5297e1c821d226d7df4a96b11752d522dcfd50b08d2cc58b38af68ce67c5 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x1530dd82eba8342920e0b0e94f1caa940c9208ee1549369307fce12672f34fcc b/test_data/test_chain/!trie_db!0x1530dd82eba8342920e0b0e94f1caa940c9208ee1549369307fce12672f34fcc similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x1530dd82eba8342920e0b0e94f1caa940c9208ee1549369307fce12672f34fcc rename to test_data/test_chain/!trie_db!0x1530dd82eba8342920e0b0e94f1caa940c9208ee1549369307fce12672f34fcc diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x157933e4f44b7ff7eb5b84bec2e32e7809151518a104fbff813500b0c235ab7c b/test_data/test_chain/!trie_db!0x157933e4f44b7ff7eb5b84bec2e32e7809151518a104fbff813500b0c235ab7c similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x157933e4f44b7ff7eb5b84bec2e32e7809151518a104fbff813500b0c235ab7c rename to test_data/test_chain/!trie_db!0x157933e4f44b7ff7eb5b84bec2e32e7809151518a104fbff813500b0c235ab7c diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x161a254a50e709306848b2b1932c171c039301fa9142d0727501a028e38ba0f9 b/test_data/test_chain/!trie_db!0x161a254a50e709306848b2b1932c171c039301fa9142d0727501a028e38ba0f9 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x161a254a50e709306848b2b1932c171c039301fa9142d0727501a028e38ba0f9 rename to test_data/test_chain/!trie_db!0x161a254a50e709306848b2b1932c171c039301fa9142d0727501a028e38ba0f9 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x162a37ba4b241919df4de217c7067bda5e49d83e82fe395a5e4d12b437a42cff b/test_data/test_chain/!trie_db!0x162a37ba4b241919df4de217c7067bda5e49d83e82fe395a5e4d12b437a42cff similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x162a37ba4b241919df4de217c7067bda5e49d83e82fe395a5e4d12b437a42cff rename to test_data/test_chain/!trie_db!0x162a37ba4b241919df4de217c7067bda5e49d83e82fe395a5e4d12b437a42cff diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x16f0a9df893b180dfea7a14cd9bfa31961a121a44cde32886b8aeef67c78ec03 b/test_data/test_chain/!trie_db!0x16f0a9df893b180dfea7a14cd9bfa31961a121a44cde32886b8aeef67c78ec03 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x16f0a9df893b180dfea7a14cd9bfa31961a121a44cde32886b8aeef67c78ec03 rename to test_data/test_chain/!trie_db!0x16f0a9df893b180dfea7a14cd9bfa31961a121a44cde32886b8aeef67c78ec03 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x193d91e77927d4dd6888eb3cd28c6c3570cef82bd0ce193d6d78a420d076988f b/test_data/test_chain/!trie_db!0x193d91e77927d4dd6888eb3cd28c6c3570cef82bd0ce193d6d78a420d076988f similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x193d91e77927d4dd6888eb3cd28c6c3570cef82bd0ce193d6d78a420d076988f rename to test_data/test_chain/!trie_db!0x193d91e77927d4dd6888eb3cd28c6c3570cef82bd0ce193d6d78a420d076988f diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x19abe03cab8ad9d724d76a8a409f5c7f02f48d24f48aaab91fbd8f0af1ab25d8 b/test_data/test_chain/!trie_db!0x19abe03cab8ad9d724d76a8a409f5c7f02f48d24f48aaab91fbd8f0af1ab25d8 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x19abe03cab8ad9d724d76a8a409f5c7f02f48d24f48aaab91fbd8f0af1ab25d8 rename to test_data/test_chain/!trie_db!0x19abe03cab8ad9d724d76a8a409f5c7f02f48d24f48aaab91fbd8f0af1ab25d8 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x1ae66f56e80b6ce3f6dd2c657d165248c788005cbee34e61ff0a5459edae1722 b/test_data/test_chain/!trie_db!0x1ae66f56e80b6ce3f6dd2c657d165248c788005cbee34e61ff0a5459edae1722 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x1ae66f56e80b6ce3f6dd2c657d165248c788005cbee34e61ff0a5459edae1722 rename to test_data/test_chain/!trie_db!0x1ae66f56e80b6ce3f6dd2c657d165248c788005cbee34e61ff0a5459edae1722 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x1b9a0ca00da4bf0c31264a2bf0a2352c41b0012d157942fcabc59e64f08ec8a2 b/test_data/test_chain/!trie_db!0x1b9a0ca00da4bf0c31264a2bf0a2352c41b0012d157942fcabc59e64f08ec8a2 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x1b9a0ca00da4bf0c31264a2bf0a2352c41b0012d157942fcabc59e64f08ec8a2 rename to test_data/test_chain/!trie_db!0x1b9a0ca00da4bf0c31264a2bf0a2352c41b0012d157942fcabc59e64f08ec8a2 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x1daf92424a9e4f706bb9234b6fb02fb4329318278fd032617e1786f2ccf66e3e b/test_data/test_chain/!trie_db!0x1daf92424a9e4f706bb9234b6fb02fb4329318278fd032617e1786f2ccf66e3e similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x1daf92424a9e4f706bb9234b6fb02fb4329318278fd032617e1786f2ccf66e3e rename to test_data/test_chain/!trie_db!0x1daf92424a9e4f706bb9234b6fb02fb4329318278fd032617e1786f2ccf66e3e diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x1e557e6b926d9d0134f16c89d535bef90b3eb53766480f01abdb8af373d9a59c b/test_data/test_chain/!trie_db!0x1e557e6b926d9d0134f16c89d535bef90b3eb53766480f01abdb8af373d9a59c similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x1e557e6b926d9d0134f16c89d535bef90b3eb53766480f01abdb8af373d9a59c rename to test_data/test_chain/!trie_db!0x1e557e6b926d9d0134f16c89d535bef90b3eb53766480f01abdb8af373d9a59c diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x1e566933d70b71a726f5cc492316cd71fe8ee35d224575d33e29280c409c3c8d b/test_data/test_chain/!trie_db!0x1e566933d70b71a726f5cc492316cd71fe8ee35d224575d33e29280c409c3c8d similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x1e566933d70b71a726f5cc492316cd71fe8ee35d224575d33e29280c409c3c8d rename to test_data/test_chain/!trie_db!0x1e566933d70b71a726f5cc492316cd71fe8ee35d224575d33e29280c409c3c8d diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x21844edeb0c63d6c416c3ac4ccf639034227a206e8d39e76dadd463b61e5508b b/test_data/test_chain/!trie_db!0x21844edeb0c63d6c416c3ac4ccf639034227a206e8d39e76dadd463b61e5508b similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x21844edeb0c63d6c416c3ac4ccf639034227a206e8d39e76dadd463b61e5508b rename to test_data/test_chain/!trie_db!0x21844edeb0c63d6c416c3ac4ccf639034227a206e8d39e76dadd463b61e5508b diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x221c15544fb2c48a614af13e7e982ccf155677eb4559bcb31ae2c5dc9462bd1f b/test_data/test_chain/!trie_db!0x221c15544fb2c48a614af13e7e982ccf155677eb4559bcb31ae2c5dc9462bd1f similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x221c15544fb2c48a614af13e7e982ccf155677eb4559bcb31ae2c5dc9462bd1f rename to test_data/test_chain/!trie_db!0x221c15544fb2c48a614af13e7e982ccf155677eb4559bcb31ae2c5dc9462bd1f diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x24716f1f68fda94f79ba00d9f8a96dec0fd15a20e2c926c191d462b34acba94f b/test_data/test_chain/!trie_db!0x24716f1f68fda94f79ba00d9f8a96dec0fd15a20e2c926c191d462b34acba94f similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x24716f1f68fda94f79ba00d9f8a96dec0fd15a20e2c926c191d462b34acba94f rename to test_data/test_chain/!trie_db!0x24716f1f68fda94f79ba00d9f8a96dec0fd15a20e2c926c191d462b34acba94f diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x25fc93ab219268b7e46014c8ac580adba1ce1051d8cb8bcb1cd238f4187e577b b/test_data/test_chain/!trie_db!0x25fc93ab219268b7e46014c8ac580adba1ce1051d8cb8bcb1cd238f4187e577b similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x25fc93ab219268b7e46014c8ac580adba1ce1051d8cb8bcb1cd238f4187e577b rename to test_data/test_chain/!trie_db!0x25fc93ab219268b7e46014c8ac580adba1ce1051d8cb8bcb1cd238f4187e577b diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x26eeb42d0c6d7914ad039df7694003b2f4f98adf0e0153a57c1f84532127f1c1 b/test_data/test_chain/!trie_db!0x26eeb42d0c6d7914ad039df7694003b2f4f98adf0e0153a57c1f84532127f1c1 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x26eeb42d0c6d7914ad039df7694003b2f4f98adf0e0153a57c1f84532127f1c1 rename to test_data/test_chain/!trie_db!0x26eeb42d0c6d7914ad039df7694003b2f4f98adf0e0153a57c1f84532127f1c1 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x294e0688e78b8ebe45c45e778e11e00302f5dc9d735569c1b5a4a0cf48b848e2 b/test_data/test_chain/!trie_db!0x294e0688e78b8ebe45c45e778e11e00302f5dc9d735569c1b5a4a0cf48b848e2 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x294e0688e78b8ebe45c45e778e11e00302f5dc9d735569c1b5a4a0cf48b848e2 rename to test_data/test_chain/!trie_db!0x294e0688e78b8ebe45c45e778e11e00302f5dc9d735569c1b5a4a0cf48b848e2 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x2ac25c8b39e9ba3a99e3983a69cc607e6b2a4f04adbe1abb9167b8b5d454056e b/test_data/test_chain/!trie_db!0x2ac25c8b39e9ba3a99e3983a69cc607e6b2a4f04adbe1abb9167b8b5d454056e similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x2ac25c8b39e9ba3a99e3983a69cc607e6b2a4f04adbe1abb9167b8b5d454056e rename to test_data/test_chain/!trie_db!0x2ac25c8b39e9ba3a99e3983a69cc607e6b2a4f04adbe1abb9167b8b5d454056e diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x2b440d3b0b2327c14c3a867f273c26a6d198524da9ecffcc6dbe65b39ff6decf b/test_data/test_chain/!trie_db!0x2b440d3b0b2327c14c3a867f273c26a6d198524da9ecffcc6dbe65b39ff6decf similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x2b440d3b0b2327c14c3a867f273c26a6d198524da9ecffcc6dbe65b39ff6decf rename to test_data/test_chain/!trie_db!0x2b440d3b0b2327c14c3a867f273c26a6d198524da9ecffcc6dbe65b39ff6decf diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x316409abe1ceb4849f2756816ef63a6112def8047feb8701fe90c1101c78fe71 b/test_data/test_chain/!trie_db!0x316409abe1ceb4849f2756816ef63a6112def8047feb8701fe90c1101c78fe71 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x316409abe1ceb4849f2756816ef63a6112def8047feb8701fe90c1101c78fe71 rename to test_data/test_chain/!trie_db!0x316409abe1ceb4849f2756816ef63a6112def8047feb8701fe90c1101c78fe71 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x334d59a6b826ca00e56207b7be9c9d3ffc03fe1bb8a08fc967edacac01f44005 b/test_data/test_chain/!trie_db!0x334d59a6b826ca00e56207b7be9c9d3ffc03fe1bb8a08fc967edacac01f44005 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x334d59a6b826ca00e56207b7be9c9d3ffc03fe1bb8a08fc967edacac01f44005 rename to test_data/test_chain/!trie_db!0x334d59a6b826ca00e56207b7be9c9d3ffc03fe1bb8a08fc967edacac01f44005 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x3438447aae59d759a4d06c10dfaf35c0f8a71dffb05ab251e40a65e313fd9e90 b/test_data/test_chain/!trie_db!0x3438447aae59d759a4d06c10dfaf35c0f8a71dffb05ab251e40a65e313fd9e90 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x3438447aae59d759a4d06c10dfaf35c0f8a71dffb05ab251e40a65e313fd9e90 rename to test_data/test_chain/!trie_db!0x3438447aae59d759a4d06c10dfaf35c0f8a71dffb05ab251e40a65e313fd9e90 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x3545df9679886d70fa5b4d5fd3483749ad064ad7dcfcb0d530ec6eab49a03877 b/test_data/test_chain/!trie_db!0x3545df9679886d70fa5b4d5fd3483749ad064ad7dcfcb0d530ec6eab49a03877 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x3545df9679886d70fa5b4d5fd3483749ad064ad7dcfcb0d530ec6eab49a03877 rename to test_data/test_chain/!trie_db!0x3545df9679886d70fa5b4d5fd3483749ad064ad7dcfcb0d530ec6eab49a03877 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x354eb16bf2e29db7155a4a6bd376f4b8d456969ca8239266ce35ba948caaeb7e b/test_data/test_chain/!trie_db!0x354eb16bf2e29db7155a4a6bd376f4b8d456969ca8239266ce35ba948caaeb7e similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x354eb16bf2e29db7155a4a6bd376f4b8d456969ca8239266ce35ba948caaeb7e rename to test_data/test_chain/!trie_db!0x354eb16bf2e29db7155a4a6bd376f4b8d456969ca8239266ce35ba948caaeb7e diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x369ec720123cab87d401f1b284c66712344edab7ff4c99da27f5e77e6263d4cd b/test_data/test_chain/!trie_db!0x369ec720123cab87d401f1b284c66712344edab7ff4c99da27f5e77e6263d4cd similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x369ec720123cab87d401f1b284c66712344edab7ff4c99da27f5e77e6263d4cd rename to test_data/test_chain/!trie_db!0x369ec720123cab87d401f1b284c66712344edab7ff4c99da27f5e77e6263d4cd diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x372afacecb5d397370430cfa7481601253172b63d77e80278ab3d4895b20001b b/test_data/test_chain/!trie_db!0x372afacecb5d397370430cfa7481601253172b63d77e80278ab3d4895b20001b similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x372afacecb5d397370430cfa7481601253172b63d77e80278ab3d4895b20001b rename to test_data/test_chain/!trie_db!0x372afacecb5d397370430cfa7481601253172b63d77e80278ab3d4895b20001b diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x3900e16f35744fd8e6732d9253866e50977eb123efb7ecb3ae0508b5d72afef2 b/test_data/test_chain/!trie_db!0x3900e16f35744fd8e6732d9253866e50977eb123efb7ecb3ae0508b5d72afef2 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x3900e16f35744fd8e6732d9253866e50977eb123efb7ecb3ae0508b5d72afef2 rename to test_data/test_chain/!trie_db!0x3900e16f35744fd8e6732d9253866e50977eb123efb7ecb3ae0508b5d72afef2 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x3a875851ff16b0c695633e0db893a7ec4043ecc3551cd7fc633f0032c3e7b326 b/test_data/test_chain/!trie_db!0x3a875851ff16b0c695633e0db893a7ec4043ecc3551cd7fc633f0032c3e7b326 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x3a875851ff16b0c695633e0db893a7ec4043ecc3551cd7fc633f0032c3e7b326 rename to test_data/test_chain/!trie_db!0x3a875851ff16b0c695633e0db893a7ec4043ecc3551cd7fc633f0032c3e7b326 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x3be1026c1b3878769a10a398a4ed467d60278e117ab6ec2b3d89e69618992bb7 b/test_data/test_chain/!trie_db!0x3be1026c1b3878769a10a398a4ed467d60278e117ab6ec2b3d89e69618992bb7 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x3be1026c1b3878769a10a398a4ed467d60278e117ab6ec2b3d89e69618992bb7 rename to test_data/test_chain/!trie_db!0x3be1026c1b3878769a10a398a4ed467d60278e117ab6ec2b3d89e69618992bb7 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x3c8ffa547eb6fc72e5db76cbe3575136c1aa46cdb7d974e86d26ddf52aeffc6e b/test_data/test_chain/!trie_db!0x3c8ffa547eb6fc72e5db76cbe3575136c1aa46cdb7d974e86d26ddf52aeffc6e similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x3c8ffa547eb6fc72e5db76cbe3575136c1aa46cdb7d974e86d26ddf52aeffc6e rename to test_data/test_chain/!trie_db!0x3c8ffa547eb6fc72e5db76cbe3575136c1aa46cdb7d974e86d26ddf52aeffc6e diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x3df45dfd0e2d184dfcf3de07627ea3b523c2a291029632e4402d8616c03d70cf b/test_data/test_chain/!trie_db!0x3df45dfd0e2d184dfcf3de07627ea3b523c2a291029632e4402d8616c03d70cf similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x3df45dfd0e2d184dfcf3de07627ea3b523c2a291029632e4402d8616c03d70cf rename to test_data/test_chain/!trie_db!0x3df45dfd0e2d184dfcf3de07627ea3b523c2a291029632e4402d8616c03d70cf diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x3e473a1ed587c1edee5e85718874bf87e3f17e314bc604df3820d5c71c249711 b/test_data/test_chain/!trie_db!0x3e473a1ed587c1edee5e85718874bf87e3f17e314bc604df3820d5c71c249711 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x3e473a1ed587c1edee5e85718874bf87e3f17e314bc604df3820d5c71c249711 rename to test_data/test_chain/!trie_db!0x3e473a1ed587c1edee5e85718874bf87e3f17e314bc604df3820d5c71c249711 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x3e9dee0a3894a2bd8b3ff56f496055d9c66346b4810abcf8ecc2f1ab13483e89 b/test_data/test_chain/!trie_db!0x3e9dee0a3894a2bd8b3ff56f496055d9c66346b4810abcf8ecc2f1ab13483e89 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x3e9dee0a3894a2bd8b3ff56f496055d9c66346b4810abcf8ecc2f1ab13483e89 rename to test_data/test_chain/!trie_db!0x3e9dee0a3894a2bd8b3ff56f496055d9c66346b4810abcf8ecc2f1ab13483e89 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x3f5286f5cae259e122279b4ad4a24c5f98f82ec5b90976e8467e3d3e6445947e b/test_data/test_chain/!trie_db!0x3f5286f5cae259e122279b4ad4a24c5f98f82ec5b90976e8467e3d3e6445947e similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x3f5286f5cae259e122279b4ad4a24c5f98f82ec5b90976e8467e3d3e6445947e rename to test_data/test_chain/!trie_db!0x3f5286f5cae259e122279b4ad4a24c5f98f82ec5b90976e8467e3d3e6445947e diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x406d82bbf3ff8b6eb8bce99f947723566e0e73bd4730e6482500142bcff67d1f b/test_data/test_chain/!trie_db!0x406d82bbf3ff8b6eb8bce99f947723566e0e73bd4730e6482500142bcff67d1f similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x406d82bbf3ff8b6eb8bce99f947723566e0e73bd4730e6482500142bcff67d1f rename to test_data/test_chain/!trie_db!0x406d82bbf3ff8b6eb8bce99f947723566e0e73bd4730e6482500142bcff67d1f diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x422861bc32af762face51a81dfb4e3f2d563beb99ee972cf1fa30b944e6b85f5 b/test_data/test_chain/!trie_db!0x422861bc32af762face51a81dfb4e3f2d563beb99ee972cf1fa30b944e6b85f5 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x422861bc32af762face51a81dfb4e3f2d563beb99ee972cf1fa30b944e6b85f5 rename to test_data/test_chain/!trie_db!0x422861bc32af762face51a81dfb4e3f2d563beb99ee972cf1fa30b944e6b85f5 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x429b0f28e1011b174b50343f41f0d9cb6707fa8659ba6f0e93ff298b0f94cb49 b/test_data/test_chain/!trie_db!0x429b0f28e1011b174b50343f41f0d9cb6707fa8659ba6f0e93ff298b0f94cb49 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x429b0f28e1011b174b50343f41f0d9cb6707fa8659ba6f0e93ff298b0f94cb49 rename to test_data/test_chain/!trie_db!0x429b0f28e1011b174b50343f41f0d9cb6707fa8659ba6f0e93ff298b0f94cb49 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x44d6226c8647524b1aa102f6a7c5d428e3ff1b78976fbcfa3d8ab1209701026f b/test_data/test_chain/!trie_db!0x44d6226c8647524b1aa102f6a7c5d428e3ff1b78976fbcfa3d8ab1209701026f similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x44d6226c8647524b1aa102f6a7c5d428e3ff1b78976fbcfa3d8ab1209701026f rename to test_data/test_chain/!trie_db!0x44d6226c8647524b1aa102f6a7c5d428e3ff1b78976fbcfa3d8ab1209701026f diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x45989b865ec84b498e81eb3804224799d80a0903e62502244ff3ab00af28a910 b/test_data/test_chain/!trie_db!0x45989b865ec84b498e81eb3804224799d80a0903e62502244ff3ab00af28a910 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x45989b865ec84b498e81eb3804224799d80a0903e62502244ff3ab00af28a910 rename to test_data/test_chain/!trie_db!0x45989b865ec84b498e81eb3804224799d80a0903e62502244ff3ab00af28a910 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x48be751a35aa9113a4b007a39e012fbd05984958b811673256623eb1e0b2d463 b/test_data/test_chain/!trie_db!0x48be751a35aa9113a4b007a39e012fbd05984958b811673256623eb1e0b2d463 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x48be751a35aa9113a4b007a39e012fbd05984958b811673256623eb1e0b2d463 rename to test_data/test_chain/!trie_db!0x48be751a35aa9113a4b007a39e012fbd05984958b811673256623eb1e0b2d463 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x48bef2949d1b9e743c3372264d49e8811a5e316cc7eb8a0eb12cc91159e9bc89 b/test_data/test_chain/!trie_db!0x48bef2949d1b9e743c3372264d49e8811a5e316cc7eb8a0eb12cc91159e9bc89 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x48bef2949d1b9e743c3372264d49e8811a5e316cc7eb8a0eb12cc91159e9bc89 rename to test_data/test_chain/!trie_db!0x48bef2949d1b9e743c3372264d49e8811a5e316cc7eb8a0eb12cc91159e9bc89 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x49d8c70a6f9beb022d9e57fbd45b8d49390d820889f2a835b74dc9bd160c5682 b/test_data/test_chain/!trie_db!0x49d8c70a6f9beb022d9e57fbd45b8d49390d820889f2a835b74dc9bd160c5682 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x49d8c70a6f9beb022d9e57fbd45b8d49390d820889f2a835b74dc9bd160c5682 rename to test_data/test_chain/!trie_db!0x49d8c70a6f9beb022d9e57fbd45b8d49390d820889f2a835b74dc9bd160c5682 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x4a620dd91dbe73f56ca2fbac126a6d98f36699888043bee37beaa2efd72f32d8 b/test_data/test_chain/!trie_db!0x4a620dd91dbe73f56ca2fbac126a6d98f36699888043bee37beaa2efd72f32d8 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x4a620dd91dbe73f56ca2fbac126a6d98f36699888043bee37beaa2efd72f32d8 rename to test_data/test_chain/!trie_db!0x4a620dd91dbe73f56ca2fbac126a6d98f36699888043bee37beaa2efd72f32d8 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x4ef305cd67b97b743669faa6b70fab3c29d545df173e5798da1a3bef0efeb5d9 b/test_data/test_chain/!trie_db!0x4ef305cd67b97b743669faa6b70fab3c29d545df173e5798da1a3bef0efeb5d9 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x4ef305cd67b97b743669faa6b70fab3c29d545df173e5798da1a3bef0efeb5d9 rename to test_data/test_chain/!trie_db!0x4ef305cd67b97b743669faa6b70fab3c29d545df173e5798da1a3bef0efeb5d9 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x4fa6053972ef0f71dfeca3ad2c42ef1471f7597831c1b4cda4508d211e1e5fe7 b/test_data/test_chain/!trie_db!0x4fa6053972ef0f71dfeca3ad2c42ef1471f7597831c1b4cda4508d211e1e5fe7 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x4fa6053972ef0f71dfeca3ad2c42ef1471f7597831c1b4cda4508d211e1e5fe7 rename to test_data/test_chain/!trie_db!0x4fa6053972ef0f71dfeca3ad2c42ef1471f7597831c1b4cda4508d211e1e5fe7 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x506ea6c4ce6d0dbb8c3047fb0dc2a337dc2aa860aadb3b0d3bc7a19f09d88012 b/test_data/test_chain/!trie_db!0x506ea6c4ce6d0dbb8c3047fb0dc2a337dc2aa860aadb3b0d3bc7a19f09d88012 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x506ea6c4ce6d0dbb8c3047fb0dc2a337dc2aa860aadb3b0d3bc7a19f09d88012 rename to test_data/test_chain/!trie_db!0x506ea6c4ce6d0dbb8c3047fb0dc2a337dc2aa860aadb3b0d3bc7a19f09d88012 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x5072a6c1e2e016ff4e5b6b35caf68673a43b7a13bb1fa82f2643bad3e4d1c253 b/test_data/test_chain/!trie_db!0x5072a6c1e2e016ff4e5b6b35caf68673a43b7a13bb1fa82f2643bad3e4d1c253 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x5072a6c1e2e016ff4e5b6b35caf68673a43b7a13bb1fa82f2643bad3e4d1c253 rename to test_data/test_chain/!trie_db!0x5072a6c1e2e016ff4e5b6b35caf68673a43b7a13bb1fa82f2643bad3e4d1c253 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x50c257a83e805b0c15f7dcdac955e22e29b2c6a89be444e7b996602c26dfc4c6 b/test_data/test_chain/!trie_db!0x50c257a83e805b0c15f7dcdac955e22e29b2c6a89be444e7b996602c26dfc4c6 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x50c257a83e805b0c15f7dcdac955e22e29b2c6a89be444e7b996602c26dfc4c6 rename to test_data/test_chain/!trie_db!0x50c257a83e805b0c15f7dcdac955e22e29b2c6a89be444e7b996602c26dfc4c6 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x512797b9b116aadab3366c66cfbff2e4b0e5ff3d557efe4d820ecd930a306176 b/test_data/test_chain/!trie_db!0x512797b9b116aadab3366c66cfbff2e4b0e5ff3d557efe4d820ecd930a306176 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x512797b9b116aadab3366c66cfbff2e4b0e5ff3d557efe4d820ecd930a306176 rename to test_data/test_chain/!trie_db!0x512797b9b116aadab3366c66cfbff2e4b0e5ff3d557efe4d820ecd930a306176 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x51e94f71fe2273409ef0acbc4986df7bb808426470a9871d1f6d3324b780c194 b/test_data/test_chain/!trie_db!0x51e94f71fe2273409ef0acbc4986df7bb808426470a9871d1f6d3324b780c194 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x51e94f71fe2273409ef0acbc4986df7bb808426470a9871d1f6d3324b780c194 rename to test_data/test_chain/!trie_db!0x51e94f71fe2273409ef0acbc4986df7bb808426470a9871d1f6d3324b780c194 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x54350d30b48d6984395cf168b20e31952619100e01a31e619f91393e34d80ab5 b/test_data/test_chain/!trie_db!0x54350d30b48d6984395cf168b20e31952619100e01a31e619f91393e34d80ab5 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x54350d30b48d6984395cf168b20e31952619100e01a31e619f91393e34d80ab5 rename to test_data/test_chain/!trie_db!0x54350d30b48d6984395cf168b20e31952619100e01a31e619f91393e34d80ab5 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x54ea506fbfef710a7ac83211106487c3920b195e7fc316d9e489de5bd09c77b2 b/test_data/test_chain/!trie_db!0x54ea506fbfef710a7ac83211106487c3920b195e7fc316d9e489de5bd09c77b2 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x54ea506fbfef710a7ac83211106487c3920b195e7fc316d9e489de5bd09c77b2 rename to test_data/test_chain/!trie_db!0x54ea506fbfef710a7ac83211106487c3920b195e7fc316d9e489de5bd09c77b2 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x562e1406eac4555052e43c2bdc9e21fd697837624e9fa4704e6ced900721fc08 b/test_data/test_chain/!trie_db!0x562e1406eac4555052e43c2bdc9e21fd697837624e9fa4704e6ced900721fc08 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x562e1406eac4555052e43c2bdc9e21fd697837624e9fa4704e6ced900721fc08 rename to test_data/test_chain/!trie_db!0x562e1406eac4555052e43c2bdc9e21fd697837624e9fa4704e6ced900721fc08 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x57507c46a4a2813bd15ab7628ad3cea6eee2913f9841d89f477c6685eeadb0f3 b/test_data/test_chain/!trie_db!0x57507c46a4a2813bd15ab7628ad3cea6eee2913f9841d89f477c6685eeadb0f3 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x57507c46a4a2813bd15ab7628ad3cea6eee2913f9841d89f477c6685eeadb0f3 rename to test_data/test_chain/!trie_db!0x57507c46a4a2813bd15ab7628ad3cea6eee2913f9841d89f477c6685eeadb0f3 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x5911f24d96912350de50f297c2d34d5d10e136757bf4cfff5fa41bfca219554a b/test_data/test_chain/!trie_db!0x5911f24d96912350de50f297c2d34d5d10e136757bf4cfff5fa41bfca219554a similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x5911f24d96912350de50f297c2d34d5d10e136757bf4cfff5fa41bfca219554a rename to test_data/test_chain/!trie_db!0x5911f24d96912350de50f297c2d34d5d10e136757bf4cfff5fa41bfca219554a diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x59199de3c5812d70d26226c5f0ab999758a19b72cbf7c4eff6d930525a8b0455 b/test_data/test_chain/!trie_db!0x59199de3c5812d70d26226c5f0ab999758a19b72cbf7c4eff6d930525a8b0455 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x59199de3c5812d70d26226c5f0ab999758a19b72cbf7c4eff6d930525a8b0455 rename to test_data/test_chain/!trie_db!0x59199de3c5812d70d26226c5f0ab999758a19b72cbf7c4eff6d930525a8b0455 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x5a548cb14b27785a732bcc95585605b033ff42b37b40803445ebbbf97dc179a8 b/test_data/test_chain/!trie_db!0x5a548cb14b27785a732bcc95585605b033ff42b37b40803445ebbbf97dc179a8 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x5a548cb14b27785a732bcc95585605b033ff42b37b40803445ebbbf97dc179a8 rename to test_data/test_chain/!trie_db!0x5a548cb14b27785a732bcc95585605b033ff42b37b40803445ebbbf97dc179a8 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x5e287c9213b0dcabfdf484092e2b6133f6826e045c391501e80374760de69320 b/test_data/test_chain/!trie_db!0x5e287c9213b0dcabfdf484092e2b6133f6826e045c391501e80374760de69320 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x5e287c9213b0dcabfdf484092e2b6133f6826e045c391501e80374760de69320 rename to test_data/test_chain/!trie_db!0x5e287c9213b0dcabfdf484092e2b6133f6826e045c391501e80374760de69320 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x60b37e6a056ee52545c169ae2074181fda1f14f9abb6363e4d9a152fd9f07c90 b/test_data/test_chain/!trie_db!0x60b37e6a056ee52545c169ae2074181fda1f14f9abb6363e4d9a152fd9f07c90 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x60b37e6a056ee52545c169ae2074181fda1f14f9abb6363e4d9a152fd9f07c90 rename to test_data/test_chain/!trie_db!0x60b37e6a056ee52545c169ae2074181fda1f14f9abb6363e4d9a152fd9f07c90 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x62ab8b4e7f7569eb032e637fcdcfd5b561442347326a3ffca40ae225d0029d4c b/test_data/test_chain/!trie_db!0x62ab8b4e7f7569eb032e637fcdcfd5b561442347326a3ffca40ae225d0029d4c similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x62ab8b4e7f7569eb032e637fcdcfd5b561442347326a3ffca40ae225d0029d4c rename to test_data/test_chain/!trie_db!0x62ab8b4e7f7569eb032e637fcdcfd5b561442347326a3ffca40ae225d0029d4c diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x63a1b8e271db0ec0a1816192da83ae3bec40470b66f31d047ef4911d0106dde2 b/test_data/test_chain/!trie_db!0x63a1b8e271db0ec0a1816192da83ae3bec40470b66f31d047ef4911d0106dde2 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x63a1b8e271db0ec0a1816192da83ae3bec40470b66f31d047ef4911d0106dde2 rename to test_data/test_chain/!trie_db!0x63a1b8e271db0ec0a1816192da83ae3bec40470b66f31d047ef4911d0106dde2 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x65455aec5f2e81c82c26a1e0484d57985264872776eb895656179b208be6451b b/test_data/test_chain/!trie_db!0x65455aec5f2e81c82c26a1e0484d57985264872776eb895656179b208be6451b similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x65455aec5f2e81c82c26a1e0484d57985264872776eb895656179b208be6451b rename to test_data/test_chain/!trie_db!0x65455aec5f2e81c82c26a1e0484d57985264872776eb895656179b208be6451b diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x66c5d0a6016165e537ac63b121df2d074c649a16b50ca7a2839abc5eb3894a9a b/test_data/test_chain/!trie_db!0x66c5d0a6016165e537ac63b121df2d074c649a16b50ca7a2839abc5eb3894a9a similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x66c5d0a6016165e537ac63b121df2d074c649a16b50ca7a2839abc5eb3894a9a rename to test_data/test_chain/!trie_db!0x66c5d0a6016165e537ac63b121df2d074c649a16b50ca7a2839abc5eb3894a9a diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x67bcaf1d60f75a22d49b037c88c00e44733094250664cbfc9d9bbf9eda3ca745 b/test_data/test_chain/!trie_db!0x67bcaf1d60f75a22d49b037c88c00e44733094250664cbfc9d9bbf9eda3ca745 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x67bcaf1d60f75a22d49b037c88c00e44733094250664cbfc9d9bbf9eda3ca745 rename to test_data/test_chain/!trie_db!0x67bcaf1d60f75a22d49b037c88c00e44733094250664cbfc9d9bbf9eda3ca745 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x6a9414509d1897a93d7701779bf75e343be5148f1740edcdf2f9935124adfc64 b/test_data/test_chain/!trie_db!0x6a9414509d1897a93d7701779bf75e343be5148f1740edcdf2f9935124adfc64 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x6a9414509d1897a93d7701779bf75e343be5148f1740edcdf2f9935124adfc64 rename to test_data/test_chain/!trie_db!0x6a9414509d1897a93d7701779bf75e343be5148f1740edcdf2f9935124adfc64 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x6cebfe106ade0f88e6b68581d9f8b4def74d71d0cbf3ec3c5039ce6d0d2c35ae b/test_data/test_chain/!trie_db!0x6cebfe106ade0f88e6b68581d9f8b4def74d71d0cbf3ec3c5039ce6d0d2c35ae similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x6cebfe106ade0f88e6b68581d9f8b4def74d71d0cbf3ec3c5039ce6d0d2c35ae rename to test_data/test_chain/!trie_db!0x6cebfe106ade0f88e6b68581d9f8b4def74d71d0cbf3ec3c5039ce6d0d2c35ae diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x72fa55f4ee28320ddd7ffa2b28fa312896c37fccfb15d6d409cbcf4a6a342b82 b/test_data/test_chain/!trie_db!0x72fa55f4ee28320ddd7ffa2b28fa312896c37fccfb15d6d409cbcf4a6a342b82 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x72fa55f4ee28320ddd7ffa2b28fa312896c37fccfb15d6d409cbcf4a6a342b82 rename to test_data/test_chain/!trie_db!0x72fa55f4ee28320ddd7ffa2b28fa312896c37fccfb15d6d409cbcf4a6a342b82 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x731ee2886a490335c1aa4b528adfdca719605a1377f014a30224664502755fa6 b/test_data/test_chain/!trie_db!0x731ee2886a490335c1aa4b528adfdca719605a1377f014a30224664502755fa6 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x731ee2886a490335c1aa4b528adfdca719605a1377f014a30224664502755fa6 rename to test_data/test_chain/!trie_db!0x731ee2886a490335c1aa4b528adfdca719605a1377f014a30224664502755fa6 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x73b9acd169ae7c4768c29d7dbbc8944bed84f86ddade7f2b48a0b0d5592ec11b b/test_data/test_chain/!trie_db!0x73b9acd169ae7c4768c29d7dbbc8944bed84f86ddade7f2b48a0b0d5592ec11b similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x73b9acd169ae7c4768c29d7dbbc8944bed84f86ddade7f2b48a0b0d5592ec11b rename to test_data/test_chain/!trie_db!0x73b9acd169ae7c4768c29d7dbbc8944bed84f86ddade7f2b48a0b0d5592ec11b diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x74952353b0991411841541f86d37934e0d826eb7411a2420ea362466d8d60e03 b/test_data/test_chain/!trie_db!0x74952353b0991411841541f86d37934e0d826eb7411a2420ea362466d8d60e03 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x74952353b0991411841541f86d37934e0d826eb7411a2420ea362466d8d60e03 rename to test_data/test_chain/!trie_db!0x74952353b0991411841541f86d37934e0d826eb7411a2420ea362466d8d60e03 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x74fa5366290bbbc6072e78cf47c7eb339089174128a36e413312695be1c2f42f b/test_data/test_chain/!trie_db!0x74fa5366290bbbc6072e78cf47c7eb339089174128a36e413312695be1c2f42f similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x74fa5366290bbbc6072e78cf47c7eb339089174128a36e413312695be1c2f42f rename to test_data/test_chain/!trie_db!0x74fa5366290bbbc6072e78cf47c7eb339089174128a36e413312695be1c2f42f diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x7604b45506a0b39430208425bde0a01f3705f6c9b1756f6c93fdc09248227c94 b/test_data/test_chain/!trie_db!0x7604b45506a0b39430208425bde0a01f3705f6c9b1756f6c93fdc09248227c94 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x7604b45506a0b39430208425bde0a01f3705f6c9b1756f6c93fdc09248227c94 rename to test_data/test_chain/!trie_db!0x7604b45506a0b39430208425bde0a01f3705f6c9b1756f6c93fdc09248227c94 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x7661280f0be4e17138aef98a3b2d8e313db3c4acab857d5f3cf3e6e2fbd8cbda b/test_data/test_chain/!trie_db!0x7661280f0be4e17138aef98a3b2d8e313db3c4acab857d5f3cf3e6e2fbd8cbda similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x7661280f0be4e17138aef98a3b2d8e313db3c4acab857d5f3cf3e6e2fbd8cbda rename to test_data/test_chain/!trie_db!0x7661280f0be4e17138aef98a3b2d8e313db3c4acab857d5f3cf3e6e2fbd8cbda diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x77a5923f8e9ef2f5935c8efc6ba46597fc03d86301b3844fe5ebd02dbc3298b2 b/test_data/test_chain/!trie_db!0x77a5923f8e9ef2f5935c8efc6ba46597fc03d86301b3844fe5ebd02dbc3298b2 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x77a5923f8e9ef2f5935c8efc6ba46597fc03d86301b3844fe5ebd02dbc3298b2 rename to test_data/test_chain/!trie_db!0x77a5923f8e9ef2f5935c8efc6ba46597fc03d86301b3844fe5ebd02dbc3298b2 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x77ecddca419c697a6aae21fa9a02f85475aaa5b109d41dc35f1893dc5bb3cf72 b/test_data/test_chain/!trie_db!0x77ecddca419c697a6aae21fa9a02f85475aaa5b109d41dc35f1893dc5bb3cf72 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x77ecddca419c697a6aae21fa9a02f85475aaa5b109d41dc35f1893dc5bb3cf72 rename to test_data/test_chain/!trie_db!0x77ecddca419c697a6aae21fa9a02f85475aaa5b109d41dc35f1893dc5bb3cf72 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x7857f0f18874ffb3d54af6e413368716e3b932b92c1e5e625e6dc947c3eb3248 b/test_data/test_chain/!trie_db!0x7857f0f18874ffb3d54af6e413368716e3b932b92c1e5e625e6dc947c3eb3248 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x7857f0f18874ffb3d54af6e413368716e3b932b92c1e5e625e6dc947c3eb3248 rename to test_data/test_chain/!trie_db!0x7857f0f18874ffb3d54af6e413368716e3b932b92c1e5e625e6dc947c3eb3248 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x7876d09d07838d1e8aa713fdcb1da8149ab4fe2240dfa1ce57ec821d5b18c981 b/test_data/test_chain/!trie_db!0x7876d09d07838d1e8aa713fdcb1da8149ab4fe2240dfa1ce57ec821d5b18c981 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x7876d09d07838d1e8aa713fdcb1da8149ab4fe2240dfa1ce57ec821d5b18c981 rename to test_data/test_chain/!trie_db!0x7876d09d07838d1e8aa713fdcb1da8149ab4fe2240dfa1ce57ec821d5b18c981 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x79543ccd0f558d5c5350afdfc3862b23e3ac166d432e8a268608ea046375137e b/test_data/test_chain/!trie_db!0x79543ccd0f558d5c5350afdfc3862b23e3ac166d432e8a268608ea046375137e similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x79543ccd0f558d5c5350afdfc3862b23e3ac166d432e8a268608ea046375137e rename to test_data/test_chain/!trie_db!0x79543ccd0f558d5c5350afdfc3862b23e3ac166d432e8a268608ea046375137e diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x79b9aa7f3bfc53dde3d5f06102bce3649bc358aa26ea150ada9053e81bf7f579 b/test_data/test_chain/!trie_db!0x79b9aa7f3bfc53dde3d5f06102bce3649bc358aa26ea150ada9053e81bf7f579 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x79b9aa7f3bfc53dde3d5f06102bce3649bc358aa26ea150ada9053e81bf7f579 rename to test_data/test_chain/!trie_db!0x79b9aa7f3bfc53dde3d5f06102bce3649bc358aa26ea150ada9053e81bf7f579 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x7ac0c41c0d80d8e020f83ae1b7f6bf62c1a5eca81c5d618a9512114809b884cb b/test_data/test_chain/!trie_db!0x7ac0c41c0d80d8e020f83ae1b7f6bf62c1a5eca81c5d618a9512114809b884cb similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x7ac0c41c0d80d8e020f83ae1b7f6bf62c1a5eca81c5d618a9512114809b884cb rename to test_data/test_chain/!trie_db!0x7ac0c41c0d80d8e020f83ae1b7f6bf62c1a5eca81c5d618a9512114809b884cb diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x7b25204f93e559dc7c1fc1a4b9fdf17f217e89849d6c5e36c99619f168b2101c b/test_data/test_chain/!trie_db!0x7b25204f93e559dc7c1fc1a4b9fdf17f217e89849d6c5e36c99619f168b2101c similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x7b25204f93e559dc7c1fc1a4b9fdf17f217e89849d6c5e36c99619f168b2101c rename to test_data/test_chain/!trie_db!0x7b25204f93e559dc7c1fc1a4b9fdf17f217e89849d6c5e36c99619f168b2101c diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x7c815b5979b2a34ecdf46a8d5fc1bb97b3a7ba7e4f814154d5982ecc39e0b63a b/test_data/test_chain/!trie_db!0x7c815b5979b2a34ecdf46a8d5fc1bb97b3a7ba7e4f814154d5982ecc39e0b63a similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x7c815b5979b2a34ecdf46a8d5fc1bb97b3a7ba7e4f814154d5982ecc39e0b63a rename to test_data/test_chain/!trie_db!0x7c815b5979b2a34ecdf46a8d5fc1bb97b3a7ba7e4f814154d5982ecc39e0b63a diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x7d057a734d406684b905569e243499dd5216cc2b606c65519b16edeaa3ed743b b/test_data/test_chain/!trie_db!0x7d057a734d406684b905569e243499dd5216cc2b606c65519b16edeaa3ed743b similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x7d057a734d406684b905569e243499dd5216cc2b606c65519b16edeaa3ed743b rename to test_data/test_chain/!trie_db!0x7d057a734d406684b905569e243499dd5216cc2b606c65519b16edeaa3ed743b diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x7e41e42b954550a5bf0a63f8e729fcbbf8da38646338b50e31c2e7fff3b5cfa5 b/test_data/test_chain/!trie_db!0x7e41e42b954550a5bf0a63f8e729fcbbf8da38646338b50e31c2e7fff3b5cfa5 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x7e41e42b954550a5bf0a63f8e729fcbbf8da38646338b50e31c2e7fff3b5cfa5 rename to test_data/test_chain/!trie_db!0x7e41e42b954550a5bf0a63f8e729fcbbf8da38646338b50e31c2e7fff3b5cfa5 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x7f58526de3503c41aa43ef3fb1891a4f45c21d7b16f3f99f4e558a33436f1f76 b/test_data/test_chain/!trie_db!0x7f58526de3503c41aa43ef3fb1891a4f45c21d7b16f3f99f4e558a33436f1f76 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x7f58526de3503c41aa43ef3fb1891a4f45c21d7b16f3f99f4e558a33436f1f76 rename to test_data/test_chain/!trie_db!0x7f58526de3503c41aa43ef3fb1891a4f45c21d7b16f3f99f4e558a33436f1f76 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x7fb0f90f7cb04e7e00015bbf2ccb39c9efdce13b1272dd0b428faed488b05fde b/test_data/test_chain/!trie_db!0x7fb0f90f7cb04e7e00015bbf2ccb39c9efdce13b1272dd0b428faed488b05fde similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x7fb0f90f7cb04e7e00015bbf2ccb39c9efdce13b1272dd0b428faed488b05fde rename to test_data/test_chain/!trie_db!0x7fb0f90f7cb04e7e00015bbf2ccb39c9efdce13b1272dd0b428faed488b05fde diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x83097864ebee0be81925b10976490ab2c71a0643e9f16e16807811b7112ed032 b/test_data/test_chain/!trie_db!0x83097864ebee0be81925b10976490ab2c71a0643e9f16e16807811b7112ed032 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x83097864ebee0be81925b10976490ab2c71a0643e9f16e16807811b7112ed032 rename to test_data/test_chain/!trie_db!0x83097864ebee0be81925b10976490ab2c71a0643e9f16e16807811b7112ed032 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x83cbaef3696047cce6331a82207455b14fe95994662a6c9133552594ce6c95aa b/test_data/test_chain/!trie_db!0x83cbaef3696047cce6331a82207455b14fe95994662a6c9133552594ce6c95aa similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x83cbaef3696047cce6331a82207455b14fe95994662a6c9133552594ce6c95aa rename to test_data/test_chain/!trie_db!0x83cbaef3696047cce6331a82207455b14fe95994662a6c9133552594ce6c95aa diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x8424779c90fd12907998c34b725204a2c6cd6237c4aec54be342f93cdc535fbe b/test_data/test_chain/!trie_db!0x8424779c90fd12907998c34b725204a2c6cd6237c4aec54be342f93cdc535fbe similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x8424779c90fd12907998c34b725204a2c6cd6237c4aec54be342f93cdc535fbe rename to test_data/test_chain/!trie_db!0x8424779c90fd12907998c34b725204a2c6cd6237c4aec54be342f93cdc535fbe diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x86981bd51e6d3e80868efc10e47ae05e5b490888d9de8efee4c3e08291b13c51 b/test_data/test_chain/!trie_db!0x86981bd51e6d3e80868efc10e47ae05e5b490888d9de8efee4c3e08291b13c51 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x86981bd51e6d3e80868efc10e47ae05e5b490888d9de8efee4c3e08291b13c51 rename to test_data/test_chain/!trie_db!0x86981bd51e6d3e80868efc10e47ae05e5b490888d9de8efee4c3e08291b13c51 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x87ff3bbe1430ed5cc0f2cc2ad5b75f139955ef1aa3d618d17cef880433e70dc6 b/test_data/test_chain/!trie_db!0x87ff3bbe1430ed5cc0f2cc2ad5b75f139955ef1aa3d618d17cef880433e70dc6 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x87ff3bbe1430ed5cc0f2cc2ad5b75f139955ef1aa3d618d17cef880433e70dc6 rename to test_data/test_chain/!trie_db!0x87ff3bbe1430ed5cc0f2cc2ad5b75f139955ef1aa3d618d17cef880433e70dc6 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x8a083a05cf77f2f36f6c055ac468fc88ab99335759bb47d22b0947229f0b170a b/test_data/test_chain/!trie_db!0x8a083a05cf77f2f36f6c055ac468fc88ab99335759bb47d22b0947229f0b170a similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x8a083a05cf77f2f36f6c055ac468fc88ab99335759bb47d22b0947229f0b170a rename to test_data/test_chain/!trie_db!0x8a083a05cf77f2f36f6c055ac468fc88ab99335759bb47d22b0947229f0b170a diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x8ac88fd296fe71814c119087c21bae16a9e5809241b5bd5a36845a5f5d357a6e b/test_data/test_chain/!trie_db!0x8ac88fd296fe71814c119087c21bae16a9e5809241b5bd5a36845a5f5d357a6e similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x8ac88fd296fe71814c119087c21bae16a9e5809241b5bd5a36845a5f5d357a6e rename to test_data/test_chain/!trie_db!0x8ac88fd296fe71814c119087c21bae16a9e5809241b5bd5a36845a5f5d357a6e diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x8b1ba0894221f78d2d10aa32895e2d402fe71d272af2994483bb9b56e2f1b6ca b/test_data/test_chain/!trie_db!0x8b1ba0894221f78d2d10aa32895e2d402fe71d272af2994483bb9b56e2f1b6ca similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x8b1ba0894221f78d2d10aa32895e2d402fe71d272af2994483bb9b56e2f1b6ca rename to test_data/test_chain/!trie_db!0x8b1ba0894221f78d2d10aa32895e2d402fe71d272af2994483bb9b56e2f1b6ca diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x8e9dd18a2a9762cc0e7a01eb55499cfbddd821895c655e75c7607cf896b6c0da b/test_data/test_chain/!trie_db!0x8e9dd18a2a9762cc0e7a01eb55499cfbddd821895c655e75c7607cf896b6c0da similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x8e9dd18a2a9762cc0e7a01eb55499cfbddd821895c655e75c7607cf896b6c0da rename to test_data/test_chain/!trie_db!0x8e9dd18a2a9762cc0e7a01eb55499cfbddd821895c655e75c7607cf896b6c0da diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x9002532949cb4c50b9cd01c41e0ecfe9b2f4e7c0f2551d1ad2d5c6f05a0a1198 b/test_data/test_chain/!trie_db!0x9002532949cb4c50b9cd01c41e0ecfe9b2f4e7c0f2551d1ad2d5c6f05a0a1198 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x9002532949cb4c50b9cd01c41e0ecfe9b2f4e7c0f2551d1ad2d5c6f05a0a1198 rename to test_data/test_chain/!trie_db!0x9002532949cb4c50b9cd01c41e0ecfe9b2f4e7c0f2551d1ad2d5c6f05a0a1198 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x903b04e989376399328450ad3e8710fba28b3530dd3076696f7fc9844df0d094 b/test_data/test_chain/!trie_db!0x903b04e989376399328450ad3e8710fba28b3530dd3076696f7fc9844df0d094 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x903b04e989376399328450ad3e8710fba28b3530dd3076696f7fc9844df0d094 rename to test_data/test_chain/!trie_db!0x903b04e989376399328450ad3e8710fba28b3530dd3076696f7fc9844df0d094 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x903b0cd1beb1b190eb88e579ed2cdedd31e48e7e4f9c188b6068620d222b568e b/test_data/test_chain/!trie_db!0x903b0cd1beb1b190eb88e579ed2cdedd31e48e7e4f9c188b6068620d222b568e similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x903b0cd1beb1b190eb88e579ed2cdedd31e48e7e4f9c188b6068620d222b568e rename to test_data/test_chain/!trie_db!0x903b0cd1beb1b190eb88e579ed2cdedd31e48e7e4f9c188b6068620d222b568e diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x907b9cb17ed4afdf1e49593aa2a077f3019a7e851ec9faf4b21ad72aea963675 b/test_data/test_chain/!trie_db!0x907b9cb17ed4afdf1e49593aa2a077f3019a7e851ec9faf4b21ad72aea963675 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x907b9cb17ed4afdf1e49593aa2a077f3019a7e851ec9faf4b21ad72aea963675 rename to test_data/test_chain/!trie_db!0x907b9cb17ed4afdf1e49593aa2a077f3019a7e851ec9faf4b21ad72aea963675 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x96a4cfbd7fbdfe5ae66bd6e9a07673a25c21b0561775ad9613e4a05b0c7f27a7 b/test_data/test_chain/!trie_db!0x96a4cfbd7fbdfe5ae66bd6e9a07673a25c21b0561775ad9613e4a05b0c7f27a7 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x96a4cfbd7fbdfe5ae66bd6e9a07673a25c21b0561775ad9613e4a05b0c7f27a7 rename to test_data/test_chain/!trie_db!0x96a4cfbd7fbdfe5ae66bd6e9a07673a25c21b0561775ad9613e4a05b0c7f27a7 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x977f3e78fd927245d850c04695f06db28c3c19f59f40e67ad6e7558c31669a10 b/test_data/test_chain/!trie_db!0x977f3e78fd927245d850c04695f06db28c3c19f59f40e67ad6e7558c31669a10 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x977f3e78fd927245d850c04695f06db28c3c19f59f40e67ad6e7558c31669a10 rename to test_data/test_chain/!trie_db!0x977f3e78fd927245d850c04695f06db28c3c19f59f40e67ad6e7558c31669a10 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x98ad39fb8468cbcb93a0990018ded196413ef989c0062341ff886889f39ab41b b/test_data/test_chain/!trie_db!0x98ad39fb8468cbcb93a0990018ded196413ef989c0062341ff886889f39ab41b similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x98ad39fb8468cbcb93a0990018ded196413ef989c0062341ff886889f39ab41b rename to test_data/test_chain/!trie_db!0x98ad39fb8468cbcb93a0990018ded196413ef989c0062341ff886889f39ab41b diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x98cb48227dc1977d88644fff7161f5b23b5c2a3e21dc1c28468b10c7c84c791b b/test_data/test_chain/!trie_db!0x98cb48227dc1977d88644fff7161f5b23b5c2a3e21dc1c28468b10c7c84c791b similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x98cb48227dc1977d88644fff7161f5b23b5c2a3e21dc1c28468b10c7c84c791b rename to test_data/test_chain/!trie_db!0x98cb48227dc1977d88644fff7161f5b23b5c2a3e21dc1c28468b10c7c84c791b diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x9bdb510955ca6fd0ae2d5c77ab871254c9a8bb50cdaa80816a22151cea8c27fa b/test_data/test_chain/!trie_db!0x9bdb510955ca6fd0ae2d5c77ab871254c9a8bb50cdaa80816a22151cea8c27fa similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x9bdb510955ca6fd0ae2d5c77ab871254c9a8bb50cdaa80816a22151cea8c27fa rename to test_data/test_chain/!trie_db!0x9bdb510955ca6fd0ae2d5c77ab871254c9a8bb50cdaa80816a22151cea8c27fa diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x9d95a14094467e02ae8432ed98cded72b5b835a1d1ebd16704f595043e2ba1f8 b/test_data/test_chain/!trie_db!0x9d95a14094467e02ae8432ed98cded72b5b835a1d1ebd16704f595043e2ba1f8 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x9d95a14094467e02ae8432ed98cded72b5b835a1d1ebd16704f595043e2ba1f8 rename to test_data/test_chain/!trie_db!0x9d95a14094467e02ae8432ed98cded72b5b835a1d1ebd16704f595043e2ba1f8 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0x9dda99178f00c917ef52162c403077b802a1e0897e3e175ba6bfa09b9b9e29ae b/test_data/test_chain/!trie_db!0x9dda99178f00c917ef52162c403077b802a1e0897e3e175ba6bfa09b9b9e29ae similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0x9dda99178f00c917ef52162c403077b802a1e0897e3e175ba6bfa09b9b9e29ae rename to test_data/test_chain/!trie_db!0x9dda99178f00c917ef52162c403077b802a1e0897e3e175ba6bfa09b9b9e29ae diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0xa5c81c7c0d0cdaed4b866b2da6cbf578a099740bced6d6ea401a08ff99e63fcd b/test_data/test_chain/!trie_db!0xa5c81c7c0d0cdaed4b866b2da6cbf578a099740bced6d6ea401a08ff99e63fcd similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0xa5c81c7c0d0cdaed4b866b2da6cbf578a099740bced6d6ea401a08ff99e63fcd rename to test_data/test_chain/!trie_db!0xa5c81c7c0d0cdaed4b866b2da6cbf578a099740bced6d6ea401a08ff99e63fcd diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0xa698486eab05e8aafce2080867bd63489acc93af9122d9cfdbfd323f1523baba b/test_data/test_chain/!trie_db!0xa698486eab05e8aafce2080867bd63489acc93af9122d9cfdbfd323f1523baba similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0xa698486eab05e8aafce2080867bd63489acc93af9122d9cfdbfd323f1523baba rename to test_data/test_chain/!trie_db!0xa698486eab05e8aafce2080867bd63489acc93af9122d9cfdbfd323f1523baba diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0xa7e84e568d915220899cd49f84d03cadbba602e3e04546e2c18064dcb0517963 b/test_data/test_chain/!trie_db!0xa7e84e568d915220899cd49f84d03cadbba602e3e04546e2c18064dcb0517963 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0xa7e84e568d915220899cd49f84d03cadbba602e3e04546e2c18064dcb0517963 rename to test_data/test_chain/!trie_db!0xa7e84e568d915220899cd49f84d03cadbba602e3e04546e2c18064dcb0517963 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0xa83e88c544f24f884fef77e11356372da4d7073fe1dc9b6d0672048f97461fbc b/test_data/test_chain/!trie_db!0xa83e88c544f24f884fef77e11356372da4d7073fe1dc9b6d0672048f97461fbc similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0xa83e88c544f24f884fef77e11356372da4d7073fe1dc9b6d0672048f97461fbc rename to test_data/test_chain/!trie_db!0xa83e88c544f24f884fef77e11356372da4d7073fe1dc9b6d0672048f97461fbc diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0xa855e7870075f22bca3187c9fcf5f0ae0f9bcf0bc40aba289d2876006140eada b/test_data/test_chain/!trie_db!0xa855e7870075f22bca3187c9fcf5f0ae0f9bcf0bc40aba289d2876006140eada similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0xa855e7870075f22bca3187c9fcf5f0ae0f9bcf0bc40aba289d2876006140eada rename to test_data/test_chain/!trie_db!0xa855e7870075f22bca3187c9fcf5f0ae0f9bcf0bc40aba289d2876006140eada diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0xa8e1de3e2a1305af70ac8d37e88888df7db23a75e44a5eb1f7da957cb254af85 b/test_data/test_chain/!trie_db!0xa8e1de3e2a1305af70ac8d37e88888df7db23a75e44a5eb1f7da957cb254af85 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0xa8e1de3e2a1305af70ac8d37e88888df7db23a75e44a5eb1f7da957cb254af85 rename to test_data/test_chain/!trie_db!0xa8e1de3e2a1305af70ac8d37e88888df7db23a75e44a5eb1f7da957cb254af85 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0xa966cb9d74a564c6798b583cbef8462394b3f99aa721ec871a2b8ee82f857c5a b/test_data/test_chain/!trie_db!0xa966cb9d74a564c6798b583cbef8462394b3f99aa721ec871a2b8ee82f857c5a similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0xa966cb9d74a564c6798b583cbef8462394b3f99aa721ec871a2b8ee82f857c5a rename to test_data/test_chain/!trie_db!0xa966cb9d74a564c6798b583cbef8462394b3f99aa721ec871a2b8ee82f857c5a diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0xaa9f11e9216645caffc0b16ba04465953bbe7a9d5c1e321f1f022d21d86bc138 b/test_data/test_chain/!trie_db!0xaa9f11e9216645caffc0b16ba04465953bbe7a9d5c1e321f1f022d21d86bc138 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0xaa9f11e9216645caffc0b16ba04465953bbe7a9d5c1e321f1f022d21d86bc138 rename to test_data/test_chain/!trie_db!0xaa9f11e9216645caffc0b16ba04465953bbe7a9d5c1e321f1f022d21d86bc138 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0xabcda7b93e50553667d1de3cb7cd9527b993f3495bffe594a0b8eecf3f74cbfb b/test_data/test_chain/!trie_db!0xabcda7b93e50553667d1de3cb7cd9527b993f3495bffe594a0b8eecf3f74cbfb similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0xabcda7b93e50553667d1de3cb7cd9527b993f3495bffe594a0b8eecf3f74cbfb rename to test_data/test_chain/!trie_db!0xabcda7b93e50553667d1de3cb7cd9527b993f3495bffe594a0b8eecf3f74cbfb diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0xac9d0eff487a98fc0b595eb169f9866cced41ca9315a0e432aed14baad4ad852 b/test_data/test_chain/!trie_db!0xac9d0eff487a98fc0b595eb169f9866cced41ca9315a0e432aed14baad4ad852 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0xac9d0eff487a98fc0b595eb169f9866cced41ca9315a0e432aed14baad4ad852 rename to test_data/test_chain/!trie_db!0xac9d0eff487a98fc0b595eb169f9866cced41ca9315a0e432aed14baad4ad852 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0xaddb2cdc826bed296244e295c743fc71d8ca532144f8c7122a7c65adec0d9745 b/test_data/test_chain/!trie_db!0xaddb2cdc826bed296244e295c743fc71d8ca532144f8c7122a7c65adec0d9745 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0xaddb2cdc826bed296244e295c743fc71d8ca532144f8c7122a7c65adec0d9745 rename to test_data/test_chain/!trie_db!0xaddb2cdc826bed296244e295c743fc71d8ca532144f8c7122a7c65adec0d9745 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0xaeb877203026a5476c69d73319e819d642e2ddc74cf15a8b219afcd9d488be5b b/test_data/test_chain/!trie_db!0xaeb877203026a5476c69d73319e819d642e2ddc74cf15a8b219afcd9d488be5b similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0xaeb877203026a5476c69d73319e819d642e2ddc74cf15a8b219afcd9d488be5b rename to test_data/test_chain/!trie_db!0xaeb877203026a5476c69d73319e819d642e2ddc74cf15a8b219afcd9d488be5b diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0xaedf1dbd059f29ddca302e42ae94381f71559c17f7d5f03ca4e49bba1f534459 b/test_data/test_chain/!trie_db!0xaedf1dbd059f29ddca302e42ae94381f71559c17f7d5f03ca4e49bba1f534459 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0xaedf1dbd059f29ddca302e42ae94381f71559c17f7d5f03ca4e49bba1f534459 rename to test_data/test_chain/!trie_db!0xaedf1dbd059f29ddca302e42ae94381f71559c17f7d5f03ca4e49bba1f534459 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0xaf884a3280efc05cbccc0c8e2fbf065aaa4165652efa1d89d174d440c96e25cf b/test_data/test_chain/!trie_db!0xaf884a3280efc05cbccc0c8e2fbf065aaa4165652efa1d89d174d440c96e25cf similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0xaf884a3280efc05cbccc0c8e2fbf065aaa4165652efa1d89d174d440c96e25cf rename to test_data/test_chain/!trie_db!0xaf884a3280efc05cbccc0c8e2fbf065aaa4165652efa1d89d174d440c96e25cf diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0xafc7c6a8161d69dc1b082bbf799d38f88c2f251a7504b87039b2a4f682cbf323 b/test_data/test_chain/!trie_db!0xafc7c6a8161d69dc1b082bbf799d38f88c2f251a7504b87039b2a4f682cbf323 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0xafc7c6a8161d69dc1b082bbf799d38f88c2f251a7504b87039b2a4f682cbf323 rename to test_data/test_chain/!trie_db!0xafc7c6a8161d69dc1b082bbf799d38f88c2f251a7504b87039b2a4f682cbf323 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0xb2aea4b00c6faa6890b6e8256dcb98b86808a19ab61c59994ab8b8bdf9acfa4d b/test_data/test_chain/!trie_db!0xb2aea4b00c6faa6890b6e8256dcb98b86808a19ab61c59994ab8b8bdf9acfa4d similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0xb2aea4b00c6faa6890b6e8256dcb98b86808a19ab61c59994ab8b8bdf9acfa4d rename to test_data/test_chain/!trie_db!0xb2aea4b00c6faa6890b6e8256dcb98b86808a19ab61c59994ab8b8bdf9acfa4d diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0xb66ab966cb58bb54b74fef7c873db3cfe39f1667ff01c5814956fa040efda263 b/test_data/test_chain/!trie_db!0xb66ab966cb58bb54b74fef7c873db3cfe39f1667ff01c5814956fa040efda263 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0xb66ab966cb58bb54b74fef7c873db3cfe39f1667ff01c5814956fa040efda263 rename to test_data/test_chain/!trie_db!0xb66ab966cb58bb54b74fef7c873db3cfe39f1667ff01c5814956fa040efda263 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0xb849d833c3c299ab14d40e9dda4d67a6f2e7a5ec13ec49680683cdc24a3df770 b/test_data/test_chain/!trie_db!0xb849d833c3c299ab14d40e9dda4d67a6f2e7a5ec13ec49680683cdc24a3df770 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0xb849d833c3c299ab14d40e9dda4d67a6f2e7a5ec13ec49680683cdc24a3df770 rename to test_data/test_chain/!trie_db!0xb849d833c3c299ab14d40e9dda4d67a6f2e7a5ec13ec49680683cdc24a3df770 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0xb975d8ac2b88dd356291b4d8f7b58de83b7a0632edb3ebaac088213b8538c22e b/test_data/test_chain/!trie_db!0xb975d8ac2b88dd356291b4d8f7b58de83b7a0632edb3ebaac088213b8538c22e similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0xb975d8ac2b88dd356291b4d8f7b58de83b7a0632edb3ebaac088213b8538c22e rename to test_data/test_chain/!trie_db!0xb975d8ac2b88dd356291b4d8f7b58de83b7a0632edb3ebaac088213b8538c22e diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0xb9bea21fee534e5d3a2efe93f17da081408739047e6491ea9058ec3b0b205326 b/test_data/test_chain/!trie_db!0xb9bea21fee534e5d3a2efe93f17da081408739047e6491ea9058ec3b0b205326 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0xb9bea21fee534e5d3a2efe93f17da081408739047e6491ea9058ec3b0b205326 rename to test_data/test_chain/!trie_db!0xb9bea21fee534e5d3a2efe93f17da081408739047e6491ea9058ec3b0b205326 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0xbd71221ec6a606a213189d3d27d5da39a39474894d83029f1397c838c9ac428b b/test_data/test_chain/!trie_db!0xbd71221ec6a606a213189d3d27d5da39a39474894d83029f1397c838c9ac428b similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0xbd71221ec6a606a213189d3d27d5da39a39474894d83029f1397c838c9ac428b rename to test_data/test_chain/!trie_db!0xbd71221ec6a606a213189d3d27d5da39a39474894d83029f1397c838c9ac428b diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0xbd787bfe3f6c07ebc0a38c8b58602d63db9e2a7766462a4a946306126aeb8d99 b/test_data/test_chain/!trie_db!0xbd787bfe3f6c07ebc0a38c8b58602d63db9e2a7766462a4a946306126aeb8d99 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0xbd787bfe3f6c07ebc0a38c8b58602d63db9e2a7766462a4a946306126aeb8d99 rename to test_data/test_chain/!trie_db!0xbd787bfe3f6c07ebc0a38c8b58602d63db9e2a7766462a4a946306126aeb8d99 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0xbdde419a2f900b2d8212f399532144a371cbacfbd707bbba51a213a44423aae3 b/test_data/test_chain/!trie_db!0xbdde419a2f900b2d8212f399532144a371cbacfbd707bbba51a213a44423aae3 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0xbdde419a2f900b2d8212f399532144a371cbacfbd707bbba51a213a44423aae3 rename to test_data/test_chain/!trie_db!0xbdde419a2f900b2d8212f399532144a371cbacfbd707bbba51a213a44423aae3 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0xbe7ac73e79834cc32500daf7984ba02dfc883fb3fd00bdfef7a66054cc9c5a2d b/test_data/test_chain/!trie_db!0xbe7ac73e79834cc32500daf7984ba02dfc883fb3fd00bdfef7a66054cc9c5a2d similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0xbe7ac73e79834cc32500daf7984ba02dfc883fb3fd00bdfef7a66054cc9c5a2d rename to test_data/test_chain/!trie_db!0xbe7ac73e79834cc32500daf7984ba02dfc883fb3fd00bdfef7a66054cc9c5a2d diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0xbea5ac5b5b294572a69eeb79ac50511dad8558456cbd1f0f99342215d69d141c b/test_data/test_chain/!trie_db!0xbea5ac5b5b294572a69eeb79ac50511dad8558456cbd1f0f99342215d69d141c similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0xbea5ac5b5b294572a69eeb79ac50511dad8558456cbd1f0f99342215d69d141c rename to test_data/test_chain/!trie_db!0xbea5ac5b5b294572a69eeb79ac50511dad8558456cbd1f0f99342215d69d141c diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0xc10146e60c892a940009077be47b47625f3ca8023e92cc10bf73329a699933ad b/test_data/test_chain/!trie_db!0xc10146e60c892a940009077be47b47625f3ca8023e92cc10bf73329a699933ad similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0xc10146e60c892a940009077be47b47625f3ca8023e92cc10bf73329a699933ad rename to test_data/test_chain/!trie_db!0xc10146e60c892a940009077be47b47625f3ca8023e92cc10bf73329a699933ad diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0xc2509c936c6a49946f4d1f8ea285ba22df97bb1283f3b5a8326d7ee1b2ba2ed2 b/test_data/test_chain/!trie_db!0xc2509c936c6a49946f4d1f8ea285ba22df97bb1283f3b5a8326d7ee1b2ba2ed2 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0xc2509c936c6a49946f4d1f8ea285ba22df97bb1283f3b5a8326d7ee1b2ba2ed2 rename to test_data/test_chain/!trie_db!0xc2509c936c6a49946f4d1f8ea285ba22df97bb1283f3b5a8326d7ee1b2ba2ed2 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0xc2ed85fcd90ef7a8f384974bbaca81c0cd8e7be2444ca686fba240a4c4877250 b/test_data/test_chain/!trie_db!0xc2ed85fcd90ef7a8f384974bbaca81c0cd8e7be2444ca686fba240a4c4877250 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0xc2ed85fcd90ef7a8f384974bbaca81c0cd8e7be2444ca686fba240a4c4877250 rename to test_data/test_chain/!trie_db!0xc2ed85fcd90ef7a8f384974bbaca81c0cd8e7be2444ca686fba240a4c4877250 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0xc31a76584f994c2a759c12f1cc81372888596ed0ec2fa57e6e99bb2c1db470b4 b/test_data/test_chain/!trie_db!0xc31a76584f994c2a759c12f1cc81372888596ed0ec2fa57e6e99bb2c1db470b4 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0xc31a76584f994c2a759c12f1cc81372888596ed0ec2fa57e6e99bb2c1db470b4 rename to test_data/test_chain/!trie_db!0xc31a76584f994c2a759c12f1cc81372888596ed0ec2fa57e6e99bb2c1db470b4 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0xc34b6254fe0b63fd193c05815394207384070546c321e43b2c8fe77c7d2f909d b/test_data/test_chain/!trie_db!0xc34b6254fe0b63fd193c05815394207384070546c321e43b2c8fe77c7d2f909d similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0xc34b6254fe0b63fd193c05815394207384070546c321e43b2c8fe77c7d2f909d rename to test_data/test_chain/!trie_db!0xc34b6254fe0b63fd193c05815394207384070546c321e43b2c8fe77c7d2f909d diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0xc4f6a1f0b681632674246c126fd0b2eb33764bdb3ec5763b93968f205314944c b/test_data/test_chain/!trie_db!0xc4f6a1f0b681632674246c126fd0b2eb33764bdb3ec5763b93968f205314944c similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0xc4f6a1f0b681632674246c126fd0b2eb33764bdb3ec5763b93968f205314944c rename to test_data/test_chain/!trie_db!0xc4f6a1f0b681632674246c126fd0b2eb33764bdb3ec5763b93968f205314944c diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0xc6b2ffa8e1912127c6c62be9e04965e471a07d039643503ec5753ff3e00ed6b6 b/test_data/test_chain/!trie_db!0xc6b2ffa8e1912127c6c62be9e04965e471a07d039643503ec5753ff3e00ed6b6 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0xc6b2ffa8e1912127c6c62be9e04965e471a07d039643503ec5753ff3e00ed6b6 rename to test_data/test_chain/!trie_db!0xc6b2ffa8e1912127c6c62be9e04965e471a07d039643503ec5753ff3e00ed6b6 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0xc74b55ae25b522915216f62ea6ffcd436f6c6d4fe14a771042f7d4cea5cfa92f b/test_data/test_chain/!trie_db!0xc74b55ae25b522915216f62ea6ffcd436f6c6d4fe14a771042f7d4cea5cfa92f similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0xc74b55ae25b522915216f62ea6ffcd436f6c6d4fe14a771042f7d4cea5cfa92f rename to test_data/test_chain/!trie_db!0xc74b55ae25b522915216f62ea6ffcd436f6c6d4fe14a771042f7d4cea5cfa92f diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0xca8b42e2b8d76c3b83702676bba49ba99eb83413f2680ef6ba27a8557eef8481 b/test_data/test_chain/!trie_db!0xca8b42e2b8d76c3b83702676bba49ba99eb83413f2680ef6ba27a8557eef8481 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0xca8b42e2b8d76c3b83702676bba49ba99eb83413f2680ef6ba27a8557eef8481 rename to test_data/test_chain/!trie_db!0xca8b42e2b8d76c3b83702676bba49ba99eb83413f2680ef6ba27a8557eef8481 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0xcaabb5eace0c874816d18d87a14bdd47d6ca59824abbd2930b90caff6fd8d258 b/test_data/test_chain/!trie_db!0xcaabb5eace0c874816d18d87a14bdd47d6ca59824abbd2930b90caff6fd8d258 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0xcaabb5eace0c874816d18d87a14bdd47d6ca59824abbd2930b90caff6fd8d258 rename to test_data/test_chain/!trie_db!0xcaabb5eace0c874816d18d87a14bdd47d6ca59824abbd2930b90caff6fd8d258 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0xcb69c18a6678a939fd2d7b440403556b57131ca3e2269d6d477c01704ab2a99a b/test_data/test_chain/!trie_db!0xcb69c18a6678a939fd2d7b440403556b57131ca3e2269d6d477c01704ab2a99a similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0xcb69c18a6678a939fd2d7b440403556b57131ca3e2269d6d477c01704ab2a99a rename to test_data/test_chain/!trie_db!0xcb69c18a6678a939fd2d7b440403556b57131ca3e2269d6d477c01704ab2a99a diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0xcd9a145c136f5eca333f964b63eff22e7d5a154dac0e47e2d9effcd796a5308f b/test_data/test_chain/!trie_db!0xcd9a145c136f5eca333f964b63eff22e7d5a154dac0e47e2d9effcd796a5308f similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0xcd9a145c136f5eca333f964b63eff22e7d5a154dac0e47e2d9effcd796a5308f rename to test_data/test_chain/!trie_db!0xcd9a145c136f5eca333f964b63eff22e7d5a154dac0e47e2d9effcd796a5308f diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0xcdd19c234ef06438bc376231a390093b367b22505d25409880d81d150779a175 b/test_data/test_chain/!trie_db!0xcdd19c234ef06438bc376231a390093b367b22505d25409880d81d150779a175 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0xcdd19c234ef06438bc376231a390093b367b22505d25409880d81d150779a175 rename to test_data/test_chain/!trie_db!0xcdd19c234ef06438bc376231a390093b367b22505d25409880d81d150779a175 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0xcf2759c659bd860d34b51ade81828c957ccf8622569c2cb25a546bd325a84a25 b/test_data/test_chain/!trie_db!0xcf2759c659bd860d34b51ade81828c957ccf8622569c2cb25a546bd325a84a25 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0xcf2759c659bd860d34b51ade81828c957ccf8622569c2cb25a546bd325a84a25 rename to test_data/test_chain/!trie_db!0xcf2759c659bd860d34b51ade81828c957ccf8622569c2cb25a546bd325a84a25 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0xcfe663a029b4580a64c6b23d74e9c54a7fb03d16ed52c503bf8dbd2ea0332a47 b/test_data/test_chain/!trie_db!0xcfe663a029b4580a64c6b23d74e9c54a7fb03d16ed52c503bf8dbd2ea0332a47 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0xcfe663a029b4580a64c6b23d74e9c54a7fb03d16ed52c503bf8dbd2ea0332a47 rename to test_data/test_chain/!trie_db!0xcfe663a029b4580a64c6b23d74e9c54a7fb03d16ed52c503bf8dbd2ea0332a47 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0xd08975b46ac1b1f8e2b45d20715c97db1e33fb7ee0a0c5de07c377436a52a88f b/test_data/test_chain/!trie_db!0xd08975b46ac1b1f8e2b45d20715c97db1e33fb7ee0a0c5de07c377436a52a88f similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0xd08975b46ac1b1f8e2b45d20715c97db1e33fb7ee0a0c5de07c377436a52a88f rename to test_data/test_chain/!trie_db!0xd08975b46ac1b1f8e2b45d20715c97db1e33fb7ee0a0c5de07c377436a52a88f diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0xd1620f6254ebf95f7c5133c1faaeb0d95e4e47a6ef5f7e9cc0c1babbf99882e6 b/test_data/test_chain/!trie_db!0xd1620f6254ebf95f7c5133c1faaeb0d95e4e47a6ef5f7e9cc0c1babbf99882e6 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0xd1620f6254ebf95f7c5133c1faaeb0d95e4e47a6ef5f7e9cc0c1babbf99882e6 rename to test_data/test_chain/!trie_db!0xd1620f6254ebf95f7c5133c1faaeb0d95e4e47a6ef5f7e9cc0c1babbf99882e6 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0xd167b284cd9e648f2508afc91308534ad0c1c0b77bb37c4abab7043a4f758ef2 b/test_data/test_chain/!trie_db!0xd167b284cd9e648f2508afc91308534ad0c1c0b77bb37c4abab7043a4f758ef2 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0xd167b284cd9e648f2508afc91308534ad0c1c0b77bb37c4abab7043a4f758ef2 rename to test_data/test_chain/!trie_db!0xd167b284cd9e648f2508afc91308534ad0c1c0b77bb37c4abab7043a4f758ef2 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0xd44519568c01afd79cb7ddd8417238739c5aaeebc833c81e0169ffd81eb32117 b/test_data/test_chain/!trie_db!0xd44519568c01afd79cb7ddd8417238739c5aaeebc833c81e0169ffd81eb32117 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0xd44519568c01afd79cb7ddd8417238739c5aaeebc833c81e0169ffd81eb32117 rename to test_data/test_chain/!trie_db!0xd44519568c01afd79cb7ddd8417238739c5aaeebc833c81e0169ffd81eb32117 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0xd82a7e871271fe9e9a8e25d05978546987306eeedd6c1fde6ff89b01f7554405 b/test_data/test_chain/!trie_db!0xd82a7e871271fe9e9a8e25d05978546987306eeedd6c1fde6ff89b01f7554405 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0xd82a7e871271fe9e9a8e25d05978546987306eeedd6c1fde6ff89b01f7554405 rename to test_data/test_chain/!trie_db!0xd82a7e871271fe9e9a8e25d05978546987306eeedd6c1fde6ff89b01f7554405 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0xd8592c6f97b855e192b45cbc3a21093b529abc9cca3c368066d44aa31c9f0a57 b/test_data/test_chain/!trie_db!0xd8592c6f97b855e192b45cbc3a21093b529abc9cca3c368066d44aa31c9f0a57 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0xd8592c6f97b855e192b45cbc3a21093b529abc9cca3c368066d44aa31c9f0a57 rename to test_data/test_chain/!trie_db!0xd8592c6f97b855e192b45cbc3a21093b529abc9cca3c368066d44aa31c9f0a57 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0xdaebc99a7107bb7774be5685fc91dc9b2a240431ff2477cb8b15d6cc57ae8bd5 b/test_data/test_chain/!trie_db!0xdaebc99a7107bb7774be5685fc91dc9b2a240431ff2477cb8b15d6cc57ae8bd5 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0xdaebc99a7107bb7774be5685fc91dc9b2a240431ff2477cb8b15d6cc57ae8bd5 rename to test_data/test_chain/!trie_db!0xdaebc99a7107bb7774be5685fc91dc9b2a240431ff2477cb8b15d6cc57ae8bd5 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0xdb0af948d55394775495207faf2541a5432ef2b567e0f6faccb7e193d64d48cf b/test_data/test_chain/!trie_db!0xdb0af948d55394775495207faf2541a5432ef2b567e0f6faccb7e193d64d48cf similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0xdb0af948d55394775495207faf2541a5432ef2b567e0f6faccb7e193d64d48cf rename to test_data/test_chain/!trie_db!0xdb0af948d55394775495207faf2541a5432ef2b567e0f6faccb7e193d64d48cf diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0xdb65034b0cb52ce3cc1db6ba302a9d4e12b2b6e91d432961f2088d6d1d8cc976 b/test_data/test_chain/!trie_db!0xdb65034b0cb52ce3cc1db6ba302a9d4e12b2b6e91d432961f2088d6d1d8cc976 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0xdb65034b0cb52ce3cc1db6ba302a9d4e12b2b6e91d432961f2088d6d1d8cc976 rename to test_data/test_chain/!trie_db!0xdb65034b0cb52ce3cc1db6ba302a9d4e12b2b6e91d432961f2088d6d1d8cc976 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0xdce4225c8f8ab070aacf8bd8759e71a54c27ec9724cb5d37c1a80370eef9bb65 b/test_data/test_chain/!trie_db!0xdce4225c8f8ab070aacf8bd8759e71a54c27ec9724cb5d37c1a80370eef9bb65 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0xdce4225c8f8ab070aacf8bd8759e71a54c27ec9724cb5d37c1a80370eef9bb65 rename to test_data/test_chain/!trie_db!0xdce4225c8f8ab070aacf8bd8759e71a54c27ec9724cb5d37c1a80370eef9bb65 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0xe1e9a9ea0c7be782a715d4444db86e0e6a408f7d7663d3d16c770a9d535feb6f b/test_data/test_chain/!trie_db!0xe1e9a9ea0c7be782a715d4444db86e0e6a408f7d7663d3d16c770a9d535feb6f similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0xe1e9a9ea0c7be782a715d4444db86e0e6a408f7d7663d3d16c770a9d535feb6f rename to test_data/test_chain/!trie_db!0xe1e9a9ea0c7be782a715d4444db86e0e6a408f7d7663d3d16c770a9d535feb6f diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0xe54a935811e12f64c01aee3104a99b1047ce696ecd3cce171e23eab2c326fbc2 b/test_data/test_chain/!trie_db!0xe54a935811e12f64c01aee3104a99b1047ce696ecd3cce171e23eab2c326fbc2 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0xe54a935811e12f64c01aee3104a99b1047ce696ecd3cce171e23eab2c326fbc2 rename to test_data/test_chain/!trie_db!0xe54a935811e12f64c01aee3104a99b1047ce696ecd3cce171e23eab2c326fbc2 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0xe6e2c72b27c006bf6a0b3e89f9d5f2137134dd25d6560f27258078b60b15aaec b/test_data/test_chain/!trie_db!0xe6e2c72b27c006bf6a0b3e89f9d5f2137134dd25d6560f27258078b60b15aaec similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0xe6e2c72b27c006bf6a0b3e89f9d5f2137134dd25d6560f27258078b60b15aaec rename to test_data/test_chain/!trie_db!0xe6e2c72b27c006bf6a0b3e89f9d5f2137134dd25d6560f27258078b60b15aaec diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0xe855e4e8bfd909066a8059e6796be225553e199a2c22f4b65ddaeea511d19014 b/test_data/test_chain/!trie_db!0xe855e4e8bfd909066a8059e6796be225553e199a2c22f4b65ddaeea511d19014 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0xe855e4e8bfd909066a8059e6796be225553e199a2c22f4b65ddaeea511d19014 rename to test_data/test_chain/!trie_db!0xe855e4e8bfd909066a8059e6796be225553e199a2c22f4b65ddaeea511d19014 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0xe9b9ea49eb759376e9b3311f8f50b0c48eb722b83adf0b99368624f2716011db b/test_data/test_chain/!trie_db!0xe9b9ea49eb759376e9b3311f8f50b0c48eb722b83adf0b99368624f2716011db similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0xe9b9ea49eb759376e9b3311f8f50b0c48eb722b83adf0b99368624f2716011db rename to test_data/test_chain/!trie_db!0xe9b9ea49eb759376e9b3311f8f50b0c48eb722b83adf0b99368624f2716011db diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0xec77d285a767ea2ec58ce52c0022aac4c71efc3f396f1989598c33e75e8bedd1 b/test_data/test_chain/!trie_db!0xec77d285a767ea2ec58ce52c0022aac4c71efc3f396f1989598c33e75e8bedd1 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0xec77d285a767ea2ec58ce52c0022aac4c71efc3f396f1989598c33e75e8bedd1 rename to test_data/test_chain/!trie_db!0xec77d285a767ea2ec58ce52c0022aac4c71efc3f396f1989598c33e75e8bedd1 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0xed57d93087e1a79ee9e3f6eadfc3d2affdb420d73dc4ecf07c5a21b22a221a98 b/test_data/test_chain/!trie_db!0xed57d93087e1a79ee9e3f6eadfc3d2affdb420d73dc4ecf07c5a21b22a221a98 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0xed57d93087e1a79ee9e3f6eadfc3d2affdb420d73dc4ecf07c5a21b22a221a98 rename to test_data/test_chain/!trie_db!0xed57d93087e1a79ee9e3f6eadfc3d2affdb420d73dc4ecf07c5a21b22a221a98 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0xed89ce8c7b8d2657d679fd3eb25076b5d12bd24ecfd91f2b19891722703a43e2 b/test_data/test_chain/!trie_db!0xed89ce8c7b8d2657d679fd3eb25076b5d12bd24ecfd91f2b19891722703a43e2 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0xed89ce8c7b8d2657d679fd3eb25076b5d12bd24ecfd91f2b19891722703a43e2 rename to test_data/test_chain/!trie_db!0xed89ce8c7b8d2657d679fd3eb25076b5d12bd24ecfd91f2b19891722703a43e2 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0xf16e2c7b466b113f3159a527a5f17bce3863cc3cda8b21f0da41228f0be40e75 b/test_data/test_chain/!trie_db!0xf16e2c7b466b113f3159a527a5f17bce3863cc3cda8b21f0da41228f0be40e75 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0xf16e2c7b466b113f3159a527a5f17bce3863cc3cda8b21f0da41228f0be40e75 rename to test_data/test_chain/!trie_db!0xf16e2c7b466b113f3159a527a5f17bce3863cc3cda8b21f0da41228f0be40e75 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0xf39ba3ac12d2744dd608f89cb539b72a387a2e605dba7ad9a4e935486657e80c b/test_data/test_chain/!trie_db!0xf39ba3ac12d2744dd608f89cb539b72a387a2e605dba7ad9a4e935486657e80c similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0xf39ba3ac12d2744dd608f89cb539b72a387a2e605dba7ad9a4e935486657e80c rename to test_data/test_chain/!trie_db!0xf39ba3ac12d2744dd608f89cb539b72a387a2e605dba7ad9a4e935486657e80c diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0xf417ac2b221084cc9f25360f16f68983f1636169ed35c027c83b2925ea63a3b9 b/test_data/test_chain/!trie_db!0xf417ac2b221084cc9f25360f16f68983f1636169ed35c027c83b2925ea63a3b9 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0xf417ac2b221084cc9f25360f16f68983f1636169ed35c027c83b2925ea63a3b9 rename to test_data/test_chain/!trie_db!0xf417ac2b221084cc9f25360f16f68983f1636169ed35c027c83b2925ea63a3b9 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0xf5bc46da5777e39236ea19c82191f7ff73ee8b732b3652ae6864c8bc2e2688e0 b/test_data/test_chain/!trie_db!0xf5bc46da5777e39236ea19c82191f7ff73ee8b732b3652ae6864c8bc2e2688e0 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0xf5bc46da5777e39236ea19c82191f7ff73ee8b732b3652ae6864c8bc2e2688e0 rename to test_data/test_chain/!trie_db!0xf5bc46da5777e39236ea19c82191f7ff73ee8b732b3652ae6864c8bc2e2688e0 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0xf5ee2d5a1e72de4b5a1e2af94497ed2082c0874454d5419cbdb0037f105e882a b/test_data/test_chain/!trie_db!0xf5ee2d5a1e72de4b5a1e2af94497ed2082c0874454d5419cbdb0037f105e882a similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0xf5ee2d5a1e72de4b5a1e2af94497ed2082c0874454d5419cbdb0037f105e882a rename to test_data/test_chain/!trie_db!0xf5ee2d5a1e72de4b5a1e2af94497ed2082c0874454d5419cbdb0037f105e882a diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0xf809a0ce500223d176d587be8c6a89aea88a70d80394f7eda04d8e4b1c17cc4e b/test_data/test_chain/!trie_db!0xf809a0ce500223d176d587be8c6a89aea88a70d80394f7eda04d8e4b1c17cc4e similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0xf809a0ce500223d176d587be8c6a89aea88a70d80394f7eda04d8e4b1c17cc4e rename to test_data/test_chain/!trie_db!0xf809a0ce500223d176d587be8c6a89aea88a70d80394f7eda04d8e4b1c17cc4e diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0xfb53e64824f62daa3a1598b6864c077c8b3feafa8d6f93bb5185dcd52a55f4b5 b/test_data/test_chain/!trie_db!0xfb53e64824f62daa3a1598b6864c077c8b3feafa8d6f93bb5185dcd52a55f4b5 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0xfb53e64824f62daa3a1598b6864c077c8b3feafa8d6f93bb5185dcd52a55f4b5 rename to test_data/test_chain/!trie_db!0xfb53e64824f62daa3a1598b6864c077c8b3feafa8d6f93bb5185dcd52a55f4b5 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0xfc06e3f1445bb4688f0502c46231fc72da5d44c6419ee71c47be24fbf1928fcf b/test_data/test_chain/!trie_db!0xfc06e3f1445bb4688f0502c46231fc72da5d44c6419ee71c47be24fbf1928fcf similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0xfc06e3f1445bb4688f0502c46231fc72da5d44c6419ee71c47be24fbf1928fcf rename to test_data/test_chain/!trie_db!0xfc06e3f1445bb4688f0502c46231fc72da5d44c6419ee71c47be24fbf1928fcf diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0xfdc8e630564f657910187c9eb1d7bf01e04231d016528da0062c123203eb1c79 b/test_data/test_chain/!trie_db!0xfdc8e630564f657910187c9eb1d7bf01e04231d016528da0062c123203eb1c79 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0xfdc8e630564f657910187c9eb1d7bf01e04231d016528da0062c123203eb1c79 rename to test_data/test_chain/!trie_db!0xfdc8e630564f657910187c9eb1d7bf01e04231d016528da0062c123203eb1c79 diff --git a/pkg/transformers/test_data/test_chain/!trie_db!0xfe3d828c2803bd586bc34641752157c205a391ec9a1b730031bccc77a9276b02 b/test_data/test_chain/!trie_db!0xfe3d828c2803bd586bc34641752157c205a391ec9a1b730031bccc77a9276b02 similarity index 100% rename from pkg/transformers/test_data/test_chain/!trie_db!0xfe3d828c2803bd586bc34641752157c205a391ec9a1b730031bccc77a9276b02 rename to test_data/test_chain/!trie_db!0xfe3d828c2803bd586bc34641752157c205a391ec9a1b730031bccc77a9276b02 diff --git a/utils/utils.go b/utils/utils.go index 3a862f51..7145f2c8 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -122,8 +122,7 @@ func CopyFile(src, dst string) error { return err } defer in.Close() - - out, err := os.OpenFile(dst, syscall.O_CREAT|syscall.O_EXCL, os.FileMode(0666)) // Doesn't overwrite files + out, err := os.OpenFile(dst, syscall.O_CREAT|syscall.O_EXCL|os.O_WRONLY, os.FileMode(0666)) // Doesn't overwrite files if err != nil { return err }