diff --git a/blocks/antelope/src/account_ram_deltas.rs b/blocks/antelope/src/account_ram_deltas.rs index a24cd1c..b28bdec 100644 --- a/blocks/antelope/src/account_ram_deltas.rs +++ b/blocks/antelope/src/account_ram_deltas.rs @@ -1,15 +1,15 @@ -use crate::pb::antelope::AccountRamDelta as RawAccountRamDelta; +use crate::pb::antelope::AccountRamDelta; use common::structs::BlockTimestamp; use substreams_antelope::pb::TransactionTrace; -pub fn collect_tx_account_ram_deltas(transaction: &TransactionTrace, timestamp: &BlockTimestamp, tx_success: bool) -> Vec { +pub fn collect_tx_account_ram_deltas(transaction: &TransactionTrace, timestamp: &BlockTimestamp, tx_success: bool) -> Vec { let mut account_ram_deltas = Vec::new(); for action_trace in transaction.action_traces.iter() { let action_index = action_trace.execution_index; for (index, delta) in action_trace.account_ram_deltas.iter().enumerate() { - account_ram_deltas.push(RawAccountRamDelta { + account_ram_deltas.push(AccountRamDelta { block_time: Some(timestamp.time.clone()), block_number: timestamp.number, block_hash: timestamp.hash.clone(), diff --git a/blocks/antelope/src/actions.rs b/blocks/antelope/src/actions.rs index 882957d..1d94345 100644 --- a/blocks/antelope/src/actions.rs +++ b/blocks/antelope/src/actions.rs @@ -4,18 +4,18 @@ use substreams::Hex; use substreams_antelope::pb::TransactionTrace; use substreams_antelope::Block; -use crate::pb::antelope::Action as RawAction; +use crate::pb::antelope::Action; // https://github.com/pinax-network/firehose-antelope/blob/534ca5bf2aeda67e8ef07a1af8fc8e0fe46473ee/proto/sf/antelope/type/v1/type.proto#L525 -pub fn collect_tx_actions(block: &Block, transaction: &TransactionTrace, timestamp: &BlockTimestamp, tx_success: bool) -> Vec { +pub fn collect_tx_actions(block: &Block, transaction: &TransactionTrace, timestamp: &BlockTimestamp, tx_success: bool) -> Vec { let header = block.header.clone().unwrap_or_default(); - let mut actions: Vec = Vec::new(); + let mut actions: Vec = Vec::new(); for trace in transaction.action_traces.iter() { let action = trace.action.clone().unwrap_or_default(); let receipt = trace.receipt.clone().unwrap_or_default(); - actions.push(RawAction { + actions.push(Action { block_time: Some(timestamp.time.clone()), block_number: timestamp.number, block_hash: timestamp.hash.clone(), diff --git a/blocks/antelope/src/auth_sequences.rs b/blocks/antelope/src/auth_sequences.rs index 72f932f..abeb418 100644 --- a/blocks/antelope/src/auth_sequences.rs +++ b/blocks/antelope/src/auth_sequences.rs @@ -1,9 +1,9 @@ use common::structs::BlockTimestamp; use substreams_antelope::pb::TransactionTrace; -use crate::pb::antelope::AuthSequence as RawAuthSequence; +use crate::pb::antelope::AuthSequence; -pub fn collect_tx_auth_sequences(transaction: &TransactionTrace, timestamp: &BlockTimestamp, tx_success: bool) -> Vec { +pub fn collect_tx_auth_sequences(transaction: &TransactionTrace, timestamp: &BlockTimestamp, tx_success: bool) -> Vec { let mut auth_sequences = Vec::new(); for action_trace in transaction.action_traces.iter() { @@ -11,7 +11,7 @@ pub fn collect_tx_auth_sequences(transaction: &TransactionTrace, timestamp: &Blo let action_index = action_trace.execution_index; for (index, auth) in receipt.auth_sequence.iter().enumerate() { - auth_sequences.push(RawAuthSequence { + auth_sequences.push(AuthSequence { block_time: Some(timestamp.time.clone()), block_number: timestamp.number, block_hash: timestamp.hash.clone(), diff --git a/blocks/antelope/src/authority.rs b/blocks/antelope/src/authority.rs index 5b5179e..fa571c2 100644 --- a/blocks/antelope/src/authority.rs +++ b/blocks/antelope/src/authority.rs @@ -1,17 +1,17 @@ -use crate::pb::antelope::{Account as RawAccount, Key as RawKey, Wait as RawWait}; +use crate::pb::antelope::{Account, Key, Wait}; use common::structs::BlockTimestamp; use substreams_antelope::pb::TransactionTrace; pub struct AuthorityVectors { - pub accounts: Vec, - pub keys: Vec, - pub waits: Vec, + pub accounts: Vec, + pub keys: Vec, + pub waits: Vec, } pub fn collect_tx_authority_vectors(transaction: &TransactionTrace, timestamp: &BlockTimestamp, tx_success: bool) -> AuthorityVectors { - let mut accounts: Vec = Vec::new(); - let mut keys: Vec = Vec::new(); - let mut waits: Vec = Vec::new(); + let mut accounts: Vec = Vec::new(); + let mut keys: Vec = Vec::new(); + let mut waits: Vec = Vec::new(); for perm_op in transaction.perm_ops.iter() { if let Some(new_perm) = &perm_op.new_perm { @@ -21,7 +21,7 @@ pub fn collect_tx_authority_vectors(transaction: &TransactionTrace, timestamp: & // Process authority accounts for (index, account) in authority.accounts.iter().enumerate() { if let Some(permission) = &account.permission { - accounts.push(RawAccount { + accounts.push(Account { block_time: Some(timestamp.time.clone()), block_number: timestamp.number, block_hash: timestamp.hash.clone(), @@ -39,7 +39,7 @@ pub fn collect_tx_authority_vectors(transaction: &TransactionTrace, timestamp: & // Process authority keys for (index, key) in authority.keys.iter().enumerate() { - keys.push(RawKey { + keys.push(Key { block_time: Some(timestamp.time.clone()), block_number: timestamp.number, block_hash: timestamp.hash.clone(), @@ -55,7 +55,7 @@ pub fn collect_tx_authority_vectors(transaction: &TransactionTrace, timestamp: & // Process authority waits for (index, wait) in authority.waits.iter().enumerate() { - waits.push(RawWait { + waits.push(Wait { block_time: Some(timestamp.time.clone()), block_number: timestamp.number, block_hash: timestamp.hash.clone(), diff --git a/blocks/antelope/src/authorizations.rs b/blocks/antelope/src/authorizations.rs index b101aad..ff38256 100644 --- a/blocks/antelope/src/authorizations.rs +++ b/blocks/antelope/src/authorizations.rs @@ -1,15 +1,15 @@ use common::structs::BlockTimestamp; use substreams_antelope::pb::TransactionTrace; -use crate::pb::antelope::Authorization as RawAuthorization; +use crate::pb::antelope::Authorization; // https://github.com/pinax-network/firehose-antelope/blob/534ca5bf2aeda67e8ef07a1af8fc8e0fe46473ee/proto/sf/antelope/type/v1/type.proto#L616 -pub fn collect_tx_authorizations(transaction: &TransactionTrace, timestamp: &BlockTimestamp, tx_success: bool) -> Vec { +pub fn collect_tx_authorizations(transaction: &TransactionTrace, timestamp: &BlockTimestamp, tx_success: bool) -> Vec { let mut authorizations = Vec::new(); for action_trace in transaction.action_traces.iter() { for (index, authorization) in action_trace.action.as_ref().unwrap().authorization.iter().enumerate() { - authorizations.push(RawAuthorization { + authorizations.push(Authorization { block_time: Some(timestamp.time.clone()), block_number: timestamp.number, block_hash: timestamp.hash.clone(), diff --git a/blocks/antelope/src/blocks.rs b/blocks/antelope/src/blocks.rs index afb6a44..e752d6b 100644 --- a/blocks/antelope/src/blocks.rs +++ b/blocks/antelope/src/blocks.rs @@ -1,15 +1,15 @@ -use crate::{pb::antelope::Block as RawBlock, size::collect_size}; +use crate::{pb::antelope::Block as EventsBlock, size::collect_size}; use common::structs::BlockTimestamp; use substreams::Hex; use substreams_antelope::Block; // https://github.com/pinax-network/firehose-antelope/blob/534ca5bf2aeda67e8ef07a1af8fc8e0fe46473ee/proto/sf/antelope/type/v1/type.proto#L21 -pub fn collect_block(block: &Block, timestamp: &BlockTimestamp) -> RawBlock { +pub fn collect_block(block: &Block, timestamp: &BlockTimestamp) -> EventsBlock { let header = block.header.clone().unwrap_or_default(); let blockroot_merkle = block.blockroot_merkle.clone().unwrap_or_default(); let size = collect_size(block); - RawBlock { + EventsBlock { time: Some(timestamp.time), number: timestamp.number, date: timestamp.date.clone(), diff --git a/blocks/antelope/src/collect_events.rs b/blocks/antelope/src/collect_events.rs index 791f27e..48acf91 100644 --- a/blocks/antelope/src/collect_events.rs +++ b/blocks/antelope/src/collect_events.rs @@ -11,15 +11,15 @@ use crate::{ creation_tree::collect_tx_creation_trees, db_ops::collect_tx_db_ops, feature_ops::collect_tx_feature_ops, - pb::antelope::Events as RawEvents, + pb::antelope::Events, perm_ops::collect_tx_perm_ops, ram_ops::collect_tx_ram_ops, table_ops::collect_tx_table_ops, transactions::{collect_transaction, is_transaction_success}, }; -pub fn collect_events(block: &Block, timestamp: &BlockTimestamp) -> RawEvents { - let mut events = RawEvents { +pub fn collect_events(block: &Block, timestamp: &BlockTimestamp) -> Events { + let mut events = Events { blocks: vec![collect_block(block, timestamp)], transactions: Vec::new(), actions: Vec::new(), diff --git a/blocks/antelope/src/creation_tree.rs b/blocks/antelope/src/creation_tree.rs index 2931db8..3df9d7f 100644 --- a/blocks/antelope/src/creation_tree.rs +++ b/blocks/antelope/src/creation_tree.rs @@ -1,12 +1,12 @@ -use crate::pb::antelope::CreationTree as RawCreationTree; +use crate::pb::antelope::CreationTree; use common::structs::BlockTimestamp; use substreams_antelope::pb::TransactionTrace; -pub fn collect_tx_creation_trees(transaction: &TransactionTrace, timestamp: &BlockTimestamp, tx_success: bool) -> Vec { +pub fn collect_tx_creation_trees(transaction: &TransactionTrace, timestamp: &BlockTimestamp, tx_success: bool) -> Vec { let mut creation_trees = Vec::new(); for creation_flat_node in transaction.creation_tree.iter() { - creation_trees.push(RawCreationTree { + creation_trees.push(CreationTree { block_time: Some(timestamp.time.clone()), block_number: timestamp.number, block_hash: timestamp.hash.clone(), diff --git a/blocks/antelope/src/db_ops.rs b/blocks/antelope/src/db_ops.rs index af2ca5e..e471191 100644 --- a/blocks/antelope/src/db_ops.rs +++ b/blocks/antelope/src/db_ops.rs @@ -2,7 +2,7 @@ use common::structs::BlockTimestamp; use substreams::Hex; use substreams_antelope::pb::TransactionTrace; -use crate::pb::antelope::DbOp as RawDbOp; +use crate::pb::antelope::DbOp; pub fn operation_to_string(operation: i32) -> String { match operation { @@ -15,11 +15,11 @@ pub fn operation_to_string(operation: i32) -> String { } // https://github.com/streamingfast/firehose-ethereum/blob/1bcb32a8eb3e43347972b6b5c9b1fcc4a08c751e/proto/sf/ethereum/type/v2/type.proto#L647 -pub fn collect_tx_db_ops(transaction: &TransactionTrace, timestamp: &BlockTimestamp, tx_success: bool) -> Vec { - let mut db_ops: Vec = Vec::new(); +pub fn collect_tx_db_ops(transaction: &TransactionTrace, timestamp: &BlockTimestamp, tx_success: bool) -> Vec { + let mut db_ops: Vec = Vec::new(); for (index, db_op) in transaction.db_ops.iter().enumerate() { - db_ops.push(RawDbOp { + db_ops.push(DbOp { block_time: Some(timestamp.time.clone()), block_number: timestamp.number, block_hash: timestamp.hash.clone(), diff --git a/blocks/antelope/src/feature_ops.rs b/blocks/antelope/src/feature_ops.rs index b263333..8a876da 100644 --- a/blocks/antelope/src/feature_ops.rs +++ b/blocks/antelope/src/feature_ops.rs @@ -1,15 +1,15 @@ use common::structs::BlockTimestamp; use substreams_antelope::pb::TransactionTrace; -use crate::pb::antelope::FeatureOp as RawFeatureOp; +use crate::pb::antelope::FeatureOp; -pub fn collect_tx_feature_ops(transaction: &TransactionTrace, timestamp: &BlockTimestamp, tx_success: bool) -> Vec { +pub fn collect_tx_feature_ops(transaction: &TransactionTrace, timestamp: &BlockTimestamp, tx_success: bool) -> Vec { let mut feature_ops = Vec::new(); for feature_op in transaction.feature_ops.iter() { let feature = feature_op.feature.as_ref().expect("feature is required"); - feature_ops.push(RawFeatureOp { + feature_ops.push(FeatureOp { block_time: Some(timestamp.time.clone()), block_number: timestamp.number, block_hash: timestamp.hash.clone(), diff --git a/blocks/antelope/src/perm_ops.rs b/blocks/antelope/src/perm_ops.rs index f2c1cb9..8e6ba40 100644 --- a/blocks/antelope/src/perm_ops.rs +++ b/blocks/antelope/src/perm_ops.rs @@ -1,7 +1,8 @@ -use crate::pb::antelope::PermOp as RawPermOp; use common::structs::BlockTimestamp; use substreams_antelope::pb::TransactionTrace; +use crate::pb::antelope::PermOp; + pub fn perm_op_operation_to_string(operation: i32) -> String { match operation { 0 => "Unknown".to_string(), @@ -12,14 +13,14 @@ pub fn perm_op_operation_to_string(operation: i32) -> String { } } -pub fn collect_tx_perm_ops(transaction: &TransactionTrace, timestamp: &BlockTimestamp, tx_success: bool) -> Vec { +pub fn collect_tx_perm_ops(transaction: &TransactionTrace, timestamp: &BlockTimestamp, tx_success: bool) -> Vec { let mut perm_ops = Vec::new(); for perm_op in transaction.perm_ops.iter() { if let Some(new_perm) = &perm_op.new_perm { let threshold = new_perm.authority.as_ref().map_or(0, |authority| authority.threshold); - perm_ops.push(RawPermOp { + perm_ops.push(PermOp { block_time: Some(timestamp.time.clone()), block_number: timestamp.number, block_hash: timestamp.hash.clone(), diff --git a/blocks/antelope/src/ram_ops.rs b/blocks/antelope/src/ram_ops.rs index 9b41f4e..a6a46df 100644 --- a/blocks/antelope/src/ram_ops.rs +++ b/blocks/antelope/src/ram_ops.rs @@ -1,7 +1,7 @@ use common::structs::BlockTimestamp; use substreams_antelope::pb::TransactionTrace; -use crate::pb::antelope::RamOp as RawRamOp; +use crate::pb::antelope::RamOp; pub fn namespace_to_string(namespace: i32) -> String { match namespace { @@ -64,11 +64,11 @@ pub fn operation_to_string(operation: i32) -> String { } } -pub fn collect_tx_ram_ops(transaction: &TransactionTrace, timestamp: &BlockTimestamp, tx_success: bool) -> Vec { +pub fn collect_tx_ram_ops(transaction: &TransactionTrace, timestamp: &BlockTimestamp, tx_success: bool) -> Vec { let mut ram_ops = Vec::new(); for ram_op in transaction.ram_ops.iter() { - ram_ops.push(RawRamOp { + ram_ops.push(RamOp { block_time: Some(timestamp.time.clone()), block_number: timestamp.number, block_hash: timestamp.hash.clone(), diff --git a/blocks/antelope/src/table_ops.rs b/blocks/antelope/src/table_ops.rs index aae96f6..cc75e0d 100644 --- a/blocks/antelope/src/table_ops.rs +++ b/blocks/antelope/src/table_ops.rs @@ -1,7 +1,7 @@ use common::structs::BlockTimestamp; use substreams_antelope::pb::TransactionTrace; -use crate::pb::antelope::TableOp as RawTableOp; +use crate::pb::antelope::TableOp; pub fn table_op_operation_to_string(operation: i32) -> String { match operation { @@ -12,11 +12,11 @@ pub fn table_op_operation_to_string(operation: i32) -> String { } } -pub fn collect_tx_table_ops(transaction: &TransactionTrace, timestamp: &BlockTimestamp, tx_success: bool) -> Vec { +pub fn collect_tx_table_ops(transaction: &TransactionTrace, timestamp: &BlockTimestamp, tx_success: bool) -> Vec { let mut table_ops = Vec::new(); for (index, table_op) in transaction.table_ops.iter().enumerate() { - table_ops.push(RawTableOp { + table_ops.push(TableOp { block_time: Some(timestamp.time.clone()), block_number: timestamp.number, block_hash: timestamp.hash.clone(), diff --git a/blocks/antelope/src/transactions.rs b/blocks/antelope/src/transactions.rs index 0d85703..1637a4e 100644 --- a/blocks/antelope/src/transactions.rs +++ b/blocks/antelope/src/transactions.rs @@ -2,7 +2,7 @@ use common::structs::BlockTimestamp; use substreams::Hex; use substreams_antelope::{pb::TransactionTrace, Block}; -use crate::pb::antelope::Transaction as RawTransaction; +use crate::pb::antelope::Transaction; pub fn transaction_status_to_string(status: i32) -> String { match status { @@ -23,13 +23,13 @@ pub fn is_transaction_success(status: i32) -> bool { } // https://github.com/pinax-network/firehose-antelope/blob/534ca5bf2aeda67e8ef07a1af8fc8e0fe46473ee/proto/sf/antelope/type/v1/type.proto#L525 -pub fn collect_transaction(block: &Block, transaction: &TransactionTrace, timestamp: &BlockTimestamp, tx_success: bool) -> RawTransaction { +pub fn collect_transaction(block: &Block, transaction: &TransactionTrace, timestamp: &BlockTimestamp, tx_success: bool) -> Transaction { let header = block.header.clone().unwrap_or_default(); let receipt = transaction.receipt.clone().unwrap_or_default(); let status_code = receipt.status; let status = transaction_status_to_string(status_code); - RawTransaction { + Transaction { block_time: Some(timestamp.time.clone()), block_number: timestamp.number, block_hash: timestamp.hash.clone(),