-
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
13fa5e3
commit 0f5dec7
Showing
9 changed files
with
49 additions
and
133 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,49 @@ | ||
use common::structs::BlockTimestamp; | ||
use common::utils::bytes_to_hex; | ||
use substreams_ethereum::pb::eth::v2::{Block, CodeChange, TransactionTrace}; | ||
use substreams_ethereum::pb::eth::v2::{Block, CodeChange as CodeChangeSource, TransactionTrace}; | ||
|
||
use crate::pb::pinax::evm::v1::CodeChange as CodeChangeEvent; | ||
use crate::pb::pinax::evm::v1::CodeChange; | ||
|
||
// 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<CodeChangeEvent> { | ||
let mut code_changes: Vec<CodeChangeEvent> = vec![]; | ||
pub fn collect_code_changes(block: &Block, timestamp: &BlockTimestamp) -> Vec<CodeChange> { | ||
let mut code_changes: Vec<CodeChange> = vec![]; | ||
|
||
// Collect code changes from system calls | ||
for call in &block.system_calls { | ||
for code_change in &call.code_changes { | ||
code_changes.push(parse_code_change(code_change, &TransactionTrace::default(), timestamp)); | ||
code_changes.push(parse_creation_trace(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(parse_code_change(code_change, transaction, timestamp)); | ||
code_changes.push(parse_creation_trace(code_change, transaction, timestamp)); | ||
} | ||
} | ||
} | ||
|
||
code_changes | ||
} | ||
|
||
pub fn parse_code_change(code_change: &CodeChange, transaction: &TransactionTrace, timestamp: &BlockTimestamp) -> CodeChangeEvent { | ||
CodeChangeEvent { | ||
pub fn parse_creation_trace(code_change: &CodeChangeSource, transaction: &TransactionTrace, timestamp: &BlockTimestamp) -> CodeChange { | ||
let factory = if transaction.to == code_change.address { "".to_string() } else { bytes_to_hex(&transaction.to) }; | ||
CodeChange { | ||
// block | ||
block_time: timestamp.time.to_string(), | ||
block_number: timestamp.number, | ||
block_hash: timestamp.hash.clone(), | ||
block_date: timestamp.date.clone(), | ||
|
||
// transaction | ||
tx_hash: Some(bytes_to_hex(&transaction.hash)), | ||
tx_hash: bytes_to_hex(&transaction.hash), | ||
|
||
// code changes | ||
// creation trace | ||
from: bytes_to_hex(&transaction.from), | ||
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, | ||
factory: factory.to_string(), | ||
code: bytes_to_hex(&code_change.new_code), | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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