diff --git a/internal/rpc/serializer.go b/internal/rpc/serializer.go index 50cc138..01f6346 100644 --- a/internal/rpc/serializer.go +++ b/internal/rpc/serializer.go @@ -167,21 +167,15 @@ func serializeTransactions(chainId *big.Int, transactions []interface{}, blockTi func serializeTransaction(chainId *big.Int, tx map[string]interface{}, blockTimestamp time.Time, receipt *common.RawReceipt) common.Transaction { return common.Transaction{ - ChainId: chainId, - Hash: interfaceToString(tx["hash"]), - Nonce: hexToUint64(tx["nonce"]), - BlockHash: interfaceToString(tx["blockHash"]), - BlockNumber: hexToBigInt(tx["blockNumber"]), - BlockTimestamp: blockTimestamp, - TransactionIndex: hexToUint64(tx["transactionIndex"]), - FromAddress: interfaceToString(tx["from"]), - ToAddress: func() string { - to := interfaceToString(tx["to"]) - if to != "" { - return to - } - return "0x0000000000000000000000000000000000000000" - }(), + ChainId: chainId, + Hash: interfaceToString(tx["hash"]), + Nonce: hexToUint64(tx["nonce"]), + BlockHash: interfaceToString(tx["blockHash"]), + BlockNumber: hexToBigInt(tx["blockNumber"]), + BlockTimestamp: blockTimestamp, + TransactionIndex: hexToUint64(tx["transactionIndex"]), + FromAddress: interfaceToString(tx["from"]), + ToAddress: interfaceToString(tx["to"]), Value: hexToBigInt(tx["value"]), Gas: hexToUint64(tx["gas"]), GasPrice: hexToBigInt(tx["gasPrice"]), diff --git a/internal/storage/clickhouse.go b/internal/storage/clickhouse.go index 41d7478..b552d36 100644 --- a/internal/storage/clickhouse.go +++ b/internal/storage/clickhouse.go @@ -32,6 +32,7 @@ type InsertOptions struct { var DEFAULT_MAX_ROWS_PER_INSERT = 100000 var ZERO_BYTES_66 = strings.Repeat("\x00", 66) var ZERO_BYTES_10 = strings.Repeat("\x00", 10) +var ZERO_BYTES_42 = strings.Repeat("\x00", 42) var defaultBlockFields = []string{ "chain_id", "block_number", "hash", "parent_hash", "block_timestamp", "nonce", @@ -749,6 +750,9 @@ func scanTransaction(rows driver.Rows) (common.Transaction, error) { if tx.FunctionSelector == ZERO_BYTES_10 { tx.FunctionSelector = "" } + if tx.ToAddress == ZERO_BYTES_42 { + tx.ToAddress = "" + } return tx, nil }