From 0769d7ef3ac72a915e3dbc27cafba57fd62ec8df Mon Sep 17 00:00:00 2001 From: Andrey Date: Mon, 15 Jul 2024 17:44:37 +0300 Subject: [PATCH 1/3] Awithc address format on customer database. --- indexer/db.go | 61 +++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 49 insertions(+), 12 deletions(-) diff --git a/indexer/db.go b/indexer/db.go index 0b62500..3630808 100644 --- a/indexer/db.go +++ b/indexer/db.go @@ -1028,6 +1028,7 @@ func (p *PostgreSQLpgx) ReadUpdates(blockchain string, fromBlock uint64, toBlock } func (p *PostgreSQLpgx) WriteEvents(blockchain string, events []EventLabel) error { + tableName := LabelsTableName(blockchain) columns := []string{"id", "label", "transaction_hash", "log_index", "block_number", "block_hash", "block_timestamp", "caller_address", "origin_address", "address", "label_name", "label_type", "label_data"} var valuesMap = make(map[string]UnnestInsertValueStruct) @@ -1068,17 +1069,17 @@ func (p *PostgreSQLpgx) WriteEvents(blockchain string, events []EventLabel) erro } valuesMap["caller_address"] = UnnestInsertValueStruct{ - Type: "TEXT", + Type: "BYTEA", Values: make([]interface{}, 0), } valuesMap["origin_address"] = UnnestInsertValueStruct{ - Type: "TEXT", + Type: "BYTEA", Values: make([]interface{}, 0), } valuesMap["address"] = UnnestInsertValueStruct{ - Type: "TEXT", + Type: "BYTEA", Values: make([]interface{}, 0), } @@ -1101,6 +1102,24 @@ func (p *PostgreSQLpgx) WriteEvents(blockchain string, events []EventLabel) erro id := uuid.New() + callerAddressBytes, err := decodeAddress(event.CallerAddress) + if err != nil { + fmt.Println("Error decoding caller address:", err, event) + continue + } + + originAddressBytes, err := decodeAddress(event.OriginAddress) + if err != nil { + fmt.Println("Error decoding origin address:", err, event) + continue + } + + addressBytes, err := decodeAddress(event.Address) + if err != nil { + fmt.Println("Error decoding address:", err, event) + continue + } + updateValues(valuesMap, "id", id) updateValues(valuesMap, "label", event.Label) updateValues(valuesMap, "transaction_hash", event.TransactionHash) @@ -1108,9 +1127,9 @@ func (p *PostgreSQLpgx) WriteEvents(blockchain string, events []EventLabel) erro updateValues(valuesMap, "block_number", event.BlockNumber) updateValues(valuesMap, "block_hash", event.BlockHash) updateValues(valuesMap, "block_timestamp", event.BlockTimestamp) - updateValues(valuesMap, "caller_address", event.CallerAddress) - updateValues(valuesMap, "origin_address", event.OriginAddress) - updateValues(valuesMap, "address", event.Address) + updateValues(valuesMap, "caller_address", callerAddressBytes) + updateValues(valuesMap, "origin_address", originAddressBytes) + updateValues(valuesMap, "address", addressBytes) updateValues(valuesMap, "label_name", event.LabelName) updateValues(valuesMap, "label_type", event.LabelType) updateValues(valuesMap, "label_data", event.LabelData) @@ -1142,7 +1161,7 @@ func (p *PostgreSQLpgx) WriteTransactions(blockchain string, transactions []Tran } valuesMap["address"] = UnnestInsertValueStruct{ - Type: "TEXT", + Type: "BYTEA", Values: make([]interface{}, 0), } @@ -1157,7 +1176,7 @@ func (p *PostgreSQLpgx) WriteTransactions(blockchain string, transactions []Tran } valuesMap["caller_address"] = UnnestInsertValueStruct{ - Type: "TEXT", + Type: "BYTEA", Values: make([]interface{}, 0), } @@ -1172,7 +1191,7 @@ func (p *PostgreSQLpgx) WriteTransactions(blockchain string, transactions []Tran } valuesMap["origin_address"] = UnnestInsertValueStruct{ - Type: "TEXT", + Type: "BYTEA", Values: make([]interface{}, 0), } @@ -1200,14 +1219,32 @@ func (p *PostgreSQLpgx) WriteTransactions(blockchain string, transactions []Tran id := uuid.New() + addressBytes, err := decodeAddress(transaction.Address) + if err != nil { + fmt.Println("Error decoding address:", err, transaction) + continue + } + + callerAddressBytes, err := decodeAddress(transaction.CallerAddress) + if err != nil { + fmt.Println("Error decoding caller address:", err, transaction) + continue + } + + originAddressBytes, err := decodeAddress(transaction.OriginAddress) + if err != nil { + fmt.Println("Error decoding origin address:", err, transaction) + continue + } + updateValues(valuesMap, "id", id) - updateValues(valuesMap, "address", transaction.Address) + updateValues(valuesMap, "address", addressBytes) updateValues(valuesMap, "block_number", transaction.BlockNumber) updateValues(valuesMap, "block_hash", transaction.BlockHash) - updateValues(valuesMap, "caller_address", transaction.CallerAddress) + updateValues(valuesMap, "caller_address", callerAddressBytes) updateValues(valuesMap, "label_name", transaction.LabelName) updateValues(valuesMap, "label_type", transaction.LabelType) - updateValues(valuesMap, "origin_address", transaction.OriginAddress) + updateValues(valuesMap, "origin_address", originAddressBytes) updateValues(valuesMap, "label", transaction.Label) updateValues(valuesMap, "transaction_hash", transaction.TransactionHash) updateValues(valuesMap, "label_data", transaction.LabelData) From 1b96bdf6310e83c2a9d18d62ca1ee354c6fa8252 Mon Sep 17 00:00:00 2001 From: Andrey Date: Mon, 15 Jul 2024 23:31:16 +0300 Subject: [PATCH 2/3] Add origin address. --- blockchain/arbitrum_one/arbitrum_one.go | 1 + blockchain/arbitrum_sepolia/arbitrum_sepolia.go | 1 + blockchain/blockchain.go.tmpl | 1 + blockchain/ethereum/ethereum.go | 1 + .../game7_orbit_arbitrum_sepolia/game7_orbit_arbitrum_sepolia.go | 1 + blockchain/mantle/mantle.go | 1 + blockchain/mantle_sepolia/mantle_sepolia.go | 1 + blockchain/polygon/polygon.go | 1 + blockchain/xai/xai.go | 1 + blockchain/xai_sepolia/xai_sepolia.go | 1 + 10 files changed, 10 insertions(+) diff --git a/blockchain/arbitrum_one/arbitrum_one.go b/blockchain/arbitrum_one/arbitrum_one.go index 5327fd9..f3975e2 100644 --- a/blockchain/arbitrum_one/arbitrum_one.go +++ b/blockchain/arbitrum_one/arbitrum_one.go @@ -796,6 +796,7 @@ func (c *Client) DecodeProtoEntireBlockToLabels(rawData *bytes.Buffer, blocksCac BlockNumber: e.BlockNumber, BlockHash: e.BlockHash, Address: e.Address, + OriginAddress: tx.FromAddress, TransactionHash: e.TransactionHash, LabelData: string(labelDataBytes), // Convert JSON byte slice to string BlockTimestamp: b.Timestamp, diff --git a/blockchain/arbitrum_sepolia/arbitrum_sepolia.go b/blockchain/arbitrum_sepolia/arbitrum_sepolia.go index 0127ded..cd1fbfb 100644 --- a/blockchain/arbitrum_sepolia/arbitrum_sepolia.go +++ b/blockchain/arbitrum_sepolia/arbitrum_sepolia.go @@ -796,6 +796,7 @@ func (c *Client) DecodeProtoEntireBlockToLabels(rawData *bytes.Buffer, blocksCac BlockNumber: e.BlockNumber, BlockHash: e.BlockHash, Address: e.Address, + OriginAddress: tx.FromAddress, TransactionHash: e.TransactionHash, LabelData: string(labelDataBytes), // Convert JSON byte slice to string BlockTimestamp: b.Timestamp, diff --git a/blockchain/blockchain.go.tmpl b/blockchain/blockchain.go.tmpl index 82f64b4..8a09922 100644 --- a/blockchain/blockchain.go.tmpl +++ b/blockchain/blockchain.go.tmpl @@ -796,6 +796,7 @@ func (c *Client) DecodeProtoEntireBlockToLabels(rawData *bytes.Buffer, blocksCac BlockNumber: e.BlockNumber, BlockHash: e.BlockHash, Address: e.Address, + OriginAddress: tx.FromAddress, TransactionHash: e.TransactionHash, LabelData: string(labelDataBytes), // Convert JSON byte slice to string BlockTimestamp: b.Timestamp, diff --git a/blockchain/ethereum/ethereum.go b/blockchain/ethereum/ethereum.go index cc14db5..349b926 100644 --- a/blockchain/ethereum/ethereum.go +++ b/blockchain/ethereum/ethereum.go @@ -786,6 +786,7 @@ func (c *Client) DecodeProtoEntireBlockToLabels(rawData *bytes.Buffer, blocksCac BlockNumber: e.BlockNumber, BlockHash: e.BlockHash, Address: e.Address, + OriginAddress: tx.FromAddress, TransactionHash: e.TransactionHash, LabelData: string(labelDataBytes), // Convert JSON byte slice to string BlockTimestamp: b.Timestamp, diff --git a/blockchain/game7_orbit_arbitrum_sepolia/game7_orbit_arbitrum_sepolia.go b/blockchain/game7_orbit_arbitrum_sepolia/game7_orbit_arbitrum_sepolia.go index e001b38..8bd9c72 100644 --- a/blockchain/game7_orbit_arbitrum_sepolia/game7_orbit_arbitrum_sepolia.go +++ b/blockchain/game7_orbit_arbitrum_sepolia/game7_orbit_arbitrum_sepolia.go @@ -796,6 +796,7 @@ func (c *Client) DecodeProtoEntireBlockToLabels(rawData *bytes.Buffer, blocksCac BlockNumber: e.BlockNumber, BlockHash: e.BlockHash, Address: e.Address, + OriginAddress: tx.FromAddress, TransactionHash: e.TransactionHash, LabelData: string(labelDataBytes), // Convert JSON byte slice to string BlockTimestamp: b.Timestamp, diff --git a/blockchain/mantle/mantle.go b/blockchain/mantle/mantle.go index 9c7fe7a..cca5b64 100644 --- a/blockchain/mantle/mantle.go +++ b/blockchain/mantle/mantle.go @@ -786,6 +786,7 @@ func (c *Client) DecodeProtoEntireBlockToLabels(rawData *bytes.Buffer, blocksCac BlockNumber: e.BlockNumber, BlockHash: e.BlockHash, Address: e.Address, + OriginAddress: tx.FromAddress, TransactionHash: e.TransactionHash, LabelData: string(labelDataBytes), // Convert JSON byte slice to string BlockTimestamp: b.Timestamp, diff --git a/blockchain/mantle_sepolia/mantle_sepolia.go b/blockchain/mantle_sepolia/mantle_sepolia.go index ec84a03..24474b9 100644 --- a/blockchain/mantle_sepolia/mantle_sepolia.go +++ b/blockchain/mantle_sepolia/mantle_sepolia.go @@ -786,6 +786,7 @@ func (c *Client) DecodeProtoEntireBlockToLabels(rawData *bytes.Buffer, blocksCac BlockNumber: e.BlockNumber, BlockHash: e.BlockHash, Address: e.Address, + OriginAddress: tx.FromAddress, TransactionHash: e.TransactionHash, LabelData: string(labelDataBytes), // Convert JSON byte slice to string BlockTimestamp: b.Timestamp, diff --git a/blockchain/polygon/polygon.go b/blockchain/polygon/polygon.go index 457740b..8bebd4e 100644 --- a/blockchain/polygon/polygon.go +++ b/blockchain/polygon/polygon.go @@ -786,6 +786,7 @@ func (c *Client) DecodeProtoEntireBlockToLabels(rawData *bytes.Buffer, blocksCac BlockNumber: e.BlockNumber, BlockHash: e.BlockHash, Address: e.Address, + OriginAddress: tx.FromAddress, TransactionHash: e.TransactionHash, LabelData: string(labelDataBytes), // Convert JSON byte slice to string BlockTimestamp: b.Timestamp, diff --git a/blockchain/xai/xai.go b/blockchain/xai/xai.go index d6bcb45..b203458 100644 --- a/blockchain/xai/xai.go +++ b/blockchain/xai/xai.go @@ -796,6 +796,7 @@ func (c *Client) DecodeProtoEntireBlockToLabels(rawData *bytes.Buffer, blocksCac BlockNumber: e.BlockNumber, BlockHash: e.BlockHash, Address: e.Address, + OriginAddress: tx.FromAddress, TransactionHash: e.TransactionHash, LabelData: string(labelDataBytes), // Convert JSON byte slice to string BlockTimestamp: b.Timestamp, diff --git a/blockchain/xai_sepolia/xai_sepolia.go b/blockchain/xai_sepolia/xai_sepolia.go index 6bafa41..ffc9d3b 100644 --- a/blockchain/xai_sepolia/xai_sepolia.go +++ b/blockchain/xai_sepolia/xai_sepolia.go @@ -796,6 +796,7 @@ func (c *Client) DecodeProtoEntireBlockToLabels(rawData *bytes.Buffer, blocksCac BlockNumber: e.BlockNumber, BlockHash: e.BlockHash, Address: e.Address, + OriginAddress: tx.FromAddress, TransactionHash: e.TransactionHash, LabelData: string(labelDataBytes), // Convert JSON byte slice to string BlockTimestamp: b.Timestamp, From bc58a4dd08292a3636e6e5440bb84d81b40809db Mon Sep 17 00:00:00 2001 From: Andrey Date: Tue, 16 Jul 2024 00:39:26 +0300 Subject: [PATCH 3/3] Bump version. --- version/version.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version/version.go b/version/version.go index 8082e53..0943984 100644 --- a/version/version.go +++ b/version/version.go @@ -1,3 +1,3 @@ package version -var SeerVersion string = "0.1.11" +var SeerVersion string = "0.1.12"