-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ee6717a
commit 4b738ca
Showing
14 changed files
with
93 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
use common::keys::balance_changes_keys; | ||
use common::sinks::insert_timestamp; | ||
use common::utils::bytes_to_hex; | ||
use substreams::pb::substreams::Clock; | ||
use substreams_database_change::pb::database::{table_change, DatabaseChanges}; | ||
use substreams_ethereum::pb::eth::v2::Block; | ||
|
||
// https://github.com/streamingfast/firehose-ethereum/blob/1bcb32a8eb3e43347972b6b5c9b1fcc4a08c751e/proto/sf/ethereum/type/v2/type.proto#L658 | ||
pub fn insert_balance_changes(tables: &mut DatabaseChanges, clock: &Clock, block: &Block) { | ||
for balance_change in block.balance_changes.clone() { | ||
let address = bytes_to_hex(balance_change.address); | ||
let new_value = bytes_to_hex(balance_change.new_value.unwrap_or_default().bytes); | ||
let old_value = bytes_to_hex(balance_change.old_value.unwrap_or_default().bytes); | ||
let ordinal = balance_change.ordinal.to_string(); | ||
let reason = balance_change.reason.to_string(); | ||
let keys = balance_changes_keys(&clock, &ordinal); | ||
let row = tables | ||
.push_change_composite("balance_changes", keys, 0, table_change::Operation::Create) | ||
.change("address", ("", address.as_str())) | ||
.change("new_value", ("", new_value.as_str())) | ||
.change("old_value", ("", old_value.as_str())) | ||
.change("ordinal", ("", ordinal.as_str())) | ||
.change("reason", ("", reason.as_str())); | ||
|
||
insert_timestamp(row, clock, false); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
mod sinks; | ||
mod balance_changes; | ||
mod blocks; | ||
mod logs; | ||
mod logs; | ||
mod sinks; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
max_width = 200 |