Implement SingleTransformerConfig
This commit is contained in:
parent
7d3bf1f0f6
commit
33f1f62c11
@ -16,11 +16,11 @@ package ilk
|
||||
|
||||
import "github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
||||
|
||||
var DripFileIlkConfig = shared.TransformerConfig{
|
||||
var DripFileIlkConfig = shared.SingleTransformerConfig{
|
||||
TransformerName: "drip file ilk",
|
||||
ContractAddresses: []string{shared.DripContractAddress},
|
||||
ContractAbi: shared.DripABI,
|
||||
Topics: []string{shared.DripFileIlkSignature},
|
||||
Topic: shared.DripFileIlkSignature,
|
||||
StartingBlockNumber: 0,
|
||||
EndingBlockNumber: 10000000,
|
||||
}
|
||||
|
@ -16,11 +16,11 @@ package repo
|
||||
|
||||
import "github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
||||
|
||||
var DripFileRepoConfig = shared.TransformerConfig{
|
||||
var DripFileRepoConfig = shared.SingleTransformerConfig{
|
||||
TransformerName: "drip file repo",
|
||||
ContractAddresses: []string{shared.DripContractAddress},
|
||||
ContractAbi: shared.DripABI,
|
||||
Topics: []string{shared.DripFileRepoSignature},
|
||||
Topic: shared.DripFileRepoSignature,
|
||||
StartingBlockNumber: 0,
|
||||
EndingBlockNumber: 10000000,
|
||||
}
|
||||
|
@ -16,11 +16,11 @@ package vow
|
||||
|
||||
import "github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
||||
|
||||
var DripFileVowConfig = shared.TransformerConfig{
|
||||
var DripFileVowConfig = shared.SingleTransformerConfig{
|
||||
TransformerName: "drip file vow",
|
||||
ContractAddresses: []string{shared.DripContractAddress},
|
||||
ContractAbi: shared.DripABI,
|
||||
Topics: []string{shared.DripFileVowSignature},
|
||||
Topic: shared.DripFileVowSignature,
|
||||
StartingBlockNumber: 0,
|
||||
EndingBlockNumber: 10000000,
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ import (
|
||||
)
|
||||
|
||||
type Transformer struct {
|
||||
Config shared.TransformerConfig
|
||||
Config shared.SingleTransformerConfig
|
||||
Converter Converter
|
||||
Repository Repository
|
||||
Fetcher shared.SettableLogFetcher
|
||||
@ -57,16 +57,14 @@ func (transformer Transformer) Execute() error {
|
||||
return err
|
||||
}
|
||||
|
||||
// Grab event signature from transformer config
|
||||
// (Double-array structure required for go-ethereum FilterQuery)
|
||||
var topic = [][]common.Hash{{common.HexToHash(transformer.Config.Topic)}}
|
||||
|
||||
log.Printf("Fetching %v event logs for %d headers \n", transformerName, len(missingHeaders))
|
||||
for _, header := range missingHeaders {
|
||||
// Grab topics from config
|
||||
var topics [][]common.Hash
|
||||
for _, topic := range transformer.Config.Topics {
|
||||
topics = append(topics, []common.Hash{common.HexToHash(topic)})
|
||||
}
|
||||
|
||||
// Fetch the missing logs for a given header
|
||||
matchingLogs, err := transformer.Fetcher.FetchLogs(transformer.Config.ContractAddresses, topics, header.BlockNumber)
|
||||
matchingLogs, err := transformer.Fetcher.FetchLogs(transformer.Config.ContractAddresses, topic, header.BlockNumber)
|
||||
if err != nil {
|
||||
log.Printf("Error fetching matching logs in %v transformer: %v", transformerName, err)
|
||||
return err
|
||||
|
@ -18,11 +18,11 @@ import (
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
||||
)
|
||||
|
||||
var DebtCeilingFileConfig = shared.TransformerConfig{
|
||||
var DebtCeilingFileConfig = shared.SingleTransformerConfig{
|
||||
TransformerName: "pit file debt ceiling",
|
||||
ContractAddresses: []string{shared.PitContractAddress},
|
||||
ContractAbi: shared.PitABI,
|
||||
Topics: []string{shared.PitFileDebtCeilingSignature},
|
||||
Topic: shared.PitFileDebtCeilingSignature,
|
||||
StartingBlockNumber: 0,
|
||||
EndingBlockNumber: 10000000,
|
||||
}
|
||||
|
@ -18,11 +18,11 @@ import (
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
||||
)
|
||||
|
||||
var IlkFileConfig = shared.TransformerConfig{
|
||||
var IlkFileConfig = shared.SingleTransformerConfig{
|
||||
TransformerName: "pit file ilk",
|
||||
ContractAddresses: []string{shared.PitContractAddress},
|
||||
ContractAbi: shared.PitABI,
|
||||
Topics: []string{shared.PitFileIlkSignature},
|
||||
Topic: shared.PitFileIlkSignature,
|
||||
StartingBlockNumber: 0,
|
||||
EndingBlockNumber: 10000000,
|
||||
}
|
||||
|
@ -18,11 +18,11 @@ import (
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
||||
)
|
||||
|
||||
var StabilityFeeFileConfig = shared.TransformerConfig{
|
||||
var StabilityFeeFileConfig = shared.SingleTransformerConfig{
|
||||
TransformerName: "pit file stability fee",
|
||||
ContractAddresses: []string{shared.PitContractAddress},
|
||||
ContractAbi: shared.PitABI,
|
||||
Topics: []string{shared.PitFileStabilityFeeSignature},
|
||||
Topic: shared.PitFileStabilityFeeSignature,
|
||||
StartingBlockNumber: 0,
|
||||
EndingBlockNumber: 10000000,
|
||||
}
|
||||
|
@ -36,6 +36,15 @@ type TransformerConfig struct {
|
||||
EndingBlockNumber int64
|
||||
}
|
||||
|
||||
type SingleTransformerConfig struct {
|
||||
TransformerName string
|
||||
ContractAddresses []string
|
||||
ContractAbi string
|
||||
Topic string
|
||||
StartingBlockNumber int64
|
||||
EndingBlockNumber int64
|
||||
}
|
||||
|
||||
func HexToInt64(byteString string) int64 {
|
||||
value := common.HexToHash(byteString)
|
||||
return value.Big().Int64()
|
||||
|
@ -16,11 +16,11 @@ package tend
|
||||
|
||||
import "github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
||||
|
||||
var TendConfig = shared.TransformerConfig{
|
||||
var TendConfig = shared.SingleTransformerConfig{
|
||||
TransformerName: "tend",
|
||||
ContractAddresses: []string{shared.FlipperContractAddress},
|
||||
ContractAbi: shared.FlipperABI,
|
||||
Topics: []string{shared.TendFunctionSignature},
|
||||
Topic: shared.TendFunctionSignature,
|
||||
StartingBlockNumber: 0,
|
||||
EndingBlockNumber: 10000000,
|
||||
}
|
||||
|
@ -18,11 +18,11 @@ import (
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
||||
)
|
||||
|
||||
var VatInitConfig = shared.TransformerConfig{
|
||||
var VatInitConfig = shared.SingleTransformerConfig{
|
||||
TransformerName: "vat init",
|
||||
ContractAddresses: []string{shared.VatContractAddress},
|
||||
ContractAbi: shared.VatABI,
|
||||
Topics: []string{shared.VatInitSignature},
|
||||
Topic: shared.VatInitSignature,
|
||||
StartingBlockNumber: 0,
|
||||
EndingBlockNumber: 10000000,
|
||||
}
|
||||
|
@ -18,11 +18,11 @@ import (
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
||||
)
|
||||
|
||||
var VatMoveConfig = shared.TransformerConfig{
|
||||
var VatMoveConfig = shared.SingleTransformerConfig{
|
||||
TransformerName: "vat move",
|
||||
ContractAddresses: []string{shared.VatContractAddress},
|
||||
ContractAbi: shared.VatABI,
|
||||
Topics: []string{shared.VatMoveSignature},
|
||||
Topic: shared.VatMoveSignature,
|
||||
StartingBlockNumber: 0,
|
||||
EndingBlockNumber: 10000000,
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user