Convert drip_file_ilk tax field to ray (#117)

This commit is contained in:
Elizabeth 2018-11-29 14:10:12 -06:00 committed by GitHub
parent ecf854c7c4
commit 8ce901d1af
2 changed files with 4 additions and 3 deletions

View File

@ -22,6 +22,7 @@ import (
"github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/types"
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants" "github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants"
) )
@ -38,7 +39,7 @@ func (DripFileIlkConverter) ToModels(ethLogs []types.Log) ([]interface{}, error)
ilk := string(bytes.Trim(ethLog.Topics[2].Bytes(), "\x00")) ilk := string(bytes.Trim(ethLog.Topics[2].Bytes(), "\x00"))
vow := string(bytes.Trim(ethLog.Topics[3].Bytes(), "\x00")) vow := string(bytes.Trim(ethLog.Topics[3].Bytes(), "\x00"))
taxBytes := ethLog.Data[len(ethLog.Data)-constants.DataItemLength:] taxBytes := ethLog.Data[len(ethLog.Data)-constants.DataItemLength:]
tax := big.NewInt(0).SetBytes(taxBytes).String() tax := shared.ConvertToRay(big.NewInt(0).SetBytes(taxBytes).String())
raw, err := json.Marshal(ethLog) raw, err := json.Marshal(ethLog)
if err != nil { if err != nil {
return nil, err return nil, err

View File

@ -35,7 +35,7 @@ var EthDripFileIlkLog = types.Log{
common.HexToHash("0x66616b6520696c6b000000000000000000000000000000000000000000000000"), common.HexToHash("0x66616b6520696c6b000000000000000000000000000000000000000000000000"),
common.HexToHash("0x66616b6520766f77000000000000000000000000000000000000000000000000"), common.HexToHash("0x66616b6520766f77000000000000000000000000000000000000000000000000"),
}, },
Data: hexutil.MustDecode("0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000641a0b287e66616b6520696c6b00000000000000000000000000000000000000000000000066616b6520766f77000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007b"), Data: hexutil.MustDecode("0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000641a0b287e66616b6520696c6b00000000000000000000000000000000000000000000000066616b6520766f77000000000000000000000000000000000000000000000000000000000000000000000000000000000000009B3F7188CE95D16E5AE0000000"),
BlockNumber: 35, BlockNumber: 35,
TxHash: common.HexToHash("0xa1c31b7e6389470902237161263558615e60b40f2e63060b2f4aeafe92d57e5f"), TxHash: common.HexToHash("0xa1c31b7e6389470902237161263558615e60b40f2e63060b2f4aeafe92d57e5f"),
TxIndex: 12, TxIndex: 12,
@ -48,7 +48,7 @@ var rawDripFileIlkLog, _ = json.Marshal(EthDripFileIlkLog)
var DripFileIlkModel = ilk2.DripFileIlkModel{ var DripFileIlkModel = ilk2.DripFileIlkModel{
Ilk: "fake ilk", Ilk: "fake ilk",
Vow: "fake vow", Vow: "fake vow",
Tax: big.NewInt(123).String(), Tax: "12300.000000000000000000000000000",
LogIndex: EthDripFileIlkLog.Index, LogIndex: EthDripFileIlkLog.Index,
TransactionIndex: EthDripFileIlkLog.TxIndex, TransactionIndex: EthDripFileIlkLog.TxIndex,
Raw: rawDripFileIlkLog, Raw: rawDripFileIlkLog,