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
+8 -5
View File
@@ -14,13 +14,16 @@
package ilk
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 DripFileIlkConfig = shared.TransformerConfig{
TransformerName: shared.DripFileIlkLabel,
ContractAddresses: []string{shared.DripContractAddress},
ContractAbi: shared.DripABI,
Topic: shared.DripFileIlkSignature,
TransformerName: constants.DripFileIlkLabel,
ContractAddresses: []string{constants.DripContractAddress},
ContractAbi: constants.DripABI,
Topic: constants.DripFileIlkSignature,
StartingBlockNumber: 0,
EndingBlockNumber: 10000000,
}
+5 -4
View File
@@ -17,11 +17,12 @@ package ilk
import (
"bytes"
"encoding/json"
"errors"
"math/big"
"errors"
"github.com/ethereum/go-ethereum/core/types"
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants"
)
type DripFileIlkConverter struct{}
@@ -36,7 +37,7 @@ func (DripFileIlkConverter) ToModels(ethLogs []types.Log) ([]interface{}, error)
ilk := string(bytes.Trim(ethLog.Topics[2].Bytes(), "\x00"))
vow := string(bytes.Trim(ethLog.Topics[3].Bytes(), "\x00"))
taxBytes := ethLog.Data[len(ethLog.Data)-shared.DataItemLength:]
taxBytes := ethLog.Data[len(ethLog.Data)-constants.DataItemLength:]
tax := big.NewInt(0).SetBytes(taxBytes).String()
raw, err := json.Marshal(ethLog)
if err != nil {
@@ -60,7 +61,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