Skip to content

Commit

Permalink
Refactor.
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrey committed Jul 24, 2024
1 parent 78be788 commit a30bacc
Show file tree
Hide file tree
Showing 10 changed files with 162 additions and 160 deletions.
32 changes: 16 additions & 16 deletions blockchain/arbitrum_one/arbitrum_one.go
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,8 @@ func (c *Client) DecodeProtoEntireBlockToLabels(rawData *bytes.Buffer, blocksCac

var labels []indexer.EventLabel
var txLabels []indexer.TransactionLabel
var decodedArgs map[string]interface{}
var decodeErr error

for _, b := range protoBlocksBatch.Blocks {
for _, tx := range b.Transactions {
Expand All @@ -724,14 +726,13 @@ func (c *Client) DecodeProtoEntireBlockToLabels(rawData *bytes.Buffer, blocksCac
return nil, nil, err
}

decodedArgs, err := seer_common.DecodeTransactionInputDataToInterface(&txContractAbi, inputData)
if err != nil {
decodedArgs = map[string]interface{}{}
fmt.Println("Error decoding transaction not decoded data: ", tx.Hash, err)
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"] = err
decodedArgs["error"] = decodeErr
label = indexer.SeerCrawlerRawLabel
}

Expand Down Expand Up @@ -784,15 +785,13 @@ func (c *Client) DecodeProtoEntireBlockToLabels(rawData *bytes.Buffer, blocksCac
}

// Decode the event data
decodedArgs, err := seer_common.DecodeLogArgsToLabelData(&contractAbi, e.Topics, e.Data)

if err != nil {
decodedArgs = map[string]interface{}{}
fmt.Println("Error decoding event not decoded data: ", e.TransactionHash, err)
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"] = err
decodedArgs["error"] = decodeErr
label = indexer.SeerCrawlerRawLabel
}

Expand Down Expand Up @@ -835,6 +834,8 @@ func (c *Client) DecodeProtoTransactionsToLabels(transactions []string, blocksCa
}

var labels []indexer.TransactionLabel
var decodedArgs map[string]interface{}
var decodeErr error

for _, transaction := range decodedTransactions {

Expand All @@ -854,15 +855,14 @@ func (c *Client) DecodeProtoTransactionsToLabels(transactions []string, blocksCa
return nil, err
}

decodedArgs, err := seer_common.DecodeTransactionInputDataToInterface(&contractAbi, inputData)
decodedArgs, decodeErr = seer_common.DecodeTransactionInputDataToInterface(&contractAbi, inputData)

if err != nil {
decodedArgs = map[string]interface{}{}
fmt.Println("Error decoding transaction not decoded data: ", transaction.Hash, err)
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"] = err
decodedArgs["error"] = decodeErr
label = indexer.SeerCrawlerRawLabel
}

Expand Down
32 changes: 16 additions & 16 deletions blockchain/arbitrum_sepolia/arbitrum_sepolia.go
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,8 @@ func (c *Client) DecodeProtoEntireBlockToLabels(rawData *bytes.Buffer, blocksCac

var labels []indexer.EventLabel
var txLabels []indexer.TransactionLabel
var decodedArgs map[string]interface{}
var decodeErr error

for _, b := range protoBlocksBatch.Blocks {
for _, tx := range b.Transactions {
Expand All @@ -724,14 +726,13 @@ func (c *Client) DecodeProtoEntireBlockToLabels(rawData *bytes.Buffer, blocksCac
return nil, nil, err
}

decodedArgs, err := seer_common.DecodeTransactionInputDataToInterface(&txContractAbi, inputData)
if err != nil {
decodedArgs = map[string]interface{}{}
fmt.Println("Error decoding transaction not decoded data: ", tx.Hash, err)
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"] = err
decodedArgs["error"] = decodeErr
label = indexer.SeerCrawlerRawLabel
}

Expand Down Expand Up @@ -784,15 +785,13 @@ func (c *Client) DecodeProtoEntireBlockToLabels(rawData *bytes.Buffer, blocksCac
}

// Decode the event data
decodedArgs, err := seer_common.DecodeLogArgsToLabelData(&contractAbi, e.Topics, e.Data)

if err != nil {
decodedArgs = map[string]interface{}{}
fmt.Println("Error decoding event not decoded data: ", e.TransactionHash, err)
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"] = err
decodedArgs["error"] = decodeErr
label = indexer.SeerCrawlerRawLabel
}

Expand Down Expand Up @@ -835,6 +834,8 @@ func (c *Client) DecodeProtoTransactionsToLabels(transactions []string, blocksCa
}

var labels []indexer.TransactionLabel
var decodedArgs map[string]interface{}
var decodeErr error

for _, transaction := range decodedTransactions {

Expand All @@ -854,15 +855,14 @@ func (c *Client) DecodeProtoTransactionsToLabels(transactions []string, blocksCa
return nil, err
}

decodedArgs, err := seer_common.DecodeTransactionInputDataToInterface(&contractAbi, inputData)
decodedArgs, decodeErr = seer_common.DecodeTransactionInputDataToInterface(&contractAbi, inputData)

if err != nil {
decodedArgs = map[string]interface{}{}
fmt.Println("Error decoding transaction not decoded data: ", transaction.Hash, err)
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"] = err
decodedArgs["error"] = decodeErr
label = indexer.SeerCrawlerRawLabel
}

Expand Down
34 changes: 18 additions & 16 deletions blockchain/blockchain.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,8 @@ func (c *Client) DecodeProtoEntireBlockToLabels(rawData *bytes.Buffer, blocksCac

var labels []indexer.EventLabel
var txLabels []indexer.TransactionLabel
var decodedArgs map[string]interface{}
var decodeErr error

for _, b := range protoBlocksBatch.Blocks {
for _, tx := range b.Transactions {
Expand All @@ -724,14 +726,13 @@ func (c *Client) DecodeProtoEntireBlockToLabels(rawData *bytes.Buffer, blocksCac
return nil, nil, err
}

decodedArgs, err := seer_common.DecodeTransactionInputDataToInterface(&txContractAbi, inputData)
if err != nil {
decodedArgs = map[string]interface{}{}
fmt.Println("Error decoding transaction not decoded data: ", tx.Hash, err)
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"] = err
decodedArgs["error"] = decodeErr
label = indexer.SeerCrawlerRawLabel
}

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

// Decode the event data
decodedArgs, err := seer_common.DecodeLogArgsToLabelData(&contractAbi, e.Topics, e.Data)

if err != nil {
decodedArgs = map[string]interface{}{}
fmt.Println("Error decoding event not decoded data: ", e.TransactionHash, 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"] = err
decodedArgs["error"] = decodeErr
label = indexer.SeerCrawlerRawLabel
}

Expand Down Expand Up @@ -835,6 +835,9 @@ func (c *Client) DecodeProtoTransactionsToLabels(transactions []string, blocksCa
}

var labels []indexer.TransactionLabel
var decodedArgs map[string]interface{}
var decodeErr error


for _, transaction := range decodedTransactions {

Expand All @@ -854,15 +857,14 @@ func (c *Client) DecodeProtoTransactionsToLabels(transactions []string, blocksCa
return nil, err
}

decodedArgs, err := seer_common.DecodeTransactionInputDataToInterface(&contractAbi, inputData)
decodedArgs, decodeErr = seer_common.DecodeTransactionInputDataToInterface(&contractAbi, inputData)

if err != nil {
decodedArgs = map[string]interface{}{}
fmt.Println("Error decoding transaction not decoded data: ", transaction.Hash, err)
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"] = err
decodedArgs["error"] = decodeErr
label = indexer.SeerCrawlerRawLabel
}

Expand Down
32 changes: 16 additions & 16 deletions blockchain/ethereum/ethereum.go
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,8 @@ func (c *Client) DecodeProtoEntireBlockToLabels(rawData *bytes.Buffer, blocksCac

var labels []indexer.EventLabel
var txLabels []indexer.TransactionLabel
var decodedArgs map[string]interface{}
var decodeErr error

for _, b := range protoBlocksBatch.Blocks {
for _, tx := range b.Transactions {
Expand All @@ -714,14 +716,13 @@ func (c *Client) DecodeProtoEntireBlockToLabels(rawData *bytes.Buffer, blocksCac
return nil, nil, err
}

decodedArgs, err := seer_common.DecodeTransactionInputDataToInterface(&txContractAbi, inputData)
if err != nil {
decodedArgs = map[string]interface{}{}
fmt.Println("Error decoding transaction not decoded data: ", tx.Hash, err)
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"] = err
decodedArgs["error"] = decodeErr
label = indexer.SeerCrawlerRawLabel
}

Expand Down Expand Up @@ -774,15 +775,13 @@ func (c *Client) DecodeProtoEntireBlockToLabels(rawData *bytes.Buffer, blocksCac
}

// Decode the event data
decodedArgs, err := seer_common.DecodeLogArgsToLabelData(&contractAbi, e.Topics, e.Data)

if err != nil {
decodedArgs = map[string]interface{}{}
fmt.Println("Error decoding event not decoded data: ", e.TransactionHash, err)
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"] = err
decodedArgs["error"] = decodeErr
label = indexer.SeerCrawlerRawLabel
}

Expand Down Expand Up @@ -825,6 +824,8 @@ func (c *Client) DecodeProtoTransactionsToLabels(transactions []string, blocksCa
}

var labels []indexer.TransactionLabel
var decodedArgs map[string]interface{}
var decodeErr error

for _, transaction := range decodedTransactions {

Expand All @@ -844,15 +845,14 @@ func (c *Client) DecodeProtoTransactionsToLabels(transactions []string, blocksCa
return nil, err
}

decodedArgs, err := seer_common.DecodeTransactionInputDataToInterface(&contractAbi, inputData)
decodedArgs, decodeErr = seer_common.DecodeTransactionInputDataToInterface(&contractAbi, inputData)

if err != nil {
decodedArgs = map[string]interface{}{}
fmt.Println("Error decoding transaction not decoded data: ", transaction.Hash, err)
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"] = err
decodedArgs["error"] = decodeErr
label = indexer.SeerCrawlerRawLabel
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,8 @@ func (c *Client) DecodeProtoEntireBlockToLabels(rawData *bytes.Buffer, blocksCac

var labels []indexer.EventLabel
var txLabels []indexer.TransactionLabel
var decodedArgs map[string]interface{}
var decodeErr error

for _, b := range protoBlocksBatch.Blocks {
for _, tx := range b.Transactions {
Expand All @@ -724,14 +726,13 @@ func (c *Client) DecodeProtoEntireBlockToLabels(rawData *bytes.Buffer, blocksCac
return nil, nil, err
}

decodedArgs, err := seer_common.DecodeTransactionInputDataToInterface(&txContractAbi, inputData)
if err != nil {
decodedArgs = map[string]interface{}{}
fmt.Println("Error decoding transaction not decoded data: ", tx.Hash, err)
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"] = err
decodedArgs["error"] = decodeErr
label = indexer.SeerCrawlerRawLabel
}

Expand Down Expand Up @@ -784,15 +785,13 @@ func (c *Client) DecodeProtoEntireBlockToLabels(rawData *bytes.Buffer, blocksCac
}

// Decode the event data
decodedArgs, err := seer_common.DecodeLogArgsToLabelData(&contractAbi, e.Topics, e.Data)

if err != nil {
decodedArgs = map[string]interface{}{}
fmt.Println("Error decoding event not decoded data: ", e.TransactionHash, err)
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"] = err
decodedArgs["error"] = decodeErr
label = indexer.SeerCrawlerRawLabel
}

Expand Down Expand Up @@ -835,6 +834,8 @@ func (c *Client) DecodeProtoTransactionsToLabels(transactions []string, blocksCa
}

var labels []indexer.TransactionLabel
var decodedArgs map[string]interface{}
var decodeErr error

for _, transaction := range decodedTransactions {

Expand All @@ -854,15 +855,14 @@ func (c *Client) DecodeProtoTransactionsToLabels(transactions []string, blocksCa
return nil, err
}

decodedArgs, err := seer_common.DecodeTransactionInputDataToInterface(&contractAbi, inputData)
decodedArgs, decodeErr = seer_common.DecodeTransactionInputDataToInterface(&contractAbi, inputData)

if err != nil {
decodedArgs = map[string]interface{}{}
fmt.Println("Error decoding transaction not decoded data: ", transaction.Hash, err)
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"] = err
decodedArgs["error"] = decodeErr
label = indexer.SeerCrawlerRawLabel
}

Expand Down
Loading

0 comments on commit a30bacc

Please sign in to comment.