forked from cerc-io/ipld-eth-server
Flop deal (#39)
*Refactor deal transformer to take in several contract addresses * Add flop address to deal transformer
This commit is contained in:
parent
369939ad84
commit
b0cd852aa3
@ -0,0 +1,2 @@
|
|||||||
|
ALTER TABLE maker.deal
|
||||||
|
DROP COLUMN contract_address;
|
@ -0,0 +1,2 @@
|
|||||||
|
ALTER TABLE maker.deal
|
||||||
|
ADD COLUMN contract_address VARCHAR;
|
@ -105,7 +105,8 @@ CREATE TABLE maker.deal (
|
|||||||
header_id integer NOT NULL,
|
header_id integer NOT NULL,
|
||||||
bid_id numeric NOT NULL,
|
bid_id numeric NOT NULL,
|
||||||
tx_idx integer NOT NULL,
|
tx_idx integer NOT NULL,
|
||||||
raw_log jsonb
|
raw_log jsonb,
|
||||||
|
contract_address character varying
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var BiteConfig = shared.TransformerConfig{
|
var BiteConfig = shared.TransformerConfig{
|
||||||
ContractAddress: shared.CatContractAddress,
|
ContractAddresses: []string{shared.CatContractAddress},
|
||||||
ContractAbi: shared.CatABI,
|
ContractAbi: shared.CatABI,
|
||||||
Topics: []string{shared.BiteSignature},
|
Topics: []string{shared.BiteSignature},
|
||||||
StartingBlockNumber: 0,
|
StartingBlockNumber: 0,
|
||||||
|
@ -51,7 +51,7 @@ var _ = Describe("Integration tests", func() {
|
|||||||
topic0 := common.HexToHash(shared.BiteSignature)
|
topic0 := common.HexToHash(shared.BiteSignature)
|
||||||
topics := [][]common.Hash{{topic0}}
|
topics := [][]common.Hash{{topic0}}
|
||||||
|
|
||||||
result, err := realFetcher.FetchLogs(shared.CatContractAddress, topics, int64(26))
|
result, err := realFetcher.FetchLogs(bite.BiteConfig.ContractAddresses, topics, int64(26))
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
Expect(len(result) > 0).To(BeTrue())
|
Expect(len(result) > 0).To(BeTrue())
|
||||||
|
@ -62,14 +62,14 @@ func (b BiteTransformer) Execute() error {
|
|||||||
|
|
||||||
log.Printf("Fetching bite event logs for %d headers \n", len(missingHeaders))
|
log.Printf("Fetching bite event logs for %d headers \n", len(missingHeaders))
|
||||||
for _, header := range missingHeaders {
|
for _, header := range missingHeaders {
|
||||||
ethLogs, err := b.Fetcher.FetchLogs(config.ContractAddress, topics, header.BlockNumber)
|
ethLogs, err := b.Fetcher.FetchLogs(config.ContractAddresses, topics, header.BlockNumber)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("Error fetching matching logs:", err)
|
log.Println("Error fetching matching logs:", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, ethLog := range ethLogs {
|
for _, ethLog := range ethLogs {
|
||||||
entity, err := b.Converter.ToEntity(config.ContractAddress, config.ContractAbi, ethLog)
|
entity, err := b.Converter.ToEntity(ethLog.Address.Hex(), config.ContractAbi, ethLog)
|
||||||
model, err := b.Converter.ToModel(entity)
|
model, err := b.Converter.ToModel(entity)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("Error converting logs:", err)
|
log.Println("Error converting logs:", err)
|
||||||
|
@ -38,7 +38,6 @@ var _ = Describe("Bite Transformer", func() {
|
|||||||
var transformer bite.BiteTransformer
|
var transformer bite.BiteTransformer
|
||||||
var blockNumber1 = rand.Int63()
|
var blockNumber1 = rand.Int63()
|
||||||
var blockNumber2 = rand.Int63()
|
var blockNumber2 = rand.Int63()
|
||||||
var testConfig shared.TransformerConfig
|
|
||||||
|
|
||||||
BeforeEach(func() {
|
BeforeEach(func() {
|
||||||
repository = bite_mocks.MockBiteRepository{}
|
repository = bite_mocks.MockBiteRepository{}
|
||||||
@ -52,14 +51,7 @@ var _ = Describe("Bite Transformer", func() {
|
|||||||
Config: bite.BiteConfig,
|
Config: bite.BiteConfig,
|
||||||
}
|
}
|
||||||
|
|
||||||
testConfig = shared.TransformerConfig{
|
transformer.SetConfig(bite.BiteConfig)
|
||||||
ContractAddress: "0x12345",
|
|
||||||
ContractAbi: "test abi",
|
|
||||||
Topics: []string{shared.BiteSignature},
|
|
||||||
StartingBlockNumber: blockNumber1,
|
|
||||||
EndingBlockNumber: blockNumber2,
|
|
||||||
}
|
|
||||||
transformer.SetConfig(testConfig)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
It("gets missing headers for blocks in the configured range", func() {
|
It("gets missing headers for blocks in the configured range", func() {
|
||||||
@ -85,7 +77,7 @@ var _ = Describe("Bite Transformer", func() {
|
|||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(fetcher.FetchedBlocks).To(Equal([]int64{blockNumber1, blockNumber2}))
|
Expect(fetcher.FetchedBlocks).To(Equal([]int64{blockNumber1, blockNumber2}))
|
||||||
Expect(fetcher.FetchedTopics).To(Equal(expectedTopics))
|
Expect(fetcher.FetchedTopics).To(Equal(expectedTopics))
|
||||||
Expect(fetcher.FetchedContractAddress).To(Equal(bite.BiteConfig.ContractAddress))
|
Expect(fetcher.FetchedContractAddresses).To(Equal([][]string{bite.BiteConfig.ContractAddresses, bite.BiteConfig.ContractAddresses}))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("returns an error if fetching logs fails", func() {
|
It("returns an error if fetching logs fails", func() {
|
||||||
@ -103,7 +95,7 @@ var _ = Describe("Bite Transformer", func() {
|
|||||||
err := transformer.Execute()
|
err := transformer.Execute()
|
||||||
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(converter.ConverterContract).To(Equal(bite.BiteConfig.ContractAddress))
|
Expect(converter.ConverterContract).To(Equal(test_data.EthBiteLog.Address.Hex()))
|
||||||
Expect(converter.ConverterAbi).To(Equal(bite.BiteConfig.ContractAbi))
|
Expect(converter.ConverterAbi).To(Equal(bite.BiteConfig.ContractAbi))
|
||||||
Expect(converter.LogsToConvert).To(Equal([]types.Log{test_data.EthBiteLog}))
|
Expect(converter.LogsToConvert).To(Equal([]types.Log{test_data.EthBiteLog}))
|
||||||
})
|
})
|
||||||
|
@ -17,7 +17,7 @@ package deal
|
|||||||
import "github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
import "github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
||||||
|
|
||||||
var Config = shared.TransformerConfig{
|
var Config = shared.TransformerConfig{
|
||||||
ContractAddress: shared.FlipperContractAddress,
|
ContractAddresses: []string{shared.FlipperContractAddress, shared.FlopperContractAddress},
|
||||||
ContractAbi: shared.FlipperABI,
|
ContractAbi: shared.FlipperABI,
|
||||||
Topics: []string{shared.DealSignature},
|
Topics: []string{shared.DealSignature},
|
||||||
StartingBlockNumber: 0,
|
StartingBlockNumber: 0,
|
||||||
|
@ -46,11 +46,13 @@ func (DealConverter) ToModels(ethLogs []types.Log) (result []DealModel, err erro
|
|||||||
|
|
||||||
model := DealModel{
|
model := DealModel{
|
||||||
BidId: bidId.String(),
|
BidId: bidId.String(),
|
||||||
|
ContractAddress: log.Address.Hex(),
|
||||||
TransactionIndex: log.TxIndex,
|
TransactionIndex: log.TxIndex,
|
||||||
Raw: raw,
|
Raw: raw,
|
||||||
}
|
}
|
||||||
result = append(result, model)
|
result = append(result, model)
|
||||||
}
|
}
|
||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@ package deal
|
|||||||
|
|
||||||
type DealModel struct {
|
type DealModel struct {
|
||||||
BidId string `db:"bid_id"`
|
BidId string `db:"bid_id"`
|
||||||
|
ContractAddress string `db:"contract_address"`
|
||||||
TransactionIndex uint `db:"tx_idx"`
|
TransactionIndex uint `db:"tx_idx"`
|
||||||
Raw []byte `db:"raw_log"`
|
Raw []byte `db:"raw_log"`
|
||||||
}
|
}
|
||||||
|
@ -38,9 +38,9 @@ func (r DealRepository) Create(headerId int64, models []DealModel) error {
|
|||||||
}
|
}
|
||||||
for _, model := range models {
|
for _, model := range models {
|
||||||
_, err = tx.Exec(
|
_, err = tx.Exec(
|
||||||
`INSERT into maker.deal (header_id, bid_id, tx_idx, raw_log)
|
`INSERT into maker.deal (header_id, bid_id, contract_address, tx_idx, raw_log)
|
||||||
VALUES($1, $2, $3, $4)`,
|
VALUES($1, $2, $3, $4, $5)`,
|
||||||
headerId, model.BidId, model.TransactionIndex, model.Raw,
|
headerId, model.BidId, model.ContractAddress, model.TransactionIndex, model.Raw,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
tx.Rollback()
|
tx.Rollback()
|
||||||
|
@ -57,9 +57,10 @@ var _ = Describe("Deal Repository", func() {
|
|||||||
db.QueryRow(`SELECT count(*) FROM maker.deal`).Scan(&count)
|
db.QueryRow(`SELECT count(*) FROM maker.deal`).Scan(&count)
|
||||||
Expect(count).To(Equal(1))
|
Expect(count).To(Equal(1))
|
||||||
var dbResult deal.DealModel
|
var dbResult deal.DealModel
|
||||||
err = db.Get(&dbResult, `SELECT bid_id, tx_idx, raw_log FROM maker.deal WHERE header_id = $1`, headerId)
|
err = db.Get(&dbResult, `SELECT bid_id, contract_address, tx_idx, raw_log FROM maker.deal WHERE header_id = $1`, headerId)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(dbResult.BidId).To(Equal(test_data.DealModel.BidId))
|
Expect(dbResult.BidId).To(Equal(test_data.DealModel.BidId))
|
||||||
|
Expect(dbResult.ContractAddress).To(Equal(test_data.DealModel.ContractAddress))
|
||||||
Expect(dbResult.TransactionIndex).To(Equal(test_data.DealModel.TransactionIndex))
|
Expect(dbResult.TransactionIndex).To(Equal(test_data.DealModel.TransactionIndex))
|
||||||
Expect(dbResult.Raw).To(MatchJSON(test_data.DealModel.Raw))
|
Expect(dbResult.Raw).To(MatchJSON(test_data.DealModel.Raw))
|
||||||
})
|
})
|
||||||
|
@ -58,7 +58,7 @@ func (t DealTransformer) Execute() error {
|
|||||||
|
|
||||||
log.Printf("Fetching deal event logs for %d headers \n", len(headers))
|
log.Printf("Fetching deal event logs for %d headers \n", len(headers))
|
||||||
for _, header := range headers {
|
for _, header := range headers {
|
||||||
ethLogs, err := t.Fetcher.FetchLogs(config.ContractAddress, topics, header.BlockNumber)
|
ethLogs, err := t.Fetcher.FetchLogs(config.ContractAddresses, topics, header.BlockNumber)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("Error fetching deal logs:", err)
|
log.Println("Error fetching deal logs:", err)
|
||||||
return err
|
return err
|
||||||
|
@ -68,7 +68,7 @@ var _ = Describe("DealTransformer", func() {
|
|||||||
dealRepository.SetMissingHeaders([]core.Header{header1, header2})
|
dealRepository.SetMissingHeaders([]core.Header{header1, header2})
|
||||||
err := transformer.Execute()
|
err := transformer.Execute()
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(fetcher.FetchedContractAddress).To(Equal(config.ContractAddress))
|
Expect(fetcher.FetchedContractAddresses).To(Equal([][]string{config.ContractAddresses, config.ContractAddresses}))
|
||||||
expectedTopics := [][]common.Hash{{common.HexToHash(shared.DealSignature)}}
|
expectedTopics := [][]common.Hash{{common.HexToHash(shared.DealSignature)}}
|
||||||
Expect(fetcher.FetchedTopics).To(Equal(expectedTopics))
|
Expect(fetcher.FetchedTopics).To(Equal(expectedTopics))
|
||||||
Expect(fetcher.FetchedBlocks).To(Equal([]int64{header1.BlockNumber, header2.BlockNumber}))
|
Expect(fetcher.FetchedBlocks).To(Equal([]int64{header1.BlockNumber, header2.BlockNumber}))
|
||||||
|
@ -17,7 +17,7 @@ package dent
|
|||||||
import "github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
import "github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
||||||
|
|
||||||
var DentConfig = shared.TransformerConfig{
|
var DentConfig = shared.TransformerConfig{
|
||||||
ContractAddress: shared.FlipperContractAddress,
|
ContractAddresses: []string{shared.FlipperContractAddress},
|
||||||
ContractAbi: shared.FlipperABI,
|
ContractAbi: shared.FlipperABI,
|
||||||
Topics: []string{shared.DentFunctionSignature},
|
Topics: []string{shared.DentFunctionSignature},
|
||||||
StartingBlockNumber: 0,
|
StartingBlockNumber: 0,
|
||||||
|
@ -53,7 +53,8 @@ func (t DentTransformer) Execute() error {
|
|||||||
headers, err := t.Repository.MissingHeaders(config.StartingBlockNumber, config.EndingBlockNumber)
|
headers, err := t.Repository.MissingHeaders(config.StartingBlockNumber, config.EndingBlockNumber)
|
||||||
log.Printf("Fetching dent event logs for %d headers \n", len(headers))
|
log.Printf("Fetching dent event logs for %d headers \n", len(headers))
|
||||||
for _, header := range headers {
|
for _, header := range headers {
|
||||||
ethLogs, err := t.Fetcher.FetchLogs(config.ContractAddress, topics, header.BlockNumber)
|
ethLogs, err := t.Fetcher.FetchLogs(config.ContractAddresses, topics, header.BlockNumber)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("Error fetching dent logs:", err)
|
log.Println("Error fetching dent logs:", err)
|
||||||
return err
|
return err
|
||||||
|
@ -73,7 +73,7 @@ var _ = Describe("DentTransformer", func() {
|
|||||||
err := transformer.Execute()
|
err := transformer.Execute()
|
||||||
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(fetcher.FetchedContractAddress).To(Equal(config.ContractAddress))
|
Expect(fetcher.FetchedContractAddresses).To(Equal([][]string{config.ContractAddresses, config.ContractAddresses}))
|
||||||
expectedTopics := [][]common.Hash{{common.HexToHash(shared.DentFunctionSignature)}}
|
expectedTopics := [][]common.Hash{{common.HexToHash(shared.DentFunctionSignature)}}
|
||||||
Expect(fetcher.FetchedTopics).To(Equal(expectedTopics))
|
Expect(fetcher.FetchedTopics).To(Equal(expectedTopics))
|
||||||
Expect(fetcher.FetchedBlocks).To(Equal([]int64{header1.BlockNumber, header2.BlockNumber}))
|
Expect(fetcher.FetchedBlocks).To(Equal([]int64{header1.BlockNumber, header2.BlockNumber}))
|
||||||
|
@ -17,7 +17,7 @@ package drip_drip
|
|||||||
import "github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
import "github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
||||||
|
|
||||||
var DripDripConfig = shared.TransformerConfig{
|
var DripDripConfig = shared.TransformerConfig{
|
||||||
ContractAddress: shared.DripContractAddress,
|
ContractAddresses: []string{shared.DripContractAddress},
|
||||||
ContractAbi: shared.DripABI,
|
ContractAbi: shared.DripABI,
|
||||||
Topics: []string{shared.DripDripSignature},
|
Topics: []string{shared.DripDripSignature},
|
||||||
StartingBlockNumber: 0,
|
StartingBlockNumber: 0,
|
||||||
|
@ -55,7 +55,7 @@ func (transformer DripDripTransformer) Execute() error {
|
|||||||
log.Printf("Fetching drip drip event logs for %d headers \n", len(missingHeaders))
|
log.Printf("Fetching drip drip event logs for %d headers \n", len(missingHeaders))
|
||||||
for _, header := range missingHeaders {
|
for _, header := range missingHeaders {
|
||||||
topics := [][]common.Hash{{common.HexToHash(shared.DripDripSignature)}}
|
topics := [][]common.Hash{{common.HexToHash(shared.DripDripSignature)}}
|
||||||
matchingLogs, err := transformer.Fetcher.FetchLogs(transformer.Config.ContractAddress, topics, header.BlockNumber)
|
matchingLogs, err := transformer.Fetcher.FetchLogs(transformer.Config.ContractAddresses, topics, header.BlockNumber)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,7 @@ var _ = Describe("Drip drip transformer", func() {
|
|||||||
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(fetcher.FetchedBlocks).To(Equal([]int64{1, 2}))
|
Expect(fetcher.FetchedBlocks).To(Equal([]int64{1, 2}))
|
||||||
Expect(fetcher.FetchedContractAddress).To(Equal(drip_drip.DripDripConfig.ContractAddress))
|
Expect(fetcher.FetchedContractAddresses).To(Equal([][]string{drip_drip.DripDripConfig.ContractAddresses, drip_drip.DripDripConfig.ContractAddresses}))
|
||||||
Expect(fetcher.FetchedTopics).To(Equal([][]common.Hash{{common.HexToHash(shared.DripDripSignature)}}))
|
Expect(fetcher.FetchedTopics).To(Equal([][]common.Hash{{common.HexToHash(shared.DripDripSignature)}}))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ package drip_file
|
|||||||
import "github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
import "github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
||||||
|
|
||||||
var DripFileConfig = shared.TransformerConfig{
|
var DripFileConfig = shared.TransformerConfig{
|
||||||
ContractAddress: shared.DripContractAddress,
|
ContractAddresses: []string{shared.DripContractAddress},
|
||||||
ContractAbi: shared.DripABI,
|
ContractAbi: shared.DripABI,
|
||||||
Topics: []string{shared.DripFileIlkSignature, shared.DripFileRepoSignature},
|
Topics: []string{shared.DripFileIlkSignature, shared.DripFileRepoSignature},
|
||||||
StartingBlockNumber: 0,
|
StartingBlockNumber: 0,
|
||||||
|
@ -56,7 +56,7 @@ func (transformer DripFileIlkTransformer) Execute() error {
|
|||||||
log.Printf("Fetching drip file ilk event logs for %d headers \n", len(missingHeaders))
|
log.Printf("Fetching drip file ilk event logs for %d headers \n", len(missingHeaders))
|
||||||
for _, header := range missingHeaders {
|
for _, header := range missingHeaders {
|
||||||
topics := [][]common.Hash{{common.HexToHash(shared.DripFileIlkSignature)}}
|
topics := [][]common.Hash{{common.HexToHash(shared.DripFileIlkSignature)}}
|
||||||
matchingLogs, err := transformer.Fetcher.FetchLogs(drip_file.DripFileConfig.ContractAddress, topics, header.BlockNumber)
|
matchingLogs, err := transformer.Fetcher.FetchLogs(drip_file.DripFileConfig.ContractAddresses, topics, header.BlockNumber)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,7 @@ var _ = Describe("Drip file ilk transformer", func() {
|
|||||||
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(fetcher.FetchedBlocks).To(Equal([]int64{1, 2}))
|
Expect(fetcher.FetchedBlocks).To(Equal([]int64{1, 2}))
|
||||||
Expect(fetcher.FetchedContractAddress).To(Equal(drip_file.DripFileConfig.ContractAddress))
|
Expect(fetcher.FetchedContractAddresses).To(Equal([][]string{drip_file.DripFileConfig.ContractAddresses, drip_file.DripFileConfig.ContractAddresses}))
|
||||||
Expect(fetcher.FetchedTopics).To(Equal([][]common.Hash{{common.HexToHash(shared.DripFileIlkSignature)}}))
|
Expect(fetcher.FetchedTopics).To(Equal([][]common.Hash{{common.HexToHash(shared.DripFileIlkSignature)}}))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ func (transformer DripFileRepoTransformer) Execute() error {
|
|||||||
log.Printf("Fetching drip file repo event logs for %d headers \n", len(missingHeaders))
|
log.Printf("Fetching drip file repo event logs for %d headers \n", len(missingHeaders))
|
||||||
for _, header := range missingHeaders {
|
for _, header := range missingHeaders {
|
||||||
topics := [][]common.Hash{{common.HexToHash(shared.DripFileRepoSignature)}}
|
topics := [][]common.Hash{{common.HexToHash(shared.DripFileRepoSignature)}}
|
||||||
matchingLogs, err := transformer.Fetcher.FetchLogs(drip_file.DripFileConfig.ContractAddress, topics, header.BlockNumber)
|
matchingLogs, err := transformer.Fetcher.FetchLogs(drip_file.DripFileConfig.ContractAddresses, topics, header.BlockNumber)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,7 @@ var _ = Describe("Drip file repo transformer", func() {
|
|||||||
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(fetcher.FetchedBlocks).To(Equal([]int64{1, 2}))
|
Expect(fetcher.FetchedBlocks).To(Equal([]int64{1, 2}))
|
||||||
Expect(fetcher.FetchedContractAddress).To(Equal(drip_file.DripFileConfig.ContractAddress))
|
Expect(fetcher.FetchedContractAddresses).To(Equal([][]string{drip_file.DripFileConfig.ContractAddresses, drip_file.DripFileConfig.ContractAddresses}))
|
||||||
Expect(fetcher.FetchedTopics).To(Equal([][]common.Hash{{common.HexToHash(shared.DripFileRepoSignature)}}))
|
Expect(fetcher.FetchedTopics).To(Equal([][]common.Hash{{common.HexToHash(shared.DripFileRepoSignature)}}))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ func (transformer DripFileVowTransformer) Execute() error {
|
|||||||
log.Printf("Fetching drip file vow event logs for %d headers \n", len(missingHeaders))
|
log.Printf("Fetching drip file vow event logs for %d headers \n", len(missingHeaders))
|
||||||
for _, header := range missingHeaders {
|
for _, header := range missingHeaders {
|
||||||
topics := [][]common.Hash{{common.HexToHash(shared.DripFileVowSignature)}}
|
topics := [][]common.Hash{{common.HexToHash(shared.DripFileVowSignature)}}
|
||||||
matchingLogs, err := transformer.Fetcher.FetchLogs(drip_file.DripFileConfig.ContractAddress, topics, header.BlockNumber)
|
matchingLogs, err := transformer.Fetcher.FetchLogs(drip_file.DripFileConfig.ContractAddresses, topics, header.BlockNumber)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,7 @@ var _ = Describe("Drip file vow transformer", func() {
|
|||||||
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(fetcher.FetchedBlocks).To(Equal([]int64{1, 2}))
|
Expect(fetcher.FetchedBlocks).To(Equal([]int64{1, 2}))
|
||||||
Expect(fetcher.FetchedContractAddress).To(Equal(drip_file.DripFileConfig.ContractAddress))
|
Expect(fetcher.FetchedContractAddresses).To(Equal([][]string{drip_file.DripFileConfig.ContractAddresses, drip_file.DripFileConfig.ContractAddresses}))
|
||||||
Expect(fetcher.FetchedTopics).To(Equal([][]common.Hash{{common.HexToHash(shared.DripFileVowSignature)}}))
|
Expect(fetcher.FetchedTopics).To(Equal([][]common.Hash{{common.HexToHash(shared.DripFileVowSignature)}}))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ package flip_kick
|
|||||||
import "github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
import "github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
||||||
|
|
||||||
var FlipKickConfig = shared.TransformerConfig{
|
var FlipKickConfig = shared.TransformerConfig{
|
||||||
ContractAddress: shared.FlipperContractAddress,
|
ContractAddresses: []string{shared.FlipperContractAddress},
|
||||||
ContractAbi: shared.FlipperABI,
|
ContractAbi: shared.FlipperABI,
|
||||||
Topics: []string{shared.FlipKickSignature},
|
Topics: []string{shared.FlipKickSignature},
|
||||||
StartingBlockNumber: 0,
|
StartingBlockNumber: 0,
|
||||||
|
@ -28,16 +28,16 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Converter interface {
|
type Converter interface {
|
||||||
ToEntities(contractAddress string, contractAbi string, ethLogs []types.Log) ([]FlipKickEntity, error)
|
ToEntities(contractAbi string, ethLogs []types.Log) ([]FlipKickEntity, error)
|
||||||
ToModels(flipKicks []FlipKickEntity) ([]FlipKickModel, error)
|
ToModels(flipKicks []FlipKickEntity) ([]FlipKickModel, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type FlipKickConverter struct{}
|
type FlipKickConverter struct{}
|
||||||
|
|
||||||
func (FlipKickConverter) ToEntities(contractAddress string, contractAbi string, ethLogs []types.Log) (results []FlipKickEntity, err error) {
|
func (FlipKickConverter) ToEntities(contractAbi string, ethLogs []types.Log) (results []FlipKickEntity, err error) {
|
||||||
for _, ethLog := range ethLogs {
|
for _, ethLog := range ethLogs {
|
||||||
entity := &FlipKickEntity{}
|
entity := &FlipKickEntity{}
|
||||||
address := common.HexToAddress(contractAddress)
|
address := ethLog.Address
|
||||||
abi, err := geth.ParseAbi(contractAbi)
|
abi, err := geth.ParseAbi(contractAbi)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -33,7 +33,7 @@ var _ = Describe("FlipKick Converter", func() {
|
|||||||
|
|
||||||
Describe("ToEntity", func() {
|
Describe("ToEntity", func() {
|
||||||
It("converts an Eth Log to a FlipKickEntity", func() {
|
It("converts an Eth Log to a FlipKickEntity", func() {
|
||||||
entities, err := converter.ToEntities(shared.FlipperContractAddress, shared.FlipperABI, []types.Log{test_data.EthFlipKickLog})
|
entities, err := converter.ToEntities(shared.FlipperABI, []types.Log{test_data.EthFlipKickLog})
|
||||||
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(len(entities)).To(Equal(1))
|
Expect(len(entities)).To(Equal(1))
|
||||||
@ -49,7 +49,7 @@ var _ = Describe("FlipKick Converter", func() {
|
|||||||
})
|
})
|
||||||
|
|
||||||
It("returns an error if converting log to entity fails", func() {
|
It("returns an error if converting log to entity fails", func() {
|
||||||
_, err := converter.ToEntities(shared.FlipperContractAddress, "error abi", []types.Log{test_data.EthFlipKickLog})
|
_, err := converter.ToEntities("error abi", []types.Log{test_data.EthFlipKickLog})
|
||||||
|
|
||||||
Expect(err).To(HaveOccurred())
|
Expect(err).To(HaveOccurred())
|
||||||
})
|
})
|
||||||
|
@ -91,10 +91,11 @@ func (fkt FlipKickTransformer) Execute() error {
|
|||||||
log.Printf("Fetching flip kick event logs for %d headers \n", len(headers))
|
log.Printf("Fetching flip kick event logs for %d headers \n", len(headers))
|
||||||
var resultingErrors []error
|
var resultingErrors []error
|
||||||
for _, header := range headers {
|
for _, header := range headers {
|
||||||
ethLogs, err := fkt.Fetcher.FetchLogs(config.ContractAddress, topics, header.BlockNumber)
|
ethLogs, err := fkt.Fetcher.FetchLogs(config.ContractAddresses, topics, header.BlockNumber)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
resultingErrors = append(resultingErrors, newTransformerError(err, header.BlockNumber, FetcherError))
|
resultingErrors = append(resultingErrors, newTransformerError(err, header.BlockNumber, FetcherError))
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(ethLogs) < 1 {
|
if len(ethLogs) < 1 {
|
||||||
err := fkt.Repository.MarkHeaderChecked(header.Id)
|
err := fkt.Repository.MarkHeaderChecked(header.Id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -102,7 +103,7 @@ func (fkt FlipKickTransformer) Execute() error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
entities, err := fkt.Converter.ToEntities(config.ContractAddress, config.ContractAbi, ethLogs)
|
entities, err := fkt.Converter.ToEntities(config.ContractAbi, ethLogs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
resultingErrors = append(resultingErrors, newTransformerError(err, header.BlockNumber, LogToEntityError))
|
resultingErrors = append(resultingErrors, newTransformerError(err, header.BlockNumber, LogToEntityError))
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,6 @@ var _ = Describe("FlipKick Transformer", func() {
|
|||||||
var fetcher mocks.MockLogFetcher
|
var fetcher mocks.MockLogFetcher
|
||||||
var converter flip_kick_mocks.MockFlipKickConverter
|
var converter flip_kick_mocks.MockFlipKickConverter
|
||||||
var repository flip_kick_mocks.MockFlipKickRepository
|
var repository flip_kick_mocks.MockFlipKickRepository
|
||||||
var testConfig shared.TransformerConfig
|
|
||||||
var blockNumber int64
|
var blockNumber int64
|
||||||
var headerId int64
|
var headerId int64
|
||||||
var headers []core.Header
|
var headers []core.Header
|
||||||
@ -51,16 +50,7 @@ var _ = Describe("FlipKick Transformer", func() {
|
|||||||
Converter: &converter,
|
Converter: &converter,
|
||||||
Repository: &repository,
|
Repository: &repository,
|
||||||
}
|
}
|
||||||
|
transformer.SetConfig(flip_kick.FlipKickConfig)
|
||||||
startingBlockNumber := rand.Int63()
|
|
||||||
testConfig = shared.TransformerConfig{
|
|
||||||
ContractAddress: "0x12345",
|
|
||||||
ContractAbi: "test abi",
|
|
||||||
Topics: []string{shared.FlipKickSignature},
|
|
||||||
StartingBlockNumber: startingBlockNumber,
|
|
||||||
EndingBlockNumber: startingBlockNumber + 5,
|
|
||||||
}
|
|
||||||
transformer.SetConfig(testConfig)
|
|
||||||
|
|
||||||
blockNumber = rand.Int63()
|
blockNumber = rand.Int63()
|
||||||
headerId = rand.Int63()
|
headerId = rand.Int63()
|
||||||
@ -83,7 +73,7 @@ var _ = Describe("FlipKick Transformer", func() {
|
|||||||
err := transformer.Execute()
|
err := transformer.Execute()
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
Expect(fetcher.FetchedContractAddress).To(Equal(testConfig.ContractAddress))
|
Expect(fetcher.FetchedContractAddresses).To(Equal([][]string{flip_kick.FlipKickConfig.ContractAddresses}))
|
||||||
Expect(fetcher.FetchedTopics).To(Equal(expectedTopics))
|
Expect(fetcher.FetchedTopics).To(Equal(expectedTopics))
|
||||||
Expect(fetcher.FetchedBlocks).To(Equal([]int64{blockNumber}))
|
Expect(fetcher.FetchedBlocks).To(Equal([]int64{blockNumber}))
|
||||||
})
|
})
|
||||||
@ -136,8 +126,8 @@ var _ = Describe("FlipKick Transformer", func() {
|
|||||||
err := transformer.Execute()
|
err := transformer.Execute()
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
Expect(converter.ConverterContract).To(Equal(testConfig.ContractAddress))
|
Expect(converter.ConverterContracts).To(Equal(flip_kick.FlipKickConfig.ContractAddresses))
|
||||||
Expect(converter.ConverterAbi).To(Equal(testConfig.ContractAbi))
|
Expect(converter.ConverterAbi).To(Equal(flip_kick.FlipKickConfig.ContractAbi))
|
||||||
Expect(converter.LogsToConvert).To(Equal(logs))
|
Expect(converter.LogsToConvert).To(Equal(logs))
|
||||||
Expect(converter.EntitiesToConvert).To(Equal([]flip_kick.FlipKickEntity{test_data.FlipKickEntity}))
|
Expect(converter.EntitiesToConvert).To(Equal([]flip_kick.FlipKickEntity{test_data.FlipKickEntity}))
|
||||||
})
|
})
|
||||||
@ -175,7 +165,7 @@ var _ = Describe("FlipKick Transformer", func() {
|
|||||||
err := transformer.Execute()
|
err := transformer.Execute()
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
Expect(repository.StartingBlockNumber).To(Equal(testConfig.StartingBlockNumber))
|
Expect(repository.StartingBlockNumber).To(Equal(flip_kick.FlipKickConfig.StartingBlockNumber))
|
||||||
Expect(repository.EndingBlockNumber).To(Equal(testConfig.EndingBlockNumber))
|
Expect(repository.EndingBlockNumber).To(Equal(flip_kick.FlipKickConfig.EndingBlockNumber))
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -17,7 +17,7 @@ package flop_kick
|
|||||||
import "github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
import "github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
||||||
|
|
||||||
var Config = shared.TransformerConfig{
|
var Config = shared.TransformerConfig{
|
||||||
ContractAddress: shared.FlopperContractAddress,
|
ContractAddresses: []string{shared.FlopperContractAddress},
|
||||||
ContractAbi: shared.FlopperABI,
|
ContractAbi: shared.FlopperABI,
|
||||||
Topics: []string{shared.FlopKickSignature},
|
Topics: []string{shared.FlopKickSignature},
|
||||||
StartingBlockNumber: 0,
|
StartingBlockNumber: 0,
|
||||||
|
@ -19,7 +19,6 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/accounts/abi/bind"
|
"github.com/ethereum/go-ethereum/accounts/abi/bind"
|
||||||
"github.com/ethereum/go-ethereum/common"
|
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
|
|
||||||
"github.com/vulcanize/vulcanizedb/pkg/geth"
|
"github.com/vulcanize/vulcanizedb/pkg/geth"
|
||||||
@ -27,17 +26,17 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Converter interface {
|
type Converter interface {
|
||||||
ToEntities(contractAddress, contractAbi string, ethLogs []types.Log) ([]Entity, error)
|
ToEntities(contractAbi string, ethLogs []types.Log) ([]Entity, error)
|
||||||
ToModels(entities []Entity) ([]Model, error)
|
ToModels(entities []Entity) ([]Model, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type FlopKickConverter struct{}
|
type FlopKickConverter struct{}
|
||||||
|
|
||||||
func (FlopKickConverter) ToEntities(contractAddress, contractAbi string, ethLogs []types.Log) ([]Entity, error) {
|
func (FlopKickConverter) ToEntities(contractAbi string, ethLogs []types.Log) ([]Entity, error) {
|
||||||
var results []Entity
|
var results []Entity
|
||||||
for _, ethLog := range ethLogs {
|
for _, ethLog := range ethLogs {
|
||||||
entity := Entity{}
|
entity := Entity{}
|
||||||
address := common.HexToAddress(contractAddress)
|
address := ethLog.Address
|
||||||
abi, err := geth.ParseAbi(contractAbi)
|
abi, err := geth.ParseAbi(contractAbi)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -30,7 +30,7 @@ var _ = Describe("FlopKick Converter", func() {
|
|||||||
Describe("ToEntities", func() {
|
Describe("ToEntities", func() {
|
||||||
It("converts a log to a FlopKick entity", func() {
|
It("converts a log to a FlopKick entity", func() {
|
||||||
converter := flop_kick.FlopKickConverter{}
|
converter := flop_kick.FlopKickConverter{}
|
||||||
entities, err := converter.ToEntities(shared.FlopperContractAddress, shared.FlopperABI, []types.Log{test_data.FlopKickLog})
|
entities, err := converter.ToEntities(shared.FlopperABI, []types.Log{test_data.FlopKickLog})
|
||||||
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
entity := entities[0]
|
entity := entities[0]
|
||||||
@ -45,7 +45,7 @@ var _ = Describe("FlopKick Converter", func() {
|
|||||||
|
|
||||||
It("returns an error if converting the log to an entity fails", func() {
|
It("returns an error if converting the log to an entity fails", func() {
|
||||||
converter := flop_kick.FlopKickConverter{}
|
converter := flop_kick.FlopKickConverter{}
|
||||||
entities, err := converter.ToEntities(shared.FlopperContractAddress, "error abi", []types.Log{test_data.FlopKickLog})
|
entities, err := converter.ToEntities("error abi", []types.Log{test_data.FlopKickLog})
|
||||||
|
|
||||||
Expect(err).To(HaveOccurred())
|
Expect(err).To(HaveOccurred())
|
||||||
Expect(entities).To(BeNil())
|
Expect(entities).To(BeNil())
|
||||||
|
@ -51,7 +51,7 @@ func (t Transformer) Execute() error {
|
|||||||
|
|
||||||
for _, header := range headers {
|
for _, header := range headers {
|
||||||
topics := [][]common.Hash{{common.HexToHash(shared.FlopKickSignature)}}
|
topics := [][]common.Hash{{common.HexToHash(shared.FlopKickSignature)}}
|
||||||
matchingLogs, err := t.Fetcher.FetchLogs(config.ContractAddress, topics, header.BlockNumber)
|
matchingLogs, err := t.Fetcher.FetchLogs(config.ContractAddresses, topics, header.BlockNumber)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -62,7 +62,7 @@ func (t Transformer) Execute() error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
entities, err := t.Converter.ToEntities(config.ContractAddress, config.ContractAbi, matchingLogs)
|
entities, err := t.Converter.ToEntities(config.ContractAbi, matchingLogs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -87,7 +87,7 @@ var _ = Describe("FlopKick Transformer", func() {
|
|||||||
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(fetcher.FetchedBlocks).To(Equal([]int64{headerOne.BlockNumber, headerTwo.BlockNumber}))
|
Expect(fetcher.FetchedBlocks).To(Equal([]int64{headerOne.BlockNumber, headerTwo.BlockNumber}))
|
||||||
Expect(fetcher.FetchedContractAddress).To(Equal(flop_kick.Config.ContractAddress))
|
Expect(fetcher.FetchedContractAddresses).To(Equal([][]string{flop_kick.Config.ContractAddresses, flop_kick.Config.ContractAddresses}))
|
||||||
Expect(fetcher.FetchedTopics).To(Equal([][]common.Hash{{common.HexToHash(shared.FlopKickSignature)}}))
|
Expect(fetcher.FetchedTopics).To(Equal([][]common.Hash{{common.HexToHash(shared.FlopKickSignature)}}))
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -154,7 +154,7 @@ var _ = Describe("FlopKick Transformer", func() {
|
|||||||
err := transformer.Execute()
|
err := transformer.Execute()
|
||||||
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(converter.PassedContractAddress).To(Equal(flop_kick.Config.ContractAddress))
|
Expect(converter.PassedContractAddresses).To(Equal(flop_kick.Config.ContractAddresses))
|
||||||
Expect(converter.PassedContractABI).To(Equal(flop_kick.Config.ContractAbi))
|
Expect(converter.PassedContractABI).To(Equal(flop_kick.Config.ContractAbi))
|
||||||
Expect(converter.PassedLogs).To(Equal([]types.Log{test_data.FlopKickLog}))
|
Expect(converter.PassedLogs).To(Equal([]types.Log{test_data.FlopKickLog}))
|
||||||
})
|
})
|
||||||
|
@ -17,7 +17,7 @@ package frob
|
|||||||
import "github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
import "github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
||||||
|
|
||||||
var FrobConfig = shared.TransformerConfig{
|
var FrobConfig = shared.TransformerConfig{
|
||||||
ContractAddress: shared.PitContractAddress,
|
ContractAddresses: []string{shared.PitContractAddress},
|
||||||
ContractAbi: shared.PitABI,
|
ContractAbi: shared.PitABI,
|
||||||
Topics: []string{shared.FrobSignature},
|
Topics: []string{shared.FrobSignature},
|
||||||
StartingBlockNumber: 0,
|
StartingBlockNumber: 0,
|
||||||
|
@ -49,7 +49,7 @@ var _ = Describe("Integration tests", func() {
|
|||||||
topic0 := common.HexToHash(shared.FrobSignature)
|
topic0 := common.HexToHash(shared.FrobSignature)
|
||||||
topics := [][]common.Hash{{topic0}}
|
topics := [][]common.Hash{{topic0}}
|
||||||
|
|
||||||
result, err := realFetcher.FetchLogs(shared.PitContractAddress, topics, int64(12))
|
result, err := realFetcher.FetchLogs(frob.FrobConfig.ContractAddresses, topics, int64(12))
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
Expect(len(result) > 0).To(BeTrue())
|
Expect(len(result) > 0).To(BeTrue())
|
||||||
|
@ -55,12 +55,12 @@ func (transformer FrobTransformer) Execute() error {
|
|||||||
log.Printf("Fetching frob event logs for %d headers \n", len(missingHeaders))
|
log.Printf("Fetching frob event logs for %d headers \n", len(missingHeaders))
|
||||||
for _, header := range missingHeaders {
|
for _, header := range missingHeaders {
|
||||||
topics := [][]common.Hash{{common.HexToHash(shared.FrobSignature)}}
|
topics := [][]common.Hash{{common.HexToHash(shared.FrobSignature)}}
|
||||||
matchingLogs, err := transformer.Fetcher.FetchLogs(FrobConfig.ContractAddress, topics, header.BlockNumber)
|
matchingLogs, err := transformer.Fetcher.FetchLogs(FrobConfig.ContractAddresses, topics, header.BlockNumber)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
for _, log := range matchingLogs {
|
for _, log := range matchingLogs {
|
||||||
entity, err := transformer.Converter.ToEntity(FrobConfig.ContractAddress, FrobConfig.ContractAbi, log)
|
entity, err := transformer.Converter.ToEntity(log.Address.Hex(), FrobConfig.ContractAbi, log)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,7 @@ var _ = Describe("Frob transformer", func() {
|
|||||||
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(fetcher.FetchedBlocks).To(Equal([]int64{1, 2}))
|
Expect(fetcher.FetchedBlocks).To(Equal([]int64{1, 2}))
|
||||||
Expect(fetcher.FetchedContractAddress).To(Equal(frob.FrobConfig.ContractAddress))
|
Expect(fetcher.FetchedContractAddresses).To(Equal([][]string{frob.FrobConfig.ContractAddresses, frob.FrobConfig.ContractAddresses}))
|
||||||
Expect(fetcher.FetchedTopics).To(Equal([][]common.Hash{{common.HexToHash(shared.FrobSignature)}}))
|
Expect(fetcher.FetchedTopics).To(Equal([][]common.Hash{{common.HexToHash(shared.FrobSignature)}}))
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -111,7 +111,7 @@ var _ = Describe("Frob transformer", func() {
|
|||||||
err := transformer.Execute()
|
err := transformer.Execute()
|
||||||
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(converter.PassedContractAddress).To(Equal(frob.FrobConfig.ContractAddress))
|
Expect(converter.PassedContractAddress).To(Equal(test_data.EthFrobLog.Address.Hex()))
|
||||||
Expect(converter.PassedContractABI).To(Equal(frob.FrobConfig.ContractAbi))
|
Expect(converter.PassedContractABI).To(Equal(frob.FrobConfig.ContractAbi))
|
||||||
Expect(converter.PassedLog).To(Equal(test_data.EthFrobLog))
|
Expect(converter.PassedLog).To(Equal(test_data.EthFrobLog))
|
||||||
})
|
})
|
||||||
|
@ -19,7 +19,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var PitFileConfig = shared.TransformerConfig{
|
var PitFileConfig = shared.TransformerConfig{
|
||||||
ContractAddress: shared.PitContractAddress,
|
ContractAddresses: []string{shared.PitContractAddress},
|
||||||
ContractAbi: shared.PitABI,
|
ContractAbi: shared.PitABI,
|
||||||
Topics: []string{shared.PitFileIlkSignature, shared.PitFileDebtCeilingSignature, shared.PitFileStabilityFeeSignature},
|
Topics: []string{shared.PitFileIlkSignature, shared.PitFileDebtCeilingSignature, shared.PitFileStabilityFeeSignature},
|
||||||
StartingBlockNumber: 0,
|
StartingBlockNumber: 0,
|
||||||
|
@ -56,7 +56,7 @@ func (transformer PitFileDebtCeilingTransformer) Execute() error {
|
|||||||
log.Printf("Fetching pit file debt ceiling event logs for %d headers \n", len(missingHeaders))
|
log.Printf("Fetching pit file debt ceiling event logs for %d headers \n", len(missingHeaders))
|
||||||
for _, header := range missingHeaders {
|
for _, header := range missingHeaders {
|
||||||
topics := [][]common.Hash{{common.HexToHash(shared.PitFileDebtCeilingSignature)}}
|
topics := [][]common.Hash{{common.HexToHash(shared.PitFileDebtCeilingSignature)}}
|
||||||
matchingLogs, err := transformer.Fetcher.FetchLogs(pit_file.PitFileConfig.ContractAddress, topics, header.BlockNumber)
|
matchingLogs, err := transformer.Fetcher.FetchLogs(pit_file.PitFileConfig.ContractAddresses, topics, header.BlockNumber)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,7 @@ var _ = Describe("", func() {
|
|||||||
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(fetcher.FetchedBlocks).To(Equal([]int64{1, 2}))
|
Expect(fetcher.FetchedBlocks).To(Equal([]int64{1, 2}))
|
||||||
Expect(fetcher.FetchedContractAddress).To(Equal(pit_file.PitFileConfig.ContractAddress))
|
Expect(fetcher.FetchedContractAddresses).To(Equal([][]string{pit_file.PitFileConfig.ContractAddresses, pit_file.PitFileConfig.ContractAddresses}))
|
||||||
Expect(fetcher.FetchedTopics).To(Equal([][]common.Hash{{common.HexToHash(shared.PitFileDebtCeilingSignature)}}))
|
Expect(fetcher.FetchedTopics).To(Equal([][]common.Hash{{common.HexToHash(shared.PitFileDebtCeilingSignature)}}))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ func (transformer PitFileIlkTransformer) Execute() error {
|
|||||||
log.Printf("Fetching pit file ilk event logs for %d headers \n", len(missingHeaders))
|
log.Printf("Fetching pit file ilk event logs for %d headers \n", len(missingHeaders))
|
||||||
for _, header := range missingHeaders {
|
for _, header := range missingHeaders {
|
||||||
topics := [][]common.Hash{{common.HexToHash(shared.PitFileIlkSignature)}}
|
topics := [][]common.Hash{{common.HexToHash(shared.PitFileIlkSignature)}}
|
||||||
matchingLogs, err := transformer.Fetcher.FetchLogs(pit_file.PitFileConfig.ContractAddress, topics, header.BlockNumber)
|
matchingLogs, err := transformer.Fetcher.FetchLogs(pit_file.PitFileConfig.ContractAddresses, topics, header.BlockNumber)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,7 @@ var _ = Describe("Pit file ilk transformer", func() {
|
|||||||
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(fetcher.FetchedBlocks).To(Equal([]int64{1, 2}))
|
Expect(fetcher.FetchedBlocks).To(Equal([]int64{1, 2}))
|
||||||
Expect(fetcher.FetchedContractAddress).To(Equal(pit_file.PitFileConfig.ContractAddress))
|
Expect(fetcher.FetchedContractAddresses).To(Equal([][]string{pit_file.PitFileConfig.ContractAddresses, pit_file.PitFileConfig.ContractAddresses}))
|
||||||
Expect(fetcher.FetchedTopics).To(Equal([][]common.Hash{{common.HexToHash(shared.PitFileIlkSignature)}}))
|
Expect(fetcher.FetchedTopics).To(Equal([][]common.Hash{{common.HexToHash(shared.PitFileIlkSignature)}}))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ func (transformer PitFileStabilityFeeTransformer) Execute() error {
|
|||||||
log.Printf("Fetching pit file stability fee event logs for %d headers \n", len(missingHeaders))
|
log.Printf("Fetching pit file stability fee event logs for %d headers \n", len(missingHeaders))
|
||||||
for _, header := range missingHeaders {
|
for _, header := range missingHeaders {
|
||||||
topics := [][]common.Hash{{common.HexToHash(shared.PitFileStabilityFeeSignature)}}
|
topics := [][]common.Hash{{common.HexToHash(shared.PitFileStabilityFeeSignature)}}
|
||||||
matchingLogs, err := transformer.Fetcher.FetchLogs(pit_file.PitFileConfig.ContractAddress, topics, header.BlockNumber)
|
matchingLogs, err := transformer.Fetcher.FetchLogs(pit_file.PitFileConfig.ContractAddresses, topics, header.BlockNumber)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,7 @@ var _ = Describe("", func() {
|
|||||||
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(fetcher.FetchedBlocks).To(Equal([]int64{1, 2}))
|
Expect(fetcher.FetchedBlocks).To(Equal([]int64{1, 2}))
|
||||||
Expect(fetcher.FetchedContractAddress).To(Equal(pit_file.PitFileConfig.ContractAddress))
|
Expect(fetcher.FetchedContractAddresses).To(Equal([][]string{pit_file.PitFileConfig.ContractAddresses, pit_file.PitFileConfig.ContractAddresses}))
|
||||||
Expect(fetcher.FetchedTopics).To(Equal([][]common.Hash{{common.HexToHash(shared.PitFileStabilityFeeSignature)}}))
|
Expect(fetcher.FetchedTopics).To(Equal([][]common.Hash{{common.HexToHash(shared.PitFileStabilityFeeSignature)}}))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -28,8 +28,8 @@ var (
|
|||||||
// temporary addresses from Kovan deployment
|
// temporary addresses from Kovan deployment
|
||||||
CatContractAddress = "0x2f34f22a00ee4b7a8f8bbc4eaee1658774c624e0"
|
CatContractAddress = "0x2f34f22a00ee4b7a8f8bbc4eaee1658774c624e0"
|
||||||
DripContractAddress = "0x891c04639a5edcae088e546fa125b5d7fb6a2b9d"
|
DripContractAddress = "0x891c04639a5edcae088e546fa125b5d7fb6a2b9d"
|
||||||
FlipperContractAddress = "0x32d496ad866d110060866b7125981c73642cc509" // ETH FLIP Contract
|
FlipperContractAddress = "0x32D496Ad866D110060866B7125981C73642cc509" // ETH FLIP Contract
|
||||||
FlopperContractAddress = "0x6191c9b0086c2ebf92300cc507009b53996fbffa" // MCD FLOP Contract
|
FlopperContractAddress = "0x6191C9b0086c2eBF92300cC507009b53996FbFFa" // MCD FLOP Contract
|
||||||
PepContractAddress = "0xB1997239Cfc3d15578A3a09730f7f84A90BB4975"
|
PepContractAddress = "0xB1997239Cfc3d15578A3a09730f7f84A90BB4975"
|
||||||
PipContractAddress = "0x9FfFE440258B79c5d6604001674A4722FfC0f7Bc"
|
PipContractAddress = "0x9FfFE440258B79c5d6604001674A4722FfC0f7Bc"
|
||||||
PitContractAddress = "0xe7cf3198787c9a4daac73371a38f29aaeeced87e"
|
PitContractAddress = "0xe7cf3198787c9a4daac73371a38f29aaeeced87e"
|
||||||
|
@ -25,7 +25,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type LogFetcher interface {
|
type LogFetcher interface {
|
||||||
FetchLogs(contractAddress string, topics [][]common.Hash, blockNumber int64) ([]types.Log, error)
|
FetchLogs(contractAddresses []string, topics [][]common.Hash, blockNumber int64) ([]types.Log, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type Fetcher struct {
|
type Fetcher struct {
|
||||||
@ -38,14 +38,24 @@ func NewFetcher(blockchain core.BlockChain) Fetcher {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fetcher Fetcher) FetchLogs(contractAddress string, topics [][]common.Hash, blockNumber int64) ([]types.Log, error) {
|
func (fetcher Fetcher) FetchLogs(contractAddresses []string, topics [][]common.Hash, blockNumber int64) ([]types.Log, error) {
|
||||||
block := big.NewInt(blockNumber)
|
block := big.NewInt(blockNumber)
|
||||||
address := common.HexToAddress(contractAddress)
|
addresses := hexStringsToAddresses(contractAddresses)
|
||||||
query := ethereum.FilterQuery{
|
query := ethereum.FilterQuery{
|
||||||
FromBlock: block,
|
FromBlock: block,
|
||||||
ToBlock: block,
|
ToBlock: block,
|
||||||
Addresses: []common.Address{address},
|
Addresses: addresses,
|
||||||
Topics: topics,
|
Topics: topics,
|
||||||
}
|
}
|
||||||
return fetcher.blockChain.GetEthLogsWithCustomQuery(query)
|
return fetcher.blockChain.GetEthLogsWithCustomQuery(query)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func hexStringsToAddresses(hexStrings []string) []common.Address {
|
||||||
|
var addresses []common.Address
|
||||||
|
for _, hexString := range hexStrings {
|
||||||
|
address := common.HexToAddress(hexString)
|
||||||
|
addresses = append(addresses, address)
|
||||||
|
}
|
||||||
|
|
||||||
|
return addresses
|
||||||
|
}
|
||||||
|
@ -28,25 +28,25 @@ import (
|
|||||||
|
|
||||||
var _ = Describe("Fetcher", func() {
|
var _ = Describe("Fetcher", func() {
|
||||||
Describe("FetchLogs", func() {
|
Describe("FetchLogs", func() {
|
||||||
|
|
||||||
It("fetches logs based on the given query", func() {
|
It("fetches logs based on the given query", func() {
|
||||||
blockChain := fakes.NewMockBlockChain()
|
blockChain := fakes.NewMockBlockChain()
|
||||||
fetcher := shared.NewFetcher(blockChain)
|
fetcher := shared.NewFetcher(blockChain)
|
||||||
blockNumber := int64(123)
|
blockNumber := int64(123)
|
||||||
address := "0xfakeAddress"
|
addresses := []string{"0xfakeAddress", "0xanotherFakeAddress"}
|
||||||
topicZeros := [][]common.Hash{{common.BytesToHash([]byte{1, 2, 3, 4, 5})}}
|
topicZeros := [][]common.Hash{{common.BytesToHash([]byte{1, 2, 3, 4, 5})}}
|
||||||
|
|
||||||
_, err := fetcher.FetchLogs(address, topicZeros, blockNumber)
|
_, err := fetcher.FetchLogs(addresses, topicZeros, blockNumber)
|
||||||
|
|
||||||
|
address1 := common.HexToAddress("0xfakeAddress")
|
||||||
|
address2 := common.HexToAddress("0xanotherFakeAddress")
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
expectedQuery := ethereum.FilterQuery{
|
expectedQuery := ethereum.FilterQuery{
|
||||||
FromBlock: big.NewInt(blockNumber),
|
FromBlock: big.NewInt(blockNumber),
|
||||||
ToBlock: big.NewInt(blockNumber),
|
ToBlock: big.NewInt(blockNumber),
|
||||||
Addresses: []common.Address{common.HexToAddress(address)},
|
Addresses: []common.Address{address1, address2},
|
||||||
Topics: topicZeros,
|
Topics: topicZeros,
|
||||||
}
|
}
|
||||||
blockChain.AssertGetEthLogsWithCustomQueryCalledWith(expectedQuery)
|
blockChain.AssertGetEthLogsWithCustomQueryCalledWith(expectedQuery)
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
It("returns an error if fetching the logs fails", func() {
|
It("returns an error if fetching the logs fails", func() {
|
||||||
@ -54,7 +54,7 @@ var _ = Describe("Fetcher", func() {
|
|||||||
blockChain.SetGetEthLogsWithCustomQueryErr(fakes.FakeError)
|
blockChain.SetGetEthLogsWithCustomQueryErr(fakes.FakeError)
|
||||||
fetcher := shared.NewFetcher(blockChain)
|
fetcher := shared.NewFetcher(blockChain)
|
||||||
|
|
||||||
_, err := fetcher.FetchLogs("", [][]common.Hash{}, int64(1))
|
_, err := fetcher.FetchLogs([]string{}, [][]common.Hash{}, int64(1))
|
||||||
|
|
||||||
Expect(err).To(HaveOccurred())
|
Expect(err).To(HaveOccurred())
|
||||||
Expect(err).To(MatchError(fakes.FakeError))
|
Expect(err).To(MatchError(fakes.FakeError))
|
||||||
|
@ -28,7 +28,7 @@ type Transformer interface {
|
|||||||
type TransformerInitializer func(db *postgres.DB, blockChain core.BlockChain) Transformer
|
type TransformerInitializer func(db *postgres.DB, blockChain core.BlockChain) Transformer
|
||||||
|
|
||||||
type TransformerConfig struct {
|
type TransformerConfig struct {
|
||||||
ContractAddress string
|
ContractAddresses []string
|
||||||
ContractAbi string
|
ContractAbi string
|
||||||
Topics []string
|
Topics []string
|
||||||
StartingBlockNumber int64
|
StartingBlockNumber int64
|
||||||
|
@ -17,7 +17,7 @@ package tend
|
|||||||
import "github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
import "github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
||||||
|
|
||||||
var TendConfig = shared.TransformerConfig{
|
var TendConfig = shared.TransformerConfig{
|
||||||
ContractAddress: shared.FlipperContractAddress,
|
ContractAddresses: []string{shared.FlipperContractAddress},
|
||||||
ContractAbi: shared.FlipperABI,
|
ContractAbi: shared.FlipperABI,
|
||||||
Topics: []string{shared.TendFunctionSignature},
|
Topics: []string{shared.TendFunctionSignature},
|
||||||
StartingBlockNumber: 0,
|
StartingBlockNumber: 0,
|
||||||
|
@ -24,7 +24,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Converter interface {
|
type Converter interface {
|
||||||
Convert(ethLogs []types.Log) ([]TendModel, error)
|
ToModels(ethLogs []types.Log) ([]TendModel, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type TendConverter struct{}
|
type TendConverter struct{}
|
||||||
@ -33,7 +33,7 @@ func NewTendConverter() TendConverter {
|
|||||||
return TendConverter{}
|
return TendConverter{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c TendConverter) Convert(ethLogs []types.Log) (results []TendModel, err error) {
|
func (c TendConverter) ToModels(ethLogs []types.Log) (results []TendModel, err error) {
|
||||||
for _, ethLog := range ethLogs {
|
for _, ethLog := range ethLogs {
|
||||||
err := validateLog(ethLog)
|
err := validateLog(ethLog)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -31,9 +31,9 @@ var _ = Describe("Tend TendConverter", func() {
|
|||||||
converter = tend.NewTendConverter()
|
converter = tend.NewTendConverter()
|
||||||
})
|
})
|
||||||
|
|
||||||
Describe("Convert", func() {
|
Describe("ToModels", func() {
|
||||||
It("converts an eth log to a db model", func() {
|
It("converts an eth log to a db model", func() {
|
||||||
models, err := converter.Convert([]types.Log{test_data.TendLogNote})
|
models, err := converter.ToModels([]types.Log{test_data.TendLogNote})
|
||||||
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(len(models)).To(Equal(1))
|
Expect(len(models)).To(Equal(1))
|
||||||
@ -43,7 +43,7 @@ var _ = Describe("Tend TendConverter", func() {
|
|||||||
It("returns an error if the log data is empty", func() {
|
It("returns an error if the log data is empty", func() {
|
||||||
emptyDataLog := test_data.TendLogNote
|
emptyDataLog := test_data.TendLogNote
|
||||||
emptyDataLog.Data = []byte{}
|
emptyDataLog.Data = []byte{}
|
||||||
_, err := converter.Convert([]types.Log{emptyDataLog})
|
_, err := converter.ToModels([]types.Log{emptyDataLog})
|
||||||
|
|
||||||
Expect(err).To(HaveOccurred())
|
Expect(err).To(HaveOccurred())
|
||||||
Expect(err).To(MatchError("tend log note data is empty"))
|
Expect(err).To(MatchError("tend log note data is empty"))
|
||||||
@ -52,7 +52,7 @@ var _ = Describe("Tend TendConverter", func() {
|
|||||||
It("returns an error if the expected amount of topics aren't in the log", func() {
|
It("returns an error if the expected amount of topics aren't in the log", func() {
|
||||||
invalidLog := test_data.TendLogNote
|
invalidLog := test_data.TendLogNote
|
||||||
invalidLog.Topics = []common.Hash{}
|
invalidLog.Topics = []common.Hash{}
|
||||||
_, err := converter.Convert([]types.Log{invalidLog})
|
_, err := converter.ToModels([]types.Log{invalidLog})
|
||||||
|
|
||||||
Expect(err).To(MatchError("tend log does not contain expected topics"))
|
Expect(err).To(MatchError("tend log does not contain expected topics"))
|
||||||
})
|
})
|
||||||
|
@ -28,6 +28,7 @@ import (
|
|||||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
||||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
|
"github.com/vulcanize/vulcanizedb/pkg/transformers/test_data"
|
||||||
"github.com/vulcanize/vulcanizedb/test_config"
|
"github.com/vulcanize/vulcanizedb/test_config"
|
||||||
|
"github.com/vulcanize/vulcanizedb/pkg/transformers/tend"
|
||||||
)
|
)
|
||||||
|
|
||||||
// These test are marked as pending until the Flip contract is deployed to Kovan.
|
// These test are marked as pending until the Flip contract is deployed to Kovan.
|
||||||
@ -48,7 +49,7 @@ var _ = Describe("Integration tests", func() {
|
|||||||
topic0 := common.HexToHash(shared.TendFunctionSignature)
|
topic0 := common.HexToHash(shared.TendFunctionSignature)
|
||||||
topics := [][]common.Hash{{topic0}}
|
topics := [][]common.Hash{{topic0}}
|
||||||
|
|
||||||
result, err := realFetcher.FetchLogs(shared.FlipperContractAddress, topics, test_data.FlipKickBlockNumber)
|
result, err := realFetcher.FetchLogs(tend.TendConfig.ContractAddresses, topics, test_data.FlipKickBlockNumber)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
Expect(len(result) > 0).To(BeTrue())
|
Expect(len(result) > 0).To(BeTrue())
|
||||||
|
@ -59,7 +59,7 @@ func (t TendTransformer) Execute() error {
|
|||||||
|
|
||||||
log.Printf("Fetching tend event logs for %d headers \n", len(missingHeaders))
|
log.Printf("Fetching tend event logs for %d headers \n", len(missingHeaders))
|
||||||
for _, header := range missingHeaders {
|
for _, header := range missingHeaders {
|
||||||
ethLogs, err := t.Fetcher.FetchLogs(config.ContractAddress, topics, header.BlockNumber)
|
ethLogs, err := t.Fetcher.FetchLogs(config.ContractAddresses, topics, header.BlockNumber)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("Error fetching matching logs:", err)
|
log.Println("Error fetching matching logs:", err)
|
||||||
return err
|
return err
|
||||||
@ -71,7 +71,7 @@ func (t TendTransformer) Execute() error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
models, err := t.Converter.Convert(ethLogs)
|
models, err := t.Converter.ToModels(ethLogs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("Error converting logs:", err)
|
log.Println("Error converting logs:", err)
|
||||||
return err
|
return err
|
||||||
|
@ -75,7 +75,7 @@ var _ = Describe("Tend Transformer", func() {
|
|||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(fetcher.FetchedBlocks).To(Equal([]int64{blockNumber1, blockNumber2}))
|
Expect(fetcher.FetchedBlocks).To(Equal([]int64{blockNumber1, blockNumber2}))
|
||||||
Expect(fetcher.FetchedTopics).To(Equal(expectedTopics))
|
Expect(fetcher.FetchedTopics).To(Equal(expectedTopics))
|
||||||
Expect(fetcher.FetchedContractAddress).To(Equal(shared.FlipperContractAddress))
|
Expect(fetcher.FetchedContractAddresses).To(Equal([][]string{tend.TendConfig.ContractAddresses, tend.TendConfig.ContractAddresses}))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("returns an error if fetching logs fails", func() {
|
It("returns an error if fetching logs fails", func() {
|
||||||
|
@ -43,6 +43,7 @@ var dealRawJson, _ = json.Marshal(DealLogNote)
|
|||||||
|
|
||||||
var DealModel = deal.DealModel{
|
var DealModel = deal.DealModel{
|
||||||
BidId: "123",
|
BidId: "123",
|
||||||
|
ContractAddress: shared.FlipperContractAddress,
|
||||||
TransactionIndex: 74,
|
TransactionIndex: 74,
|
||||||
Raw: dealRawJson,
|
Raw: dealRawJson,
|
||||||
}
|
}
|
@ -22,15 +22,17 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type MockFlipKickConverter struct {
|
type MockFlipKickConverter struct {
|
||||||
ConverterContract string
|
ConverterContracts []string
|
||||||
ConverterAbi string
|
ConverterAbi string
|
||||||
LogsToConvert []types.Log
|
LogsToConvert []types.Log
|
||||||
EntitiesToConvert []flip_kick.FlipKickEntity
|
EntitiesToConvert []flip_kick.FlipKickEntity
|
||||||
ConverterError error
|
ConverterError error
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mfkc *MockFlipKickConverter) ToEntities(contractAddress string, contractAbi string, ethLogs []types.Log) ([]flip_kick.FlipKickEntity, error) {
|
func (mfkc *MockFlipKickConverter) ToEntities(contractAbi string, ethLogs []types.Log) ([]flip_kick.FlipKickEntity, error) {
|
||||||
mfkc.ConverterContract = contractAddress
|
for _, log := range ethLogs {
|
||||||
|
mfkc.ConverterContracts = append(mfkc.ConverterContracts, log.Address.Hex())
|
||||||
|
}
|
||||||
mfkc.ConverterAbi = contractAbi
|
mfkc.ConverterAbi = contractAbi
|
||||||
mfkc.LogsToConvert = append(mfkc.LogsToConvert, ethLogs...)
|
mfkc.LogsToConvert = append(mfkc.LogsToConvert, ethLogs...)
|
||||||
return []flip_kick.FlipKickEntity{test_data.FlipKickEntity}, mfkc.ConverterError
|
return []flip_kick.FlipKickEntity{test_data.FlipKickEntity}, mfkc.ConverterError
|
||||||
|
@ -21,16 +21,18 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type MockConverter struct {
|
type MockConverter struct {
|
||||||
PassedContractAddress string
|
PassedContractAddresses []string
|
||||||
PassedContractABI string
|
PassedContractABI string
|
||||||
PassedLogs []types.Log
|
PassedLogs []types.Log
|
||||||
PassedEntities []flop_kick.Entity
|
PassedEntities []flop_kick.Entity
|
||||||
entityConverterError error
|
entityConverterError error
|
||||||
modelConverterError error
|
modelConverterError error
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *MockConverter) ToEntities(contractAddress, contractAbi string, ethLogs []types.Log) ([]flop_kick.Entity, error) {
|
func (c *MockConverter) ToEntities(contractAbi string, ethLogs []types.Log) ([]flop_kick.Entity, error) {
|
||||||
c.PassedContractAddress = contractAddress
|
for _, log := range ethLogs {
|
||||||
|
c.PassedContractAddresses = append(c.PassedContractAddresses, log.Address.Hex())
|
||||||
|
}
|
||||||
c.PassedContractABI = contractAbi
|
c.PassedContractABI = contractAbi
|
||||||
c.PassedLogs = ethLogs
|
c.PassedLogs = ethLogs
|
||||||
|
|
||||||
|
@ -20,15 +20,15 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type MockLogFetcher struct {
|
type MockLogFetcher struct {
|
||||||
FetchedContractAddress string
|
FetchedContractAddresses [][]string
|
||||||
FetchedTopics [][]common.Hash
|
FetchedTopics [][]common.Hash
|
||||||
FetchedBlocks []int64
|
FetchedBlocks []int64
|
||||||
fetcherError error
|
fetcherError error
|
||||||
FetchedLogs []types.Log
|
FetchedLogs []types.Log
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mlf *MockLogFetcher) FetchLogs(contractAddress string, topics [][]common.Hash, blockNumber int64) ([]types.Log, error) {
|
func (mlf *MockLogFetcher) FetchLogs(contractAddresses []string, topics [][]common.Hash, blockNumber int64) ([]types.Log, error) {
|
||||||
mlf.FetchedContractAddress = contractAddress
|
mlf.FetchedContractAddresses = append(mlf.FetchedContractAddresses, contractAddresses)
|
||||||
mlf.FetchedTopics = topics
|
mlf.FetchedTopics = topics
|
||||||
mlf.FetchedBlocks = append(mlf.FetchedBlocks, blockNumber)
|
mlf.FetchedBlocks = append(mlf.FetchedBlocks, blockNumber)
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ type MockTendConverter struct {
|
|||||||
ConverterError error
|
ConverterError error
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *MockTendConverter) Convert(ethLogs []types.Log) ([]tend.TendModel, error) {
|
func (c *MockTendConverter) ToModels(ethLogs []types.Log) ([]tend.TendModel, error) {
|
||||||
c.LogsToConvert = append(c.LogsToConvert, ethLogs...)
|
c.LogsToConvert = append(c.LogsToConvert, ethLogs...)
|
||||||
return []tend.TendModel{test_data.TendModel}, c.ConverterError
|
return []tend.TendModel{test_data.TendModel}, c.ConverterError
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var VatInitConfig = shared.TransformerConfig{
|
var VatInitConfig = shared.TransformerConfig{
|
||||||
ContractAddress: shared.VatContractAddress,
|
ContractAddresses: []string{shared.VatContractAddress},
|
||||||
ContractAbi: shared.VatABI,
|
ContractAbi: shared.VatABI,
|
||||||
Topics: []string{shared.VatInitSignature},
|
Topics: []string{shared.VatInitSignature},
|
||||||
StartingBlockNumber: 0,
|
StartingBlockNumber: 0,
|
||||||
|
@ -55,7 +55,7 @@ func (transformer VatInitTransformer) Execute() error {
|
|||||||
log.Printf("Fetching vat init event logs for %d headers \n", len(missingHeaders))
|
log.Printf("Fetching vat init event logs for %d headers \n", len(missingHeaders))
|
||||||
for _, header := range missingHeaders {
|
for _, header := range missingHeaders {
|
||||||
topics := [][]common.Hash{{common.HexToHash(shared.VatInitSignature)}}
|
topics := [][]common.Hash{{common.HexToHash(shared.VatInitSignature)}}
|
||||||
matchingLogs, err := transformer.Fetcher.FetchLogs(VatInitConfig.ContractAddress, topics, header.BlockNumber)
|
matchingLogs, err := transformer.Fetcher.FetchLogs(VatInitConfig.ContractAddresses, topics, header.BlockNumber)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,7 @@ var _ = Describe("Vat init transformer", func() {
|
|||||||
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
Expect(fetcher.FetchedBlocks).To(Equal([]int64{1, 2}))
|
Expect(fetcher.FetchedBlocks).To(Equal([]int64{1, 2}))
|
||||||
Expect(fetcher.FetchedContractAddress).To(Equal(vat_init.VatInitConfig.ContractAddress))
|
Expect(fetcher.FetchedContractAddresses).To(Equal([][]string{vat_init.VatInitConfig.ContractAddresses, vat_init.VatInitConfig.ContractAddresses}))
|
||||||
Expect(fetcher.FetchedTopics).To(Equal([][]common.Hash{{common.HexToHash(shared.VatInitSignature)}}))
|
Expect(fetcher.FetchedTopics).To(Equal([][]common.Hash{{common.HexToHash(shared.VatInitSignature)}}))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user