Extract constants package

- Reduce clutter in the shared package
This commit is contained in:
Rob Mulholand
2018-11-08 13:08:59 -06:00
parent 8c5192f82f
commit 8c168ed332
87 changed files with 604 additions and 542 deletions
@@ -14,13 +14,16 @@
package chop_lump
import "github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
import (
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants"
)
var CatFileChopLumpConfig = shared.TransformerConfig{
TransformerName: shared.CatFileChopLumpLabel,
ContractAddresses: []string{shared.CatContractAddress},
ContractAbi: shared.CatABI,
Topic: shared.CatFileChopLumpSignature,
TransformerName: constants.CatFileChopLumpLabel,
ContractAddresses: []string{constants.CatContractAddress},
ContractAbi: constants.CatABI,
Topic: constants.CatFileChopLumpSignature,
StartingBlockNumber: 0,
EndingBlockNumber: 10000000,
}
@@ -19,7 +19,7 @@ import (
"encoding/json"
"errors"
"github.com/ethereum/go-ethereum/core/types"
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants"
"math/big"
)
@@ -34,7 +34,7 @@ func (CatFileChopLumpConverter) ToModels(ethLogs []types.Log) ([]interface{}, er
}
ilk := string(bytes.Trim(ethLog.Topics[2].Bytes(), "\x00"))
what := string(bytes.Trim(ethLog.Topics[3].Bytes(), "\x00"))
dataBytes := ethLog.Data[len(ethLog.Data)-shared.DataItemLength:]
dataBytes := ethLog.Data[len(ethLog.Data)-constants.DataItemLength:]
data := big.NewInt(0).SetBytes(dataBytes).String()
raw, err := json.Marshal(ethLog)
@@ -58,7 +58,7 @@ func verifyLog(log types.Log) error {
if len(log.Topics) < 4 {
return errors.New("log missing topics")
}
if len(log.Data) < shared.DataItemLength {
if len(log.Data) < constants.DataItemLength {
return errors.New("log missing data")
}
return nil
+8 -5
View File
@@ -14,13 +14,16 @@
package flip
import "github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
import (
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants"
)
var CatFileFlipConfig = shared.TransformerConfig{
TransformerName: shared.CatFileFlipLabel,
ContractAddresses: []string{shared.CatContractAddress},
ContractAbi: shared.CatABI,
Topic: shared.CatFileFlipSignature,
TransformerName: constants.CatFileFlipLabel,
ContractAddresses: []string{constants.CatContractAddress},
ContractAbi: constants.CatABI,
Topic: constants.CatFileFlipSignature,
StartingBlockNumber: 0,
EndingBlockNumber: 10000000,
}
+3 -3
View File
@@ -20,7 +20,7 @@ import (
"errors"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants"
)
type CatFileFlipConverter struct{}
@@ -34,7 +34,7 @@ func (CatFileFlipConverter) ToModels(ethLogs []types.Log) ([]interface{}, error)
}
ilk := string(bytes.Trim(ethLog.Topics[2].Bytes(), "\x00"))
what := string(bytes.Trim(ethLog.Topics[3].Bytes(), "\x00"))
flipBytes := ethLog.Data[len(ethLog.Data)-shared.DataItemLength:]
flipBytes := ethLog.Data[len(ethLog.Data)-constants.DataItemLength:]
flip := common.BytesToAddress(flipBytes).String()
raw, err := json.Marshal(ethLog)
@@ -58,7 +58,7 @@ func verifyLog(log types.Log) error {
if len(log.Topics) < 4 {
return errors.New("log missing topics")
}
if len(log.Data) < shared.DataItemLength {
if len(log.Data) < constants.DataItemLength {
return errors.New("log missing data")
}
return nil
+8 -5
View File
@@ -14,13 +14,16 @@
package pit_vow
import "github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
import (
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants"
)
var CatFilePitVowConfig = shared.TransformerConfig{
TransformerName: shared.CatFilePitVowLabel,
ContractAddresses: []string{shared.CatContractAddress},
ContractAbi: shared.CatABI,
Topic: shared.CatFilePitVowSignature,
TransformerName: constants.CatFilePitVowLabel,
ContractAddresses: []string{constants.CatContractAddress},
ContractAbi: constants.CatABI,
Topic: constants.CatFilePitVowSignature,
StartingBlockNumber: 0,
EndingBlockNumber: 10000000,
}
@@ -20,7 +20,7 @@ import (
"errors"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants"
)
type CatFilePitVowConverter struct{}
@@ -57,7 +57,7 @@ func verifyLog(log types.Log) error {
if len(log.Topics) < 4 {
return errors.New("log missing topics")
}
if len(log.Data) < shared.DataItemLength {
if len(log.Data) < constants.DataItemLength {
return errors.New("log missing data")
}
return nil