-
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
25e69be
commit 5a57ef1
Showing
8 changed files
with
226 additions
and
312 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,47 @@ | ||
use common::structs::BlockTimestamp; | ||
use common::utils::bytes_to_hex; | ||
|
||
use substreams_ethereum::pb::eth::v2::Block; | ||
use substreams_ethereum::pb::eth::v2::{AccountCreation, Block, TransactionTrace}; | ||
|
||
use crate::pb::evm::AccountCreation; | ||
use crate::pb::evm::AccountCreation as AccountCreationEvent; | ||
|
||
// https://github.com/streamingfast/firehose-ethereum/blob/1bcb32a8eb3e43347972b6b5c9b1fcc4a08c751e/proto/sf/ethereum/type/v2/type.proto#L736 | ||
// DetailLevel: EXTENDED | ||
pub fn collect_account_creations(block: &Block, timestamp: &BlockTimestamp) -> Vec<AccountCreation> { | ||
let mut account_creations: Vec<AccountCreation> = vec![]; | ||
pub fn collect_account_creations(block: &Block, timestamp: &BlockTimestamp) -> Vec<AccountCreationEvent> { | ||
let mut account_creations: Vec<AccountCreationEvent> = vec![]; | ||
|
||
// Collect account creations from system calls | ||
for call in &block.system_calls { | ||
for account_creation in &call.account_creations { | ||
account_creations.push(AccountCreation { | ||
// block | ||
block_time: Some(timestamp.time), | ||
block_number: timestamp.number, | ||
block_hash: timestamp.hash.clone(), | ||
block_date: timestamp.date.clone(), | ||
|
||
// transaction | ||
tx_hash: Some("".to_string()), | ||
|
||
// account creation | ||
account: bytes_to_hex(&account_creation.account), | ||
ordinal: account_creation.ordinal, | ||
}); | ||
account_creations.push(parse_account_creation(account_creation, &TransactionTrace::default(), timestamp)); | ||
} | ||
} | ||
|
||
// Collect account creations from transaction traces | ||
for transaction in &block.transaction_traces { | ||
for call in &transaction.calls { | ||
for account_creation in &call.account_creations { | ||
account_creations.push(AccountCreation { | ||
// block | ||
block_time: Some(timestamp.time), | ||
block_number: timestamp.number, | ||
block_hash: timestamp.hash.clone(), | ||
block_date: timestamp.date.clone(), | ||
|
||
// transaction | ||
tx_hash: Some(bytes_to_hex(&transaction.hash)), | ||
|
||
// account creation | ||
account: bytes_to_hex(&account_creation.account), | ||
ordinal: account_creation.ordinal, | ||
}); | ||
account_creations.push(parse_account_creation(account_creation, transaction, timestamp)); | ||
} | ||
} | ||
} | ||
|
||
account_creations | ||
} | ||
|
||
pub fn parse_account_creation(account_creation: &AccountCreation, transaction: &TransactionTrace, timestamp: &BlockTimestamp) -> AccountCreationEvent { | ||
AccountCreationEvent { | ||
// block | ||
block_time: Some(timestamp.time), | ||
block_number: timestamp.number, | ||
block_hash: timestamp.hash.clone(), | ||
block_date: timestamp.date.clone(), | ||
|
||
// transaction | ||
tx_hash: Some(bytes_to_hex(&transaction.hash)), | ||
|
||
// account creation | ||
account: bytes_to_hex(&account_creation.account), | ||
ordinal: account_creation.ordinal, | ||
} | ||
} |
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,63 +1,50 @@ | ||
use common::structs::BlockTimestamp; | ||
use common::utils::bytes_to_hex; | ||
use substreams_ethereum::pb::eth::v2::Block; | ||
use substreams_ethereum::pb::eth::v2::{Block, CodeChange, TransactionTrace}; | ||
|
||
use crate::pb::evm::CodeChange; | ||
use crate::pb::evm::CodeChange as CodeChangeEvent; | ||
|
||
// https://github.com/streamingfast/firehose-ethereum/blob/1bcb32a8eb3e43347972b6b5c9b1fcc4a08c751e/proto/sf/ethereum/type/v2/type.proto#L744 | ||
// DetailLevel: EXTENDED | ||
pub fn collect_code_changes(block: &Block, timestamp: &BlockTimestamp) -> Vec<CodeChange> { | ||
let mut code_changes: Vec<CodeChange> = vec![]; | ||
pub fn collect_code_changes(block: &Block, timestamp: &BlockTimestamp) -> Vec<CodeChangeEvent> { | ||
let mut code_changes: Vec<CodeChangeEvent> = vec![]; | ||
|
||
// Collect code changes from system calls | ||
for call in &block.system_calls { | ||
for code_change in &call.code_changes { | ||
code_changes.push(CodeChange { | ||
// block | ||
block_time: Some(timestamp.time), | ||
block_number: timestamp.number, | ||
block_hash: timestamp.hash.clone(), | ||
block_date: timestamp.date.clone(), | ||
|
||
// transaction | ||
tx_hash: Some(String::new()), | ||
|
||
// code changes | ||
address: bytes_to_hex(&code_change.address), | ||
old_hash: bytes_to_hex(&code_change.old_hash), | ||
old_code: bytes_to_hex(&code_change.old_code), | ||
new_hash: bytes_to_hex(&code_change.new_hash), | ||
new_code: bytes_to_hex(&code_change.new_code), | ||
ordinal: code_change.ordinal, | ||
}); | ||
code_changes.push(parse_code_change(code_change, &TransactionTrace::default(), timestamp)); | ||
} | ||
} | ||
|
||
// Collect code changes from transaction traces | ||
for transaction in &block.transaction_traces { | ||
for call in &transaction.calls { | ||
for code_change in &call.code_changes { | ||
code_changes.push(CodeChange { | ||
// block | ||
block_time: Some(timestamp.time), | ||
block_number: timestamp.number, | ||
block_hash: timestamp.hash.clone(), | ||
block_date: timestamp.date.clone(), | ||
|
||
// transaction | ||
tx_hash: Some(bytes_to_hex(&transaction.hash)), | ||
|
||
// code changes | ||
address: bytes_to_hex(&code_change.address), | ||
old_hash: bytes_to_hex(&code_change.old_hash), | ||
old_code: bytes_to_hex(&code_change.old_code), | ||
new_hash: bytes_to_hex(&code_change.new_hash), | ||
new_code: bytes_to_hex(&code_change.new_code), | ||
ordinal: code_change.ordinal, | ||
}); | ||
code_changes.push(parse_code_change(code_change, transaction, timestamp)); | ||
} | ||
} | ||
} | ||
|
||
code_changes | ||
} | ||
|
||
pub fn parse_code_change(code_change: &CodeChange, transaction: &TransactionTrace, timestamp: &BlockTimestamp) -> CodeChangeEvent { | ||
CodeChangeEvent { | ||
// block | ||
block_time: Some(timestamp.time), | ||
block_number: timestamp.number, | ||
block_hash: timestamp.hash.clone(), | ||
block_date: timestamp.date.clone(), | ||
|
||
// transaction | ||
tx_hash: Some(bytes_to_hex(&transaction.hash)), | ||
|
||
// code changes | ||
address: bytes_to_hex(&code_change.address), | ||
old_hash: bytes_to_hex(&code_change.old_hash), | ||
old_code: bytes_to_hex(&code_change.old_code), | ||
new_hash: bytes_to_hex(&code_change.new_hash), | ||
new_code: bytes_to_hex(&code_change.new_code), | ||
ordinal: code_change.ordinal, | ||
} | ||
} |
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
Oops, something went wrong.