Fix Pit file converters
- Use topics 2 & 3 instead of topic 1 (call data instead of msg.sender) - Prefer extracting fields from topics rather than data
This commit is contained in:
parent
c17ad1f826
commit
02853014b2
@ -18,8 +18,8 @@ import (
|
||||
"encoding/json"
|
||||
"math/big"
|
||||
|
||||
"bytes"
|
||||
"errors"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
||||
)
|
||||
@ -35,9 +35,8 @@ func (PitFileDebtCeilingConverter) ToModel(ethLog types.Log) (PitFileDebtCeiling
|
||||
if err != nil {
|
||||
return PitFileDebtCeilingModel{}, err
|
||||
}
|
||||
what := common.HexToAddress(ethLog.Topics[1].String()).String()
|
||||
riskBytes := ethLog.Data[len(ethLog.Data)-shared.DataItemLength:]
|
||||
data := big.NewInt(0).SetBytes(riskBytes).String()
|
||||
what := string(bytes.Trim(ethLog.Topics[2].Bytes(), "\x00"))
|
||||
data := big.NewInt(0).SetBytes(ethLog.Topics[3].Bytes()).String()
|
||||
|
||||
raw, err := json.Marshal(ethLog)
|
||||
return PitFileDebtCeilingModel{
|
||||
|
@ -35,7 +35,7 @@ func (PitFileStabilityFeeConverter) ToModel(ethLog types.Log) (PitFileStabilityF
|
||||
return PitFileStabilityFeeModel{}, err
|
||||
}
|
||||
what := string(bytes.Trim(ethLog.Topics[2].Bytes(), "\x00"))
|
||||
data := common.HexToAddress(ethLog.Topics[1].String()).Hex()
|
||||
data := common.HexToAddress(ethLog.Topics[3].String()).Hex()
|
||||
|
||||
raw, err := json.Marshal(ethLog)
|
||||
return PitFileStabilityFeeModel{
|
||||
|
@ -33,10 +33,10 @@ var EthPitFileDebtCeilingLog = types.Log{
|
||||
Topics: []common.Hash{
|
||||
common.HexToHash("0x29ae811400000000000000000000000000000000000000000000000000000000"),
|
||||
common.HexToHash("0x00000000000000000000000064d922894153be9eef7b7218dc565d1d0ce2a092"),
|
||||
common.HexToHash("0x6472697000000000000000000000000000000000000000000000000000000000"),
|
||||
common.HexToHash("0x000000000000000000000000000000000000000000000000000000000000007b"),
|
||||
common.HexToHash("0x4c696e6500000000000000000000000000000000000000000000000000000000"),
|
||||
common.HexToHash("0x000000000000000000000000000000000000000000000000000000000001e240"),
|
||||
},
|
||||
Data: hexutil.MustDecode("0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000004429ae81146472697000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007b"),
|
||||
Data: hexutil.MustDecode("0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000004429ae81144c696e6500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001e240"),
|
||||
BlockNumber: 22,
|
||||
TxHash: common.HexToHash("0xd744878a0b6655e3ba729e1019f56b563b4a16750196b8ad6104f3977db43f42"),
|
||||
TxIndex: 333,
|
||||
@ -47,8 +47,8 @@ var EthPitFileDebtCeilingLog = types.Log{
|
||||
|
||||
var rawPitFileDebtCeilingLog, _ = json.Marshal(EthPitFileDebtCeilingLog)
|
||||
var PitFileDebtCeilingModel = debt_ceiling.PitFileDebtCeilingModel{
|
||||
What: "0x64d922894153BE9EEf7b7218dc565d1D0Ce2a092",
|
||||
Data: big.NewInt(123).String(),
|
||||
What: "Line",
|
||||
Data: big.NewInt(123456).String(),
|
||||
TransactionIndex: EthPitFileDebtCeilingLog.TxIndex,
|
||||
Raw: rawPitFileDebtCeilingLog,
|
||||
}
|
||||
@ -85,7 +85,7 @@ var EthPitFileStabilityFeeLog = types.Log{
|
||||
common.HexToHash("0xd4e8be8300000000000000000000000000000000000000000000000000000000"),
|
||||
common.HexToHash("0x00000000000000000000000064d922894153be9eef7b7218dc565d1d0ce2a092"),
|
||||
common.HexToHash("0x6472697000000000000000000000000000000000000000000000000000000000"),
|
||||
common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
||||
common.HexToHash("0x0000000000000000000000008e84a1e068d77059cbe263c43ad0cdc130863313"),
|
||||
},
|
||||
Data: hexutil.MustDecode("0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000044d4e8be8364726970000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"),
|
||||
BlockNumber: 12,
|
||||
@ -99,7 +99,7 @@ var EthPitFileStabilityFeeLog = types.Log{
|
||||
var rawPitFileStabilityFeeLog, _ = json.Marshal(EthPitFileStabilityFeeLog)
|
||||
var PitFileStabilityFeeModel = stability_fee.PitFileStabilityFeeModel{
|
||||
What: "drip",
|
||||
Data: "0x64d922894153BE9EEf7b7218dc565d1D0Ce2a092",
|
||||
Data: "0x8E84a1e068d77059Cbe263C43AD0cDc130863313",
|
||||
TransactionIndex: EthPitFileStabilityFeeLog.TxIndex,
|
||||
Raw: rawPitFileStabilityFeeLog,
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user