From 8ce901d1afa94defa836dda9ae463390fe2acbec Mon Sep 17 00:00:00 2001 From: Elizabeth Date: Thu, 29 Nov 2018 14:10:12 -0600 Subject: [PATCH] Convert drip_file_ilk tax field to ray (#117) --- pkg/transformers/drip_file/ilk/converter.go | 3 ++- pkg/transformers/test_data/drip_file.go | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pkg/transformers/drip_file/ilk/converter.go b/pkg/transformers/drip_file/ilk/converter.go index 907862ab..19f348e8 100644 --- a/pkg/transformers/drip_file/ilk/converter.go +++ b/pkg/transformers/drip_file/ilk/converter.go @@ -22,6 +22,7 @@ import ( "github.com/ethereum/go-ethereum/core/types" + "github.com/vulcanize/vulcanizedb/pkg/transformers/shared" "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")) vow := string(bytes.Trim(ethLog.Topics[3].Bytes(), "\x00")) 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) if err != nil { return nil, err diff --git a/pkg/transformers/test_data/drip_file.go b/pkg/transformers/test_data/drip_file.go index 9be218cc..38de451b 100644 --- a/pkg/transformers/test_data/drip_file.go +++ b/pkg/transformers/test_data/drip_file.go @@ -35,7 +35,7 @@ var EthDripFileIlkLog = types.Log{ common.HexToHash("0x66616b6520696c6b000000000000000000000000000000000000000000000000"), common.HexToHash("0x66616b6520766f77000000000000000000000000000000000000000000000000"), }, - Data: hexutil.MustDecode("0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000641a0b287e66616b6520696c6b00000000000000000000000000000000000000000000000066616b6520766f77000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007b"), + Data: hexutil.MustDecode("0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000641a0b287e66616b6520696c6b00000000000000000000000000000000000000000000000066616b6520766f77000000000000000000000000000000000000000000000000000000000000000000000000000000000000009B3F7188CE95D16E5AE0000000"), BlockNumber: 35, TxHash: common.HexToHash("0xa1c31b7e6389470902237161263558615e60b40f2e63060b2f4aeafe92d57e5f"), TxIndex: 12, @@ -48,7 +48,7 @@ var rawDripFileIlkLog, _ = json.Marshal(EthDripFileIlkLog) var DripFileIlkModel = ilk2.DripFileIlkModel{ Ilk: "fake ilk", Vow: "fake vow", - Tax: big.NewInt(123).String(), + Tax: "12300.000000000000000000000000000", LogIndex: EthDripFileIlkLog.Index, TransactionIndex: EthDripFileIlkLog.TxIndex, Raw: rawDripFileIlkLog,