Skip to content

Commit

Permalink
Merge pull request #25 from moonstream-to/indexers-deploy
Browse files Browse the repository at this point in the history
Small fix and deploy scripts.
  • Loading branch information
Andrei-Dolgolev authored Jun 7, 2024
2 parents 53d19ea + 626423b commit 14fa9a3
Show file tree
Hide file tree
Showing 27 changed files with 598 additions and 346 deletions.
15 changes: 5 additions & 10 deletions blockchain/arbitrum_one/arbitrum_one.go
Original file line number Diff line number Diff line change
Expand Up @@ -495,15 +495,13 @@ func (c *Client) DecodeProtoEventsToLabels(events []string, blocksCache map[uint
var topicSelector string

if len(event.Topics) > 0 {
topicSelector = event.Topics[0][:10]
topicSelector = event.Topics[0]
} else {
continue
}

checksumAddress := common.HexToAddress(event.Address).Hex()

// Get the ABI string
contractAbi, err := abi.JSON(strings.NewReader(abiMap[checksumAddress][topicSelector]["abi"]))
contractAbi, err := abi.JSON(strings.NewReader(abiMap[event.Address][topicSelector]["abi"]))
if err != nil {
fmt.Println("Error initializing contract ABI: ", err)
return nil, err
Expand All @@ -529,7 +527,7 @@ func (c *Client) DecodeProtoEventsToLabels(events []string, blocksCache map[uint
// Convert event to label
eventLabel := indexer.EventLabel{
Label: indexer.SeerCrawlerLabel,
LabelName: abiMap[checksumAddress][topicSelector]["abi_name"],
LabelName: abiMap[event.Address][topicSelector]["abi_name"],
LabelType: "event",
BlockNumber: event.BlockNumber,
BlockHash: event.BlockHash,
Expand Down Expand Up @@ -561,10 +559,7 @@ func (c *Client) DecodeProtoTransactionsToLabels(transactions []string, blocksCa

selector := transaction.Input[:10]

// To checksum address
checksumAddress := common.HexToAddress(transaction.ToAddress).Hex()

contractAbi, err := abi.JSON(strings.NewReader(abiMap[checksumAddress][selector]["abi"]))
contractAbi, err := abi.JSON(strings.NewReader(abiMap[transaction.ToAddress][selector]["abi"]))

if err != nil {
return nil, err
Expand Down Expand Up @@ -597,7 +592,7 @@ func (c *Client) DecodeProtoTransactionsToLabels(transactions []string, blocksCa
BlockNumber: transaction.BlockNumber,
BlockHash: transaction.BlockHash,
CallerAddress: transaction.FromAddress,
LabelName: abiMap[checksumAddress][selector]["abi_name"],
LabelName: abiMap[transaction.ToAddress][selector]["abi_name"],
LabelType: "tx_call",
OriginAddress: transaction.FromAddress,
Label: indexer.SeerCrawlerLabel,
Expand Down
15 changes: 5 additions & 10 deletions blockchain/arbitrum_sepolia/arbitrum_sepolia.go
Original file line number Diff line number Diff line change
Expand Up @@ -495,15 +495,13 @@ func (c *Client) DecodeProtoEventsToLabels(events []string, blocksCache map[uint
var topicSelector string

if len(event.Topics) > 0 {
topicSelector = event.Topics[0][:10]
topicSelector = event.Topics[0]
} else {
continue
}

checksumAddress := common.HexToAddress(event.Address).Hex()

// Get the ABI string
contractAbi, err := abi.JSON(strings.NewReader(abiMap[checksumAddress][topicSelector]["abi"]))
contractAbi, err := abi.JSON(strings.NewReader(abiMap[event.Address][topicSelector]["abi"]))
if err != nil {
fmt.Println("Error initializing contract ABI: ", err)
return nil, err
Expand All @@ -529,7 +527,7 @@ func (c *Client) DecodeProtoEventsToLabels(events []string, blocksCache map[uint
// Convert event to label
eventLabel := indexer.EventLabel{
Label: indexer.SeerCrawlerLabel,
LabelName: abiMap[checksumAddress][topicSelector]["abi_name"],
LabelName: abiMap[event.Address][topicSelector]["abi_name"],
LabelType: "event",
BlockNumber: event.BlockNumber,
BlockHash: event.BlockHash,
Expand Down Expand Up @@ -561,10 +559,7 @@ func (c *Client) DecodeProtoTransactionsToLabels(transactions []string, blocksCa

selector := transaction.Input[:10]

// To checksum address
checksumAddress := common.HexToAddress(transaction.ToAddress).Hex()

contractAbi, err := abi.JSON(strings.NewReader(abiMap[checksumAddress][selector]["abi"]))
contractAbi, err := abi.JSON(strings.NewReader(abiMap[transaction.ToAddress][selector]["abi"]))

if err != nil {
return nil, err
Expand Down Expand Up @@ -597,7 +592,7 @@ func (c *Client) DecodeProtoTransactionsToLabels(transactions []string, blocksCa
BlockNumber: transaction.BlockNumber,
BlockHash: transaction.BlockHash,
CallerAddress: transaction.FromAddress,
LabelName: abiMap[checksumAddress][selector]["abi_name"],
LabelName: abiMap[transaction.ToAddress][selector]["abi_name"],
LabelType: "tx_call",
OriginAddress: transaction.FromAddress,
Label: indexer.SeerCrawlerLabel,
Expand Down
15 changes: 5 additions & 10 deletions blockchain/blockchain.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -495,15 +495,13 @@ func (c *Client) DecodeProtoEventsToLabels(events []string, blocksCache map[uint
var topicSelector string

if len(event.Topics) > 0 {
topicSelector = event.Topics[0][:10]
topicSelector = event.Topics[0]
} else {
continue
}

checksumAddress := common.HexToAddress(event.Address).Hex()

// Get the ABI string
contractAbi, err := abi.JSON(strings.NewReader(abiMap[checksumAddress][topicSelector]["abi"]))
contractAbi, err := abi.JSON(strings.NewReader(abiMap[event.Address][topicSelector]["abi"]))
if err != nil {
fmt.Println("Error initializing contract ABI: ", err)
return nil, err
Expand All @@ -529,7 +527,7 @@ func (c *Client) DecodeProtoEventsToLabels(events []string, blocksCache map[uint
// Convert event to label
eventLabel := indexer.EventLabel{
Label: indexer.SeerCrawlerLabel,
LabelName: abiMap[checksumAddress][topicSelector]["abi_name"],
LabelName: abiMap[event.Address][topicSelector]["abi_name"],
LabelType: "event",
BlockNumber: event.BlockNumber,
BlockHash: event.BlockHash,
Expand Down Expand Up @@ -561,10 +559,7 @@ func (c *Client) DecodeProtoTransactionsToLabels(transactions []string, blocksCa

selector := transaction.Input[:10]

// To checksum address
checksumAddress := common.HexToAddress(transaction.ToAddress).Hex()

contractAbi, err := abi.JSON(strings.NewReader(abiMap[checksumAddress][selector]["abi"]))
contractAbi, err := abi.JSON(strings.NewReader(abiMap[transaction.ToAddress][selector]["abi"]))

if err != nil {
return nil, err
Expand Down Expand Up @@ -597,7 +592,7 @@ func (c *Client) DecodeProtoTransactionsToLabels(transactions []string, blocksCa
BlockNumber: transaction.BlockNumber,
BlockHash: transaction.BlockHash,
CallerAddress: transaction.FromAddress,
LabelName: abiMap[checksumAddress][selector]["abi_name"],
LabelName: abiMap[transaction.ToAddress][selector]["abi_name"],
LabelType: "tx_call",
OriginAddress: transaction.FromAddress,
Label: indexer.SeerCrawlerLabel,
Expand Down
15 changes: 5 additions & 10 deletions blockchain/ethereum/ethereum.go
Original file line number Diff line number Diff line change
Expand Up @@ -490,15 +490,13 @@ func (c *Client) DecodeProtoEventsToLabels(events []string, blocksCache map[uint
var topicSelector string

if len(event.Topics) > 0 {
topicSelector = event.Topics[0][:10]
topicSelector = event.Topics[0]
} else {
continue
}

checksumAddress := common.HexToAddress(event.Address).Hex()

// Get the ABI string
contractAbi, err := abi.JSON(strings.NewReader(abiMap[checksumAddress][topicSelector]["abi"]))
contractAbi, err := abi.JSON(strings.NewReader(abiMap[event.Address][topicSelector]["abi"]))
if err != nil {
fmt.Println("Error initializing contract ABI: ", err)
return nil, err
Expand All @@ -524,7 +522,7 @@ func (c *Client) DecodeProtoEventsToLabels(events []string, blocksCache map[uint
// Convert event to label
eventLabel := indexer.EventLabel{
Label: indexer.SeerCrawlerLabel,
LabelName: abiMap[checksumAddress][topicSelector]["abi_name"],
LabelName: abiMap[event.Address][topicSelector]["abi_name"],
LabelType: "event",
BlockNumber: event.BlockNumber,
BlockHash: event.BlockHash,
Expand Down Expand Up @@ -556,10 +554,7 @@ func (c *Client) DecodeProtoTransactionsToLabels(transactions []string, blocksCa

selector := transaction.Input[:10]

// To checksum address
checksumAddress := common.HexToAddress(transaction.ToAddress).Hex()

contractAbi, err := abi.JSON(strings.NewReader(abiMap[checksumAddress][selector]["abi"]))
contractAbi, err := abi.JSON(strings.NewReader(abiMap[transaction.ToAddress][selector]["abi"]))

if err != nil {
return nil, err
Expand Down Expand Up @@ -592,7 +587,7 @@ func (c *Client) DecodeProtoTransactionsToLabels(transactions []string, blocksCa
BlockNumber: transaction.BlockNumber,
BlockHash: transaction.BlockHash,
CallerAddress: transaction.FromAddress,
LabelName: abiMap[checksumAddress][selector]["abi_name"],
LabelName: abiMap[transaction.ToAddress][selector]["abi_name"],
LabelType: "tx_call",
OriginAddress: transaction.FromAddress,
Label: indexer.SeerCrawlerLabel,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -495,15 +495,13 @@ func (c *Client) DecodeProtoEventsToLabels(events []string, blocksCache map[uint
var topicSelector string

if len(event.Topics) > 0 {
topicSelector = event.Topics[0][:10]
topicSelector = event.Topics[0]
} else {
continue
}

checksumAddress := common.HexToAddress(event.Address).Hex()

// Get the ABI string
contractAbi, err := abi.JSON(strings.NewReader(abiMap[checksumAddress][topicSelector]["abi"]))
contractAbi, err := abi.JSON(strings.NewReader(abiMap[event.Address][topicSelector]["abi"]))
if err != nil {
fmt.Println("Error initializing contract ABI: ", err)
return nil, err
Expand All @@ -529,7 +527,7 @@ func (c *Client) DecodeProtoEventsToLabels(events []string, blocksCache map[uint
// Convert event to label
eventLabel := indexer.EventLabel{
Label: indexer.SeerCrawlerLabel,
LabelName: abiMap[checksumAddress][topicSelector]["abi_name"],
LabelName: abiMap[event.Address][topicSelector]["abi_name"],
LabelType: "event",
BlockNumber: event.BlockNumber,
BlockHash: event.BlockHash,
Expand Down Expand Up @@ -561,10 +559,7 @@ func (c *Client) DecodeProtoTransactionsToLabels(transactions []string, blocksCa

selector := transaction.Input[:10]

// To checksum address
checksumAddress := common.HexToAddress(transaction.ToAddress).Hex()

contractAbi, err := abi.JSON(strings.NewReader(abiMap[checksumAddress][selector]["abi"]))
contractAbi, err := abi.JSON(strings.NewReader(abiMap[transaction.ToAddress][selector]["abi"]))

if err != nil {
return nil, err
Expand Down Expand Up @@ -597,7 +592,7 @@ func (c *Client) DecodeProtoTransactionsToLabels(transactions []string, blocksCa
BlockNumber: transaction.BlockNumber,
BlockHash: transaction.BlockHash,
CallerAddress: transaction.FromAddress,
LabelName: abiMap[checksumAddress][selector]["abi_name"],
LabelName: abiMap[transaction.ToAddress][selector]["abi_name"],
LabelType: "tx_call",
OriginAddress: transaction.FromAddress,
Label: indexer.SeerCrawlerLabel,
Expand Down
15 changes: 5 additions & 10 deletions blockchain/mantle/mantle.go
Original file line number Diff line number Diff line change
Expand Up @@ -490,15 +490,13 @@ func (c *Client) DecodeProtoEventsToLabels(events []string, blocksCache map[uint
var topicSelector string

if len(event.Topics) > 0 {
topicSelector = event.Topics[0][:10]
topicSelector = event.Topics[0]
} else {
continue
}

checksumAddress := common.HexToAddress(event.Address).Hex()

// Get the ABI string
contractAbi, err := abi.JSON(strings.NewReader(abiMap[checksumAddress][topicSelector]["abi"]))
contractAbi, err := abi.JSON(strings.NewReader(abiMap[event.Address][topicSelector]["abi"]))
if err != nil {
fmt.Println("Error initializing contract ABI: ", err)
return nil, err
Expand All @@ -524,7 +522,7 @@ func (c *Client) DecodeProtoEventsToLabels(events []string, blocksCache map[uint
// Convert event to label
eventLabel := indexer.EventLabel{
Label: indexer.SeerCrawlerLabel,
LabelName: abiMap[checksumAddress][topicSelector]["abi_name"],
LabelName: abiMap[event.Address][topicSelector]["abi_name"],
LabelType: "event",
BlockNumber: event.BlockNumber,
BlockHash: event.BlockHash,
Expand Down Expand Up @@ -556,10 +554,7 @@ func (c *Client) DecodeProtoTransactionsToLabels(transactions []string, blocksCa

selector := transaction.Input[:10]

// To checksum address
checksumAddress := common.HexToAddress(transaction.ToAddress).Hex()

contractAbi, err := abi.JSON(strings.NewReader(abiMap[checksumAddress][selector]["abi"]))
contractAbi, err := abi.JSON(strings.NewReader(abiMap[transaction.ToAddress][selector]["abi"]))

if err != nil {
return nil, err
Expand Down Expand Up @@ -592,7 +587,7 @@ func (c *Client) DecodeProtoTransactionsToLabels(transactions []string, blocksCa
BlockNumber: transaction.BlockNumber,
BlockHash: transaction.BlockHash,
CallerAddress: transaction.FromAddress,
LabelName: abiMap[checksumAddress][selector]["abi_name"],
LabelName: abiMap[transaction.ToAddress][selector]["abi_name"],
LabelType: "tx_call",
OriginAddress: transaction.FromAddress,
Label: indexer.SeerCrawlerLabel,
Expand Down
13 changes: 5 additions & 8 deletions blockchain/mantle_sepolia/mantle_sepolia.go
Original file line number Diff line number Diff line change
Expand Up @@ -490,15 +490,13 @@ func (c *Client) DecodeProtoEventsToLabels(events []string, blocksCache map[uint
var topicSelector string

if len(event.Topics) > 0 {
topicSelector = event.Topics[0][:10]
topicSelector = event.Topics[0]
} else {
continue
}

checksumAddress := common.HexToAddress(event.Address).Hex()

// Get the ABI string
contractAbi, err := abi.JSON(strings.NewReader(abiMap[checksumAddress][topicSelector]["abi"]))
contractAbi, err := abi.JSON(strings.NewReader(abiMap[event.Address][topicSelector]["abi"]))
if err != nil {
fmt.Println("Error initializing contract ABI: ", err)
return nil, err
Expand All @@ -524,7 +522,7 @@ func (c *Client) DecodeProtoEventsToLabels(events []string, blocksCache map[uint
// Convert event to label
eventLabel := indexer.EventLabel{
Label: indexer.SeerCrawlerLabel,
LabelName: abiMap[checksumAddress][topicSelector]["abi_name"],
LabelName: abiMap[event.Address][topicSelector]["abi_name"],
LabelType: "event",
BlockNumber: event.BlockNumber,
BlockHash: event.BlockHash,
Expand Down Expand Up @@ -557,9 +555,8 @@ func (c *Client) DecodeProtoTransactionsToLabels(transactions []string, blocksCa
selector := transaction.Input[:10]

// To checksum address
checksumAddress := common.HexToAddress(transaction.ToAddress).Hex()

contractAbi, err := abi.JSON(strings.NewReader(abiMap[checksumAddress][selector]["abi"]))
contractAbi, err := abi.JSON(strings.NewReader(abiMap[transaction.ToAddress][selector]["abi"]))

if err != nil {
return nil, err
Expand Down Expand Up @@ -592,7 +589,7 @@ func (c *Client) DecodeProtoTransactionsToLabels(transactions []string, blocksCa
BlockNumber: transaction.BlockNumber,
BlockHash: transaction.BlockHash,
CallerAddress: transaction.FromAddress,
LabelName: abiMap[checksumAddress][selector]["abi_name"],
LabelName: abiMap[transaction.ToAddress][selector]["abi_name"],
LabelType: "tx_call",
OriginAddress: transaction.FromAddress,
Label: indexer.SeerCrawlerLabel,
Expand Down
17 changes: 7 additions & 10 deletions blockchain/polygon/polygon.go
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,7 @@ func (c *Client) DecodeProtoEventsToLabels(events []string, blocksCache map[uint
decodedEvents, err := c.DecodeProtoEventLogs(events)

if err != nil {
fmt.Println("Error decoding events: ", err)
return nil, err
}

Expand All @@ -490,15 +491,14 @@ func (c *Client) DecodeProtoEventsToLabels(events []string, blocksCache map[uint
var topicSelector string

if len(event.Topics) > 0 {
topicSelector = event.Topics[0][:10]
topicSelector = event.Topics[0]
} else {
continue
}

checksumAddress := common.HexToAddress(event.Address).Hex()

// Get the ABI string
contractAbi, err := abi.JSON(strings.NewReader(abiMap[checksumAddress][topicSelector]["abi"]))
contractAbi, err := abi.JSON(strings.NewReader(abiMap[event.Address][topicSelector]["abi"]))

if err != nil {
fmt.Println("Error initializing contract ABI: ", err)
return nil, err
Expand All @@ -524,7 +524,7 @@ func (c *Client) DecodeProtoEventsToLabels(events []string, blocksCache map[uint
// Convert event to label
eventLabel := indexer.EventLabel{
Label: indexer.SeerCrawlerLabel,
LabelName: abiMap[checksumAddress][topicSelector]["abi_name"],
LabelName: abiMap[event.Address][topicSelector]["abi_name"],
LabelType: "event",
BlockNumber: event.BlockNumber,
BlockHash: event.BlockHash,
Expand Down Expand Up @@ -556,10 +556,7 @@ func (c *Client) DecodeProtoTransactionsToLabels(transactions []string, blocksCa

selector := transaction.Input[:10]

// To checksum address
checksumAddress := common.HexToAddress(transaction.ToAddress).Hex()

contractAbi, err := abi.JSON(strings.NewReader(abiMap[checksumAddress][selector]["abi"]))
contractAbi, err := abi.JSON(strings.NewReader(abiMap[transaction.ToAddress][selector]["abi"]))

if err != nil {
return nil, err
Expand Down Expand Up @@ -592,7 +589,7 @@ func (c *Client) DecodeProtoTransactionsToLabels(transactions []string, blocksCa
BlockNumber: transaction.BlockNumber,
BlockHash: transaction.BlockHash,
CallerAddress: transaction.FromAddress,
LabelName: abiMap[checksumAddress][selector]["abi_name"],
LabelName: abiMap[transaction.ToAddress][selector]["abi_name"],
LabelType: "tx_call",
OriginAddress: transaction.FromAddress,
Label: indexer.SeerCrawlerLabel,
Expand Down
Loading

0 comments on commit 14fa9a3

Please sign in to comment.