Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add topic3. #37

Merged
merged 3 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion blockchain/arbitrum_one/arbitrum_one.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ func (c *Client) ParseEvents(from, to *big.Int, blocksCache map[uint64]indexer.B
parsedEvents = append(parsedEvents, parsedEvent)

// Prepare events to index
var topic0, topic1, topic2 *string
var topic0, topic1, topic2, topic3 *string

if len(parsedEvent.Topics) == 0 {
fmt.Println("No topics found for event: ", parsedEvent)
Expand All @@ -326,6 +326,10 @@ func (c *Client) ParseEvents(from, to *big.Int, blocksCache map[uint64]indexer.B
topic2 = &parsedEvent.Topics[2] // Third topic, if present
}

if len(parsedEvent.Topics) > 3 {
topic3 = &parsedEvent.Topics[3] // Fourth topic, if present
}

eventsIndex = append(eventsIndex, indexer.LogIndex{
Address: parsedEvent.Address,
BlockNumber: parsedEvent.BlockNumber,
Expand All @@ -335,6 +339,7 @@ func (c *Client) ParseEvents(from, to *big.Int, blocksCache map[uint64]indexer.B
Selector: topic0, // First topic
Topic1: topic1,
Topic2: topic2,
Topic3: topic3,
RowID: uint64(i), // TODO: Remove
LogIndex: parsedEvent.LogIndex,
Path: "",
Expand Down
7 changes: 6 additions & 1 deletion blockchain/arbitrum_sepolia/arbitrum_sepolia.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ func (c *Client) ParseEvents(from, to *big.Int, blocksCache map[uint64]indexer.B
parsedEvents = append(parsedEvents, parsedEvent)

// Prepare events to index
var topic0, topic1, topic2 *string
var topic0, topic1, topic2, topic3 *string

if len(parsedEvent.Topics) == 0 {
fmt.Println("No topics found for event: ", parsedEvent)
Expand All @@ -326,6 +326,10 @@ func (c *Client) ParseEvents(from, to *big.Int, blocksCache map[uint64]indexer.B
topic2 = &parsedEvent.Topics[2] // Third topic, if present
}

if len(parsedEvent.Topics) > 3 {
topic3 = &parsedEvent.Topics[3] // Fourth topic, if present
}

eventsIndex = append(eventsIndex, indexer.LogIndex{
Address: parsedEvent.Address,
BlockNumber: parsedEvent.BlockNumber,
Expand All @@ -335,6 +339,7 @@ func (c *Client) ParseEvents(from, to *big.Int, blocksCache map[uint64]indexer.B
Selector: topic0, // First topic
Topic1: topic1,
Topic2: topic2,
Topic3: topic3,
RowID: uint64(i), // TODO: Remove
LogIndex: parsedEvent.LogIndex,
Path: "",
Expand Down
7 changes: 6 additions & 1 deletion blockchain/blockchain.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ func (c *Client) ParseEvents(from, to *big.Int, blocksCache map[uint64]indexer.B
parsedEvents = append(parsedEvents, parsedEvent)

// Prepare events to index
var topic0, topic1, topic2 *string
var topic0, topic1, topic2, topic3 *string

if len(parsedEvent.Topics) == 0 {
fmt.Println("No topics found for event: ", parsedEvent)
Expand All @@ -326,6 +326,10 @@ func (c *Client) ParseEvents(from, to *big.Int, blocksCache map[uint64]indexer.B
topic2 = &parsedEvent.Topics[2] // Third topic, if present
}

if len(parsedEvent.Topics) > 3 {
topic3 = &parsedEvent.Topics[3] // Fourth topic, if present
}

eventsIndex = append(eventsIndex, indexer.LogIndex{
Address: parsedEvent.Address,
BlockNumber: parsedEvent.BlockNumber,
Expand All @@ -335,6 +339,7 @@ func (c *Client) ParseEvents(from, to *big.Int, blocksCache map[uint64]indexer.B
Selector: topic0, // First topic
Topic1: topic1,
Topic2: topic2,
Topic3: topic3,
RowID: uint64(i), // TODO: Remove
LogIndex: parsedEvent.LogIndex,
Path: "",
Expand Down
7 changes: 6 additions & 1 deletion blockchain/ethereum/ethereum.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ func (c *Client) ParseEvents(from, to *big.Int, blocksCache map[uint64]indexer.B
parsedEvents = append(parsedEvents, parsedEvent)

// Prepare events to index
var topic0, topic1, topic2 *string
var topic0, topic1, topic2, topic3 *string

if len(parsedEvent.Topics) == 0 {
fmt.Println("No topics found for event: ", parsedEvent)
Expand All @@ -326,6 +326,10 @@ func (c *Client) ParseEvents(from, to *big.Int, blocksCache map[uint64]indexer.B
topic2 = &parsedEvent.Topics[2] // Third topic, if present
}

if len(parsedEvent.Topics) > 3 {
topic3 = &parsedEvent.Topics[3] // Fourth topic, if present
}

eventsIndex = append(eventsIndex, indexer.LogIndex{
Address: parsedEvent.Address,
BlockNumber: parsedEvent.BlockNumber,
Expand All @@ -335,6 +339,7 @@ func (c *Client) ParseEvents(from, to *big.Int, blocksCache map[uint64]indexer.B
Selector: topic0, // First topic
Topic1: topic1,
Topic2: topic2,
Topic3: topic3,
RowID: uint64(i), // TODO: Remove
LogIndex: parsedEvent.LogIndex,
Path: "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ func (c *Client) ParseEvents(from, to *big.Int, blocksCache map[uint64]indexer.B
parsedEvents = append(parsedEvents, parsedEvent)

// Prepare events to index
var topic0, topic1, topic2 *string
var topic0, topic1, topic2, topic3 *string

if len(parsedEvent.Topics) == 0 {
fmt.Println("No topics found for event: ", parsedEvent)
Expand All @@ -326,6 +326,10 @@ func (c *Client) ParseEvents(from, to *big.Int, blocksCache map[uint64]indexer.B
topic2 = &parsedEvent.Topics[2] // Third topic, if present
}

if len(parsedEvent.Topics) > 3 {
topic3 = &parsedEvent.Topics[3] // Fourth topic, if present
}

eventsIndex = append(eventsIndex, indexer.LogIndex{
Address: parsedEvent.Address,
BlockNumber: parsedEvent.BlockNumber,
Expand All @@ -335,6 +339,7 @@ func (c *Client) ParseEvents(from, to *big.Int, blocksCache map[uint64]indexer.B
Selector: topic0, // First topic
Topic1: topic1,
Topic2: topic2,
Topic3: topic3,
RowID: uint64(i), // TODO: Remove
LogIndex: parsedEvent.LogIndex,
Path: "",
Expand Down
7 changes: 6 additions & 1 deletion blockchain/mantle/mantle.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ func (c *Client) ParseEvents(from, to *big.Int, blocksCache map[uint64]indexer.B
parsedEvents = append(parsedEvents, parsedEvent)

// Prepare events to index
var topic0, topic1, topic2 *string
var topic0, topic1, topic2, topic3 *string

if len(parsedEvent.Topics) == 0 {
fmt.Println("No topics found for event: ", parsedEvent)
Expand All @@ -326,6 +326,10 @@ func (c *Client) ParseEvents(from, to *big.Int, blocksCache map[uint64]indexer.B
topic2 = &parsedEvent.Topics[2] // Third topic, if present
}

if len(parsedEvent.Topics) > 3 {
topic3 = &parsedEvent.Topics[3] // Fourth topic, if present
}

eventsIndex = append(eventsIndex, indexer.LogIndex{
Address: parsedEvent.Address,
BlockNumber: parsedEvent.BlockNumber,
Expand All @@ -335,6 +339,7 @@ func (c *Client) ParseEvents(from, to *big.Int, blocksCache map[uint64]indexer.B
Selector: topic0, // First topic
Topic1: topic1,
Topic2: topic2,
Topic3: topic3,
RowID: uint64(i), // TODO: Remove
LogIndex: parsedEvent.LogIndex,
Path: "",
Expand Down
7 changes: 6 additions & 1 deletion blockchain/mantle_sepolia/mantle_sepolia.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ func (c *Client) ParseEvents(from, to *big.Int, blocksCache map[uint64]indexer.B
parsedEvents = append(parsedEvents, parsedEvent)

// Prepare events to index
var topic0, topic1, topic2 *string
var topic0, topic1, topic2, topic3 *string

if len(parsedEvent.Topics) == 0 {
fmt.Println("No topics found for event: ", parsedEvent)
Expand All @@ -326,6 +326,10 @@ func (c *Client) ParseEvents(from, to *big.Int, blocksCache map[uint64]indexer.B
topic2 = &parsedEvent.Topics[2] // Third topic, if present
}

if len(parsedEvent.Topics) > 3 {
topic3 = &parsedEvent.Topics[3] // Fourth topic, if present
}

eventsIndex = append(eventsIndex, indexer.LogIndex{
Address: parsedEvent.Address,
BlockNumber: parsedEvent.BlockNumber,
Expand All @@ -335,6 +339,7 @@ func (c *Client) ParseEvents(from, to *big.Int, blocksCache map[uint64]indexer.B
Selector: topic0, // First topic
Topic1: topic1,
Topic2: topic2,
Topic3: topic3,
RowID: uint64(i), // TODO: Remove
LogIndex: parsedEvent.LogIndex,
Path: "",
Expand Down
7 changes: 6 additions & 1 deletion blockchain/polygon/polygon.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ func (c *Client) ParseEvents(from, to *big.Int, blocksCache map[uint64]indexer.B
parsedEvents = append(parsedEvents, parsedEvent)

// Prepare events to index
var topic0, topic1, topic2 *string
var topic0, topic1, topic2, topic3 *string

if len(parsedEvent.Topics) == 0 {
fmt.Println("No topics found for event: ", parsedEvent)
Expand All @@ -326,6 +326,10 @@ func (c *Client) ParseEvents(from, to *big.Int, blocksCache map[uint64]indexer.B
topic2 = &parsedEvent.Topics[2] // Third topic, if present
}

if len(parsedEvent.Topics) > 3 {
topic3 = &parsedEvent.Topics[3] // Fourth topic, if present
}

eventsIndex = append(eventsIndex, indexer.LogIndex{
Address: parsedEvent.Address,
BlockNumber: parsedEvent.BlockNumber,
Expand All @@ -335,6 +339,7 @@ func (c *Client) ParseEvents(from, to *big.Int, blocksCache map[uint64]indexer.B
Selector: topic0, // First topic
Topic1: topic1,
Topic2: topic2,
Topic3: topic3,
RowID: uint64(i), // TODO: Remove
LogIndex: parsedEvent.LogIndex,
Path: "",
Expand Down
7 changes: 6 additions & 1 deletion blockchain/xai/xai.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ func (c *Client) ParseEvents(from, to *big.Int, blocksCache map[uint64]indexer.B
parsedEvents = append(parsedEvents, parsedEvent)

// Prepare events to index
var topic0, topic1, topic2 *string
var topic0, topic1, topic2, topic3 *string

if len(parsedEvent.Topics) == 0 {
fmt.Println("No topics found for event: ", parsedEvent)
Expand All @@ -326,6 +326,10 @@ func (c *Client) ParseEvents(from, to *big.Int, blocksCache map[uint64]indexer.B
topic2 = &parsedEvent.Topics[2] // Third topic, if present
}

if len(parsedEvent.Topics) > 3 {
topic3 = &parsedEvent.Topics[3] // Fourth topic, if present
}

eventsIndex = append(eventsIndex, indexer.LogIndex{
Address: parsedEvent.Address,
BlockNumber: parsedEvent.BlockNumber,
Expand All @@ -335,6 +339,7 @@ func (c *Client) ParseEvents(from, to *big.Int, blocksCache map[uint64]indexer.B
Selector: topic0, // First topic
Topic1: topic1,
Topic2: topic2,
Topic3: topic3,
RowID: uint64(i), // TODO: Remove
LogIndex: parsedEvent.LogIndex,
Path: "",
Expand Down
7 changes: 6 additions & 1 deletion blockchain/xai_sepolia/xai_sepolia.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ func (c *Client) ParseEvents(from, to *big.Int, blocksCache map[uint64]indexer.B
parsedEvents = append(parsedEvents, parsedEvent)

// Prepare events to index
var topic0, topic1, topic2 *string
var topic0, topic1, topic2, topic3 *string

if len(parsedEvent.Topics) == 0 {
fmt.Println("No topics found for event: ", parsedEvent)
Expand All @@ -326,6 +326,10 @@ func (c *Client) ParseEvents(from, to *big.Int, blocksCache map[uint64]indexer.B
topic2 = &parsedEvent.Topics[2] // Third topic, if present
}

if len(parsedEvent.Topics) > 3 {
topic3 = &parsedEvent.Topics[3] // Fourth topic, if present
}

eventsIndex = append(eventsIndex, indexer.LogIndex{
Address: parsedEvent.Address,
BlockNumber: parsedEvent.BlockNumber,
Expand All @@ -335,6 +339,7 @@ func (c *Client) ParseEvents(from, to *big.Int, blocksCache map[uint64]indexer.B
Selector: topic0, // First topic
Topic1: topic1,
Topic2: topic2,
Topic3: topic3,
RowID: uint64(i), // TODO: Remove
LogIndex: parsedEvent.LogIndex,
Path: "",
Expand Down
8 changes: 7 additions & 1 deletion indexer/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ func (p *PostgreSQLpgx) writeTransactionIndexToDB(tableName string, indexes []Tr

func (p *PostgreSQLpgx) writeLogIndexToDB(tableName string, indexes []LogIndex) error {

columns := []string{"transaction_hash", "block_hash", "address", "selector", "topic1", "topic2", "row_id", "log_index", "path"}
columns := []string{"transaction_hash", "block_hash", "address", "selector", "topic1", "topic2", "topic3", "row_id", "log_index", "path"}

var valuesMap = make(map[string]UnnestInsertValueStruct)

Expand Down Expand Up @@ -542,6 +542,11 @@ func (p *PostgreSQLpgx) writeLogIndexToDB(tableName string, indexes []LogIndex)
Values: make([]interface{}, 0),
}

valuesMap["topic3"] = UnnestInsertValueStruct{
Type: "TEXT",
Values: make([]interface{}, 0),
}

valuesMap["row_id"] = UnnestInsertValueStruct{
Type: "BIGINT",
Values: make([]interface{}, 0),
Expand Down Expand Up @@ -571,6 +576,7 @@ func (p *PostgreSQLpgx) writeLogIndexToDB(tableName string, indexes []LogIndex)
updateValues(valuesMap, "selector", index.Selector)
updateValues(valuesMap, "topic1", index.Topic1)
updateValues(valuesMap, "topic2", index.Topic2)
updateValues(valuesMap, "topic3", index.Topic3)
updateValues(valuesMap, "row_id", index.RowID)
updateValues(valuesMap, "log_index", index.LogIndex)
updateValues(valuesMap, "path", index.Path)
Expand Down
6 changes: 4 additions & 2 deletions indexer/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,16 @@ type LogIndex struct {
BlockTimestamp uint64
Address string
TransactionHash string
Selector *string // TODO: 1) Add Topic1, Topic2. 2) Rename Topic0 to selector
Selector *string
Topic1 *string
Topic2 *string
Topic3 *string
RowID uint64
LogIndex uint64
Path string
}

func NewLogIndex(chain string, address string, blockNumber uint64, blockHash string, transactionHash string, BlockTimestamp uint64, topic0 *string, topic1 *string, topic2 *string, row_id uint64, logIndex uint64, path string) LogIndex {
func NewLogIndex(chain string, address string, blockNumber uint64, blockHash string, transactionHash string, BlockTimestamp uint64, topic0 *string, topic1 *string, topic2 *string, topic3 *string, row_id uint64, logIndex uint64, path string) LogIndex {
return LogIndex{
chain: chain,
Address: address,
Expand All @@ -98,6 +99,7 @@ func NewLogIndex(chain string, address string, blockNumber uint64, blockHash str
Selector: topic0,
Topic1: topic1,
Topic2: topic2,
Topic3: topic3,
RowID: row_id,
LogIndex: logIndex,
Path: path,
Expand Down
2 changes: 1 addition & 1 deletion version/version.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package version

var SeerVersion string = "0.1.10"
var SeerVersion string = "0.1.11"
Loading