Skip to content

Commit

Permalink
Merge pull request #82 from IanCal/main
Browse files Browse the repository at this point in the history
feat:Add the contract address of the event source
  • Loading branch information
BohuTANG authored Sep 10, 2022
2 parents 3c4d445 + 87b0b46 commit 245b14e
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 2 deletions.
14 changes: 12 additions & 2 deletions ethetl/src/exporters/logs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ impl LogsExporter {
let mut block_hash_vec = Vec::new();
let mut block_number_vec = Vec::new();
let mut contract_address_vec = Vec::new();
let mut event_address_vec = Vec::new();
let mut data_vec = Vec::new();
let mut topics_vec = Vec::new();

Expand All @@ -73,6 +74,7 @@ impl LogsExporter {
contract_address_vec.push(h160_to_hex(
&receipt.contract_address.unwrap_or_else(Address::zero),
));
event_address_vec.push(h160_to_hex(&log.address));
data_vec.push(bytes_to_hex(&log.data));
let topics = log
.topics
Expand All @@ -91,6 +93,7 @@ impl LogsExporter {
let block_hash_array = Utf8Array::<i32>::from_slice(block_hash_vec);
let block_number_array = UInt64Array::from_slice(block_number_vec);
let contract_address_array = Utf8Array::<i32>::from_slice(contract_address_vec);
let event_address_array = Utf8Array::<i32>::from_slice(event_address_vec);
let data_array = Utf8Array::<i32>::from_slice(data_vec);
let topics_array = Utf8Array::<i32>::from_slice(topics_vec);

Expand All @@ -108,11 +111,16 @@ impl LogsExporter {
let block_hash_field = Field::new("block_hash", block_hash_array.data_type().clone(), true);
let block_number_field =
Field::new("block_number", block_number_array.data_type().clone(), true);
let contracet_address_field = Field::new(
let contract_address_field = Field::new(
"contract_address",
contract_address_array.data_type().clone(),
true,
);
let event_address_field = Field::new(
"event_address",
event_address_array.data_type().clone(),
true,
);
let data_field = Field::new("data", data_array.data_type().clone(), true);
let topics_field = Field::new("topics", topics_array.data_type().clone(), true);

Expand All @@ -122,7 +130,8 @@ impl LogsExporter {
transaction_index_field,
block_hash_field,
block_number_field,
contracet_address_field,
contract_address_field,
event_address_field,
data_field,
topics_field,
]);
Expand All @@ -133,6 +142,7 @@ impl LogsExporter {
block_hash_array.boxed(),
block_number_array.boxed(),
contract_address_array.boxed(),
event_address_array.boxed(),
data_array.boxed(),
topics_array.boxed(),
])?;
Expand Down
1 change: 1 addition & 0 deletions schemas/databend/1_schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ CREATE TABLE logs
block_hash VARCHAR,
block_number BIGINT UNSIGNED,
contract_address VARCHAR,
event_address VARCHAR,
data VARCHAR,
topics VARCHAR
);
Expand Down
1 change: 1 addition & 0 deletions schemas/databend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ Cloud: https://app.databend.com/
| block_hash | VARCHAR |
| block_number | BIGINT UNSIGNED |
| contract_address | VARCHAR |
| event_address | VARCHAR |
| data | VARCHAR |
| topics | VARCHAR |

Expand Down
1 change: 1 addition & 0 deletions schemas/snowflake/1_schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ CREATE TABLE logs
block_hash VARCHAR,
block_number BIGINT,
contract_address VARCHAR,
event_address VARCHAR,
data VARCHAR,
topics VARCHAR
);
Expand Down
1 change: 1 addition & 0 deletions schemas/snowflake/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ Cloud: https://app.snowflake.com/
| block_hash | VARCHAR |
| block_number | BIGINT |
| contract_address | VARCHAR |
| event_address | VARCHAR |
| data | VARCHAR |
| topics | VARCHAR |

Expand Down

0 comments on commit 245b14e

Please sign in to comment.