Skip to content

Commit

Permalink
Fix decided args structure.
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrey committed Jul 24, 2024
1 parent a30bacc commit ddb8c97
Show file tree
Hide file tree
Showing 10 changed files with 386 additions and 268 deletions.
72 changes: 40 additions & 32 deletions blockchain/arbitrum_one/arbitrum_one.go
Original file line number Diff line number Diff line change
Expand Up @@ -435,14 +435,14 @@ func (c *Client) ProcessBlocksToBatch(msgs []proto.Message) (proto.Message, erro
}

return &ArbitrumOneBlocksBatch{
Blocks: blocks,
Blocks: blocks,
SeerVersion: version.SeerVersion,
}, nil
}

func ToEntireBlocksBatchFromLogProto(obj *ArbitrumOneBlocksBatch) *seer_common.BlocksBatchJson {
blocksBatchJson := seer_common.BlocksBatchJson{
Blocks: []seer_common.BlockJson{},
Blocks: []seer_common.BlockJson{},
SeerVersion: obj.SeerVersion,
}

Expand Down Expand Up @@ -519,10 +519,10 @@ func ToEntireBlocksBatchFromLogProto(obj *ArbitrumOneBlocksBatch) *seer_common.B
BaseFeePerGas: b.BaseFeePerGas,
IndexedAt: fmt.Sprintf("%d", b.IndexedAt),

MixHash: b.MixHash,
SendCount: b.SendCount,
SendRoot: b.SendRoot,
L1BlockNumber: fmt.Sprintf("%d", b.L1BlockNumber),
MixHash: b.MixHash,
SendCount: b.SendCount,
SendRoot: b.SendRoot,
L1BlockNumber: fmt.Sprintf("%d", b.L1BlockNumber),

Transactions: txs,
})
Expand Down Expand Up @@ -553,10 +553,10 @@ func ToProtoSingleBlock(obj *seer_common.BlockJson) *ArbitrumOneBlock {
TransactionsRoot: obj.TransactionsRoot,
IndexedAt: fromHex(obj.IndexedAt).Uint64(),

MixHash: obj.MixHash,
SendCount: obj.SendCount,
SendRoot: obj.SendRoot,
L1BlockNumber: fromHex(obj.L1BlockNumber).Uint64(),
MixHash: obj.MixHash,
SendCount: obj.SendCount,
SendRoot: obj.SendRoot,
L1BlockNumber: fromHex(obj.L1BlockNumber).Uint64(),
}
}

Expand Down Expand Up @@ -674,12 +674,12 @@ func (c *Client) DecodeProtoBlocks(data []string) ([]*ArbitrumOneBlock, error) {
func (c *Client) DecodeProtoEntireBlockToJson(rawData *bytes.Buffer) (*seer_common.BlocksBatchJson, error) {
var protoBlocksBatch ArbitrumOneBlocksBatch

dataBytes := rawData.Bytes()
dataBytes := rawData.Bytes()

err := proto.Unmarshal(dataBytes, &protoBlocksBatch)
if err != nil {
return nil, fmt.Errorf("failed to unmarshal data: %v", err)
}
err := proto.Unmarshal(dataBytes, &protoBlocksBatch)
if err != nil {
return nil, fmt.Errorf("failed to unmarshal data: %v", err)
}

blocksBatchJson := ToEntireBlocksBatchFromLogProto(&protoBlocksBatch)

Expand All @@ -691,10 +691,10 @@ func (c *Client) DecodeProtoEntireBlockToLabels(rawData *bytes.Buffer, blocksCac

dataBytes := rawData.Bytes()

err := proto.Unmarshal(dataBytes, &protoBlocksBatch)
if err != nil {
return nil, nil, fmt.Errorf("failed to unmarshal data: %v", err)
}
err := proto.Unmarshal(dataBytes, &protoBlocksBatch)
if err != nil {
return nil, nil, fmt.Errorf("failed to unmarshal data: %v", err)
}

var labels []indexer.EventLabel
var txLabels []indexer.TransactionLabel
Expand Down Expand Up @@ -729,10 +729,12 @@ func (c *Client) DecodeProtoEntireBlockToLabels(rawData *bytes.Buffer, blocksCac
decodedArgs, decodeErr := seer_common.DecodeTransactionInputDataToInterface(&txContractAbi, inputData)
if decodeErr != nil {
fmt.Println("Error decoding transaction not decoded data: ", tx.Hash, decodeErr)
decodedArgs["input_raw"] = tx
decodedArgs["abi"] = abiMap[tx.ToAddress][selector]["abi"]
decodedArgs["selector"] = selector
decodedArgs["error"] = decodeErr
decodedArgs = map[string]interface{}{
"input_raw": tx,
"abi": abiMap[tx.ToAddress][selector]["abi"],
"selector": selector,
"error": decodeErr,
}
label = indexer.SeerCrawlerRawLabel
}

Expand Down Expand Up @@ -784,14 +786,17 @@ func (c *Client) DecodeProtoEntireBlockToLabels(rawData *bytes.Buffer, blocksCac
return nil, nil, err
}


// Decode the event data
decodedArgs, decodeErr = seer_common.DecodeLogArgsToLabelData(&contractAbi, e.Topics, e.Data)
if decodeErr != nil {
fmt.Println("Error decoding event not decoded data: ", e.TransactionHash, decodeErr)
decodedArgs["input_raw"] = e
decodedArgs["abi"] = abiMap[e.Address][topicSelector]["abi"]
decodedArgs["selector"] = topicSelector
decodedArgs["error"] = decodeErr
decodedArgs = map[string]interface{}{
"input_raw": e,
"abi": abiMap[e.Address][topicSelector]["abi"],
"selector": topicSelector,
"error": decodeErr,
}
label = indexer.SeerCrawlerRawLabel
}

Expand Down Expand Up @@ -837,6 +842,7 @@ func (c *Client) DecodeProtoTransactionsToLabels(transactions []string, blocksCa
var decodedArgs map[string]interface{}
var decodeErr error


for _, transaction := range decodedTransactions {

label := indexer.SeerCrawlerLabel
Expand All @@ -859,10 +865,12 @@ func (c *Client) DecodeProtoTransactionsToLabels(transactions []string, blocksCa

if decodeErr != nil {
fmt.Println("Error decoding transaction not decoded data: ", transaction.Hash, decodeErr)
decodedArgs["input_raw"] = transaction
decodedArgs["abi"] = abiMap[transaction.ToAddress][selector]["abi"]
decodedArgs["selector"] = selector
decodedArgs["error"] = decodeErr
decodedArgs = map[string]interface{}{
"input_raw": transaction,
"abi": abiMap[transaction.ToAddress][selector]["abi"],
"selector": selector,
"error": decodeErr,
}
label = indexer.SeerCrawlerRawLabel
}

Expand Down Expand Up @@ -894,4 +902,4 @@ func (c *Client) DecodeProtoTransactionsToLabels(transactions []string, blocksCa
}

return labels, nil
}
}
72 changes: 40 additions & 32 deletions blockchain/arbitrum_sepolia/arbitrum_sepolia.go
Original file line number Diff line number Diff line change
Expand Up @@ -435,14 +435,14 @@ func (c *Client) ProcessBlocksToBatch(msgs []proto.Message) (proto.Message, erro
}

return &ArbitrumSepoliaBlocksBatch{
Blocks: blocks,
Blocks: blocks,
SeerVersion: version.SeerVersion,
}, nil
}

func ToEntireBlocksBatchFromLogProto(obj *ArbitrumSepoliaBlocksBatch) *seer_common.BlocksBatchJson {
blocksBatchJson := seer_common.BlocksBatchJson{
Blocks: []seer_common.BlockJson{},
Blocks: []seer_common.BlockJson{},
SeerVersion: obj.SeerVersion,
}

Expand Down Expand Up @@ -519,10 +519,10 @@ func ToEntireBlocksBatchFromLogProto(obj *ArbitrumSepoliaBlocksBatch) *seer_comm
BaseFeePerGas: b.BaseFeePerGas,
IndexedAt: fmt.Sprintf("%d", b.IndexedAt),

MixHash: b.MixHash,
SendCount: b.SendCount,
SendRoot: b.SendRoot,
L1BlockNumber: fmt.Sprintf("%d", b.L1BlockNumber),
MixHash: b.MixHash,
SendCount: b.SendCount,
SendRoot: b.SendRoot,
L1BlockNumber: fmt.Sprintf("%d", b.L1BlockNumber),

Transactions: txs,
})
Expand Down Expand Up @@ -553,10 +553,10 @@ func ToProtoSingleBlock(obj *seer_common.BlockJson) *ArbitrumSepoliaBlock {
TransactionsRoot: obj.TransactionsRoot,
IndexedAt: fromHex(obj.IndexedAt).Uint64(),

MixHash: obj.MixHash,
SendCount: obj.SendCount,
SendRoot: obj.SendRoot,
L1BlockNumber: fromHex(obj.L1BlockNumber).Uint64(),
MixHash: obj.MixHash,
SendCount: obj.SendCount,
SendRoot: obj.SendRoot,
L1BlockNumber: fromHex(obj.L1BlockNumber).Uint64(),
}
}

Expand Down Expand Up @@ -674,12 +674,12 @@ func (c *Client) DecodeProtoBlocks(data []string) ([]*ArbitrumSepoliaBlock, erro
func (c *Client) DecodeProtoEntireBlockToJson(rawData *bytes.Buffer) (*seer_common.BlocksBatchJson, error) {
var protoBlocksBatch ArbitrumSepoliaBlocksBatch

dataBytes := rawData.Bytes()
dataBytes := rawData.Bytes()

err := proto.Unmarshal(dataBytes, &protoBlocksBatch)
if err != nil {
return nil, fmt.Errorf("failed to unmarshal data: %v", err)
}
err := proto.Unmarshal(dataBytes, &protoBlocksBatch)
if err != nil {
return nil, fmt.Errorf("failed to unmarshal data: %v", err)
}

blocksBatchJson := ToEntireBlocksBatchFromLogProto(&protoBlocksBatch)

Expand All @@ -691,10 +691,10 @@ func (c *Client) DecodeProtoEntireBlockToLabels(rawData *bytes.Buffer, blocksCac

dataBytes := rawData.Bytes()

err := proto.Unmarshal(dataBytes, &protoBlocksBatch)
if err != nil {
return nil, nil, fmt.Errorf("failed to unmarshal data: %v", err)
}
err := proto.Unmarshal(dataBytes, &protoBlocksBatch)
if err != nil {
return nil, nil, fmt.Errorf("failed to unmarshal data: %v", err)
}

var labels []indexer.EventLabel
var txLabels []indexer.TransactionLabel
Expand Down Expand Up @@ -729,10 +729,12 @@ func (c *Client) DecodeProtoEntireBlockToLabels(rawData *bytes.Buffer, blocksCac
decodedArgs, decodeErr := seer_common.DecodeTransactionInputDataToInterface(&txContractAbi, inputData)
if decodeErr != nil {
fmt.Println("Error decoding transaction not decoded data: ", tx.Hash, decodeErr)
decodedArgs["input_raw"] = tx
decodedArgs["abi"] = abiMap[tx.ToAddress][selector]["abi"]
decodedArgs["selector"] = selector
decodedArgs["error"] = decodeErr
decodedArgs = map[string]interface{}{
"input_raw": tx,
"abi": abiMap[tx.ToAddress][selector]["abi"],
"selector": selector,
"error": decodeErr,
}
label = indexer.SeerCrawlerRawLabel
}

Expand Down Expand Up @@ -784,14 +786,17 @@ func (c *Client) DecodeProtoEntireBlockToLabels(rawData *bytes.Buffer, blocksCac
return nil, nil, err
}


// Decode the event data
decodedArgs, decodeErr = seer_common.DecodeLogArgsToLabelData(&contractAbi, e.Topics, e.Data)
if decodeErr != nil {
fmt.Println("Error decoding event not decoded data: ", e.TransactionHash, decodeErr)
decodedArgs["input_raw"] = e
decodedArgs["abi"] = abiMap[e.Address][topicSelector]["abi"]
decodedArgs["selector"] = topicSelector
decodedArgs["error"] = decodeErr
decodedArgs = map[string]interface{}{
"input_raw": e,
"abi": abiMap[e.Address][topicSelector]["abi"],
"selector": topicSelector,
"error": decodeErr,
}
label = indexer.SeerCrawlerRawLabel
}

Expand Down Expand Up @@ -837,6 +842,7 @@ func (c *Client) DecodeProtoTransactionsToLabels(transactions []string, blocksCa
var decodedArgs map[string]interface{}
var decodeErr error


for _, transaction := range decodedTransactions {

label := indexer.SeerCrawlerLabel
Expand All @@ -859,10 +865,12 @@ func (c *Client) DecodeProtoTransactionsToLabels(transactions []string, blocksCa

if decodeErr != nil {
fmt.Println("Error decoding transaction not decoded data: ", transaction.Hash, decodeErr)
decodedArgs["input_raw"] = transaction
decodedArgs["abi"] = abiMap[transaction.ToAddress][selector]["abi"]
decodedArgs["selector"] = selector
decodedArgs["error"] = decodeErr
decodedArgs = map[string]interface{}{
"input_raw": transaction,
"abi": abiMap[transaction.ToAddress][selector]["abi"],
"selector": selector,
"error": decodeErr,
}
label = indexer.SeerCrawlerRawLabel
}

Expand Down Expand Up @@ -894,4 +902,4 @@ func (c *Client) DecodeProtoTransactionsToLabels(transactions []string, blocksCa
}

return labels, nil
}
}
30 changes: 18 additions & 12 deletions blockchain/blockchain.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -729,10 +729,12 @@ func (c *Client) DecodeProtoEntireBlockToLabels(rawData *bytes.Buffer, blocksCac
decodedArgs, decodeErr := seer_common.DecodeTransactionInputDataToInterface(&txContractAbi, inputData)
if decodeErr != nil {
fmt.Println("Error decoding transaction not decoded data: ", tx.Hash, decodeErr)
decodedArgs["input_raw"] = tx
decodedArgs["abi"] = abiMap[tx.ToAddress][selector]["abi"]
decodedArgs["selector"] = selector
decodedArgs["error"] = decodeErr
decodedArgs = map[string]interface{}{
"input_raw": tx,
"abi": abiMap[tx.ToAddress][selector]["abi"],
"selector": selector,
"error": decodeErr,
}
label = indexer.SeerCrawlerRawLabel
}

Expand Down Expand Up @@ -789,10 +791,12 @@ func (c *Client) DecodeProtoEntireBlockToLabels(rawData *bytes.Buffer, blocksCac
decodedArgs, decodeErr = seer_common.DecodeLogArgsToLabelData(&contractAbi, e.Topics, e.Data)
if decodeErr != nil {
fmt.Println("Error decoding event not decoded data: ", e.TransactionHash, decodeErr)
decodedArgs["input_raw"] = e
decodedArgs["abi"] = abiMap[e.Address][topicSelector]["abi"]
decodedArgs["selector"] = topicSelector
decodedArgs["error"] = decodeErr
decodedArgs = map[string]interface{}{
"input_raw": e,
"abi": abiMap[e.Address][topicSelector]["abi"],
"selector": topicSelector,
"error": decodeErr,
}
label = indexer.SeerCrawlerRawLabel
}

Expand Down Expand Up @@ -861,10 +865,12 @@ func (c *Client) DecodeProtoTransactionsToLabels(transactions []string, blocksCa

if decodeErr != nil {
fmt.Println("Error decoding transaction not decoded data: ", transaction.Hash, decodeErr)
decodedArgs["input_raw"] = transaction
decodedArgs["abi"] = abiMap[transaction.ToAddress][selector]["abi"]
decodedArgs["selector"] = selector
decodedArgs["error"] = decodeErr
decodedArgs = map[string]interface{}{
"input_raw": transaction,
"abi": abiMap[transaction.ToAddress][selector]["abi"],
"selector": selector,
"error": decodeErr,
}
label = indexer.SeerCrawlerRawLabel
}

Expand Down
Loading

0 comments on commit ddb8c97

Please sign in to comment.