composeAndExecute command that loads and executes over arbitrary transformer set exported from a go plugin generated according to config file; test for plugin generation, loading, and execution; work on plugins README
This commit is contained in:
parent
fa4abe4e5c
commit
6c2d895023
9
Gopkg.lock
generated
9
Gopkg.lock
generated
@ -28,6 +28,14 @@
|
||||
pruneopts = ""
|
||||
revision = "cff30e1d23fc9e800b2b5b4b41ef1817dda07e9f"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:5d47691333460db6ac83ced03c79b4bdb9aff3e322be24affb7855bed8affc6c"
|
||||
name = "github.com/dave/jennifer"
|
||||
packages = ["jen"]
|
||||
pruneopts = ""
|
||||
revision = "14e399b6b5e8456c66c45c955fc27b568bacb5c9"
|
||||
version = "v1.3.0"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:aaeffbff5bd24654cb4c190ed75d6c7b57b4f5d6741914c1a7a6bb7447e756c5"
|
||||
name = "github.com/deckarep/golang-set"
|
||||
@ -549,6 +557,7 @@
|
||||
analyzer-name = "dep"
|
||||
analyzer-version = 1
|
||||
input-imports = [
|
||||
"github.com/dave/jennifer/jen",
|
||||
"github.com/ethereum/go-ethereum",
|
||||
"github.com/ethereum/go-ethereum/accounts/abi",
|
||||
"github.com/ethereum/go-ethereum/accounts/abi/bind",
|
||||
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
package cmd
|
||||
|
||||
import (
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/vulcanize/vulcanizedb/libraries/shared"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants"
|
||||
)
|
||||
|
||||
// backfillMakerLogsCmd represents the backfillMakerLogs command
|
||||
var backfillMakerLogsCmd = &cobra.Command{
|
||||
Use: "backfillMakerLogs",
|
||||
Short: "Backfill Maker event logs",
|
||||
Long: `Backfills Maker event logs based on previously populated block Header records.
|
||||
This currently includes logs related to Multi-collateral Dai (frob), Auctions (flip-kick),
|
||||
and Price Feeds (ETH/USD, MKR/USD, and REP/USD - LogValue).
|
||||
|
||||
vulcanizedb backfillMakerLogs --config environments/local.toml
|
||||
|
||||
This command expects a light sync to have been run, and the presence of header records in the Vulcanize database.`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
backfillMakerLogs()
|
||||
},
|
||||
}
|
||||
|
||||
func backfillMakerLogs() {
|
||||
blockChain := getBlockChain()
|
||||
db, err := postgres.NewDB(databaseConfig, blockChain.Node())
|
||||
if err != nil {
|
||||
log.Fatal("Failed to initialize database.")
|
||||
}
|
||||
|
||||
watcher := shared.NewEventWatcher(db, blockChain)
|
||||
|
||||
watcher.AddTransformers(transformers.TransformerInitializers())
|
||||
err = watcher.Execute(constants.HeaderMissing)
|
||||
if err != nil {
|
||||
// TODO Handle watcher error in backfillMakerLogs
|
||||
}
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(backfillMakerLogsCmd)
|
||||
}
|
121
cmd/composeAndExecute.go
Normal file
121
cmd/composeAndExecute.go
Normal file
@ -0,0 +1,121 @@
|
||||
// Copyright © 2019 Vulcanize, Inc
|
||||
//
|
||||
// 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"plugin"
|
||||
"time"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/vulcanize/vulcanizedb/libraries/shared/transformer"
|
||||
"github.com/vulcanize/vulcanizedb/libraries/shared/watcher"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/autogen"
|
||||
"github.com/vulcanize/vulcanizedb/utils"
|
||||
)
|
||||
|
||||
// executePluginCmd represents the execute command
|
||||
var composeAndExecuteCmd = &cobra.Command{
|
||||
Use: "composeAndExecute",
|
||||
Short: "Composes, loads, and executes transformer initializer plugin",
|
||||
Long: `This command needs a config .toml file of form:
|
||||
|
||||
[database]
|
||||
name = "vulcanize_public"
|
||||
hostname = "localhost"
|
||||
user = "vulcanize"
|
||||
password = "vulcanize"
|
||||
port = 5432
|
||||
|
||||
[client]
|
||||
ipcPath = "http://kovan0.vulcanize.io:8545"
|
||||
|
||||
[exporter]
|
||||
filePath = "~/go/src/github.com/vulcanize/vulcanizedb/plugins"
|
||||
fileName = "exporter"
|
||||
[exporter.transformers]
|
||||
transformerImport1 = "github.com/path_to/transformerInitializer1"
|
||||
transformerImport2 = "github.com/path_to/transformerInitializer2"
|
||||
|
||||
Note: If any of the imported transformer need additional
|
||||
config variables do not forget to include those as well
|
||||
|
||||
This information is used to write and build a .so with an arbitrary transformer
|
||||
set composed from the transformer imports specified in the config file
|
||||
This .so is loaded as a plugin and the set of transformer initializers is
|
||||
loaded into and executed over by a generic watcher`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
composeAndExecute()
|
||||
},
|
||||
}
|
||||
|
||||
func composeAndExecute() {
|
||||
generator := autogen.NewGenerator(autogenConfig)
|
||||
err := generator.GenerateTransformerPlugin()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
ticker := time.NewTicker(pollingInterval)
|
||||
defer ticker.Stop()
|
||||
|
||||
blockChain := getBlockChain()
|
||||
db := utils.LoadPostgres(databaseConfig, blockChain.Node())
|
||||
|
||||
_, pluginPath, err := autogen.GetPaths(autogenConfig)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
plug, err := plugin.Open(pluginPath)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
symExporter, err := plug.Lookup("Exporter")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
exporter, ok := symExporter.(Exporter)
|
||||
if !ok {
|
||||
fmt.Println("plugged-in symbol not of type Exporter")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
initializers := exporter.Export()
|
||||
w := watcher.NewWatcher(&db, blockChain)
|
||||
w.AddTransformers(initializers)
|
||||
|
||||
for range ticker.C {
|
||||
err := w.Execute()
|
||||
if err != nil {
|
||||
// TODO Handle watcher errors in composeAndExecute
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
type Exporter interface {
|
||||
Export() []transformer.TransformerInitializer
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(composeAndExecuteCmd)
|
||||
composeAndExecuteCmd.Flags().Int64VarP(&startingBlockNumber, "starting-block-number", "s", 0, "Block number to start transformer execution from")
|
||||
}
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/vulcanize/vulcanizedb/libraries/shared"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers"
|
||||
shared2 "github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants"
|
||||
)
|
||||
|
||||
// continuousLogSyncCmd represents the continuousLogSync command
|
||||
var continuousLogSyncCmd = &cobra.Command{
|
||||
Use: "continuousLogSync",
|
||||
Short: "Continuously sync logs at the head of the chain",
|
||||
Long: fmt.Sprintf(`Continously syncs logs based on the configured transformers.
|
||||
|
||||
vulcanizedb continousLogSync --config environments/local.toml
|
||||
|
||||
Available transformers for (optional) selection with --transformers:
|
||||
%v
|
||||
|
||||
This command expects a light sync to have been run, and the presence of header records in the Vulcanize database.`,
|
||||
constants.AllTransformerLabels()),
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
syncMakerLogs()
|
||||
},
|
||||
}
|
||||
|
||||
var transformerNames []string
|
||||
var recheckHeadersArg bool
|
||||
|
||||
func syncMakerLogs() {
|
||||
ticker := time.NewTicker(pollingInterval)
|
||||
defer ticker.Stop()
|
||||
|
||||
blockChain := getBlockChain()
|
||||
db, err := postgres.NewDB(databaseConfig, blockChain.Node())
|
||||
if err != nil {
|
||||
log.Fatal("Failed to initialize database.")
|
||||
}
|
||||
|
||||
initializers := getTransformerInitializers(transformerNames)
|
||||
|
||||
watcher := shared.NewEventWatcher(db, blockChain)
|
||||
watcher.AddTransformers(initializers)
|
||||
|
||||
for range ticker.C {
|
||||
if recheckHeadersArg {
|
||||
err = watcher.Execute(constants.HeaderRecheck)
|
||||
} else {
|
||||
err = watcher.Execute(constants.HeaderMissing)
|
||||
}
|
||||
if err != nil {
|
||||
// TODO Handle watcher errors in ContinuousLogSync
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func getTransformerInitializers(transformerNames []string) []shared2.TransformerInitializer {
|
||||
var initializers []shared2.TransformerInitializer
|
||||
|
||||
if transformerNames[0] == "all" {
|
||||
initializers = transformers.TransformerInitializers()
|
||||
} else {
|
||||
initializerMap := buildTransformerInitializerMap()
|
||||
for _, transformerName := range transformerNames {
|
||||
initializers = append(initializers, initializerMap[transformerName])
|
||||
}
|
||||
}
|
||||
return initializers
|
||||
}
|
||||
|
||||
func buildTransformerInitializerMap() map[string]shared2.TransformerInitializer {
|
||||
initializerMap := make(map[string]shared2.TransformerInitializer)
|
||||
|
||||
initializerMap[constants.BiteLabel] = transformers.GetBiteTransformer().NewTransformer
|
||||
initializerMap[constants.CatFileChopLumpLabel] = transformers.GetCatFileChopLumpTransformer().NewLogNoteTransformer
|
||||
initializerMap[constants.CatFileFlipLabel] = transformers.GetCatFileFlipTransformer().NewLogNoteTransformer
|
||||
initializerMap[constants.CatFilePitVowLabel] = transformers.GetCatFilePitVowTransformer().NewLogNoteTransformer
|
||||
initializerMap[constants.DealLabel] = transformers.GetDealTransformer().NewLogNoteTransformer
|
||||
initializerMap[constants.DentLabel] = transformers.GetDentTransformer().NewLogNoteTransformer
|
||||
initializerMap[constants.DripDripLabel] = transformers.GetDripDripTransformer().NewLogNoteTransformer
|
||||
initializerMap[constants.DripFileIlkLabel] = transformers.GetDripFileIlkTransformer().NewLogNoteTransformer
|
||||
initializerMap[constants.DripFileRepoLabel] = transformers.GetDripFileRepoTransformer().NewLogNoteTransformer
|
||||
initializerMap[constants.DripFileVowLabel] = transformers.GetDripFileVowTransformer().NewLogNoteTransformer
|
||||
initializerMap[constants.FlapKickLabel] = transformers.GetFlapKickTransformer().NewTransformer
|
||||
initializerMap[constants.FlipKickLabel] = transformers.GetFlipKickTransformer().NewTransformer
|
||||
initializerMap[constants.FlopKickLabel] = transformers.GetFlopKickTransformer().NewTransformer
|
||||
initializerMap[constants.FrobLabel] = transformers.GetFrobTransformer().NewTransformer
|
||||
initializerMap[constants.PitFileDebtCeilingLabel] = transformers.GetPitFileDebtCeilingTransformer().NewLogNoteTransformer
|
||||
initializerMap[constants.PitFileIlkLabel] = transformers.GetPitFileIlkTransformer().NewLogNoteTransformer
|
||||
initializerMap[constants.PriceFeedLabel] = transformers.GetPriceFeedTransformer().NewLogNoteTransformer
|
||||
initializerMap[constants.TendLabel] = transformers.GetTendTransformer().NewLogNoteTransformer
|
||||
initializerMap[constants.VatFluxLabel] = transformers.GetVatFluxTransformer().NewLogNoteTransformer
|
||||
initializerMap[constants.VatFoldLabel] = transformers.GetVatFoldTransformer().NewLogNoteTransformer
|
||||
initializerMap[constants.VatGrabLabel] = transformers.GetVatGrabTransformer().NewLogNoteTransformer
|
||||
initializerMap[constants.VatHealLabel] = transformers.GetVatHealTransformer().NewLogNoteTransformer
|
||||
initializerMap[constants.VatInitLabel] = transformers.GetVatInitTransformer().NewLogNoteTransformer
|
||||
initializerMap[constants.VatMoveLabel] = transformers.GetVatMoveTransformer().NewLogNoteTransformer
|
||||
initializerMap[constants.VatSlipLabel] = transformers.GetVatSlipTransformer().NewLogNoteTransformer
|
||||
initializerMap[constants.VatTollLabel] = transformers.GetVatTollTransformer().NewLogNoteTransformer
|
||||
initializerMap[constants.VatTuneLabel] = transformers.GetVatTuneTransformer().NewLogNoteTransformer
|
||||
initializerMap[constants.VowFlogLabel] = transformers.GetFlogTransformer().NewLogNoteTransformer
|
||||
|
||||
return initializerMap
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(continuousLogSyncCmd)
|
||||
continuousLogSyncCmd.Flags().StringSliceVar(&transformerNames, "transformers", []string{"all"}, "transformer names to be run during this command")
|
||||
continuousLogSyncCmd.Flags().BoolVar(&recheckHeadersArg, "recheckHeaders", false, "checks headers that are already checked for each transformer.")
|
||||
}
|
15
cmd/root.go
15
cmd/root.go
@ -28,6 +28,7 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
|
||||
"github.com/vulcanize/vulcanizedb/pkg/autogen"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/config"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/geth"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/geth/client"
|
||||
@ -38,6 +39,7 @@ import (
|
||||
var (
|
||||
cfgFile string
|
||||
databaseConfig config.Database
|
||||
autogenConfig autogen.Config
|
||||
ipc string
|
||||
levelDbPath string
|
||||
startingBlockNumber int64
|
||||
@ -53,7 +55,7 @@ const (
|
||||
|
||||
var rootCmd = &cobra.Command{
|
||||
Use: "vulcanizedb",
|
||||
PersistentPreRun: database,
|
||||
PersistentPreRun: configure,
|
||||
}
|
||||
|
||||
func Execute() {
|
||||
@ -63,7 +65,7 @@ func Execute() {
|
||||
}
|
||||
}
|
||||
|
||||
func database(cmd *cobra.Command, args []string) {
|
||||
func configure(cmd *cobra.Command, args []string) {
|
||||
ipc = viper.GetString("client.ipcpath")
|
||||
levelDbPath = viper.GetString("client.leveldbpath")
|
||||
storageDiffsPath = viper.GetString("filesystem.storageDiffsPath")
|
||||
@ -74,6 +76,11 @@ func database(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"),
|
||||
Imports: viper.GetStringMapString("exporter.transformers"),
|
||||
}
|
||||
viper.Set("database.config", databaseConfig)
|
||||
}
|
||||
|
||||
@ -93,6 +100,8 @@ func init() {
|
||||
rootCmd.PersistentFlags().String("client-levelDbPath", "", "location of levelDb chaindata")
|
||||
rootCmd.PersistentFlags().String("datadog-name", "vulcanize-test", "datadog service name")
|
||||
rootCmd.PersistentFlags().String("filesystem-storageDiffsPath", "", "location of storage diffs csv file")
|
||||
rootCmd.PersistentFlags().String("exporter-path", "~/go/src/github.com/vulcanize/vulcanizedb/plugins", "file path to transformer exporter plugin")
|
||||
rootCmd.PersistentFlags().String("exporter-name", "exporter", "name of exporter plugin")
|
||||
|
||||
viper.BindPFlag("database.name", rootCmd.PersistentFlags().Lookup("database-name"))
|
||||
viper.BindPFlag("database.port", rootCmd.PersistentFlags().Lookup("database-port"))
|
||||
@ -103,6 +112,8 @@ func init() {
|
||||
viper.BindPFlag("client.levelDbPath", rootCmd.PersistentFlags().Lookup("client-levelDbPath"))
|
||||
viper.BindPFlag("datadog.name", rootCmd.PersistentFlags().Lookup("datadog-name"))
|
||||
viper.BindPFlag("filesystem.storageDiffsPath", rootCmd.PersistentFlags().Lookup("filesystem-storageDiffsPath"))
|
||||
viper.BindPFlag("exporter.filePath", rootCmd.PersistentFlags().Lookup("exporter-path"))
|
||||
viper.BindPFlag("exporter.fileName", rootCmd.PersistentFlags().Lookup("exporter-name"))
|
||||
}
|
||||
|
||||
func initConfig() {
|
||||
|
82
environments/compose.toml
Normal file
82
environments/compose.toml
Normal file
@ -0,0 +1,82 @@
|
||||
[database]
|
||||
name = "vulcanize_public"
|
||||
hostname = "localhost"
|
||||
user = "vulcanize"
|
||||
password = "vulcanize"
|
||||
port = 5432
|
||||
|
||||
[client]
|
||||
ipcPath = "http://kovan0.vulcanize.io:8545"
|
||||
|
||||
[datadog]
|
||||
name = "maker_vdb_staging"
|
||||
|
||||
[exporter]
|
||||
filePath = "$GOPATH/src/github.com/vulcanize/vulcanizedb/plugins/"
|
||||
fileName = "exporter"
|
||||
[exporter.transformers]
|
||||
bite = "github.com/vulcanize/mcd_transformers/transformers/bite"
|
||||
cat_chop_lump = "github.com/vulcanize/maker_transformers/cat/chop_lump"
|
||||
cat_flip = "github.com/vulcanize/mcd_transformers/transformers/cat/flip"
|
||||
cat_pit_vow = "github.com/vulcanize/mcd_transformers/transformers/cat/pit_vow"
|
||||
deal = "github.com/vulcanize/mcd_transformers/transformers/deal"
|
||||
dent = "github.com/vulcanize/mcd_transformers/transformers/dent"
|
||||
drip_drip = "github.com/vulcanize/mcd_transformers/transformers/drip_drip"
|
||||
drip_file_ilk = "github.com/vulcanize/mcd_transformers/transformers/drip_file/ilk"
|
||||
drip_file_repo = "github.com/vulcanize/mcd_transformers/transformers/drip_file/repo"
|
||||
drip_file_vow = "github.com/vulcanize/mcd_transformers/transformers/drip_file/vow"
|
||||
flap_kick = "github.com/vulcanize/mcd_transformers/transformers/flap_kick"
|
||||
flip_kick = "github.com/vulcanize/mcd_transformers/transformers/flip_kick"
|
||||
flop_kick = "github.com/vulcanize/mcd_transformers/transformers/flop_kick"
|
||||
frob = "github.com/vulcanize/mcd_transformers/transformers/frob"
|
||||
pit_file_debt_ceiling = "github.com/vulcanize/mcd_transformers/transformers/pit_file/debt_ceiling"
|
||||
pit_file_ilk = "github.com/vulcanize/mcd_transformers/transformers/pit_file/ilk"
|
||||
price_feeds = "github.com/vulcanize/mcd_transformers/transformers/price_feeds"
|
||||
tend = "github.com/vulcanize/mcd_transformers/transformers/tend"
|
||||
vat_flux = "github.com/vulcanize/mcd_transformers/transformers/vat_flux"
|
||||
vat_fold = "github.com/vulcanize/mcd_transformers/transformers/vat_fold"
|
||||
vat_grab = "github.com/vulcanize/mcd_transformers/transformers/vat_grab"
|
||||
vat_heal = "github.com/vulcanize/mcd_transformers/transformers/vat_heal"
|
||||
vat_init = "github.com/vulcanize/mcd_transformers/transformers/vat_init"
|
||||
vat_move = "github.com/vulcanize/mcd_transformers/transformers/vat_move"
|
||||
vat_slip = "github.com/vulcanize/mcd_transformers/transformers/vat_slip"
|
||||
vat_toll = "github.com/vulcanize/mcd_transformers/transformers/vat_toll"
|
||||
vat_tune = "github.com/vulcanize/mcd_transformers/transformers/vat_tune"
|
||||
vow_flog = "github.com/vulcanize/mcd_transformers/transformers/vow_flog"
|
||||
|
||||
[contract]
|
||||
[contract.address]
|
||||
cat = "0x2f34f22a00ee4b7a8f8bbc4eaee1658774c624e0"
|
||||
drip = "0x891c04639a5edcae088e546fa125b5d7fb6a2b9d"
|
||||
eth_flip = "0x32D496Ad866D110060866B7125981C73642cc509"
|
||||
mcd_flap = "0x8868BAd8e74FcA4505676D1B5B21EcC23328d132"
|
||||
mcd_flop = "0x6191C9b0086c2eBF92300cC507009b53996FbFFa"
|
||||
pep = "0xB1997239Cfc3d15578A3a09730f7f84A90BB4975"
|
||||
pip = "0x9FfFE440258B79c5d6604001674A4722FfC0f7Bc"
|
||||
pit = "0xe7cf3198787c9a4daac73371a38f29aaeeced87e"
|
||||
rep = "0xf88bbdc1e2718f8857f30a180076ec38d53cf296"
|
||||
vat = "0xcd726790550afcd77e9a7a47e86a3f9010af126b"
|
||||
vow = "0x3728e9777B2a0a611ee0F89e00E01044ce4736d1"
|
||||
[contract.abi]
|
||||
cat = '[{"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"}]'
|
||||
drip = '[{"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"}]'
|
||||
mcd_flap = '[{"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"}]'
|
||||
eth_flip = '[{"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"}]'
|
||||
mcd_flop = '[{"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"}]'
|
||||
medianizer = '[{"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)
|
||||
pit = '[{"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"}]'
|
||||
vat = '[{"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"}]'
|
||||
vow = '[{"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"}]'
|
||||
[contract.deployment-block]
|
||||
cat = 8751794
|
||||
drip = 8762197
|
||||
eth_flip = 8535561
|
||||
mcd_flap = 8535544
|
||||
mcd_flop = 8535545
|
||||
pep = 8760655
|
||||
pip = 8760588
|
||||
pit = 8535538
|
||||
rep = 8760681
|
||||
vat = 8535536
|
||||
vow = 8751792
|
@ -1,20 +1,7 @@
|
||||
// VulcanizeDB
|
||||
// Copyright © 2018 Vulcanize
|
||||
// Auto-gen this code for different transformer interfaces/configs
|
||||
// based on config file to allow for more modularity
|
||||
|
||||
// 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
package shared
|
||||
package transformer
|
||||
|
||||
import (
|
||||
"github.com/ethereum/go-ethereum/common"
|
35
libraries/shared/transformer/transformer_suite_test.go
Normal file
35
libraries/shared/transformer/transformer_suite_test.go
Normal file
@ -0,0 +1,35 @@
|
||||
// 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
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)
|
||||
})
|
17
libraries/shared/transformer/transformer_test.go
Normal file
17
libraries/shared/transformer/transformer_test.go
Normal file
@ -0,0 +1,17 @@
|
||||
// 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
package transformer_test
|
@ -14,12 +14,15 @@
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package shared
|
||||
package watcher
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
||||
"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"
|
||||
@ -27,7 +30,7 @@ import (
|
||||
)
|
||||
|
||||
type EventWatcher struct {
|
||||
Transformers []shared.Transformer
|
||||
Transformers []transformer.Transformer
|
||||
DB *postgres.DB
|
||||
Fetcher shared.LogFetcher
|
||||
Chunker shared.Chunker
|
||||
@ -47,16 +50,16 @@ func NewEventWatcher(db *postgres.DB, bc core.BlockChain) EventWatcher {
|
||||
}
|
||||
|
||||
// Adds transformers to the watcher and updates the chunker, so that it will consider the new transformers.
|
||||
func (watcher *EventWatcher) AddTransformers(initializers []shared.TransformerInitializer) {
|
||||
func (watcher *EventWatcher) AddTransformers(initializers []transformer.TransformerInitializer) {
|
||||
var contractAddresses []common.Address
|
||||
var topic0s []common.Hash
|
||||
var configs []shared.TransformerConfig
|
||||
var configs []transformer.TransformerConfig
|
||||
|
||||
for _, initializer := range initializers {
|
||||
transformer := initializer(watcher.DB)
|
||||
watcher.Transformers = append(watcher.Transformers, transformer)
|
||||
t := initializer(watcher.DB)
|
||||
watcher.Transformers = append(watcher.Transformers, t)
|
||||
|
||||
config := transformer.GetConfig()
|
||||
config := t.GetConfig()
|
||||
configs = append(configs, config)
|
||||
|
||||
if watcher.StartingBlock == nil {
|
||||
@ -65,7 +68,7 @@ func (watcher *EventWatcher) AddTransformers(initializers []shared.TransformerIn
|
||||
watcher.StartingBlock = &config.StartingBlockNumber
|
||||
}
|
||||
|
||||
addresses := shared.HexStringsToAddresses(config.ContractAddresses)
|
||||
addresses := transformer.HexStringsToAddresses(config.ContractAddresses)
|
||||
contractAddresses = append(contractAddresses, addresses...)
|
||||
topic0s = append(topic0s, common.HexToHash(config.Topic))
|
||||
}
|
||||
@ -105,10 +108,10 @@ func (watcher *EventWatcher) Execute(recheckHeaders constants.TransformerExecuti
|
||||
|
||||
// Can't quit early and mark as checked if there are no logs. If we are running continuousLogSync,
|
||||
// not all logs we're interested in might have been fetched.
|
||||
for _, transformer := range watcher.Transformers {
|
||||
transformerName := transformer.GetConfig().TransformerName
|
||||
for _, t := range watcher.Transformers {
|
||||
transformerName := t.GetConfig().TransformerName
|
||||
logChunk := chunkedLogs[transformerName]
|
||||
err = transformer.Execute(logChunk, header, constants.HeaderMissing)
|
||||
err = t.Execute(logChunk, header, constants.HeaderMissing)
|
||||
if err != nil {
|
||||
log.Errorf("%v transformer failed to execute in watcher: %v", transformerName, err)
|
||||
return err
|
@ -14,7 +14,7 @@
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package shared_test
|
||||
package watcher_test
|
||||
|
||||
import (
|
||||
"errors"
|
||||
@ -25,85 +25,85 @@ import (
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"github.com/vulcanize/vulcanizedb/libraries/shared"
|
||||
"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"
|
||||
shared2 "github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data/mocks"
|
||||
"github.com/vulcanize/vulcanizedb/test_config"
|
||||
)
|
||||
|
||||
var _ = Describe("EventWatcher", func() {
|
||||
var _ = Describe("Watcher", func() {
|
||||
It("initialises correctly", func() {
|
||||
db := test_config.NewTestDB(core.Node{ID: "testNode"})
|
||||
bc := fakes.NewMockBlockChain()
|
||||
|
||||
watcher := shared.NewEventWatcher(db, bc)
|
||||
w := watcher.NewEventWatcher(db, bc)
|
||||
|
||||
Expect(watcher.DB).To(Equal(db))
|
||||
Expect(watcher.Fetcher).NotTo(BeNil())
|
||||
Expect(watcher.Chunker).NotTo(BeNil())
|
||||
Expect(w.DB).To(Equal(db))
|
||||
Expect(w.Fetcher).NotTo(BeNil())
|
||||
Expect(w.Chunker).NotTo(BeNil())
|
||||
})
|
||||
|
||||
It("adds transformers", func() {
|
||||
watcher := shared.NewEventWatcher(nil, nil)
|
||||
w := watcher.NewEventWatcher(nil, nil)
|
||||
fakeTransformer := &mocks.MockTransformer{}
|
||||
fakeTransformer.SetTransformerConfig(mocks.FakeTransformerConfig)
|
||||
watcher.AddTransformers([]shared2.TransformerInitializer{fakeTransformer.FakeTransformerInitializer})
|
||||
w.AddTransformers([]transformer.TransformerInitializer{fakeTransformer.FakeTransformerInitializer})
|
||||
|
||||
Expect(len(watcher.Transformers)).To(Equal(1))
|
||||
Expect(watcher.Transformers).To(ConsistOf(fakeTransformer))
|
||||
Expect(watcher.Topics).To(Equal([]common.Hash{common.HexToHash("FakeTopic")}))
|
||||
Expect(watcher.Addresses).To(Equal([]common.Address{common.HexToAddress("FakeAddress")}))
|
||||
Expect(len(w.Transformers)).To(Equal(1))
|
||||
Expect(w.Transformers).To(ConsistOf(fakeTransformer))
|
||||
Expect(w.Topics).To(Equal([]common.Hash{common.HexToHash("FakeTopic")}))
|
||||
Expect(w.Addresses).To(Equal([]common.Address{common.HexToAddress("FakeAddress")}))
|
||||
})
|
||||
|
||||
It("adds transformers from multiple sources", func() {
|
||||
watcher := shared.NewEventWatcher(nil, nil)
|
||||
w := watcher.NewEventWatcher(nil, nil)
|
||||
fakeTransformer1 := &mocks.MockTransformer{}
|
||||
fakeTransformer1.SetTransformerConfig(mocks.FakeTransformerConfig)
|
||||
|
||||
fakeTransformer2 := &mocks.MockTransformer{}
|
||||
fakeTransformer2.SetTransformerConfig(mocks.FakeTransformerConfig)
|
||||
|
||||
watcher.AddTransformers([]shared2.TransformerInitializer{fakeTransformer1.FakeTransformerInitializer})
|
||||
watcher.AddTransformers([]shared2.TransformerInitializer{fakeTransformer2.FakeTransformerInitializer})
|
||||
w.AddTransformers([]transformer.TransformerInitializer{fakeTransformer1.FakeTransformerInitializer})
|
||||
w.AddTransformers([]transformer.TransformerInitializer{fakeTransformer2.FakeTransformerInitializer})
|
||||
|
||||
Expect(len(watcher.Transformers)).To(Equal(2))
|
||||
Expect(watcher.Topics).To(Equal([]common.Hash{common.HexToHash("FakeTopic"),
|
||||
Expect(len(w.Transformers)).To(Equal(2))
|
||||
Expect(w.Topics).To(Equal([]common.Hash{common.HexToHash("FakeTopic"),
|
||||
common.HexToHash("FakeTopic")}))
|
||||
Expect(watcher.Addresses).To(Equal([]common.Address{common.HexToAddress("FakeAddress"),
|
||||
Expect(w.Addresses).To(Equal([]common.Address{common.HexToAddress("FakeAddress"),
|
||||
common.HexToAddress("FakeAddress")}))
|
||||
})
|
||||
|
||||
It("calculates earliest starting block number", func() {
|
||||
fakeTransformer1 := &mocks.MockTransformer{}
|
||||
fakeTransformer1.SetTransformerConfig(shared2.TransformerConfig{StartingBlockNumber: 5})
|
||||
fakeTransformer1.SetTransformerConfig(transformer.TransformerConfig{StartingBlockNumber: 5})
|
||||
|
||||
fakeTransformer2 := &mocks.MockTransformer{}
|
||||
fakeTransformer2.SetTransformerConfig(shared2.TransformerConfig{StartingBlockNumber: 3})
|
||||
fakeTransformer2.SetTransformerConfig(transformer.TransformerConfig{StartingBlockNumber: 3})
|
||||
|
||||
watcher := shared.NewEventWatcher(nil, nil)
|
||||
watcher.AddTransformers([]shared2.TransformerInitializer{
|
||||
w := watcher.NewEventWatcher(nil, nil)
|
||||
w.AddTransformers([]transformer.TransformerInitializer{
|
||||
fakeTransformer1.FakeTransformerInitializer,
|
||||
fakeTransformer2.FakeTransformerInitializer,
|
||||
})
|
||||
|
||||
Expect(*watcher.StartingBlock).To(Equal(int64(3)))
|
||||
Expect(*w.StartingBlock).To(Equal(int64(3)))
|
||||
})
|
||||
|
||||
It("returns an error when run without transformers", func() {
|
||||
watcher := shared.NewEventWatcher(nil, nil)
|
||||
err := watcher.Execute(constants.HeaderMissing)
|
||||
w := watcher.NewEventWatcher(nil, nil)
|
||||
err := w.Execute(constants.HeaderMissing)
|
||||
Expect(err).To(MatchError("No transformers added to watcher"))
|
||||
})
|
||||
|
||||
Describe("with missing headers", func() {
|
||||
var (
|
||||
db *postgres.DB
|
||||
watcher shared.EventWatcher
|
||||
w watcher.EventWatcher
|
||||
mockBlockChain fakes.MockBlockChain
|
||||
headerRepository repositories.HeaderRepository
|
||||
repository mocks.MockWatcherRepository
|
||||
@ -118,27 +118,25 @@ var _ = Describe("EventWatcher", func() {
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
repository = mocks.MockWatcherRepository{}
|
||||
watcher = shared.NewEventWatcher(db, &mockBlockChain)
|
||||
w = watcher.NewEventWatcher(db, &mockBlockChain)
|
||||
})
|
||||
|
||||
It("executes each transformer", func() {
|
||||
fakeTransformer := &mocks.MockTransformer{}
|
||||
watcher.AddTransformers([]shared2.TransformerInitializer{fakeTransformer.FakeTransformerInitializer})
|
||||
w.AddTransformers([]transformer.TransformerInitializer{fakeTransformer.FakeTransformerInitializer})
|
||||
repository.SetMissingHeaders([]core.Header{fakes.FakeHeader})
|
||||
|
||||
err := watcher.Execute(constants.HeaderMissing)
|
||||
|
||||
err := w.Execute(constants.HeaderMissing)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(fakeTransformer.ExecuteWasCalled).To(BeTrue())
|
||||
})
|
||||
|
||||
It("returns an error if transformer returns an error", func() {
|
||||
fakeTransformer := &mocks.MockTransformer{ExecuteError: errors.New("Something bad happened")}
|
||||
watcher.AddTransformers([]shared2.TransformerInitializer{fakeTransformer.FakeTransformerInitializer})
|
||||
w.AddTransformers([]transformer.TransformerInitializer{fakeTransformer.FakeTransformerInitializer})
|
||||
repository.SetMissingHeaders([]core.Header{fakes.FakeHeader})
|
||||
|
||||
err := watcher.Execute(constants.HeaderMissing)
|
||||
|
||||
err := w.Execute(constants.HeaderMissing)
|
||||
Expect(err).To(HaveOccurred())
|
||||
Expect(fakeTransformer.ExecuteWasCalled).To(BeFalse())
|
||||
})
|
||||
@ -147,10 +145,10 @@ var _ = Describe("EventWatcher", func() {
|
||||
transformerA := &mocks.MockTransformer{}
|
||||
transformerB := &mocks.MockTransformer{}
|
||||
|
||||
configA := shared2.TransformerConfig{TransformerName: "transformerA",
|
||||
configA := transformer.TransformerConfig{TransformerName: "transformerA",
|
||||
ContractAddresses: []string{"0x000000000000000000000000000000000000000A"},
|
||||
Topic: "0xA"}
|
||||
configB := shared2.TransformerConfig{TransformerName: "transformerB",
|
||||
configB := transformer.TransformerConfig{TransformerName: "transformerB",
|
||||
ContractAddresses: []string{"0x000000000000000000000000000000000000000b"},
|
||||
Topic: "0xB"}
|
||||
|
||||
@ -164,11 +162,11 @@ var _ = Describe("EventWatcher", func() {
|
||||
mockBlockChain.SetGetEthLogsWithCustomQueryReturnLogs([]types.Log{logA, logB})
|
||||
|
||||
repository.SetMissingHeaders([]core.Header{fakes.FakeHeader})
|
||||
watcher = shared.NewEventWatcher(db, &mockBlockChain)
|
||||
watcher.AddTransformers([]shared2.TransformerInitializer{
|
||||
w = watcher.NewEventWatcher(db, &mockBlockChain)
|
||||
w.AddTransformers([]transformer.TransformerInitializer{
|
||||
transformerA.FakeTransformerInitializer, transformerB.FakeTransformerInitializer})
|
||||
|
||||
err := watcher.Execute(constants.HeaderMissing)
|
||||
err := w.Execute(constants.HeaderMissing)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(transformerA.PassedLogs).To(Equal([]types.Log{logA}))
|
||||
Expect(transformerB.PassedLogs).To(Equal([]types.Log{logB}))
|
||||
@ -184,17 +182,17 @@ var _ = Describe("EventWatcher", func() {
|
||||
It("fetches logs for added transformers", func() {
|
||||
addresses := []string{"0xA", "0xB"}
|
||||
topic := "0x1"
|
||||
fakeTransformer.SetTransformerConfig(shared2.TransformerConfig{
|
||||
fakeTransformer.SetTransformerConfig(transformer.TransformerConfig{
|
||||
Topic: topic, ContractAddresses: addresses})
|
||||
watcher.AddTransformers([]shared2.TransformerInitializer{fakeTransformer.FakeTransformerInitializer})
|
||||
w.AddTransformers([]transformer.TransformerInitializer{fakeTransformer.FakeTransformerInitializer})
|
||||
|
||||
err := watcher.Execute(constants.HeaderMissing)
|
||||
err := w.Execute(constants.HeaderMissing)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
fakeHash := common.HexToHash(fakes.FakeHeader.Hash)
|
||||
mockBlockChain.AssertGetEthLogsWithCustomQueryCalledWith(ethereum.FilterQuery{
|
||||
BlockHash: &fakeHash,
|
||||
Addresses: shared2.HexStringsToAddresses(addresses),
|
||||
Addresses: transformer.HexStringsToAddresses(addresses),
|
||||
Topics: [][]common.Hash{{common.HexToHash(topic)}},
|
||||
})
|
||||
})
|
||||
@ -203,8 +201,8 @@ var _ = Describe("EventWatcher", func() {
|
||||
fetcherError := errors.New("FetcherError")
|
||||
mockBlockChain.SetGetEthLogsWithCustomQueryErr(fetcherError)
|
||||
|
||||
watcher.AddTransformers([]shared2.TransformerInitializer{fakeTransformer.FakeTransformerInitializer})
|
||||
err := watcher.Execute(constants.HeaderMissing)
|
||||
w.AddTransformers([]transformer.TransformerInitializer{fakeTransformer.FakeTransformerInitializer})
|
||||
err := w.Execute(constants.HeaderMissing)
|
||||
Expect(err).To(MatchError(fetcherError))
|
||||
})
|
||||
})
|
@ -14,7 +14,7 @@
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package shared_test
|
||||
package watcher_test
|
||||
|
||||
import (
|
||||
log "github.com/sirupsen/logrus"
|
||||
@ -27,7 +27,7 @@ import (
|
||||
|
||||
func TestShared(t *testing.T) {
|
||||
RegisterFailHandler(Fail)
|
||||
RunSpecs(t, "Shared Suite")
|
||||
RunSpecs(t, "Shared Watcher Suite")
|
||||
}
|
||||
|
||||
var _ = BeforeSuite(func() {
|
23
pkg/autogen/config.go
Normal file
23
pkg/autogen/config.go
Normal file
@ -0,0 +1,23 @@
|
||||
// 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
package autogen
|
||||
|
||||
type Config struct {
|
||||
Imports map[string]string // Map of import alias to import path
|
||||
FilePath string
|
||||
FileName string
|
||||
}
|
138
pkg/autogen/generator.go
Normal file
138
pkg/autogen/generator.go
Normal file
@ -0,0 +1,138 @@
|
||||
// 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
package autogen
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
. "github.com/dave/jennifer/jen"
|
||||
"github.com/mitchellh/go-homedir"
|
||||
)
|
||||
|
||||
type Generator interface {
|
||||
GenerateTransformerPlugin() error
|
||||
}
|
||||
|
||||
type generator struct {
|
||||
*Config
|
||||
}
|
||||
|
||||
func NewGenerator(config Config) *generator {
|
||||
return &generator{
|
||||
Config: &config,
|
||||
}
|
||||
}
|
||||
|
||||
func (g *generator) GenerateTransformerPlugin() error {
|
||||
if g.Config == nil {
|
||||
return errors.New("generator needs a config file")
|
||||
}
|
||||
if g.Config.FilePath == "" {
|
||||
return errors.New("generator is missing file path")
|
||||
}
|
||||
if len(g.Config.Imports) < 1 {
|
||||
return errors.New("generator needs to be configured with imports")
|
||||
}
|
||||
|
||||
// Create file path
|
||||
goFile, soFile, err := GetPaths(*g.Config)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Clear previous .go and .so files if they exist
|
||||
err = 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
|
||||
f.ImportAlias("github.com/vulcanize/vulcanizedb/libraries/shared/transformer", "interface")
|
||||
for alias, imp := range g.Config.Imports {
|
||||
f.ImportAlias(imp, alias)
|
||||
}
|
||||
|
||||
// Collect TransformerInitializer names
|
||||
importedInitializers := make([]Code, 0, len(g.Config.Imports))
|
||||
for _, path := range g.Config.Imports {
|
||||
importedInitializers = append(importedInitializers, Qual(path, "TransformerInitializer"))
|
||||
}
|
||||
|
||||
// Create Exporter variable with method to export a set of the configured TransformerInitializers
|
||||
f.Type().Id("exporter").String()
|
||||
f.Var().Id("Exporter").Id("exporter")
|
||||
f.Func().Params(
|
||||
Id("e").Id("exporter"),
|
||||
).Id("Export").Params().Index().Qual(
|
||||
"github.com/vulcanize/vulcanizedb/libraries/shared/transformer",
|
||||
"TransformerInitializer").Block(
|
||||
Return(Index().Qual(
|
||||
"github.com/vulcanize/vulcanizedb/libraries/shared/transformer",
|
||||
"TransformerInitializer").Values(importedInitializers...)))
|
||||
|
||||
// Write code to destination file
|
||||
err = f.Save(goFile)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Build the .go file into a .so plugin
|
||||
return exec.Command("go", "build", "-buildmode=plugin", "-o", soFile, goFile).Run()
|
||||
}
|
||||
|
||||
func GetPaths(config Config) (string, string, error) {
|
||||
path, err := homedir.Expand(filepath.Clean(config.FilePath))
|
||||
if err != nil {
|
||||
return "", "", err
|
||||
}
|
||||
if strings.Contains(path, "$GOPATH") {
|
||||
env := os.Getenv("GOPATH")
|
||||
spl := strings.Split(path, "$GOPATH")[1]
|
||||
path = filepath.Join(env, spl)
|
||||
}
|
||||
|
||||
name := strings.Split(config.FileName, ".")[0]
|
||||
goFile := filepath.Join(path, name+".go")
|
||||
soFile := filepath.Join(path, name+".so")
|
||||
|
||||
return goFile, soFile, nil
|
||||
}
|
||||
|
||||
func ClearFiles(files ...string) error {
|
||||
for _, file := range files {
|
||||
if _, err := os.Stat(file); err == nil {
|
||||
err = os.Remove(file)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
} else if os.IsNotExist(err) {
|
||||
// fall through
|
||||
} else {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
35
pkg/autogen/generator_suite_test.go
Normal file
35
pkg/autogen/generator_suite_test.go
Normal file
@ -0,0 +1,35 @@
|
||||
// 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
package autogen_test
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"testing"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
func TestRepository(t *testing.T) {
|
||||
RegisterFailHandler(Fail)
|
||||
RunSpecs(t, "Autogen Suite Test")
|
||||
}
|
||||
|
||||
var _ = BeforeSuite(func() {
|
||||
log.SetOutput(ioutil.Discard)
|
||||
})
|
138
pkg/autogen/generator_test.go
Normal file
138
pkg/autogen/generator_test.go
Normal file
@ -0,0 +1,138 @@
|
||||
// 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
package autogen_test
|
||||
|
||||
import (
|
||||
"plugin"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
"github.com/spf13/viper"
|
||||
|
||||
"github.com/vulcanize/vulcanizedb/libraries/shared/transformer"
|
||||
"github.com/vulcanize/vulcanizedb/libraries/shared/watcher"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/autogen"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/autogen/test_helpers"
|
||||
"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"
|
||||
)
|
||||
|
||||
var testConfig = autogen.Config{
|
||||
Imports: map[string]string{
|
||||
"bite": "github.com/vulcanize/vulcanizedb/pkg/autogen/test_helpers/bite",
|
||||
"deal": "github.com/vulcanize/vulcanizedb/pkg/autogen/test_helpers/deal",
|
||||
},
|
||||
FileName: "testTransformerSet",
|
||||
FilePath: "$GOPATH/src/github.com/vulcanize/vulcanizedb/pkg/autogen/test_helpers/test/",
|
||||
}
|
||||
|
||||
var targetConfig = autogen.Config{
|
||||
Imports: map[string]string{
|
||||
"bite": "github.com/vulcanize/vulcanizedb/pkg/autogen/test_helpers/bite",
|
||||
"deal": "github.com/vulcanize/vulcanizedb/pkg/autogen/test_helpers/deal",
|
||||
},
|
||||
FileName: "targetTransformerSet",
|
||||
FilePath: "$GOPATH/src/github.com/vulcanize/vulcanizedb/pkg/autogen/test_helpers/target/",
|
||||
}
|
||||
|
||||
type Exporter interface {
|
||||
Export() []transformer.TransformerInitializer
|
||||
}
|
||||
|
||||
var _ = Describe("Generator test", func() {
|
||||
var g autogen.Generator
|
||||
var goPath, soPath string
|
||||
var err error
|
||||
var bc core.BlockChain
|
||||
var db *postgres.DB
|
||||
var hr repositories.HeaderRepository
|
||||
var headerID int64
|
||||
viper.SetConfigName("compose")
|
||||
viper.AddConfigPath("$GOPATH/src/github.com/vulcanize/vulcanizedb/environments/")
|
||||
|
||||
BeforeEach(func() {
|
||||
goPath, soPath, err = autogen.GetPaths(testConfig)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
g = autogen.NewGenerator(testConfig)
|
||||
err = g.GenerateTransformerPlugin()
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
})
|
||||
|
||||
AfterEach(func() {
|
||||
err := autogen.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)))
|
||||
})
|
||||
})
|
||||
})
|
8
pkg/autogen/test_helpers/bite/initializer.go
Normal file
8
pkg/autogen/test_helpers/bite/initializer.go
Normal file
@ -0,0 +1,8 @@
|
||||
package bite
|
||||
|
||||
import (
|
||||
"github.com/vulcanize/vulcanizedb/libraries/shared/transformer"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers"
|
||||
)
|
||||
|
||||
var TransformerInitializer transformer.TransformerInitializer = transformers.GetBiteTransformer().NewTransformer
|
65
pkg/autogen/test_helpers/database.go
Normal file
65
pkg/autogen/test_helpers/database.go
Normal file
@ -0,0 +1,65 @@
|
||||
package test_helpers
|
||||
|
||||
import (
|
||||
"github.com/ethereum/go-ethereum/ethclient"
|
||||
"github.com/ethereum/go-ethereum/rpc"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"github.com/vulcanize/vulcanizedb/pkg/config"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/core"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
|
||||
"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"
|
||||
)
|
||||
|
||||
func SetupDBandBC() (*postgres.DB, core.BlockChain) {
|
||||
infuraIPC := "http://kovan0.vulcanize.io:8545"
|
||||
rawRpcClient, err := rpc.Dial(infuraIPC)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
rpcClient := client.NewRpcClient(rawRpcClient, infuraIPC)
|
||||
ethClient := ethclient.NewClient(rawRpcClient)
|
||||
blockChainClient := client.NewEthClient(ethClient)
|
||||
node := node.MakeNode(rpcClient)
|
||||
transactionConverter := rpc2.NewRpcTransactionConverter(ethClient)
|
||||
blockChain := geth.NewBlockChain(blockChainClient, rpcClient, node, transactionConverter)
|
||||
|
||||
db, err := postgres.NewDB(config.Database{
|
||||
Hostname: "localhost",
|
||||
Name: "vulcanize_private",
|
||||
Port: 5432,
|
||||
}, blockChain.Node())
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
return db, blockChain
|
||||
}
|
||||
|
||||
func TearDown(db *postgres.DB) {
|
||||
tx, err := db.Begin()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
_, err = tx.Exec(`DELETE FROM headers`)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
_, err = tx.Exec(`DELETE FROM logs`)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
_, err = tx.Exec(`DELETE FROM log_filters`)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
_, err = tx.Exec(`DELETE FROM transactions`)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
_, err = tx.Exec(`DELETE FROM receipts`)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
_, err = tx.Exec(`DELETE FROM checked_headers`)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
_, err = tx.Exec(`DELETE FROM maker.bite`)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
err = tx.Commit()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
}
|
8
pkg/autogen/test_helpers/deal/initializer.go
Normal file
8
pkg/autogen/test_helpers/deal/initializer.go
Normal file
@ -0,0 +1,8 @@
|
||||
package deal
|
||||
|
||||
import (
|
||||
"github.com/vulcanize/vulcanizedb/libraries/shared/transformer"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers"
|
||||
)
|
||||
|
||||
var TransformerInitializer transformer.TransformerInitializer = transformers.GetDealTransformer().NewLogNoteTransformer
|
3
pkg/autogen/test_helpers/test/README.md
Normal file
3
pkg/autogen/test_helpers/test/README.md
Normal file
@ -0,0 +1,3 @@
|
||||
### Test
|
||||
|
||||
This empty directory is for holding the output code generated, and then deleted, during the generator_tests
|
@ -324,7 +324,7 @@ var _ = Describe("Transformer", func() {
|
||||
Expect(res.Address).To(Equal("0x0000000000000000000000000000000000000000"))
|
||||
Expect(res.TokenName).To(Equal(""))
|
||||
|
||||
err = db.QueryRowx(fmt.Sprintf("SELECT * FROM full_%s.owner_method WHERE node_ = '0x95832c7a47ff8a7840e28b78ceMADEUPaaf4HASHc186badTHIS288IS625bFAKE' AND block = '6194636'", ensAddr)).StructScan(&res)
|
||||
err = db.QueryRowx(fmt.Sprintf("SELECT * FROM full_%s.owner_method WHERE node_ = '0x95832c7a47ff8a7840e28b78ceMADEUPaaf4HASHc186badTHItransformers.8IS625bFAKE' AND block = '6194636'", ensAddr)).StructScan(&res)
|
||||
Expect(err).To(HaveOccurred())
|
||||
})
|
||||
|
||||
|
@ -331,7 +331,7 @@ var _ = Describe("Transformer", func() {
|
||||
Expect(res.Address).To(Equal("0x0000000000000000000000000000000000000000"))
|
||||
Expect(res.TokenName).To(Equal(""))
|
||||
|
||||
err = db.QueryRowx(fmt.Sprintf("SELECT * FROM light_%s.owner_method WHERE node_ = '0x95832c7a47ff8a7840e28b78ceMADEUPaaf4HASHc186badTHIS288IS625bFAKE' AND block = '6885696'", ensAddr)).StructScan(&res)
|
||||
err = db.QueryRowx(fmt.Sprintf("SELECT * FROM light_%s.owner_method WHERE node_ = '0x95832c7a47ff8a7840e28b78ceMADEUPaaf4HASHc186badTHItransformers.8IS625bFAKE' AND block = '6885696'", ensAddr)).StructScan(&res)
|
||||
Expect(err).To(HaveOccurred())
|
||||
})
|
||||
|
||||
@ -491,7 +491,7 @@ var _ = Describe("Transformer", func() {
|
||||
Expect(owner.Address).To(Equal("0x0000000000000000000000000000000000000000"))
|
||||
Expect(owner.TokenName).To(Equal(""))
|
||||
|
||||
err = db.QueryRowx(fmt.Sprintf("SELECT * FROM light_%s.owner_method WHERE node_ = '0x95832c7a47ff8a7840e28b78ceMADEUPaaf4HASHc186badTHIS288IS625bFAKE' AND block = '6885696'", ensAddr)).StructScan(&owner)
|
||||
err = db.QueryRowx(fmt.Sprintf("SELECT * FROM light_%s.owner_method WHERE node_ = '0x95832c7a47ff8a7840e28b78ceMADEUPaaf4HASHc186badTHItransformers.8IS625bFAKE' AND block = '6885696'", ensAddr)).StructScan(&owner)
|
||||
Expect(err).To(HaveOccurred())
|
||||
|
||||
bal := test_helpers.BalanceOf{}
|
||||
|
@ -17,12 +17,12 @@
|
||||
package bite
|
||||
|
||||
import (
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
||||
shared_t "github.com/vulcanize/vulcanizedb/libraries/shared/transformer"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants"
|
||||
)
|
||||
|
||||
func GetBiteConfig() shared.TransformerConfig {
|
||||
return shared.TransformerConfig{
|
||||
func GetBiteConfig() shared_t.TransformerConfig {
|
||||
return shared_t.TransformerConfig{
|
||||
TransformerName: constants.BiteLabel,
|
||||
ContractAddresses: []string{constants.CatContractAddress()},
|
||||
ContractAbi: constants.CatABI(),
|
||||
|
@ -17,12 +17,12 @@
|
||||
package chop_lump
|
||||
|
||||
import (
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
||||
shared_t "github.com/vulcanize/vulcanizedb/libraries/shared/transformer"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants"
|
||||
)
|
||||
|
||||
func GetCatFileChopLumpConfig() shared.TransformerConfig {
|
||||
return shared.TransformerConfig{
|
||||
func GetCatFileChopLumpConfig() shared_t.TransformerConfig {
|
||||
return shared_t.TransformerConfig{
|
||||
TransformerName: constants.CatFileChopLumpLabel,
|
||||
ContractAddresses: []string{constants.CatContractAddress()},
|
||||
ContractAbi: constants.CatABI(),
|
||||
|
@ -17,12 +17,12 @@
|
||||
package flip
|
||||
|
||||
import (
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
||||
shared_t "github.com/vulcanize/vulcanizedb/libraries/shared/transformer"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants"
|
||||
)
|
||||
|
||||
func GetCatFileFlipConfig() shared.TransformerConfig {
|
||||
return shared.TransformerConfig{
|
||||
func GetCatFileFlipConfig() shared_t.TransformerConfig {
|
||||
return shared_t.TransformerConfig{
|
||||
TransformerName: constants.CatFileFlipLabel,
|
||||
ContractAddresses: []string{constants.CatContractAddress()},
|
||||
ContractAbi: constants.CatABI(),
|
||||
|
@ -17,12 +17,12 @@
|
||||
package pit_vow
|
||||
|
||||
import (
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
||||
shared_t "github.com/vulcanize/vulcanizedb/libraries/shared/transformer"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants"
|
||||
)
|
||||
|
||||
func GetCatFilePitVowConfig() shared.TransformerConfig {
|
||||
return shared.TransformerConfig{
|
||||
func GetCatFilePitVowConfig() shared_t.TransformerConfig {
|
||||
return shared_t.TransformerConfig{
|
||||
TransformerName: constants.CatFilePitVowLabel,
|
||||
ContractAddresses: []string{constants.CatContractAddress()},
|
||||
ContractAbi: constants.CatABI(),
|
||||
|
@ -17,12 +17,13 @@
|
||||
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.TransformerConfig {
|
||||
return shared.TransformerConfig{
|
||||
func GetDealConfig() shared_t.TransformerConfig {
|
||||
return shared_t.TransformerConfig{
|
||||
TransformerName: constants.DealLabel,
|
||||
ContractAddresses: []string{constants.FlapperContractAddress(), constants.FlipperContractAddress(), constants.FlopperContractAddress()},
|
||||
ContractAbi: constants.FlipperABI(),
|
||||
|
@ -17,12 +17,13 @@
|
||||
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.TransformerConfig {
|
||||
return shared.TransformerConfig{
|
||||
func GetDentConfig() shared_t.TransformerConfig {
|
||||
return shared_t.TransformerConfig{
|
||||
TransformerName: constants.DentLabel,
|
||||
ContractAddresses: []string{constants.FlipperContractAddress(), constants.FlopperContractAddress()},
|
||||
ContractAbi: constants.FlipperABI(),
|
||||
|
@ -17,12 +17,12 @@
|
||||
package drip_drip
|
||||
|
||||
import (
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
||||
shared_t "github.com/vulcanize/vulcanizedb/libraries/shared/transformer"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants"
|
||||
)
|
||||
|
||||
func GetDripDripConfig() shared.TransformerConfig {
|
||||
return shared.TransformerConfig{
|
||||
func GetDripDripConfig() shared_t.TransformerConfig {
|
||||
return shared_t.TransformerConfig{
|
||||
ContractAddresses: []string{constants.DripContractAddress()},
|
||||
ContractAbi: constants.DripABI(),
|
||||
Topic: constants.GetDripDripSignature(),
|
||||
|
@ -17,12 +17,12 @@
|
||||
package ilk
|
||||
|
||||
import (
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
||||
shared_t "github.com/vulcanize/vulcanizedb/libraries/shared/transformer"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants"
|
||||
)
|
||||
|
||||
func GetDripFileIlkConfig() shared.TransformerConfig {
|
||||
return shared.TransformerConfig{
|
||||
func GetDripFileIlkConfig() shared_t.TransformerConfig {
|
||||
return shared_t.TransformerConfig{
|
||||
TransformerName: constants.DripFileIlkLabel,
|
||||
ContractAddresses: []string{constants.DripContractAddress()},
|
||||
ContractAbi: constants.DripABI(),
|
||||
|
@ -17,12 +17,12 @@
|
||||
package repo
|
||||
|
||||
import (
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
||||
shared_t "github.com/vulcanize/vulcanizedb/libraries/shared/transformer"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants"
|
||||
)
|
||||
|
||||
func GetDripFileRepoConfig() shared.TransformerConfig {
|
||||
return shared.TransformerConfig{
|
||||
func GetDripFileRepoConfig() shared_t.TransformerConfig {
|
||||
return shared_t.TransformerConfig{
|
||||
TransformerName: constants.DripFileRepoLabel,
|
||||
ContractAddresses: []string{constants.DripContractAddress()},
|
||||
ContractAbi: constants.DripABI(),
|
||||
|
@ -17,12 +17,12 @@
|
||||
package vow
|
||||
|
||||
import (
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
||||
shared_t "github.com/vulcanize/vulcanizedb/libraries/shared/transformer"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants"
|
||||
)
|
||||
|
||||
func GetDripFileVowConfig() shared.TransformerConfig {
|
||||
return shared.TransformerConfig{
|
||||
func GetDripFileVowConfig() shared_t.TransformerConfig {
|
||||
return shared_t.TransformerConfig{
|
||||
TransformerName: constants.DripFileVowLabel,
|
||||
ContractAddresses: []string{constants.DripContractAddress()},
|
||||
ContractAbi: constants.DripABI(),
|
||||
|
@ -20,19 +20,19 @@ 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"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants"
|
||||
)
|
||||
|
||||
type LogNoteTransformer struct {
|
||||
Config shared.TransformerConfig
|
||||
Config shared_t.TransformerConfig
|
||||
Converter LogNoteConverter
|
||||
Repository Repository
|
||||
}
|
||||
|
||||
func (transformer LogNoteTransformer) NewLogNoteTransformer(db *postgres.DB) shared.Transformer {
|
||||
func (transformer LogNoteTransformer) NewLogNoteTransformer(db *postgres.DB) shared_t.Transformer {
|
||||
transformer.Repository.SetDB(db)
|
||||
return transformer
|
||||
}
|
||||
@ -68,6 +68,6 @@ func (transformer LogNoteTransformer) GetName() string {
|
||||
return transformer.Config.TransformerName
|
||||
}
|
||||
|
||||
func (transformer LogNoteTransformer) GetConfig() shared.TransformerConfig {
|
||||
func (transformer LogNoteTransformer) GetConfig() shared_t.TransformerConfig {
|
||||
return transformer.Config
|
||||
}
|
||||
|
@ -17,17 +17,19 @@
|
||||
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"
|
||||
"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"
|
||||
"math/rand"
|
||||
)
|
||||
|
||||
var _ = Describe("LogNoteTransformer", func() {
|
||||
@ -35,7 +37,7 @@ var _ = Describe("LogNoteTransformer", func() {
|
||||
repository mocks.MockRepository
|
||||
converter mocks.MockLogNoteConverter
|
||||
headerOne core.Header
|
||||
transformer shared.Transformer
|
||||
transformer shared_t.Transformer
|
||||
model test_data.GenericModel
|
||||
config = test_data.GenericTestConfig
|
||||
logs = test_data.GenericTestLogs
|
||||
|
@ -20,19 +20,19 @@ 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"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants"
|
||||
)
|
||||
|
||||
type Transformer struct {
|
||||
Config shared.TransformerConfig
|
||||
Config shared_t.TransformerConfig
|
||||
Converter Converter
|
||||
Repository Repository
|
||||
}
|
||||
|
||||
func (transformer Transformer) NewTransformer(db *postgres.DB) shared.Transformer {
|
||||
func (transformer Transformer) NewTransformer(db *postgres.DB) shared_t.Transformer {
|
||||
transformer.Repository.SetDB(db)
|
||||
return transformer
|
||||
}
|
||||
@ -75,6 +75,6 @@ func (transformer Transformer) GetName() string {
|
||||
return transformer.Config.TransformerName
|
||||
}
|
||||
|
||||
func (transformer Transformer) GetConfig() shared.TransformerConfig {
|
||||
func (transformer Transformer) GetConfig() shared_t.TransformerConfig {
|
||||
return transformer.Config
|
||||
}
|
||||
|
@ -17,24 +17,26 @@
|
||||
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"
|
||||
"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"
|
||||
"math/rand"
|
||||
)
|
||||
|
||||
var _ = Describe("Transformer", func() {
|
||||
var (
|
||||
repository mocks.MockRepository
|
||||
converter mocks.MockConverter
|
||||
transformer shared.Transformer
|
||||
transformer shared_t.Transformer
|
||||
headerOne core.Header
|
||||
config = test_data.GenericTestConfig
|
||||
logs = test_data.GenericTestLogs
|
||||
|
@ -17,12 +17,12 @@
|
||||
package flap_kick
|
||||
|
||||
import (
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
||||
shared_t "github.com/vulcanize/vulcanizedb/libraries/shared/transformer"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants"
|
||||
)
|
||||
|
||||
func GetFlapKickConfig() shared.TransformerConfig {
|
||||
return shared.TransformerConfig{
|
||||
func GetFlapKickConfig() shared_t.TransformerConfig {
|
||||
return shared_t.TransformerConfig{
|
||||
TransformerName: constants.FlapKickLabel,
|
||||
ContractAddresses: []string{constants.FlapperContractAddress()},
|
||||
ContractAbi: constants.FlapperABI(),
|
||||
|
@ -17,12 +17,12 @@
|
||||
package flip_kick
|
||||
|
||||
import (
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
||||
shared_t "github.com/vulcanize/vulcanizedb/libraries/shared/transformer"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants"
|
||||
)
|
||||
|
||||
func GetFlipKickConfig() shared.TransformerConfig {
|
||||
return shared.TransformerConfig{
|
||||
func GetFlipKickConfig() shared_t.TransformerConfig {
|
||||
return shared_t.TransformerConfig{
|
||||
TransformerName: constants.FlipKickLabel,
|
||||
ContractAddresses: []string{constants.FlipperContractAddress()},
|
||||
ContractAbi: constants.FlipperABI(),
|
||||
|
@ -17,12 +17,12 @@
|
||||
package flop_kick
|
||||
|
||||
import (
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
||||
shared_t "github.com/vulcanize/vulcanizedb/libraries/shared/transformer"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants"
|
||||
)
|
||||
|
||||
func GetFlopKickConfig() shared.TransformerConfig {
|
||||
return shared.TransformerConfig{
|
||||
func GetFlopKickConfig() shared_t.TransformerConfig {
|
||||
return shared_t.TransformerConfig{
|
||||
TransformerName: constants.FlopKickLabel,
|
||||
ContractAddresses: []string{constants.FlopperContractAddress()},
|
||||
ContractAbi: constants.FlopperABI(),
|
||||
|
@ -17,12 +17,12 @@
|
||||
package frob
|
||||
|
||||
import (
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
||||
shared_t "github.com/vulcanize/vulcanizedb/libraries/shared/transformer"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants"
|
||||
)
|
||||
|
||||
func GetFrobConfig() shared.TransformerConfig {
|
||||
return shared.TransformerConfig{
|
||||
func GetFrobConfig() shared_t.TransformerConfig {
|
||||
return shared_t.TransformerConfig{
|
||||
TransformerName: constants.FrobLabel,
|
||||
ContractAddresses: []string{constants.PitContractAddress()},
|
||||
ContractAbi: constants.PitABI(),
|
||||
|
@ -24,6 +24,7 @@ import (
|
||||
"github.com/ethereum/go-ethereum/accounts/abi/bind"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
|
||||
shared_t "github.com/vulcanize/vulcanizedb/libraries/shared/transformer"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/geth"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/bite"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/factories"
|
||||
@ -33,7 +34,7 @@ import (
|
||||
"github.com/vulcanize/vulcanizedb/test_config"
|
||||
)
|
||||
|
||||
var testBiteConfig = shared.TransformerConfig{
|
||||
var testBiteConfig = shared_t.TransformerConfig{
|
||||
TransformerName: constants.BiteLabel,
|
||||
ContractAddresses: []string{test_data.KovanCatContractAddress},
|
||||
ContractAbi: test_data.KovanCatABI,
|
||||
|
@ -29,6 +29,7 @@ import (
|
||||
. "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/client"
|
||||
@ -66,7 +67,7 @@ var _ = Describe("Cat File transformer", func() {
|
||||
header, err := persistHeader(db, chopLumpBlockNumber, blockChain)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
config := shared.TransformerConfig{
|
||||
config := shared_t.TransformerConfig{
|
||||
TransformerName: constants.CatFileChopLumpLabel,
|
||||
ContractAddresses: []string{test_data.KovanCatContractAddress},
|
||||
ContractAbi: test_data.KovanCatABI,
|
||||
@ -162,7 +163,7 @@ var _ = Describe("Cat File transformer", func() {
|
||||
header, err := persistHeader(db, flipBlockNumber, blockChain)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
config := shared.TransformerConfig{
|
||||
config := shared_t.TransformerConfig{
|
||||
TransformerName: constants.CatFileFlipLabel,
|
||||
ContractAddresses: []string{test_data.KovanCatContractAddress},
|
||||
ContractAbi: test_data.KovanCatABI,
|
||||
@ -250,7 +251,7 @@ var _ = Describe("Cat File transformer", func() {
|
||||
header, err := persistHeader(db, pitVowBlockNumber, blockChain)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
config := shared.TransformerConfig{
|
||||
config := shared_t.TransformerConfig{
|
||||
TransformerName: constants.CatFilePitVowLabel,
|
||||
ContractAddresses: []string{test_data.KovanCatContractAddress},
|
||||
ContractAbi: test_data.KovanCatABI,
|
||||
|
@ -23,6 +23,7 @@ import (
|
||||
"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"
|
||||
@ -35,7 +36,7 @@ var _ = Describe("Deal transformer", func() {
|
||||
var (
|
||||
db *postgres.DB
|
||||
blockChain core.BlockChain
|
||||
config shared.TransformerConfig
|
||||
config shared_t.TransformerConfig
|
||||
initializer factories.LogNoteTransformer
|
||||
fetcher *shared.Fetcher
|
||||
addresses []common.Address
|
||||
@ -50,7 +51,7 @@ var _ = Describe("Deal transformer", func() {
|
||||
db = test_config.NewTestDB(blockChain.Node())
|
||||
test_config.CleanTestDB(db)
|
||||
|
||||
config = shared.TransformerConfig{
|
||||
config = shared_t.TransformerConfig{
|
||||
TransformerName: constants.DealLabel,
|
||||
ContractAddresses: []string{test_data.KovanFlapperContractAddress, test_data.KovanFlipperContractAddress, test_data.KovanFlopperContractAddress},
|
||||
ContractAbi: test_data.KovanFlipperABI,
|
||||
@ -66,7 +67,7 @@ var _ = Describe("Deal transformer", func() {
|
||||
}
|
||||
|
||||
fetcher = shared.NewFetcher(blockChain)
|
||||
addresses = shared.HexStringsToAddresses(config.ContractAddresses)
|
||||
addresses = shared_t.HexStringsToAddresses(config.ContractAddresses)
|
||||
topics = []common.Hash{common.HexToHash(config.Topic)}
|
||||
|
||||
})
|
||||
|
@ -7,6 +7,7 @@ import (
|
||||
"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"
|
||||
@ -20,8 +21,8 @@ var _ = Describe("Dent transformer", func() {
|
||||
db *postgres.DB
|
||||
blockChain core.BlockChain
|
||||
fetcher *shared.Fetcher
|
||||
transformer shared.Transformer
|
||||
config shared.TransformerConfig
|
||||
transformer shared_t.Transformer
|
||||
config shared_t.TransformerConfig
|
||||
addresses []common.Address
|
||||
topics []common.Hash
|
||||
initializer factories.LogNoteTransformer
|
||||
@ -35,7 +36,7 @@ var _ = Describe("Dent transformer", func() {
|
||||
db = test_config.NewTestDB(blockChain.Node())
|
||||
test_config.CleanTestDB(db)
|
||||
|
||||
config = shared.TransformerConfig{
|
||||
config = shared_t.TransformerConfig{
|
||||
TransformerName: constants.DentLabel,
|
||||
ContractAddresses: []string{test_data.KovanFlipperContractAddress, test_data.KovanFlopperContractAddress},
|
||||
ContractAbi: test_data.KovanFlipperABI,
|
||||
@ -44,7 +45,7 @@ var _ = Describe("Dent transformer", func() {
|
||||
EndingBlockNumber: -1,
|
||||
}
|
||||
|
||||
addresses = shared.HexStringsToAddresses(config.ContractAddresses)
|
||||
addresses = shared_t.HexStringsToAddresses(config.ContractAddresses)
|
||||
topics = []common.Hash{common.HexToHash(config.Topic)}
|
||||
fetcher = shared.NewFetcher(blockChain)
|
||||
|
||||
|
@ -20,14 +20,16 @@ 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_drip"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/factories"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
|
||||
"strconv"
|
||||
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/drip_drip"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants"
|
||||
"github.com/vulcanize/vulcanizedb/test_config"
|
||||
)
|
||||
@ -36,7 +38,7 @@ var _ = Describe("DripDrip Transformer", func() {
|
||||
var (
|
||||
db *postgres.DB
|
||||
blockChain core.BlockChain
|
||||
config shared.TransformerConfig
|
||||
config shared_t.TransformerConfig
|
||||
)
|
||||
|
||||
BeforeEach(func() {
|
||||
@ -47,7 +49,7 @@ var _ = Describe("DripDrip Transformer", func() {
|
||||
db = test_config.NewTestDB(blockChain.Node())
|
||||
test_config.CleanTestDB(db)
|
||||
|
||||
config = shared.TransformerConfig{
|
||||
config = shared_t.TransformerConfig{
|
||||
ContractAddresses: []string{test_data.KovanDripContractAddress},
|
||||
ContractAbi: test_data.KovanDripABI,
|
||||
Topic: test_data.KovanDripDripSignature,
|
||||
@ -73,7 +75,7 @@ var _ = Describe("DripDrip Transformer", func() {
|
||||
|
||||
fetcher := shared.NewFetcher(blockChain)
|
||||
logs, err := fetcher.FetchLogs(
|
||||
shared.HexStringsToAddresses(config.ContractAddresses),
|
||||
shared_t.HexStringsToAddresses(config.ContractAddresses),
|
||||
[]common.Hash{common.HexToHash(config.Topic)},
|
||||
header)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
@ -109,7 +111,7 @@ var _ = Describe("DripDrip Transformer", func() {
|
||||
|
||||
fetcher := shared.NewFetcher(blockChain)
|
||||
logs, err := fetcher.FetchLogs(
|
||||
shared.HexStringsToAddresses(config.ContractAddresses),
|
||||
shared_t.HexStringsToAddresses(config.ContractAddresses),
|
||||
[]common.Hash{common.HexToHash(config.Topic)},
|
||||
header)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
@ -20,13 +20,15 @@ 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/drip_file/vow"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants"
|
||||
"github.com/vulcanize/vulcanizedb/test_config"
|
||||
)
|
||||
@ -48,7 +50,7 @@ var _ = Describe("Drip File Vow LogNoteTransformer", func() {
|
||||
|
||||
It("transforms DripFileVow log events", func() {
|
||||
blockNumber := int64(8762197)
|
||||
config := shared.TransformerConfig{
|
||||
config := shared_t.TransformerConfig{
|
||||
TransformerName: constants.DripFileVowLabel,
|
||||
ContractAddresses: []string{test_data.KovanDripContractAddress},
|
||||
ContractAbi: test_data.KovanDripABI,
|
||||
@ -69,7 +71,7 @@ var _ = Describe("Drip File Vow LogNoteTransformer", func() {
|
||||
|
||||
fetcher := shared.NewFetcher(blockChain)
|
||||
logs, err := fetcher.FetchLogs(
|
||||
shared.HexStringsToAddresses(config.ContractAddresses),
|
||||
shared_t.HexStringsToAddresses(config.ContractAddresses),
|
||||
[]common.Hash{common.HexToHash(config.Topic)},
|
||||
header)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
@ -88,7 +90,7 @@ var _ = Describe("Drip File Vow LogNoteTransformer", func() {
|
||||
|
||||
It("rechecks drip file vow event", func() {
|
||||
blockNumber := int64(8762197)
|
||||
config := shared.TransformerConfig{
|
||||
config := shared_t.TransformerConfig{
|
||||
TransformerName: constants.DripFileVowLabel,
|
||||
ContractAddresses: []string{test_data.KovanDripContractAddress},
|
||||
ContractAbi: test_data.KovanDripABI,
|
||||
@ -109,7 +111,7 @@ var _ = Describe("Drip File Vow LogNoteTransformer", func() {
|
||||
|
||||
fetcher := shared.NewFetcher(blockChain)
|
||||
logs, err := fetcher.FetchLogs(
|
||||
shared.HexStringsToAddresses(config.ContractAddresses),
|
||||
shared_t.HexStringsToAddresses(config.ContractAddresses),
|
||||
[]common.Hash{common.HexToHash(config.Topic)},
|
||||
header)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
@ -27,6 +27,7 @@ import (
|
||||
. "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"
|
||||
@ -50,7 +51,7 @@ var _ = Describe("FlapKick Transformer", func() {
|
||||
|
||||
It("fetches and transforms a FlapKick event from Kovan chain", func() {
|
||||
blockNumber := int64(9002933)
|
||||
config := shared.TransformerConfig{
|
||||
config := shared_t.TransformerConfig{
|
||||
TransformerName: constants.FlapKickLabel,
|
||||
ContractAddresses: []string{test_data.KovanFlapperContractAddress},
|
||||
ContractAbi: test_data.KovanFlapperABI,
|
||||
@ -70,7 +71,7 @@ var _ = Describe("FlapKick Transformer", func() {
|
||||
|
||||
fetcher := shared.NewFetcher(blockChain)
|
||||
logs, err := fetcher.FetchLogs(
|
||||
shared.HexStringsToAddresses(config.ContractAddresses),
|
||||
shared_t.HexStringsToAddresses(config.ContractAddresses),
|
||||
[]common.Hash{common.HexToHash(config.Topic)},
|
||||
header)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
@ -24,6 +24,7 @@ import (
|
||||
. "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"
|
||||
@ -59,7 +60,7 @@ var _ = Describe("FlipKick Transformer", func() {
|
||||
|
||||
It("fetches and transforms a FlipKick event from Kovan chain", func() {
|
||||
blockNumber := int64(8956476)
|
||||
config := shared.TransformerConfig{
|
||||
config := shared_t.TransformerConfig{
|
||||
TransformerName: constants.FlipKickLabel,
|
||||
ContractAddresses: []string{test_data.KovanFlipperContractAddress},
|
||||
ContractAbi: test_data.KovanFlipperABI,
|
||||
@ -86,7 +87,7 @@ var _ = Describe("FlipKick Transformer", func() {
|
||||
|
||||
fetcher := shared.NewFetcher(blockChain)
|
||||
logs, err := fetcher.FetchLogs(
|
||||
shared.HexStringsToAddresses(config.ContractAddresses),
|
||||
shared_t.HexStringsToAddresses(config.ContractAddresses),
|
||||
[]common.Hash{common.HexToHash(config.Topic)},
|
||||
header)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
@ -24,6 +24,7 @@ import (
|
||||
. "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"
|
||||
@ -39,7 +40,7 @@ var _ = Describe("FlopKick Transformer", func() {
|
||||
var (
|
||||
db *postgres.DB
|
||||
blockChain core.BlockChain
|
||||
config shared.TransformerConfig
|
||||
config shared_t.TransformerConfig
|
||||
initializer factories.Transformer
|
||||
fetcher shared.LogFetcher
|
||||
addresses []common.Address
|
||||
@ -54,7 +55,7 @@ var _ = Describe("FlopKick Transformer", func() {
|
||||
db = test_config.NewTestDB(blockChain.Node())
|
||||
test_config.CleanTestDB(db)
|
||||
|
||||
config = shared.TransformerConfig{
|
||||
config = shared_t.TransformerConfig{
|
||||
TransformerName: constants.FlopKickLabel,
|
||||
ContractAddresses: []string{test_data.KovanFlopperContractAddress},
|
||||
ContractAbi: test_data.KovanFlopperABI,
|
||||
@ -70,7 +71,7 @@ var _ = Describe("FlopKick Transformer", func() {
|
||||
}
|
||||
|
||||
fetcher = shared.NewFetcher(blockChain)
|
||||
addresses = shared.HexStringsToAddresses(config.ContractAddresses)
|
||||
addresses = shared_t.HexStringsToAddresses(config.ContractAddresses)
|
||||
topics = []common.Hash{common.HexToHash(config.Topic)}
|
||||
})
|
||||
|
||||
|
@ -23,6 +23,7 @@ import (
|
||||
. "github.com/onsi/gomega"
|
||||
"strconv"
|
||||
|
||||
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"
|
||||
@ -39,7 +40,7 @@ var _ = Describe("Frob Transformer", func() {
|
||||
db *postgres.DB
|
||||
blockChain core.BlockChain
|
||||
fetcher *shared.Fetcher
|
||||
config shared.TransformerConfig
|
||||
config shared_t.TransformerConfig
|
||||
initializer factories.Transformer
|
||||
)
|
||||
|
||||
@ -52,7 +53,7 @@ var _ = Describe("Frob Transformer", func() {
|
||||
test_config.CleanTestDB(db)
|
||||
|
||||
fetcher = shared.NewFetcher(blockChain)
|
||||
config = shared.TransformerConfig{
|
||||
config = shared_t.TransformerConfig{
|
||||
TransformerName: constants.FrobLabel,
|
||||
ContractAddresses: []string{test_data.KovanPitContractAddress},
|
||||
ContractAbi: test_data.KovanPitABI,
|
||||
@ -77,7 +78,7 @@ var _ = Describe("Frob Transformer", func() {
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
logs, err := fetcher.FetchLogs(
|
||||
shared.HexStringsToAddresses(config.ContractAddresses),
|
||||
shared_t.HexStringsToAddresses(config.ContractAddresses),
|
||||
[]common.Hash{common.HexToHash(config.Topic)},
|
||||
header)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
@ -27,6 +27,7 @@ import (
|
||||
"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"
|
||||
)
|
||||
@ -48,7 +49,7 @@ var _ = Describe("PitFileDebtCeiling LogNoteTransformer", func() {
|
||||
|
||||
It("fetches and transforms a PitFileDebtCeiling event from Kovan chain", func() {
|
||||
blockNumber := int64(8535578)
|
||||
config := shared.TransformerConfig{
|
||||
config := shared_t.TransformerConfig{
|
||||
TransformerName: constants.PitFileDebtCeilingLabel,
|
||||
ContractAddresses: []string{test_data.KovanPitContractAddress},
|
||||
ContractAbi: test_data.KovanPitABI,
|
||||
@ -62,7 +63,7 @@ var _ = Describe("PitFileDebtCeiling LogNoteTransformer", func() {
|
||||
|
||||
fetcher := shared.NewFetcher(blockChain)
|
||||
logs, err := fetcher.FetchLogs(
|
||||
shared.HexStringsToAddresses(config.ContractAddresses),
|
||||
shared_t.HexStringsToAddresses(config.ContractAddresses),
|
||||
[]common.Hash{common.HexToHash(config.Topic)},
|
||||
header)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
@ -26,6 +26,7 @@ import (
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
|
||||
"strconv"
|
||||
|
||||
shared_t "github.com/vulcanize/vulcanizedb/libraries/shared/transformer"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/factories"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/pit_file/ilk"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
||||
@ -48,7 +49,7 @@ var _ = Describe("PitFileIlk LogNoteTransformer", func() {
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
db = test_config.NewTestDB(blockChain.Node())
|
||||
test_config.CleanTestDB(db)
|
||||
config := shared.TransformerConfig{
|
||||
config := shared_t.TransformerConfig{
|
||||
TransformerName: constants.PitFileIlkLabel,
|
||||
ContractAddresses: []string{test_data.KovanPitContractAddress},
|
||||
ContractAbi: test_data.KovanPitABI,
|
||||
@ -57,7 +58,7 @@ var _ = Describe("PitFileIlk LogNoteTransformer", func() {
|
||||
EndingBlockNumber: -1,
|
||||
}
|
||||
|
||||
addresses = shared.HexStringsToAddresses(config.ContractAddresses)
|
||||
addresses = shared_t.HexStringsToAddresses(config.ContractAddresses)
|
||||
topics = []common.Hash{common.HexToHash(config.Topic)}
|
||||
|
||||
initializer = factories.LogNoteTransformer{
|
||||
|
@ -9,6 +9,7 @@ import (
|
||||
"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"
|
||||
@ -21,7 +22,7 @@ var _ = Describe("Price feeds transformer", func() {
|
||||
var (
|
||||
db *postgres.DB
|
||||
blockChain core.BlockChain
|
||||
config shared.TransformerConfig
|
||||
config shared_t.TransformerConfig
|
||||
fetcher *shared.Fetcher
|
||||
initializer factories.LogNoteTransformer
|
||||
topics []common.Hash
|
||||
@ -35,7 +36,7 @@ var _ = Describe("Price feeds transformer", func() {
|
||||
db = test_config.NewTestDB(blockChain.Node())
|
||||
test_config.CleanTestDB(db)
|
||||
|
||||
config = shared.TransformerConfig{
|
||||
config = shared_t.TransformerConfig{
|
||||
TransformerName: constants.PriceFeedLabel,
|
||||
ContractAddresses: []string{
|
||||
test_data.KovanPepContractAddress,
|
||||
@ -69,7 +70,7 @@ var _ = Describe("Price feeds transformer", func() {
|
||||
initializer.Config.EndingBlockNumber = blockNumber
|
||||
|
||||
logs, err := fetcher.FetchLogs(
|
||||
shared.HexStringsToAddresses(addresses),
|
||||
shared_t.HexStringsToAddresses(addresses),
|
||||
topics,
|
||||
header)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
@ -134,7 +135,7 @@ var _ = Describe("Price feeds transformer", func() {
|
||||
initializer.Config.EndingBlockNumber = blockNumber
|
||||
|
||||
logs, err := fetcher.FetchLogs(
|
||||
shared.HexStringsToAddresses(addresses),
|
||||
shared_t.HexStringsToAddresses(addresses),
|
||||
topics,
|
||||
header)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
@ -160,7 +161,7 @@ var _ = Describe("Price feeds transformer", func() {
|
||||
initializer.Config.EndingBlockNumber = blockNumber
|
||||
|
||||
logs, err := fetcher.FetchLogs(
|
||||
shared.HexStringsToAddresses(addresses),
|
||||
shared_t.HexStringsToAddresses(addresses),
|
||||
topics,
|
||||
header)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
@ -20,6 +20,7 @@ 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"
|
||||
@ -34,7 +35,7 @@ var _ = Describe("Tend LogNoteTransformer", func() {
|
||||
var (
|
||||
db *postgres.DB
|
||||
blockChain core.BlockChain
|
||||
config shared.TransformerConfig
|
||||
config shared_t.TransformerConfig
|
||||
fetcher *shared.Fetcher
|
||||
initializer factories.LogNoteTransformer
|
||||
addresses []common.Address
|
||||
@ -49,7 +50,7 @@ var _ = Describe("Tend LogNoteTransformer", func() {
|
||||
db = test_config.NewTestDB(blockChain.Node())
|
||||
test_config.CleanTestDB(db)
|
||||
|
||||
config = shared.TransformerConfig{
|
||||
config = shared_t.TransformerConfig{
|
||||
TransformerName: constants.TendLabel,
|
||||
ContractAddresses: []string{test_data.KovanFlapperContractAddress, test_data.KovanFlipperContractAddress},
|
||||
ContractAbi: test_data.KovanFlipperABI,
|
||||
@ -59,7 +60,7 @@ var _ = Describe("Tend LogNoteTransformer", func() {
|
||||
}
|
||||
|
||||
fetcher = shared.NewFetcher(blockChain)
|
||||
addresses = shared.HexStringsToAddresses(config.ContractAddresses)
|
||||
addresses = shared_t.HexStringsToAddresses(config.ContractAddresses)
|
||||
topics = []common.Hash{common.HexToHash(config.Topic)}
|
||||
|
||||
initializer = factories.LogNoteTransformer{
|
||||
|
@ -24,6 +24,7 @@ import (
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
|
||||
"strconv"
|
||||
|
||||
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_flux"
|
||||
@ -33,7 +34,7 @@ import (
|
||||
var _ = Describe("VatFlux LogNoteTransformer", func() {
|
||||
It("transforms VatFlux log events", func() {
|
||||
blockNumber := int64(9004474)
|
||||
config := shared.TransformerConfig{
|
||||
config := shared_t.TransformerConfig{
|
||||
TransformerName: constants.VatFluxLabel,
|
||||
ContractAddresses: []string{test_data.KovanVatContractAddress},
|
||||
ContractAbi: test_data.KovanVatABI,
|
||||
@ -55,7 +56,7 @@ var _ = Describe("VatFlux LogNoteTransformer", func() {
|
||||
|
||||
fetcher := shared.NewFetcher(blockChain)
|
||||
logs, err := fetcher.FetchLogs(
|
||||
shared.HexStringsToAddresses(config.ContractAddresses),
|
||||
shared_t.HexStringsToAddresses(config.ContractAddresses),
|
||||
[]common.Hash{common.HexToHash(config.Topic)},
|
||||
header)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
@ -27,6 +27,7 @@ import (
|
||||
"github.com/vulcanize/vulcanizedb/test_config"
|
||||
"strconv"
|
||||
|
||||
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_fold"
|
||||
@ -49,7 +50,7 @@ var _ = Describe("VatFold Transformer", func() {
|
||||
|
||||
It("transforms VatFold log events", func() {
|
||||
blockNumber := int64(9367233)
|
||||
config := shared.TransformerConfig{
|
||||
config := shared_t.TransformerConfig{
|
||||
TransformerName: constants.VatFoldLabel,
|
||||
ContractAddresses: []string{test_data.KovanVatContractAddress},
|
||||
ContractAbi: test_data.KovanVatABI,
|
||||
@ -63,7 +64,7 @@ var _ = Describe("VatFold Transformer", func() {
|
||||
|
||||
fetcher := shared.NewFetcher(blockChain)
|
||||
logs, err := fetcher.FetchLogs(
|
||||
shared.HexStringsToAddresses(config.ContractAddresses),
|
||||
shared_t.HexStringsToAddresses(config.ContractAddresses),
|
||||
[]common.Hash{common.HexToHash(config.Topic)},
|
||||
header)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
@ -26,6 +26,7 @@ import (
|
||||
. "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/shared"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/vat_grab"
|
||||
@ -35,7 +36,7 @@ import (
|
||||
var _ = Describe("Vat Grab Transformer", func() {
|
||||
It("transforms VatGrab log events", func() {
|
||||
blockNumber := int64(8958230)
|
||||
config := shared.TransformerConfig{
|
||||
config := shared_t.TransformerConfig{
|
||||
TransformerName: constants.VatGrabLabel,
|
||||
ContractAddresses: []string{test_data.KovanVatContractAddress},
|
||||
ContractAbi: test_data.KovanVatABI,
|
||||
@ -57,7 +58,7 @@ var _ = Describe("Vat Grab Transformer", func() {
|
||||
|
||||
fetcher := shared.NewFetcher(blockChain)
|
||||
logs, err := fetcher.FetchLogs(
|
||||
shared.HexStringsToAddresses(config.ContractAddresses),
|
||||
shared_t.HexStringsToAddresses(config.ContractAddresses),
|
||||
[]common.Hash{common.HexToHash(config.Topic)},
|
||||
header)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
@ -23,6 +23,7 @@ import (
|
||||
"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"
|
||||
@ -32,7 +33,7 @@ import (
|
||||
var _ = Describe("VatHeal Transformer", func() {
|
||||
It("transforms VatHeal log events", func() {
|
||||
blockNumber := int64(8935578)
|
||||
config := shared.TransformerConfig{
|
||||
config := shared_t.TransformerConfig{
|
||||
TransformerName: constants.VatHealLabel,
|
||||
ContractAddresses: []string{test_data.KovanVatContractAddress},
|
||||
ContractAbi: test_data.KovanVatABI,
|
||||
@ -54,7 +55,7 @@ var _ = Describe("VatHeal Transformer", func() {
|
||||
|
||||
fetcher := shared.NewFetcher(blockChain)
|
||||
logs, err := fetcher.FetchLogs(
|
||||
shared.HexStringsToAddresses(config.ContractAddresses),
|
||||
shared_t.HexStringsToAddresses(config.ContractAddresses),
|
||||
[]common.Hash{common.HexToHash(config.Topic)},
|
||||
header)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
@ -26,6 +26,7 @@ import (
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
|
||||
"strconv"
|
||||
|
||||
shared_t "github.com/vulcanize/vulcanizedb/libraries/shared/transformer"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/vat_init"
|
||||
"github.com/vulcanize/vulcanizedb/test_config"
|
||||
)
|
||||
@ -33,7 +34,7 @@ import (
|
||||
var _ = Describe("VatInit LogNoteTransformer", func() {
|
||||
It("transforms VatInit log events", func() {
|
||||
blockNumber := int64(8535561)
|
||||
config := shared.TransformerConfig{
|
||||
config := shared_t.TransformerConfig{
|
||||
TransformerName: constants.VatInitLabel,
|
||||
ContractAddresses: []string{test_data.KovanVatContractAddress},
|
||||
ContractAbi: test_data.KovanVatABI,
|
||||
@ -55,7 +56,7 @@ var _ = Describe("VatInit LogNoteTransformer", func() {
|
||||
|
||||
fetcher := shared.NewFetcher(blockChain)
|
||||
logs, err := fetcher.FetchLogs(
|
||||
shared.HexStringsToAddresses(config.ContractAddresses),
|
||||
shared_t.HexStringsToAddresses(config.ContractAddresses),
|
||||
[]common.Hash{common.HexToHash(config.Topic)},
|
||||
header)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
@ -25,6 +25,7 @@ import (
|
||||
"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"
|
||||
)
|
||||
@ -32,7 +33,7 @@ import (
|
||||
var _ = Describe("VatMove LogNoteTransformer", func() {
|
||||
It("transforms VatMove log events", func() {
|
||||
blockNumber := int64(9004628)
|
||||
config := shared.TransformerConfig{
|
||||
config := shared_t.TransformerConfig{
|
||||
TransformerName: constants.VatMoveLabel,
|
||||
ContractAddresses: []string{test_data.KovanVatContractAddress},
|
||||
ContractAbi: test_data.KovanVatABI,
|
||||
@ -54,7 +55,7 @@ var _ = Describe("VatMove LogNoteTransformer", func() {
|
||||
|
||||
fetcher := shared.NewFetcher(blockChain)
|
||||
logs, err := fetcher.FetchLogs(
|
||||
shared.HexStringsToAddresses(config.ContractAddresses),
|
||||
shared_t.HexStringsToAddresses(config.ContractAddresses),
|
||||
[]common.Hash{common.HexToHash(config.Topic)},
|
||||
header)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
@ -8,6 +8,7 @@ import (
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
|
||||
"strconv"
|
||||
|
||||
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"
|
||||
@ -33,7 +34,7 @@ var _ = Describe("Vat slip transformer", func() {
|
||||
|
||||
It("persists vat slip event", func() {
|
||||
blockNumber := int64(8953655)
|
||||
config := shared.TransformerConfig{
|
||||
config := shared_t.TransformerConfig{
|
||||
TransformerName: constants.VatSlipLabel,
|
||||
ContractAddresses: []string{test_data.KovanVatContractAddress},
|
||||
ContractAbi: test_data.KovanVatABI,
|
||||
@ -47,7 +48,7 @@ var _ = Describe("Vat slip transformer", func() {
|
||||
|
||||
fetcher := shared.NewFetcher(blockChain)
|
||||
logs, err := fetcher.FetchLogs(
|
||||
shared.HexStringsToAddresses(config.ContractAddresses),
|
||||
shared_t.HexStringsToAddresses(config.ContractAddresses),
|
||||
[]common.Hash{common.HexToHash(config.Topic)},
|
||||
header)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
@ -26,6 +26,7 @@ import (
|
||||
. "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/shared"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/vat_tune"
|
||||
@ -35,7 +36,7 @@ import (
|
||||
var _ = Describe("VatTune LogNoteTransformer", func() {
|
||||
It("transforms VatTune log events", func() {
|
||||
blockNumber := int64(8761670)
|
||||
config := shared.TransformerConfig{
|
||||
config := shared_t.TransformerConfig{
|
||||
TransformerName: constants.VatTuneLabel,
|
||||
ContractAddresses: []string{test_data.KovanVatContractAddress},
|
||||
ContractAbi: test_data.KovanVatABI,
|
||||
@ -57,7 +58,7 @@ var _ = Describe("VatTune LogNoteTransformer", func() {
|
||||
|
||||
fetcher := shared.NewFetcher(blockChain)
|
||||
logs, err := fetcher.FetchLogs(
|
||||
shared.HexStringsToAddresses(config.ContractAddresses),
|
||||
shared_t.HexStringsToAddresses(config.ContractAddresses),
|
||||
[]common.Hash{common.HexToHash(config.Topic)},
|
||||
header)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
@ -25,6 +25,7 @@ import (
|
||||
"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"
|
||||
@ -48,7 +49,7 @@ var _ = Describe("VowFlog LogNoteTransformer", func() {
|
||||
|
||||
It("transforms VowFlog log events", func() {
|
||||
blockNumber := int64(8946819)
|
||||
config := shared.TransformerConfig{
|
||||
config := shared_t.TransformerConfig{
|
||||
TransformerName: constants.VowFlogLabel,
|
||||
ContractAddresses: []string{test_data.KovanVowContractAddress},
|
||||
ContractAbi: test_data.KovanVowABI,
|
||||
@ -62,7 +63,7 @@ var _ = Describe("VowFlog LogNoteTransformer", func() {
|
||||
|
||||
fetcher := shared.NewFetcher(blockChain)
|
||||
logs, err := fetcher.FetchLogs(
|
||||
shared.HexStringsToAddresses(config.ContractAddresses),
|
||||
shared_t.HexStringsToAddresses(config.ContractAddresses),
|
||||
[]common.Hash{common.HexToHash(config.Topic)},
|
||||
header)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
@ -17,12 +17,12 @@
|
||||
package debt_ceiling
|
||||
|
||||
import (
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
||||
shared_t "github.com/vulcanize/vulcanizedb/libraries/shared/transformer"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants"
|
||||
)
|
||||
|
||||
func GetDebtCeilingFileConfig() shared.TransformerConfig {
|
||||
return shared.TransformerConfig{
|
||||
func GetDebtCeilingFileConfig() shared_t.TransformerConfig {
|
||||
return shared_t.TransformerConfig{
|
||||
TransformerName: constants.PitFileDebtCeilingLabel,
|
||||
ContractAddresses: []string{constants.PitContractAddress()},
|
||||
ContractAbi: constants.PitABI(),
|
||||
|
@ -17,12 +17,12 @@
|
||||
package ilk
|
||||
|
||||
import (
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
||||
shared_t "github.com/vulcanize/vulcanizedb/libraries/shared/transformer"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants"
|
||||
)
|
||||
|
||||
func GetIlkFileConfig() shared.TransformerConfig {
|
||||
return shared.TransformerConfig{
|
||||
func GetIlkFileConfig() shared_t.TransformerConfig {
|
||||
return shared_t.TransformerConfig{
|
||||
TransformerName: constants.PitFileIlkLabel,
|
||||
ContractAddresses: []string{constants.PitContractAddress()},
|
||||
ContractAbi: constants.PitABI(),
|
||||
|
@ -17,12 +17,13 @@
|
||||
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.TransformerConfig {
|
||||
return shared.TransformerConfig{
|
||||
func GetPriceFeedConfig() shared_t.TransformerConfig {
|
||||
return shared_t.TransformerConfig{
|
||||
TransformerName: constants.PriceFeedLabel,
|
||||
ContractAddresses: []string{
|
||||
constants.PepContractAddress(), constants.PipContractAddress(), constants.RepContractAddress(),
|
||||
|
@ -20,10 +20,12 @@ import (
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"strings"
|
||||
|
||||
shared_t "github.com/vulcanize/vulcanizedb/libraries/shared/transformer"
|
||||
)
|
||||
|
||||
type Chunker interface {
|
||||
AddConfigs(transformerConfigs []TransformerConfig)
|
||||
AddConfigs(transformerConfigs []shared_t.TransformerConfig)
|
||||
ChunkLogs(logs []types.Log) map[string][]types.Log
|
||||
}
|
||||
|
||||
@ -42,7 +44,7 @@ func NewLogChunker() *LogChunker {
|
||||
}
|
||||
|
||||
// Configures the chunker by adding more addreses and topics to consider.
|
||||
func (chunker *LogChunker) AddConfigs(transformerConfigs []TransformerConfig) {
|
||||
func (chunker *LogChunker) AddConfigs(transformerConfigs []shared_t.TransformerConfig) {
|
||||
for _, config := range transformerConfigs {
|
||||
for _, address := range config.ContractAddresses {
|
||||
var lowerCaseAddress = strings.ToLower(address)
|
||||
|
@ -21,34 +21,35 @@ import (
|
||||
"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/transformers/shared"
|
||||
)
|
||||
|
||||
var _ = Describe("Log chunker", func() {
|
||||
var (
|
||||
configs []shared.TransformerConfig
|
||||
configs []shared_t.TransformerConfig
|
||||
chunker *shared.LogChunker
|
||||
)
|
||||
|
||||
BeforeEach(func() {
|
||||
configA := shared.TransformerConfig{
|
||||
configA := shared_t.TransformerConfig{
|
||||
TransformerName: "TransformerA",
|
||||
ContractAddresses: []string{"0x00000000000000000000000000000000000000A1", "0x00000000000000000000000000000000000000A2"},
|
||||
Topic: "0xA",
|
||||
}
|
||||
configB := shared.TransformerConfig{
|
||||
configB := shared_t.TransformerConfig{
|
||||
TransformerName: "TransformerB",
|
||||
ContractAddresses: []string{"0x00000000000000000000000000000000000000B1"},
|
||||
Topic: "0xB",
|
||||
}
|
||||
|
||||
configC := shared.TransformerConfig{
|
||||
configC := shared_t.TransformerConfig{
|
||||
TransformerName: "TransformerC",
|
||||
ContractAddresses: []string{"0x00000000000000000000000000000000000000A2"},
|
||||
Topic: "0xC",
|
||||
}
|
||||
|
||||
configs = []shared.TransformerConfig{configA, configB, configC}
|
||||
configs = []shared_t.TransformerConfig{configA, configB, configC}
|
||||
chunker = shared.NewLogChunker()
|
||||
chunker.AddConfigs(configs)
|
||||
})
|
||||
@ -71,24 +72,24 @@ var _ = Describe("Log chunker", func() {
|
||||
|
||||
Describe("AddConfigs", func() {
|
||||
It("can add more configs later", func() {
|
||||
configD := shared.TransformerConfig{
|
||||
configD := shared_t.TransformerConfig{
|
||||
TransformerName: "TransformerD",
|
||||
ContractAddresses: []string{"0x000000000000000000000000000000000000000D"},
|
||||
Topic: "0xD",
|
||||
}
|
||||
chunker.AddConfigs([]shared.TransformerConfig{configD})
|
||||
chunker.AddConfigs([]shared_t.TransformerConfig{configD})
|
||||
|
||||
Expect(chunker.AddressToNames).To(ContainElement([]string{"TransformerD"}))
|
||||
Expect(chunker.NameToTopic0).To(ContainElement(common.HexToHash("0xD")))
|
||||
})
|
||||
|
||||
It("lower cases address", func() {
|
||||
configD := shared.TransformerConfig{
|
||||
configD := shared_t.TransformerConfig{
|
||||
TransformerName: "TransformerD",
|
||||
ContractAddresses: []string{"0x000000000000000000000000000000000000000D"},
|
||||
Topic: "0xD",
|
||||
}
|
||||
chunker.AddConfigs([]shared.TransformerConfig{configD})
|
||||
chunker.AddConfigs([]shared_t.TransformerConfig{configD})
|
||||
|
||||
Expect(chunker.AddressToNames["0x000000000000000000000000000000000000000d"]).To(Equal([]string{"TransformerD"}))
|
||||
})
|
||||
|
@ -17,12 +17,13 @@
|
||||
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.TransformerConfig {
|
||||
return shared.TransformerConfig{
|
||||
func GetTendConfig() shared_t.TransformerConfig {
|
||||
return shared_t.TransformerConfig{
|
||||
TransformerName: constants.TendLabel,
|
||||
ContractAddresses: []string{constants.FlapperContractAddress(), constants.FlipperContractAddress()},
|
||||
ContractAbi: constants.FlipperABI(),
|
||||
|
@ -17,11 +17,12 @@
|
||||
package test_data
|
||||
|
||||
import (
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
||||
"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{}
|
||||
@ -37,7 +38,7 @@ var GenericTestLogs = []types.Log{{
|
||||
BlockNumber: uint64(startingBlockNumber),
|
||||
}}
|
||||
|
||||
var GenericTestConfig = shared.TransformerConfig{
|
||||
var GenericTestConfig = shared_t.TransformerConfig{
|
||||
TransformerName: "generic-test-transformer",
|
||||
ContractAddresses: []string{address},
|
||||
ContractAbi: randomString(100),
|
||||
|
@ -2,9 +2,10 @@ package mocks
|
||||
|
||||
import (
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
|
||||
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"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants"
|
||||
)
|
||||
|
||||
@ -13,7 +14,7 @@ type MockTransformer struct {
|
||||
ExecuteError error
|
||||
PassedLogs []types.Log
|
||||
PassedHeader core.Header
|
||||
config shared.TransformerConfig
|
||||
config shared_t.TransformerConfig
|
||||
}
|
||||
|
||||
func (mh *MockTransformer) Execute(logs []types.Log, header core.Header, recheckHeaders constants.TransformerExecution) error {
|
||||
@ -26,19 +27,19 @@ func (mh *MockTransformer) Execute(logs []types.Log, header core.Header, recheck
|
||||
return nil
|
||||
}
|
||||
|
||||
func (mh *MockTransformer) GetConfig() shared.TransformerConfig {
|
||||
func (mh *MockTransformer) GetConfig() shared_t.TransformerConfig {
|
||||
return mh.config
|
||||
}
|
||||
|
||||
func (mh *MockTransformer) SetTransformerConfig(config shared.TransformerConfig) {
|
||||
func (mh *MockTransformer) SetTransformerConfig(config shared_t.TransformerConfig) {
|
||||
mh.config = config
|
||||
}
|
||||
|
||||
func (mh *MockTransformer) FakeTransformerInitializer(db *postgres.DB) shared.Transformer {
|
||||
func (mh *MockTransformer) FakeTransformerInitializer(db *postgres.DB) shared_t.Transformer {
|
||||
return mh
|
||||
}
|
||||
|
||||
var FakeTransformerConfig = shared.TransformerConfig{
|
||||
var FakeTransformerConfig = shared_t.TransformerConfig{
|
||||
TransformerName: "FakeTransformer",
|
||||
ContractAddresses: []string{"FakeAddress"},
|
||||
Topic: "FakeTopic",
|
||||
|
@ -17,6 +17,7 @@
|
||||
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"
|
||||
@ -35,7 +36,6 @@ import (
|
||||
"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/shared"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/tend"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/vat_flux"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/vat_fold"
|
||||
@ -315,7 +315,7 @@ func getLogNoteTransformers() []factories.LogNoteTransformer {
|
||||
|
||||
// `TransformerInitializers` returns a list of functions, that given a db pointer
|
||||
// will return a `shared.Transformer`
|
||||
func TransformerInitializers() (initializers []shared.TransformerInitializer) {
|
||||
func TransformerInitializers() (initializers []shared_t.TransformerInitializer) {
|
||||
for _, transformer := range getLogNoteTransformers() {
|
||||
initializers = append(initializers, transformer.NewLogNoteTransformer)
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
package vat_flux
|
||||
|
||||
import (
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
||||
shared_t "github.com/vulcanize/vulcanizedb/libraries/shared/transformer"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants"
|
||||
)
|
||||
|
||||
func GetVatFluxConfig() shared.TransformerConfig {
|
||||
return shared.TransformerConfig{
|
||||
func GetVatFluxConfig() shared_t.TransformerConfig {
|
||||
return shared_t.TransformerConfig{
|
||||
TransformerName: constants.VatFluxLabel,
|
||||
ContractAddresses: []string{constants.VatContractAddress()},
|
||||
ContractAbi: constants.VatABI(),
|
||||
|
@ -17,12 +17,12 @@
|
||||
package vat_fold
|
||||
|
||||
import (
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
||||
shared_t "github.com/vulcanize/vulcanizedb/libraries/shared/transformer"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants"
|
||||
)
|
||||
|
||||
func GetVatFoldConfig() shared.TransformerConfig {
|
||||
return shared.TransformerConfig{
|
||||
func GetVatFoldConfig() shared_t.TransformerConfig {
|
||||
return shared_t.TransformerConfig{
|
||||
TransformerName: constants.VatFoldLabel,
|
||||
ContractAddresses: []string{constants.VatContractAddress()},
|
||||
ContractAbi: constants.VatABI(),
|
||||
|
@ -1,12 +1,12 @@
|
||||
package vat_grab
|
||||
|
||||
import (
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
||||
shared_t "github.com/vulcanize/vulcanizedb/libraries/shared/transformer"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants"
|
||||
)
|
||||
|
||||
func GetVatGrabConfig() shared.TransformerConfig {
|
||||
return shared.TransformerConfig{
|
||||
func GetVatGrabConfig() shared_t.TransformerConfig {
|
||||
return shared_t.TransformerConfig{
|
||||
TransformerName: constants.VatGrabLabel,
|
||||
ContractAddresses: []string{constants.VatContractAddress()},
|
||||
ContractAbi: constants.VatABI(),
|
||||
|
@ -17,12 +17,12 @@
|
||||
package vat_heal
|
||||
|
||||
import (
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
||||
shared_t "github.com/vulcanize/vulcanizedb/libraries/shared/transformer"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants"
|
||||
)
|
||||
|
||||
func GetVatHealConfig() shared.TransformerConfig {
|
||||
return shared.TransformerConfig{
|
||||
func GetVatHealConfig() shared_t.TransformerConfig {
|
||||
return shared_t.TransformerConfig{
|
||||
TransformerName: constants.VatHealLabel,
|
||||
ContractAddresses: []string{constants.VatContractAddress()},
|
||||
ContractAbi: constants.VatABI(),
|
||||
|
@ -17,12 +17,12 @@
|
||||
package vat_init
|
||||
|
||||
import (
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
||||
shared_t "github.com/vulcanize/vulcanizedb/libraries/shared/transformer"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants"
|
||||
)
|
||||
|
||||
func GetVatInitConfig() shared.TransformerConfig {
|
||||
return shared.TransformerConfig{
|
||||
func GetVatInitConfig() shared_t.TransformerConfig {
|
||||
return shared_t.TransformerConfig{
|
||||
TransformerName: constants.VatInitLabel,
|
||||
ContractAddresses: []string{constants.VatContractAddress()},
|
||||
ContractAbi: constants.VatABI(),
|
||||
|
@ -17,12 +17,12 @@
|
||||
package vat_move
|
||||
|
||||
import (
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
||||
shared_t "github.com/vulcanize/vulcanizedb/libraries/shared/transformer"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants"
|
||||
)
|
||||
|
||||
func GetVatMoveConfig() shared.TransformerConfig {
|
||||
return shared.TransformerConfig{
|
||||
func GetVatMoveConfig() shared_t.TransformerConfig {
|
||||
return shared_t.TransformerConfig{
|
||||
TransformerName: constants.VatMoveLabel,
|
||||
ContractAddresses: []string{constants.VatContractAddress()},
|
||||
ContractAbi: constants.VatABI(),
|
||||
|
@ -1,12 +1,12 @@
|
||||
package vat_slip
|
||||
|
||||
import (
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
||||
shared_t "github.com/vulcanize/vulcanizedb/libraries/shared/transformer"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants"
|
||||
)
|
||||
|
||||
func GetVatSlipConfig() shared.TransformerConfig {
|
||||
return shared.TransformerConfig{
|
||||
func GetVatSlipConfig() shared_t.TransformerConfig {
|
||||
return shared_t.TransformerConfig{
|
||||
TransformerName: constants.VatSlipLabel,
|
||||
ContractAddresses: []string{constants.VatContractAddress()},
|
||||
ContractAbi: constants.VatABI(),
|
||||
|
@ -1,12 +1,12 @@
|
||||
package vat_toll
|
||||
|
||||
import (
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
||||
shared_t "github.com/vulcanize/vulcanizedb/libraries/shared/transformer"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants"
|
||||
)
|
||||
|
||||
func GetVatTollConfig() shared.TransformerConfig {
|
||||
return shared.TransformerConfig{
|
||||
func GetVatTollConfig() shared_t.TransformerConfig {
|
||||
return shared_t.TransformerConfig{
|
||||
TransformerName: constants.VatTollLabel,
|
||||
ContractAddresses: []string{constants.VatContractAddress()},
|
||||
ContractAbi: constants.VatABI(),
|
||||
|
@ -1,12 +1,12 @@
|
||||
package vat_tune
|
||||
|
||||
import (
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
||||
shared_t "github.com/vulcanize/vulcanizedb/libraries/shared/transformer"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants"
|
||||
)
|
||||
|
||||
func GetVatTuneConfig() shared.TransformerConfig {
|
||||
return shared.TransformerConfig{
|
||||
func GetVatTuneConfig() shared_t.TransformerConfig {
|
||||
return shared_t.TransformerConfig{
|
||||
TransformerName: constants.VatTuneLabel,
|
||||
ContractAddresses: []string{constants.VatContractAddress()},
|
||||
ContractAbi: constants.VatABI(),
|
||||
|
@ -17,12 +17,12 @@
|
||||
package vow_flog
|
||||
|
||||
import (
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
||||
shared_t "github.com/vulcanize/vulcanizedb/libraries/shared/transformer"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants"
|
||||
)
|
||||
|
||||
func GetVowFlogConfig() shared.TransformerConfig {
|
||||
return shared.TransformerConfig{
|
||||
func GetVowFlogConfig() shared_t.TransformerConfig {
|
||||
return shared_t.TransformerConfig{
|
||||
TransformerName: constants.VowFlogLabel,
|
||||
ContractAddresses: []string{constants.VowContractAddress()},
|
||||
ContractAbi: constants.VowABI(),
|
||||
|
58
plugins/README.md
Normal file
58
plugins/README.md
Normal file
@ -0,0 +1,58 @@
|
||||
## Plugins
|
||||
|
||||
This directory is for Exporter plugins (.go and .so files) generated by, output from, and linked to from the composeAndExecute command
|
||||
These plugins are generated using information provided in a .toml config file
|
||||
|
||||
The config file requires, at a minimum, the below fields:
|
||||
|
||||
```toml
|
||||
[database]
|
||||
name = "vulcanize_public"
|
||||
hostname = "localhost"
|
||||
user = "vulcanize"
|
||||
password = "vulcanize"
|
||||
port = 5432
|
||||
|
||||
[client]
|
||||
ipcPath = "http://kovan0.vulcanize.io:8545"
|
||||
|
||||
[exporter]
|
||||
filePath = "$GOPATH/src/github.com/vulcanize/vulcanizedb/plugins/"
|
||||
fileName = "exporter"
|
||||
[exporter.transformers]
|
||||
transformer1 = "github.com/path/to/transformer1"
|
||||
transformer2 = "github.com/path/to/transformer2"
|
||||
transformer3 = "github.com/path/to/transformer3"
|
||||
```
|
||||
|
||||
In the above, the exporter.transformers are mappings of import aliases to their import paths
|
||||
If the individual transformers require additional configuration variables be sure to include them in the .toml file
|
||||
|
||||
The general structure of a plugin .go file, and what we would see with the above config is below
|
||||
Note that `shared_transformer` is a reserved alias needed for the generic TransformerInitializer type:
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
shared_transformer "github.com/vulcanize/vulcanizedb/libraries/shared/transformer"
|
||||
transformer1 "github.com/path/to/transformer1"
|
||||
transformer2 "github.com/path/to/transformer2"
|
||||
transformer3 "github.com/path/to/transformer3"
|
||||
)
|
||||
|
||||
type exporter string
|
||||
|
||||
var Exporter exporter
|
||||
|
||||
func (e exporter) Export() []shared_transformer.TransformerInitializer {
|
||||
return []shared_transformer.TransformerInitializer{
|
||||
transformer1.TransformerInitializer,
|
||||
transformer2.TransformerInitializer,
|
||||
transformer3.TransformerInitializer,
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
As such, to plug in an external transformer all we need to do is 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
|
30
vendor/github.com/dave/jennifer/.gitignore
generated
vendored
Normal file
30
vendor/github.com/dave/jennifer/.gitignore
generated
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
*.iml
|
||||
|
||||
# Compiled Object files, Static and Dynamic libs (Shared Objects)
|
||||
*.o
|
||||
*.a
|
||||
*.so
|
||||
|
||||
# Folders
|
||||
_obj
|
||||
_test
|
||||
|
||||
# Architecture specific extensions/prefixes
|
||||
*.[568vq]
|
||||
[568vq].out
|
||||
|
||||
*.cgo1.go
|
||||
*.cgo2.c
|
||||
_cgo_defun.c
|
||||
_cgo_gotypes.go
|
||||
_cgo_export.*
|
||||
|
||||
_testmain.go
|
||||
|
||||
*.exe
|
||||
*.test
|
||||
*.prof
|
||||
|
||||
.DS_Store
|
||||
.idea/
|
||||
coverage.out
|
14
vendor/github.com/dave/jennifer/.travis.yml
generated
vendored
Normal file
14
vendor/github.com/dave/jennifer/.travis.yml
generated
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
language: go
|
||||
go:
|
||||
- 1.x
|
||||
notificaitons:
|
||||
email:
|
||||
recipients: dave@brophy.uk
|
||||
on_failure: always
|
||||
install:
|
||||
- go get -u github.com/dave/courtney
|
||||
- go get -t -v ./...
|
||||
script:
|
||||
- courtney -e
|
||||
after_success:
|
||||
- bash <(curl -s https://codecov.io/bash)
|
21
vendor/github.com/dave/jennifer/LICENSE
generated
vendored
Normal file
21
vendor/github.com/dave/jennifer/LICENSE
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2017 David Brophy
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
1052
vendor/github.com/dave/jennifer/README.md
generated
vendored
Normal file
1052
vendor/github.com/dave/jennifer/README.md
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
422
vendor/github.com/dave/jennifer/README.md.tpl
generated
vendored
Normal file
422
vendor/github.com/dave/jennifer/README.md.tpl
generated
vendored
Normal file
@ -0,0 +1,422 @@
|
||||
[![Build Status](https://travis-ci.org/dave/jennifer.svg?branch=master)](https://travis-ci.org/dave/jennifer) [![Go Report Card](https://goreportcard.com/badge/github.com/dave/jennifer)](https://goreportcard.com/report/github.com/dave/jennifer) [![codecov](https://img.shields.io/badge/codecov-100%25-brightgreen.svg)](https://codecov.io/gh/dave/jennifer) ![stability-stable](https://img.shields.io/badge/stability-stable-brightgreen.svg) [![Sourcegraph](https://sourcegraph.com/github.com/dave/jennifer/jen/-/badge.svg)](https://sourcegraph.com/github.com/dave/jennifer?badge) <a href="https://patreon.com/davebrophy" title="Help with my hosting bills using Patreon"><img src="https://img.shields.io/badge/patreon-donate-yellow.svg" style="max-width:100%;"></a>
|
||||
|
||||
# Jennifer
|
||||
Jennifer is a code generator for Go.
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
. "github.com/dave/jennifer/jen"
|
||||
)
|
||||
|
||||
func main() {{ "ExampleNewFile" | code }}
|
||||
```
|
||||
Output:
|
||||
```go
|
||||
{{ "ExampleNewFile" | output }}
|
||||
```
|
||||
|
||||
### Install
|
||||
```
|
||||
go get -u github.com/dave/jennifer/jen
|
||||
```
|
||||
|
||||
### Need help?
|
||||
If you get stuck, have a question, would like a code review, or just want a
|
||||
chat: I'm happy to help! Feel free to open an issue, email me or mention @dave
|
||||
in your PR.
|
||||
|
||||
### Examples
|
||||
Jennifer has a comprehensive suite of examples - see [godoc](https://godoc.org/github.com/dave/jennifer/jen#pkg-examples) for an index. Here's some examples of jennifer being used in the real-world:
|
||||
|
||||
* [genjen](genjen/render.go) (which generates much of jennifer, using data in [data.go](genjen/data.go))
|
||||
* [zerogen](https://github.com/mrsinham/zerogen/blob/master/generator.go)
|
||||
* [go-contentful-generator](https://github.com/nicolai86/go-contentful-generator)
|
||||
|
||||
### Rendering
|
||||
For testing, a File or Statement can be rendered with the fmt package
|
||||
using the %#v verb.
|
||||
|
||||
{{ "ExampleCall_fmt" | example }}
|
||||
|
||||
This is not recommended for use in production because any error will cause a
|
||||
panic. For production use, [File.Render](#render) or [File.Save](#save) are
|
||||
preferred.
|
||||
|
||||
# Identifiers
|
||||
**Identifiers** [Keywords](#keywords) [Operators](#operators) [Braces](#braces) [Parentheses](#parentheses) [Control flow](#control-flow) [Collections](#collections) [Literals](#literals) [Comments](#comments) [Helpers](#helpers) [Misc](#misc) [File](#file)
|
||||
|
||||
### Id
|
||||
{{ "Id" | doc }}
|
||||
|
||||
{{ "ExampleId" | example }}
|
||||
|
||||
### Dot
|
||||
{{ "Dot" | doc }}
|
||||
|
||||
{{ "ExampleDot" | example }}
|
||||
|
||||
### Qual
|
||||
{{ "Qual[0]" | doc }}
|
||||
|
||||
{{ "ExampleQual" | example }}
|
||||
|
||||
{{ "Qual[1:4]" | doc }}
|
||||
|
||||
{{ "ExampleQual_file" | example }}
|
||||
|
||||
{{ "Qual[4:]" | doc }}
|
||||
|
||||
### List
|
||||
{{ "List" | doc }}
|
||||
|
||||
{{ "ExampleList" | example }}
|
||||
|
||||
# Keywords
|
||||
[Identifiers](#identifiers) **Keywords** [Operators](#operators) [Braces](#braces) [Parentheses](#parentheses) [Control flow](#control-flow) [Collections](#collections) [Literals](#literals) [Comments](#comments) [Helpers](#helpers) [Misc](#misc) [File](#file)
|
||||
|
||||
Simple keywords, predeclared identifiers and built-in functions are self
|
||||
explanatory:
|
||||
|
||||
| Construct | Name |
|
||||
| ---------------- | ---- |
|
||||
| Keywords | Break, Chan, Const, Continue, Default, Defer, Else, Fallthrough, Func, Go, Goto, Range, Select, Type, Var |
|
||||
| Functions | Append, Cap, Close, Complex, Copy, Delete, Imag, Len, Make, New, Panic, Print, Println, Real, Recover |
|
||||
| Types | Bool, Byte, Complex64, Complex128, Error, Float32, Float64, Int, Int8, Int16, Int32, Int64, Rune, String, Uint, Uint8, Uint16, Uint32, Uint64, Uintptr |
|
||||
| Constants | True, False, Iota, Nil |
|
||||
| Helpers | Err |
|
||||
|
||||
Built-in functions take a list of parameters and render them appropriately:
|
||||
|
||||
{{ "ExampleAppend_more" | example }}
|
||||
|
||||
Special cases for [If, For](#if-for), [Interface, Struct](#interface-struct), [Switch, Case](#switch-select), [Return](#return) and [Map](#map) are explained below.
|
||||
|
||||
# Operators
|
||||
[Identifiers](#identifiers) [Keywords](#keywords) **Operators** [Braces](#braces) [Parentheses](#parentheses) [Control flow](#control-flow) [Collections](#collections) [Literals](#literals) [Comments](#comments) [Helpers](#helpers) [Misc](#misc) [File](#file)
|
||||
|
||||
{{ "Op" | doc }}
|
||||
|
||||
{{ "ExampleOp" | example }}
|
||||
|
||||
{{ "ExampleOp_star" | example }}
|
||||
|
||||
{{ "ExampleOp_variadic" | example }}
|
||||
|
||||
{{ "ExampleOp_complex_conditions" | example }}
|
||||
|
||||
# Braces
|
||||
[Identifiers](#identifiers) [Keywords](#keywords) [Operators](#operators) **Braces** [Parentheses](#parentheses) [Control flow](#control-flow) [Collections](#collections) [Literals](#literals) [Comments](#comments) [Helpers](#helpers) [Misc](#misc) [File](#file)
|
||||
|
||||
Several methods render curly braces, summarized below:
|
||||
|
||||
| Name | Prefix | Separator | Example |
|
||||
| ------------------------------ | ------------ | --------- | -------------------------------------|
|
||||
| [Block](#block) | | `\n` | `func a() { ... }` or `if a { ... }` |
|
||||
| [Interface](#interface-struct) | `interface` | `\n` | `interface { ... }` |
|
||||
| [Struct](#interface-struct) | `struct` | `\n` | `struct { ... }` |
|
||||
| [Values](#values) | | `,` | `[]int{1, 2}` or `A{B: "c"}` |
|
||||
|
||||
### Block
|
||||
{{ "Block[:2]" | doc }}
|
||||
|
||||
{{ "ExampleBlock" | example }}
|
||||
|
||||
{{ "ExampleBlock_if" | example }}
|
||||
|
||||
{{ "Block[2:]" | doc }} [See example](#switch-select).
|
||||
|
||||
### Interface, Struct
|
||||
Interface and Struct render the keyword followed by a statement list enclosed
|
||||
by curly braces.
|
||||
|
||||
{{ "ExampleInterface_empty" | example }}
|
||||
|
||||
{{ "ExampleInterface" | example }}
|
||||
|
||||
{{ "ExampleStruct_empty" | example }}
|
||||
|
||||
{{ "ExampleStruct" | example }}
|
||||
|
||||
# Parentheses
|
||||
[Identifiers](#identifiers) [Keywords](#keywords) [Operators](#operators) [Braces](#braces) **Parentheses** [Control flow](#control-flow) [Collections](#collections) [Literals](#literals) [Comments](#comments) [Helpers](#helpers) [Misc](#misc) [File](#file)
|
||||
|
||||
Several methods output parenthesis, summarized below:
|
||||
|
||||
| Name | Prefix | Separator | Example |
|
||||
| ----------------- | ------ | --------- | --------------------------------- |
|
||||
| [Call](#call) | | `,` | `fmt.Println(b, c)` |
|
||||
| [Params](#params) | | `,` | `func (a *A) Foo(i int) { ... }` |
|
||||
| [Defs](#defs) | | `\n` | `const ( ... )` |
|
||||
| [Parens](#parens) | | | `[]byte(s)` or `a / (b + c)` |
|
||||
| [Assert](#assert) | `.` | | `s, ok := i.(string)` |
|
||||
|
||||
### Call
|
||||
{{ "Call" | doc }}
|
||||
|
||||
{{ "ExampleCall" | example }}
|
||||
|
||||
### Params
|
||||
{{ "Params" | doc }}
|
||||
|
||||
{{ "ExampleParams" | example }}
|
||||
|
||||
### Defs
|
||||
{{ "Defs" | doc }}
|
||||
|
||||
{{ "ExampleDefs" | example }}
|
||||
|
||||
### Parens
|
||||
{{ "Parens" | doc }}
|
||||
|
||||
{{ "ExampleParens" | example }}
|
||||
|
||||
{{ "ExampleParens_order" | example }}
|
||||
|
||||
### Assert
|
||||
{{ "Assert" | doc }}
|
||||
|
||||
{{ "ExampleAssert" | example }}
|
||||
|
||||
# Control flow
|
||||
[Identifiers](#identifiers) [Keywords](#keywords) [Operators](#operators) [Braces](#braces) [Parentheses](#parentheses) **Control flow** [Collections](#collections) [Literals](#literals) [Comments](#comments) [Helpers](#helpers) [Misc](#misc) [File](#file)
|
||||
|
||||
### If, For
|
||||
If and For render the keyword followed by a semicolon separated list.
|
||||
|
||||
{{ "ExampleIf" | example }}
|
||||
|
||||
{{ "ExampleFor" | example }}
|
||||
|
||||
### Switch, Select
|
||||
Switch, Select, Case and Block are used to build switch or select statements:
|
||||
|
||||
{{ "ExampleSwitch" | example }}
|
||||
|
||||
### Return
|
||||
{{ "Return" | doc }}
|
||||
|
||||
{{ "ExampleReturn" | example }}
|
||||
|
||||
# Collections
|
||||
[Identifiers](#identifiers) [Keywords](#keywords) [Operators](#operators) [Braces](#braces) [Parentheses](#parentheses) [Control flow](#control-flow) **Collections** [Literals](#literals) [Comments](#comments) [Helpers](#helpers) [Misc](#misc) [File](#file)
|
||||
|
||||
### Map
|
||||
{{ "Map" | doc }}
|
||||
|
||||
{{ "ExampleMap" | example }}
|
||||
|
||||
### Index
|
||||
{{ "Index" | doc }}
|
||||
|
||||
{{ "ExampleIndex" | example }}
|
||||
|
||||
{{ "ExampleIndex_index" | example }}
|
||||
|
||||
{{ "ExampleIndex_empty" | example }}
|
||||
|
||||
### Values
|
||||
{{ "Values" | doc }}
|
||||
|
||||
{{ "ExampleValues" | example }}
|
||||
|
||||
{{ "Dict" | doc }}
|
||||
|
||||
{{ "ExampleValues_dict_multiple" | example }}
|
||||
|
||||
{{ "ExampleValues_dict_composite" | example }}
|
||||
|
||||
{{ "DictFunc[0]" | doc }}
|
||||
|
||||
{{ "ExampleDictFunc" | example }}
|
||||
|
||||
Note: the items are ordered by key when rendered to ensure repeatable code.
|
||||
|
||||
# Literals
|
||||
[Identifiers](#identifiers) [Keywords](#keywords) [Operators](#operators) [Braces](#braces) [Parentheses](#parentheses) [Control flow](#control-flow) [Collections](#collections) **Literals** [Comments](#comments) [Helpers](#helpers) [Misc](#misc) [File](#file)
|
||||
|
||||
### Lit
|
||||
{{ "Lit" | doc }}
|
||||
|
||||
{{ "ExampleLit" | example }}
|
||||
|
||||
{{ "ExampleLit_float" | example }}
|
||||
|
||||
{{ "LitFunc[1:2]" | doc }}
|
||||
|
||||
{{ "ExampleLitFunc" | example }}
|
||||
|
||||
For the default constant types (bool, int, float64, string, complex128), Lit
|
||||
will render the untyped constant.
|
||||
|
||||
| Code | Output |
|
||||
| ------------- | ---------- |
|
||||
| `Lit(true)` | `true` |
|
||||
| `Lit(1)` | `1` |
|
||||
| `Lit(1.0)` | `1.0` |
|
||||
| `Lit("foo")` | `"foo"` |
|
||||
| `Lit(0 + 1i)` | `(0 + 1i)` |
|
||||
|
||||
For all other built-in types (float32, int8, int16, int32, int64, uint, uint8,
|
||||
uint16, uint32, uint64, uintptr, complex64), Lit will also render the type.
|
||||
|
||||
| Code | Output |
|
||||
| ------------------------ | ------------------- |
|
||||
| `Lit(float32(1))` | `float32(1)` |
|
||||
| `Lit(int16(1))` | `int16(1)` |
|
||||
| `Lit(uint8(0x1))` | `uint8(0x1)` |
|
||||
| `Lit(complex64(0 + 1i))` | `complex64(0 + 1i)` |
|
||||
|
||||
The built-in alias types byte and rune need a special case. LitRune and LitByte
|
||||
render rune and byte literals.
|
||||
|
||||
| Code | Output |
|
||||
| ------------------------ | ----------- |
|
||||
| `LitRune('x')` | `'x'` |
|
||||
| `LitByte(byte(0x1))` | `byte(0x1)` |
|
||||
|
||||
# Comments
|
||||
[Identifiers](#identifiers) [Keywords](#keywords) [Operators](#operators) [Braces](#braces) [Parentheses](#parentheses) [Control flow](#control-flow) [Collections](#collections) [Literals](#literals) **Comments** [Helpers](#helpers) [Misc](#misc) [File](#file)
|
||||
|
||||
### Comment
|
||||
{{ "Comment[:2]" | doc }}
|
||||
|
||||
{{ "ExampleComment" | example }}
|
||||
|
||||
{{ "ExampleComment_multiline" | example }}
|
||||
|
||||
{{ "Comment[2:]" | doc }}
|
||||
|
||||
{{ "ExampleComment_formatting_disabled" | example }}
|
||||
|
||||
### Commentf
|
||||
{{ "Commentf[0]" | doc }}
|
||||
|
||||
{{ "ExampleCommentf" | example }}
|
||||
|
||||
# Helpers
|
||||
[Identifiers](#identifiers) [Keywords](#keywords) [Operators](#operators) [Braces](#braces) [Parentheses](#parentheses) [Control flow](#control-flow) [Collections](#collections) [Literals](#literals) [Comments](#comments) **Helpers** [Misc](#misc) [File](#file)
|
||||
|
||||
### Func methods
|
||||
All constructs that accept a variadic list of items are paired with GroupFunc
|
||||
functions that accept a func(*Group). Use for embedding logic.
|
||||
|
||||
{{ "ExampleValuesFunc" | example }}
|
||||
|
||||
{{ "ExampleBlockFunc" | example }}
|
||||
|
||||
### Add
|
||||
{{ "Add" | doc }}
|
||||
|
||||
{{ "ExampleAdd" | example }}
|
||||
|
||||
{{ "ExampleAdd_var" | example }}
|
||||
|
||||
### Do
|
||||
{{ "Do" | doc }}
|
||||
|
||||
{{ "ExampleDo" | example }}
|
||||
|
||||
# Misc
|
||||
[Identifiers](#identifiers) [Keywords](#keywords) [Operators](#operators) [Braces](#braces) [Parentheses](#parentheses) [Control flow](#control-flow) [Collections](#collections) [Literals](#literals) [Comments](#comments) [Helpers](#helpers) **Misc** [File](#file)
|
||||
|
||||
### Tag
|
||||
{{ "Tag" | doc }}
|
||||
|
||||
{{ "ExampleTag" | example }}
|
||||
|
||||
Note: the items are ordered by key when rendered to ensure repeatable code.
|
||||
|
||||
### Null
|
||||
{{ "Null" | doc }}
|
||||
|
||||
In lists, nil will produce the same effect.
|
||||
|
||||
{{ "ExampleNull_and_nil" | example }}
|
||||
|
||||
### Empty
|
||||
{{ "Empty" | doc }}
|
||||
|
||||
{{ "ExampleEmpty" | example }}
|
||||
|
||||
### Line
|
||||
{{ "Line" | doc }}
|
||||
|
||||
### Clone
|
||||
Be careful when passing *Statement. Consider the following...
|
||||
|
||||
{{ "ExampleStatement_Clone_broken" | example }}
|
||||
|
||||
Id("a") returns a *Statement, which the Call() method appends to twice. To
|
||||
avoid this, use Clone. {{ "Statement.Clone" | doc }}
|
||||
|
||||
{{ "ExampleStatement_Clone_fixed" | example }}
|
||||
|
||||
### Cgo
|
||||
The cgo "C" pseudo-package is a special case, and always renders without a package alias. The
|
||||
import can be added with `Qual`, `Anon` or by supplying a preamble. The preamble is added with
|
||||
`File.CgoPreamble` which has the same semantics as [Comment](#comments). If a preamble is provided,
|
||||
the import is separated, and preceded by the preamble.
|
||||
|
||||
{{ "ExampleFile_CgoPreamble" | example }}
|
||||
|
||||
# File
|
||||
[Identifiers](#identifiers) [Keywords](#keywords) [Operators](#operators) [Braces](#braces) [Parentheses](#parentheses) [Control flow](#control-flow) [Collections](#collections) [Literals](#literals) [Comments](#comments) [Helpers](#helpers) [Misc](#misc) **File**
|
||||
|
||||
{{ "File" | doc }}
|
||||
|
||||
### NewFile
|
||||
{{ "NewFile" | doc }}
|
||||
|
||||
### NewFilePath
|
||||
{{ "NewFilePath" | doc }}
|
||||
|
||||
### NewFilePathName
|
||||
{{ "NewFilePathName" | doc }}
|
||||
|
||||
{{ "ExampleNewFilePathName" | example }}
|
||||
|
||||
### Save
|
||||
{{ "File.Save" | doc }}
|
||||
|
||||
### Render
|
||||
{{ "File.Render" | doc }}
|
||||
|
||||
{{ "ExampleFile_Render" | example }}
|
||||
|
||||
### Anon
|
||||
{{ "File.Anon" | doc }}
|
||||
|
||||
{{ "ExampleFile_Anon" | example }}
|
||||
|
||||
### ImportName
|
||||
{{ "File.ImportName" | doc }}
|
||||
|
||||
{{ "ExampleFile_ImportName" | example }}
|
||||
|
||||
### ImportNames
|
||||
{{ "File.ImportNames" | doc }}
|
||||
|
||||
### ImportAlias
|
||||
{{ "File.ImportAlias" | doc }}
|
||||
|
||||
{{ "ExampleFile_ImportAlias" | example }}
|
||||
|
||||
### Comments
|
||||
{{ "File.PackageComment" | doc }}
|
||||
|
||||
{{ "File.HeaderComment" | doc }}
|
||||
|
||||
{{ "File.CanonicalPath" | doc }}
|
||||
|
||||
{{ "ExampleFile_HeaderAndPackageComments" | example }}
|
||||
|
||||
{{ "File.CgoPreamble" | doc }}
|
||||
|
||||
### PackagePrefix
|
||||
{{ "File.PackagePrefix" | doc }}
|
||||
|
||||
{{ "ExampleFile_PackagePrefix" | example }}
|
307
vendor/github.com/dave/jennifer/genjen/data.go
generated
vendored
Normal file
307
vendor/github.com/dave/jennifer/genjen/data.go
generated
vendored
Normal file
@ -0,0 +1,307 @@
|
||||
package main
|
||||
|
||||
var keywords = []string{"break", "default", "func", "select", "chan", "else", "const", "fallthrough", "type", "continue", "var", "goto", "defer", "go", "range"}
|
||||
|
||||
var identifiers = []string{"bool", "byte", "complex64", "complex128", "error", "float32", "float64", "int", "int8", "int16", "int32", "int64", "rune", "string", "uint", "uint8", "uint16", "uint32", "uint64", "uintptr", "true", "false", "iota", "nil", "err"}
|
||||
|
||||
var groups = []struct {
|
||||
name string // name of the function / method
|
||||
comment string // comment appended to name
|
||||
variadic bool // is the parameter variadic?
|
||||
opening string // opening token
|
||||
closing string // closing token
|
||||
separator string // separator token
|
||||
multi bool // items are always on multiple lines
|
||||
parameters []string // parameter names
|
||||
preventFunc bool // prevent the fooFunc function/method
|
||||
}{
|
||||
{
|
||||
name: "Parens",
|
||||
comment: "renders a single item in parenthesis. Use for type conversion or to specify evaluation order.",
|
||||
variadic: false,
|
||||
opening: "(",
|
||||
closing: ")",
|
||||
separator: "",
|
||||
parameters: []string{"item"},
|
||||
},
|
||||
{
|
||||
name: "List",
|
||||
comment: "renders a comma separated list. Use for multiple return functions.",
|
||||
variadic: true,
|
||||
opening: "",
|
||||
closing: "",
|
||||
separator: ",",
|
||||
parameters: []string{"items"},
|
||||
},
|
||||
{
|
||||
name: "Values",
|
||||
comment: "renders a comma separated list enclosed by curly braces. Use for slice or composite literals.",
|
||||
variadic: true,
|
||||
opening: "{",
|
||||
closing: "}",
|
||||
separator: ",",
|
||||
parameters: []string{"values"},
|
||||
},
|
||||
{
|
||||
name: "Index",
|
||||
comment: "renders a colon separated list enclosed by square brackets. Use for array / slice indexes and definitions.",
|
||||
variadic: true,
|
||||
opening: "[",
|
||||
closing: "]",
|
||||
separator: ":",
|
||||
parameters: []string{"items"},
|
||||
},
|
||||
{
|
||||
name: "Block",
|
||||
comment: "renders a statement list enclosed by curly braces. Use for code blocks. A special case applies when used directly after Case or Default, where the braces are omitted. This allows use in switch and select statements.",
|
||||
variadic: true,
|
||||
opening: "{",
|
||||
closing: "}",
|
||||
multi: true,
|
||||
parameters: []string{"statements"},
|
||||
},
|
||||
{
|
||||
name: "Defs",
|
||||
comment: "renders a statement list enclosed in parenthesis. Use for definition lists.",
|
||||
variadic: true,
|
||||
opening: "(",
|
||||
closing: ")",
|
||||
multi: true,
|
||||
parameters: []string{"definitions"},
|
||||
},
|
||||
{
|
||||
name: "Call",
|
||||
comment: "renders a comma separated list enclosed by parenthesis. Use for function calls.",
|
||||
variadic: true,
|
||||
opening: "(",
|
||||
closing: ")",
|
||||
separator: ",",
|
||||
parameters: []string{"params"},
|
||||
},
|
||||
{
|
||||
name: "Params",
|
||||
comment: "renders a comma separated list enclosed by parenthesis. Use for function parameters and method receivers.",
|
||||
variadic: true,
|
||||
opening: "(",
|
||||
closing: ")",
|
||||
separator: ",",
|
||||
parameters: []string{"params"},
|
||||
},
|
||||
{
|
||||
name: "Assert",
|
||||
comment: "renders a period followed by a single item enclosed by parenthesis. Use for type assertions.",
|
||||
variadic: false,
|
||||
opening: ".(",
|
||||
closing: ")",
|
||||
separator: "",
|
||||
parameters: []string{"typ"},
|
||||
},
|
||||
{
|
||||
name: "Map",
|
||||
comment: "renders the keyword followed by a single item enclosed by square brackets. Use for map definitions.",
|
||||
variadic: false,
|
||||
opening: "map[",
|
||||
closing: "]",
|
||||
separator: "",
|
||||
parameters: []string{"typ"},
|
||||
},
|
||||
{
|
||||
name: "If",
|
||||
comment: "renders the keyword followed by a semicolon separated list.",
|
||||
variadic: true,
|
||||
opening: "if ",
|
||||
closing: "",
|
||||
separator: ";",
|
||||
parameters: []string{"conditions"},
|
||||
},
|
||||
{
|
||||
name: "Return",
|
||||
comment: "renders the keyword followed by a comma separated list.",
|
||||
variadic: true,
|
||||
opening: "return ",
|
||||
closing: "",
|
||||
separator: ",",
|
||||
parameters: []string{"results"},
|
||||
},
|
||||
{
|
||||
name: "For",
|
||||
comment: "renders the keyword followed by a semicolon separated list.",
|
||||
variadic: true,
|
||||
opening: "for ",
|
||||
closing: "",
|
||||
separator: ";",
|
||||
parameters: []string{"conditions"},
|
||||
},
|
||||
{
|
||||
name: "Switch",
|
||||
comment: "renders the keyword followed by a semicolon separated list.",
|
||||
variadic: true,
|
||||
opening: "switch ",
|
||||
closing: "",
|
||||
separator: ";",
|
||||
parameters: []string{"conditions"},
|
||||
},
|
||||
{
|
||||
name: "Interface",
|
||||
comment: "renders the keyword followed by a method list enclosed by curly braces.",
|
||||
variadic: true,
|
||||
opening: "interface{",
|
||||
closing: "}",
|
||||
multi: true,
|
||||
parameters: []string{"methods"},
|
||||
},
|
||||
{
|
||||
name: "Struct",
|
||||
comment: "renders the keyword followed by a field list enclosed by curly braces.",
|
||||
variadic: true,
|
||||
opening: "struct{",
|
||||
closing: "}",
|
||||
multi: true,
|
||||
parameters: []string{"fields"},
|
||||
},
|
||||
{
|
||||
name: "Case",
|
||||
comment: "renders the keyword followed by a comma separated list.",
|
||||
variadic: true,
|
||||
opening: "case ",
|
||||
closing: ":",
|
||||
separator: ",",
|
||||
parameters: []string{"cases"},
|
||||
},
|
||||
{
|
||||
name: "Append",
|
||||
comment: "renders the append built-in function.",
|
||||
variadic: true,
|
||||
opening: "append(",
|
||||
closing: ")",
|
||||
separator: ",",
|
||||
parameters: []string{"args"},
|
||||
},
|
||||
{
|
||||
name: "Cap",
|
||||
comment: "renders the cap built-in function.",
|
||||
variadic: false,
|
||||
opening: "cap(",
|
||||
closing: ")",
|
||||
separator: ",",
|
||||
parameters: []string{"v"},
|
||||
},
|
||||
{
|
||||
name: "Close",
|
||||
comment: "renders the close built-in function.",
|
||||
variadic: false,
|
||||
opening: "close(",
|
||||
closing: ")",
|
||||
separator: ",",
|
||||
parameters: []string{"c"},
|
||||
},
|
||||
{
|
||||
name: "Complex",
|
||||
comment: "renders the complex built-in function.",
|
||||
variadic: false,
|
||||
opening: "complex(",
|
||||
closing: ")",
|
||||
separator: ",",
|
||||
parameters: []string{"r", "i"},
|
||||
},
|
||||
{
|
||||
name: "Copy",
|
||||
comment: "renders the copy built-in function.",
|
||||
variadic: false,
|
||||
opening: "copy(",
|
||||
closing: ")",
|
||||
separator: ",",
|
||||
parameters: []string{"dst", "src"},
|
||||
},
|
||||
{
|
||||
name: "Delete",
|
||||
comment: "renders the delete built-in function.",
|
||||
variadic: false,
|
||||
opening: "delete(",
|
||||
closing: ")",
|
||||
separator: ",",
|
||||
parameters: []string{"m", "key"},
|
||||
},
|
||||
{
|
||||
name: "Imag",
|
||||
comment: "renders the imag built-in function.",
|
||||
variadic: false,
|
||||
opening: "imag(",
|
||||
closing: ")",
|
||||
separator: ",",
|
||||
parameters: []string{"c"},
|
||||
},
|
||||
{
|
||||
name: "Len",
|
||||
comment: "renders the len built-in function.",
|
||||
variadic: false,
|
||||
opening: "len(",
|
||||
closing: ")",
|
||||
separator: ",",
|
||||
parameters: []string{"v"},
|
||||
},
|
||||
{
|
||||
name: "Make",
|
||||
comment: "renders the make built-in function. The final parameter of the make function is optional, so it is represented by a variadic parameter list.",
|
||||
variadic: true,
|
||||
opening: "make(",
|
||||
closing: ")",
|
||||
separator: ",",
|
||||
parameters: []string{"args"},
|
||||
preventFunc: true, // the underlying function is not variadic, so we prevent the MakeFunc variation
|
||||
},
|
||||
{
|
||||
name: "New",
|
||||
comment: "renders the new built-in function.",
|
||||
variadic: false,
|
||||
opening: "new(",
|
||||
closing: ")",
|
||||
separator: ",",
|
||||
parameters: []string{"typ"},
|
||||
},
|
||||
{
|
||||
name: "Panic",
|
||||
comment: "renders the panic built-in function.",
|
||||
variadic: false,
|
||||
opening: "panic(",
|
||||
closing: ")",
|
||||
separator: ",",
|
||||
parameters: []string{"v"},
|
||||
},
|
||||
{
|
||||
name: "Print",
|
||||
comment: "renders the print built-in function.",
|
||||
variadic: true,
|
||||
opening: "print(",
|
||||
closing: ")",
|
||||
separator: ",",
|
||||
parameters: []string{"args"},
|
||||
},
|
||||
{
|
||||
name: "Println",
|
||||
comment: "renders the println built-in function.",
|
||||
variadic: true,
|
||||
opening: "println(",
|
||||
closing: ")",
|
||||
separator: ",",
|
||||
parameters: []string{"args"},
|
||||
},
|
||||
{
|
||||
name: "Real",
|
||||
comment: "renders the real built-in function.",
|
||||
variadic: false,
|
||||
opening: "real(",
|
||||
closing: ")",
|
||||
separator: ",",
|
||||
parameters: []string{"c"},
|
||||
},
|
||||
{
|
||||
name: "Recover",
|
||||
comment: "renders the recover built-in function.",
|
||||
variadic: false,
|
||||
opening: "recover(",
|
||||
closing: ")",
|
||||
separator: ",",
|
||||
parameters: []string{},
|
||||
},
|
||||
}
|
17
vendor/github.com/dave/jennifer/genjen/main.go
generated
vendored
Normal file
17
vendor/github.com/dave/jennifer/genjen/main.go
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io/ioutil"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// notest
|
||||
buf := &bytes.Buffer{}
|
||||
if err := render(buf); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if err := ioutil.WriteFile("./jen/generated.go", buf.Bytes(), 0644); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
260
vendor/github.com/dave/jennifer/genjen/render.go
generated
vendored
Normal file
260
vendor/github.com/dave/jennifer/genjen/render.go
generated
vendored
Normal file
@ -0,0 +1,260 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"io"
|
||||
"strings"
|
||||
|
||||
. "github.com/dave/jennifer/jen"
|
||||
)
|
||||
|
||||
func render(w io.Writer) error {
|
||||
file := NewFile("jen")
|
||||
|
||||
file.HeaderComment("This file is generated - do not edit.")
|
||||
file.Line()
|
||||
|
||||
for _, b := range groups {
|
||||
b := b // b used in closures
|
||||
comment := Commentf("%s %s", b.name, b.comment)
|
||||
|
||||
if b.variadic && len(b.parameters) > 1 {
|
||||
panic("should not have variadic function with multiple params")
|
||||
}
|
||||
|
||||
var variadic Code
|
||||
if b.variadic {
|
||||
variadic = Op("...")
|
||||
}
|
||||
var funcParams []Code
|
||||
var callParams []Code
|
||||
for _, name := range b.parameters {
|
||||
funcParams = append(funcParams, Id(name).Add(variadic).Id("Code"))
|
||||
callParams = append(callParams, Id(name).Add(variadic))
|
||||
}
|
||||
|
||||
addFunctionAndGroupMethod(
|
||||
file,
|
||||
b.name,
|
||||
comment,
|
||||
funcParams,
|
||||
callParams,
|
||||
false,
|
||||
)
|
||||
|
||||
/*
|
||||
// <comment>
|
||||
func (s *Statement) <name>(<funcParams>) *Statement {
|
||||
g := &Group{
|
||||
items: []Code{<paramNames>}|<paramNames[0]>,
|
||||
name: "<name>",
|
||||
open: "<opening>",
|
||||
close: "<closing>",
|
||||
separator: "<separator>",
|
||||
multi: <multi>,
|
||||
}
|
||||
*s = append(*s, g)
|
||||
return s
|
||||
}
|
||||
*/
|
||||
file.Add(comment)
|
||||
file.Func().Params(
|
||||
Id("s").Op("*").Id("Statement"),
|
||||
).Id(b.name).Params(
|
||||
funcParams...,
|
||||
).Op("*").Id("Statement").Block(
|
||||
Id("g").Op(":=").Op("&").Id("Group").Values(Dict{
|
||||
Id("items"): Do(func(s *Statement) {
|
||||
if b.variadic {
|
||||
s.Id(b.parameters[0])
|
||||
} else {
|
||||
s.Index().Id("Code").ValuesFunc(func(g *Group) {
|
||||
for _, name := range b.parameters {
|
||||
g.Id(name)
|
||||
}
|
||||
})
|
||||
}
|
||||
}),
|
||||
Id("name"): Lit(strings.ToLower(b.name)),
|
||||
Id("open"): Lit(b.opening),
|
||||
Id("close"): Lit(b.closing),
|
||||
Id("separator"): Lit(b.separator),
|
||||
Id("multi"): Lit(b.multi),
|
||||
}),
|
||||
Op("*").Id("s").Op("=").Append(Op("*").Id("s"), Id("g")),
|
||||
Return(Id("s")),
|
||||
)
|
||||
|
||||
if b.variadic && !b.preventFunc {
|
||||
|
||||
funcName := b.name + "Func"
|
||||
funcComment := Commentf("%sFunc %s", b.name, b.comment)
|
||||
funcFuncParams := []Code{Id("f").Func().Params(Op("*").Id("Group"))}
|
||||
funcCallParams := []Code{Id("f")}
|
||||
|
||||
addFunctionAndGroupMethod(
|
||||
file,
|
||||
funcName,
|
||||
funcComment,
|
||||
funcFuncParams,
|
||||
funcCallParams,
|
||||
false,
|
||||
)
|
||||
|
||||
/*
|
||||
// <funcComment>
|
||||
func (s *Statement) <funcName>(f func(*Group)) *Statement {
|
||||
g := &Group{
|
||||
name: "<name>",
|
||||
open: "<opening>",
|
||||
close: "<closing>",
|
||||
separator: "<separator>",
|
||||
multi: <multi>,
|
||||
}
|
||||
f(g)
|
||||
*s = append(*s, g)
|
||||
return s
|
||||
}
|
||||
*/
|
||||
file.Add(funcComment)
|
||||
file.Func().Params(
|
||||
Id("s").Op("*").Id("Statement"),
|
||||
).Id(funcName).Params(
|
||||
funcFuncParams...,
|
||||
).Op("*").Id("Statement").Block(
|
||||
Id("g").Op(":=").Op("&").Id("Group").Values(Dict{
|
||||
Id("name"): Lit(strings.ToLower(b.name)),
|
||||
Id("open"): Lit(b.opening),
|
||||
Id("close"): Lit(b.closing),
|
||||
Id("separator"): Lit(b.separator),
|
||||
Id("multi"): Lit(b.multi),
|
||||
}),
|
||||
Id("f").Call(Id("g")),
|
||||
Op("*").Id("s").Op("=").Append(Op("*").Id("s"), Id("g")),
|
||||
Return(Id("s")),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
type tkn struct {
|
||||
token string
|
||||
name string
|
||||
tokenType string
|
||||
tokenDesc string
|
||||
}
|
||||
tokens := []tkn{}
|
||||
for _, v := range identifiers {
|
||||
tokens = append(tokens, tkn{
|
||||
token: v,
|
||||
name: strings.ToUpper(v[:1]) + v[1:],
|
||||
tokenType: "identifierToken",
|
||||
tokenDesc: "identifier",
|
||||
})
|
||||
}
|
||||
for _, v := range keywords {
|
||||
tokens = append(tokens, tkn{
|
||||
token: v,
|
||||
name: strings.ToUpper(v[:1]) + v[1:],
|
||||
tokenType: "keywordToken",
|
||||
tokenDesc: "keyword",
|
||||
})
|
||||
}
|
||||
|
||||
for i, t := range tokens {
|
||||
t := t // used in closures
|
||||
comment := Commentf(
|
||||
"%s renders the %s %s.",
|
||||
t.name,
|
||||
t.token,
|
||||
t.tokenDesc,
|
||||
)
|
||||
addFunctionAndGroupMethod(
|
||||
file,
|
||||
t.name,
|
||||
comment,
|
||||
nil,
|
||||
nil,
|
||||
i != 0, // only enforce test coverage on one item
|
||||
)
|
||||
|
||||
/*
|
||||
// <comment>
|
||||
func (s *Statement) <name>() *Statement {
|
||||
t := token{
|
||||
typ: <tokenType>,
|
||||
content: "<token>",
|
||||
}
|
||||
*s = append(*s, t)
|
||||
return s
|
||||
}
|
||||
*/
|
||||
file.Add(comment)
|
||||
file.Func().Params(
|
||||
Id("s").Op("*").Id("Statement"),
|
||||
).Id(t.name).Params().Op("*").Id("Statement").Block(
|
||||
Do(func(s *Statement) {
|
||||
if i != 0 {
|
||||
// only enforce test coverage on one item
|
||||
s.Comment("notest")
|
||||
}
|
||||
}),
|
||||
Id("t").Op(":=").Id("token").Values(Dict{
|
||||
Id("typ"): Id(t.tokenType),
|
||||
Id("content"): Lit(t.token),
|
||||
}),
|
||||
Op("*").Id("s").Op("=").Append(Op("*").Id("s"), Id("t")),
|
||||
Return(Id("s")),
|
||||
)
|
||||
}
|
||||
|
||||
return file.Render(w)
|
||||
}
|
||||
|
||||
// For each method on *Statement, this generates a package level
|
||||
// function and a method on *Group, both with the same name.
|
||||
func addFunctionAndGroupMethod(
|
||||
file *File,
|
||||
name string,
|
||||
comment *Statement,
|
||||
funcParams []Code,
|
||||
callParams []Code,
|
||||
notest bool,
|
||||
) {
|
||||
/*
|
||||
// <comment>
|
||||
func <name>(<funcParams>) *Statement {
|
||||
return newStatement().<name>(<callParams>)
|
||||
}
|
||||
*/
|
||||
file.Add(comment)
|
||||
file.Func().Id(name).Params(funcParams...).Op("*").Id("Statement").Block(
|
||||
Do(func(s *Statement) {
|
||||
if notest {
|
||||
// only enforce test coverage on one item
|
||||
s.Comment("notest")
|
||||
}
|
||||
}),
|
||||
Return(Id("newStatement").Call().Dot(name).Call(callParams...)),
|
||||
)
|
||||
/*
|
||||
// <comment>
|
||||
func (g *Group) <name>(<funcParams>) *Statement {
|
||||
s := <name>(<callParams>)
|
||||
g.items = append(g.items, s)
|
||||
return s
|
||||
}
|
||||
*/
|
||||
file.Add(comment)
|
||||
file.Func().Params(
|
||||
Id("g").Op("*").Id("Group"),
|
||||
).Id(name).Params(funcParams...).Op("*").Id("Statement").Block(
|
||||
Do(func(s *Statement) {
|
||||
if notest {
|
||||
// only enforce test coverage on one item
|
||||
s.Comment("notest")
|
||||
}
|
||||
}),
|
||||
Id("s").Op(":=").Id(name).Params(callParams...),
|
||||
Id("g").Dot("items").Op("=").Append(Id("g").Dot("items"), Id("s")),
|
||||
Return(Id("s")),
|
||||
)
|
||||
}
|
35
vendor/github.com/dave/jennifer/genjen/render_test.go
generated
vendored
Normal file
35
vendor/github.com/dave/jennifer/genjen/render_test.go
generated
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"regexp"
|
||||
"testing"
|
||||
|
||||
"bytes"
|
||||
)
|
||||
|
||||
func TestRender(t *testing.T) {
|
||||
|
||||
buf := &bytes.Buffer{}
|
||||
if err := render(buf); err != nil {
|
||||
t.Fatal(err.Error())
|
||||
}
|
||||
generatedString := buf.String()
|
||||
|
||||
existingFilePath := "../jen/generated.go"
|
||||
existingBytes, err := ioutil.ReadFile(existingFilePath)
|
||||
if err != nil {
|
||||
t.Fatal(err.Error())
|
||||
}
|
||||
existingString := string(existingBytes)
|
||||
|
||||
// The "goimports" tool will often re-order the imports, so this is a
|
||||
// kludge to remove it before comparing. This is not ideal!
|
||||
importsRegex := regexp.MustCompile(`(?ms:\nimport \(\n.*\n\)\n)`)
|
||||
generatedString = importsRegex.ReplaceAllString(generatedString, "-")
|
||||
existingString = importsRegex.ReplaceAllString(existingString, "-")
|
||||
|
||||
if generatedString != existingString {
|
||||
t.Fatalf("Generated code is not what is present:\n%s", generatedString)
|
||||
}
|
||||
}
|
52
vendor/github.com/dave/jennifer/gennames/README.md
generated
vendored
Normal file
52
vendor/github.com/dave/jennifer/gennames/README.md
generated
vendored
Normal file
@ -0,0 +1,52 @@
|
||||
# gennames
|
||||
For large projects, it may be useful to generate an index of package names for commonly used packages.
|
||||
The index of names can be added to each generated file using `File.ImportNames`. The `gennames` command
|
||||
is used internally to generate the list of standard library package names.
|
||||
|
||||
### Usage
|
||||
|
||||
```
|
||||
Usage of gennames:
|
||||
-filter string
|
||||
Regex to filter paths (operates on full path including vendor directory) (default ".*")
|
||||
-name string
|
||||
Name of the variable to define (default "PackageNames")
|
||||
-novendor
|
||||
Exclude packages in vendor directories
|
||||
-output string
|
||||
Output filename to write (default "./package-names.go")
|
||||
-package string
|
||||
Package name in generated file (default "main")
|
||||
-path string
|
||||
Path to pass to go list command (default "all")
|
||||
-standard
|
||||
Use standard library packages
|
||||
```
|
||||
|
||||
### Path
|
||||
Supply a `path` to pass to the `go list` command. You may use the wildcard `/...` to recursively return
|
||||
packages, but it's worth remembering that vendored packages are not returned by this method unless the
|
||||
path itself is a vendored path. Use `all` to return all packages in your `GOPATH` (including vendored
|
||||
packages), however remember this may take some time for a large `GOPATH`.
|
||||
|
||||
### Filter
|
||||
Supply a regex `filter` to limit the packages that are returned by the `go list` command. The filter
|
||||
operates on the full vendored package path (e.g. `github.com/foo/bar/vendor/github.com/baz/qux`), however
|
||||
the package path added to the index is unvendored (e.g. `github.com/baz/qux`).
|
||||
|
||||
### Examples
|
||||
|
||||
```
|
||||
gennames -filter "foo|bar"
|
||||
```
|
||||
|
||||
Create a file named `package-names.go` with `package main` listing the names of all packages with paths
|
||||
containing `foo` or `bar`.
|
||||
|
||||
```
|
||||
gennames -output "foo/names.go" -package "foo" -path "github.com/foo/bar/vendor/..."
|
||||
```
|
||||
|
||||
Create a file named `foo/names.go` with `package foo` listing the names of all packages that are vendored
|
||||
inside `github.com/foo/bar`.
|
||||
|
141
vendor/github.com/dave/jennifer/gennames/hints.go
generated
vendored
Normal file
141
vendor/github.com/dave/jennifer/gennames/hints.go
generated
vendored
Normal file
@ -0,0 +1,141 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"go/build"
|
||||
"io"
|
||||
"os/exec"
|
||||
"strings"
|
||||
|
||||
"regexp"
|
||||
|
||||
"path/filepath"
|
||||
|
||||
. "github.com/dave/jennifer/jen"
|
||||
)
|
||||
|
||||
func hints(w io.Writer, pkg, name, goListPath, filter string, standard, novendor bool) error {
|
||||
|
||||
// notest
|
||||
|
||||
file := NewFile(pkg)
|
||||
|
||||
file.HeaderComment("This file is generated - do not edit.")
|
||||
file.Line()
|
||||
|
||||
packages, err := getPackages(goListPath, filter, standard, novendor)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
/*
|
||||
// <name> contains package name hints
|
||||
var <name> = map[string]string{
|
||||
...
|
||||
}
|
||||
*/
|
||||
file.Commentf("%s contains package name hints", name)
|
||||
file.Var().Id(name).Op("=").Map(String()).String().Values(DictFunc(func(d Dict) {
|
||||
for path, name := range packages {
|
||||
d[Lit(path)] = Lit(name)
|
||||
}
|
||||
}))
|
||||
|
||||
return file.Render(w)
|
||||
}
|
||||
|
||||
func getPackages(goListPath, filter string, standard, novendor bool) (map[string]string, error) {
|
||||
|
||||
// notest
|
||||
|
||||
r, err := regexp.Compile(filter)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
cmd := exec.Command("go", "list", "-e", "-f", "{{ .Standard }} {{ .ImportPath }} {{ .Name }}", goListPath)
|
||||
cmd.Env = []string{
|
||||
fmt.Sprintf("GOPATH=%s", build.Default.GOPATH),
|
||||
fmt.Sprintf("GOROOT=%s", build.Default.GOROOT),
|
||||
}
|
||||
if standard {
|
||||
cmd.Dir = filepath.Join(build.Default.GOROOT, "src")
|
||||
} else {
|
||||
cmd.Dir = filepath.Join(build.Default.GOPATH, "src")
|
||||
}
|
||||
b, err := cmd.Output()
|
||||
if err != nil {
|
||||
if x, ok := err.(*exec.ExitError); ok {
|
||||
return nil, fmt.Errorf("go list command returned an error - %s: %s", err.Error(), string(x.Stderr))
|
||||
}
|
||||
return nil, fmt.Errorf("go list command returned an error: %s", err.Error())
|
||||
}
|
||||
all := strings.Split(strings.TrimSpace(string(b)), "\n")
|
||||
|
||||
packages := map[string]string{}
|
||||
for _, j := range all {
|
||||
|
||||
parts := strings.Split(j, " ")
|
||||
|
||||
isStandard := parts[0] == "true"
|
||||
if isStandard != standard {
|
||||
continue
|
||||
}
|
||||
|
||||
path := parts[1]
|
||||
name := parts[2]
|
||||
|
||||
if novendor && hasVendor(path) {
|
||||
continue
|
||||
}
|
||||
|
||||
if name == "main" {
|
||||
continue
|
||||
}
|
||||
|
||||
if !r.MatchString(path) {
|
||||
continue
|
||||
}
|
||||
|
||||
path = unvendorPath(path)
|
||||
|
||||
if packages[path] != "" {
|
||||
continue
|
||||
}
|
||||
|
||||
packages[path] = name
|
||||
}
|
||||
return packages, nil
|
||||
}
|
||||
|
||||
func unvendorPath(path string) string {
|
||||
// notest
|
||||
i, ok := findVendor(path)
|
||||
if !ok {
|
||||
return path
|
||||
}
|
||||
return path[i+len("vendor/"):]
|
||||
}
|
||||
|
||||
// FindVendor looks for the last non-terminating "vendor" path element in the given import path.
|
||||
// If there isn't one, FindVendor returns ok=false.
|
||||
// Otherwise, FindVendor returns ok=true and the index of the "vendor".
|
||||
// Copied from cmd/go/internal/load
|
||||
func findVendor(path string) (index int, ok bool) {
|
||||
// notest
|
||||
// Two cases, depending on internal at start of string or not.
|
||||
// The order matters: we must return the index of the final element,
|
||||
// because the final one is where the effective import path starts.
|
||||
switch {
|
||||
case strings.Contains(path, "/vendor/"):
|
||||
return strings.LastIndex(path, "/vendor/") + 1, true
|
||||
case strings.HasPrefix(path, "vendor/"):
|
||||
return 0, true
|
||||
}
|
||||
return 0, false
|
||||
}
|
||||
|
||||
func hasVendor(path string) bool {
|
||||
// notest
|
||||
_, v := findVendor(path)
|
||||
return v
|
||||
}
|
29
vendor/github.com/dave/jennifer/gennames/main.go
generated
vendored
Normal file
29
vendor/github.com/dave/jennifer/gennames/main.go
generated
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"flag"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// notest
|
||||
|
||||
var out = flag.String("output", "./package-names.go", "Output filename to write")
|
||||
var pkg = flag.String("package", "main", "Package name in generated file")
|
||||
var name = flag.String("name", "PackageNames", "Name of the variable to define")
|
||||
var filter = flag.String("filter", ".*", "Regex to filter paths (operates on full path including vendor directory)")
|
||||
var standard = flag.Bool("standard", false, "Use standard library packages")
|
||||
var novendor = flag.Bool("novendor", false, "Exclude packages in vendor directories")
|
||||
var goListPath = flag.String("path", "all", "Path to pass to go list command")
|
||||
flag.Parse()
|
||||
|
||||
buf := &bytes.Buffer{}
|
||||
if err := hints(buf, *pkg, *name, *goListPath, *filter, *standard, *novendor); err != nil {
|
||||
log.Fatal(err.Error())
|
||||
}
|
||||
if err := ioutil.WriteFile(*out, buf.Bytes(), 0644); err != nil {
|
||||
log.Fatal(err.Error())
|
||||
}
|
||||
}
|
19
vendor/github.com/dave/jennifer/jen/add.go
generated
vendored
Normal file
19
vendor/github.com/dave/jennifer/jen/add.go
generated
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
package jen
|
||||
|
||||
// Add appends the provided items to the statement.
|
||||
func Add(code ...Code) *Statement {
|
||||
return newStatement().Add(code...)
|
||||
}
|
||||
|
||||
// Add appends the provided items to the statement.
|
||||
func (g *Group) Add(code ...Code) *Statement {
|
||||
s := Add(code...)
|
||||
g.items = append(g.items, s)
|
||||
return s
|
||||
}
|
||||
|
||||
// Add appends the provided items to the statement.
|
||||
func (s *Statement) Add(code ...Code) *Statement {
|
||||
*s = append(*s, code...)
|
||||
return s
|
||||
}
|
108
vendor/github.com/dave/jennifer/jen/comments.go
generated
vendored
Normal file
108
vendor/github.com/dave/jennifer/jen/comments.go
generated
vendored
Normal file
@ -0,0 +1,108 @@
|
||||
package jen
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Comment adds a comment. If the provided string contains a newline, the
|
||||
// comment is formatted in multiline style. If the comment string starts
|
||||
// with "//" or "/*", the automatic formatting is disabled and the string is
|
||||
// rendered directly.
|
||||
func Comment(str string) *Statement {
|
||||
return newStatement().Comment(str)
|
||||
}
|
||||
|
||||
// Comment adds a comment. If the provided string contains a newline, the
|
||||
// comment is formatted in multiline style. If the comment string starts
|
||||
// with "//" or "/*", the automatic formatting is disabled and the string is
|
||||
// rendered directly.
|
||||
func (g *Group) Comment(str string) *Statement {
|
||||
s := Comment(str)
|
||||
g.items = append(g.items, s)
|
||||
return s
|
||||
}
|
||||
|
||||
// Comment adds a comment. If the provided string contains a newline, the
|
||||
// comment is formatted in multiline style. If the comment string starts
|
||||
// with "//" or "/*", the automatic formatting is disabled and the string is
|
||||
// rendered directly.
|
||||
func (s *Statement) Comment(str string) *Statement {
|
||||
c := comment{
|
||||
comment: str,
|
||||
}
|
||||
*s = append(*s, c)
|
||||
return s
|
||||
}
|
||||
|
||||
// Commentf adds a comment, using a format string and a list of parameters. If
|
||||
// the provided string contains a newline, the comment is formatted in
|
||||
// multiline style. If the comment string starts with "//" or "/*", the
|
||||
// automatic formatting is disabled and the string is rendered directly.
|
||||
func Commentf(format string, a ...interface{}) *Statement {
|
||||
return newStatement().Commentf(format, a...)
|
||||
}
|
||||
|
||||
// Commentf adds a comment, using a format string and a list of parameters. If
|
||||
// the provided string contains a newline, the comment is formatted in
|
||||
// multiline style. If the comment string starts with "//" or "/*", the
|
||||
// automatic formatting is disabled and the string is rendered directly.
|
||||
func (g *Group) Commentf(format string, a ...interface{}) *Statement {
|
||||
s := Commentf(format, a...)
|
||||
g.items = append(g.items, s)
|
||||
return s
|
||||
}
|
||||
|
||||
// Commentf adds a comment, using a format string and a list of parameters. If
|
||||
// the provided string contains a newline, the comment is formatted in
|
||||
// multiline style. If the comment string starts with "//" or "/*", the
|
||||
// automatic formatting is disabled and the string is rendered directly.
|
||||
func (s *Statement) Commentf(format string, a ...interface{}) *Statement {
|
||||
c := comment{
|
||||
comment: fmt.Sprintf(format, a...),
|
||||
}
|
||||
*s = append(*s, c)
|
||||
return s
|
||||
}
|
||||
|
||||
type comment struct {
|
||||
comment string
|
||||
}
|
||||
|
||||
func (c comment) isNull(f *File) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (c comment) render(f *File, w io.Writer, s *Statement) error {
|
||||
if strings.HasPrefix(c.comment, "//") || strings.HasPrefix(c.comment, "/*") {
|
||||
// automatic formatting disabled.
|
||||
if _, err := w.Write([]byte(c.comment)); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
if strings.Contains(c.comment, "\n") {
|
||||
if _, err := w.Write([]byte("/*\n")); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
if _, err := w.Write([]byte("// ")); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if _, err := w.Write([]byte(c.comment)); err != nil {
|
||||
return err
|
||||
}
|
||||
if strings.Contains(c.comment, "\n") {
|
||||
if !strings.HasSuffix(c.comment, "\n") {
|
||||
if _, err := w.Write([]byte("\n")); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if _, err := w.Write([]byte("*/")); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
61
vendor/github.com/dave/jennifer/jen/custom.go
generated
vendored
Normal file
61
vendor/github.com/dave/jennifer/jen/custom.go
generated
vendored
Normal file
@ -0,0 +1,61 @@
|
||||
package jen
|
||||
|
||||
// Options specifies options for the Custom method
|
||||
type Options struct {
|
||||
Open string
|
||||
Close string
|
||||
Separator string
|
||||
Multi bool
|
||||
}
|
||||
|
||||
// Custom renders a customized statement list. Pass in options to specify multi-line, and tokens for open, close, separator.
|
||||
func Custom(options Options, statements ...Code) *Statement {
|
||||
return newStatement().Custom(options, statements...)
|
||||
}
|
||||
|
||||
// Custom renders a customized statement list. Pass in options to specify multi-line, and tokens for open, close, separator.
|
||||
func (g *Group) Custom(options Options, statements ...Code) *Statement {
|
||||
s := Custom(options, statements...)
|
||||
g.items = append(g.items, s)
|
||||
return s
|
||||
}
|
||||
|
||||
// Custom renders a customized statement list. Pass in options to specify multi-line, and tokens for open, close, separator.
|
||||
func (s *Statement) Custom(options Options, statements ...Code) *Statement {
|
||||
g := &Group{
|
||||
close: options.Close,
|
||||
items: statements,
|
||||
multi: options.Multi,
|
||||
name: "custom",
|
||||
open: options.Open,
|
||||
separator: options.Separator,
|
||||
}
|
||||
*s = append(*s, g)
|
||||
return s
|
||||
}
|
||||
|
||||
// CustomFunc renders a customized statement list. Pass in options to specify multi-line, and tokens for open, close, separator.
|
||||
func CustomFunc(options Options, f func(*Group)) *Statement {
|
||||
return newStatement().CustomFunc(options, f)
|
||||
}
|
||||
|
||||
// CustomFunc renders a customized statement list. Pass in options to specify multi-line, and tokens for open, close, separator.
|
||||
func (g *Group) CustomFunc(options Options, f func(*Group)) *Statement {
|
||||
s := CustomFunc(options, f)
|
||||
g.items = append(g.items, s)
|
||||
return s
|
||||
}
|
||||
|
||||
// CustomFunc renders a customized statement list. Pass in options to specify multi-line, and tokens for open, close, separator.
|
||||
func (s *Statement) CustomFunc(options Options, f func(*Group)) *Statement {
|
||||
g := &Group{
|
||||
close: options.Close,
|
||||
multi: options.Multi,
|
||||
name: "custom",
|
||||
open: options.Open,
|
||||
separator: options.Separator,
|
||||
}
|
||||
f(g)
|
||||
*s = append(*s, g)
|
||||
return s
|
||||
}
|
81
vendor/github.com/dave/jennifer/jen/dict.go
generated
vendored
Normal file
81
vendor/github.com/dave/jennifer/jen/dict.go
generated
vendored
Normal file
@ -0,0 +1,81 @@
|
||||
package jen
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io"
|
||||
"sort"
|
||||
)
|
||||
|
||||
// Dict renders as key/value pairs. Use with Values for map or composite
|
||||
// literals.
|
||||
type Dict map[Code]Code
|
||||
|
||||
// DictFunc executes a func(Dict) to generate the value. Use with Values for
|
||||
// map or composite literals.
|
||||
func DictFunc(f func(Dict)) Dict {
|
||||
d := Dict{}
|
||||
f(d)
|
||||
return d
|
||||
}
|
||||
|
||||
func (d Dict) render(f *File, w io.Writer, s *Statement) error {
|
||||
first := true
|
||||
// must order keys to ensure repeatable source
|
||||
type kv struct {
|
||||
k Code
|
||||
v Code
|
||||
}
|
||||
lookup := map[string]kv{}
|
||||
keys := []string{}
|
||||
for k, v := range d {
|
||||
if k.isNull(f) || v.isNull(f) {
|
||||
continue
|
||||
}
|
||||
buf := &bytes.Buffer{}
|
||||
if err := k.render(f, buf, nil); err != nil {
|
||||
return err
|
||||
}
|
||||
keys = append(keys, buf.String())
|
||||
lookup[buf.String()] = kv{k: k, v: v}
|
||||
}
|
||||
sort.Strings(keys)
|
||||
for _, key := range keys {
|
||||
k := lookup[key].k
|
||||
v := lookup[key].v
|
||||
if first && len(keys) > 1 {
|
||||
if _, err := w.Write([]byte("\n")); err != nil {
|
||||
return err
|
||||
}
|
||||
first = false
|
||||
}
|
||||
if err := k.render(f, w, nil); err != nil {
|
||||
return err
|
||||
}
|
||||
if _, err := w.Write([]byte(":")); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := v.render(f, w, nil); err != nil {
|
||||
return err
|
||||
}
|
||||
if len(keys) > 1 {
|
||||
if _, err := w.Write([]byte(",\n")); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d Dict) isNull(f *File) bool {
|
||||
if d == nil || len(d) == 0 {
|
||||
return true
|
||||
}
|
||||
for k, v := range d {
|
||||
if !k.isNull(f) && !v.isNull(f) {
|
||||
// if any of the key/value pairs are both not null, the Dict is not
|
||||
// null
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
22
vendor/github.com/dave/jennifer/jen/do.go
generated
vendored
Normal file
22
vendor/github.com/dave/jennifer/jen/do.go
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
package jen
|
||||
|
||||
// Do calls the provided function with the statement as a parameter. Use for
|
||||
// embedding logic.
|
||||
func Do(f func(*Statement)) *Statement {
|
||||
return newStatement().Do(f)
|
||||
}
|
||||
|
||||
// Do calls the provided function with the statement as a parameter. Use for
|
||||
// embedding logic.
|
||||
func (g *Group) Do(f func(*Statement)) *Statement {
|
||||
s := Do(f)
|
||||
g.items = append(g.items, s)
|
||||
return s
|
||||
}
|
||||
|
||||
// Do calls the provided function with the statement as a parameter. Use for
|
||||
// embedding logic.
|
||||
func (s *Statement) Do(f func(*Statement)) *Statement {
|
||||
f(s)
|
||||
return s
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user