Skip to content

Commit

Permalink
Remove Raw prefix from imports
Browse files Browse the repository at this point in the history
  • Loading branch information
zolting committed Nov 20, 2024
1 parent 906d057 commit ae99601
Show file tree
Hide file tree
Showing 14 changed files with 52 additions and 51 deletions.
6 changes: 3 additions & 3 deletions blocks/antelope/src/account_ram_deltas.rs
Original file line number Diff line number Diff line change
@@ -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<RawAccountRamDelta> {
pub fn collect_tx_account_ram_deltas(transaction: &TransactionTrace, timestamp: &BlockTimestamp, tx_success: bool) -> Vec<AccountRamDelta> {
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(),
Expand Down
8 changes: 4 additions & 4 deletions blocks/antelope/src/actions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<RawAction> {
pub fn collect_tx_actions(block: &Block, transaction: &TransactionTrace, timestamp: &BlockTimestamp, tx_success: bool) -> Vec<Action> {
let header = block.header.clone().unwrap_or_default();
let mut actions: Vec<RawAction> = Vec::new();
let mut actions: Vec<Action> = 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(),
Expand Down
6 changes: 3 additions & 3 deletions blocks/antelope/src/auth_sequences.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
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<RawAuthSequence> {
pub fn collect_tx_auth_sequences(transaction: &TransactionTrace, timestamp: &BlockTimestamp, tx_success: bool) -> Vec<AuthSequence> {
let mut auth_sequences = Vec::new();

for action_trace in transaction.action_traces.iter() {
let receipt = action_trace.receipt.as_ref().expect("Action trace receipt is required");
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(),
Expand Down
20 changes: 10 additions & 10 deletions blocks/antelope/src/authority.rs
Original file line number Diff line number Diff line change
@@ -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<RawAccount>,
pub keys: Vec<RawKey>,
pub waits: Vec<RawWait>,
pub accounts: Vec<Account>,
pub keys: Vec<Key>,
pub waits: Vec<Wait>,
}

pub fn collect_tx_authority_vectors(transaction: &TransactionTrace, timestamp: &BlockTimestamp, tx_success: bool) -> AuthorityVectors {
let mut accounts: Vec<RawAccount> = Vec::new();
let mut keys: Vec<RawKey> = Vec::new();
let mut waits: Vec<RawWait> = Vec::new();
let mut accounts: Vec<Account> = Vec::new();
let mut keys: Vec<Key> = Vec::new();
let mut waits: Vec<Wait> = Vec::new();

for perm_op in transaction.perm_ops.iter() {
if let Some(new_perm) = &perm_op.new_perm {
Expand All @@ -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(),
Expand All @@ -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(),
Expand All @@ -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(),
Expand Down
6 changes: 3 additions & 3 deletions blocks/antelope/src/authorizations.rs
Original file line number Diff line number Diff line change
@@ -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<RawAuthorization> {
pub fn collect_tx_authorizations(transaction: &TransactionTrace, timestamp: &BlockTimestamp, tx_success: bool) -> Vec<Authorization> {
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(),
Expand Down
6 changes: 3 additions & 3 deletions blocks/antelope/src/blocks.rs
Original file line number Diff line number Diff line change
@@ -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(),
Expand Down
6 changes: 3 additions & 3 deletions blocks/antelope/src/collect_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
6 changes: 3 additions & 3 deletions blocks/antelope/src/creation_tree.rs
Original file line number Diff line number Diff line change
@@ -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<RawCreationTree> {
pub fn collect_tx_creation_trees(transaction: &TransactionTrace, timestamp: &BlockTimestamp, tx_success: bool) -> Vec<CreationTree> {
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(),
Expand Down
8 changes: 4 additions & 4 deletions blocks/antelope/src/db_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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<RawDbOp> {
let mut db_ops: Vec<RawDbOp> = Vec::new();
pub fn collect_tx_db_ops(transaction: &TransactionTrace, timestamp: &BlockTimestamp, tx_success: bool) -> Vec<DbOp> {
let mut db_ops: Vec<DbOp> = 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(),
Expand Down
6 changes: 3 additions & 3 deletions blocks/antelope/src/feature_ops.rs
Original file line number Diff line number Diff line change
@@ -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<RawFeatureOp> {
pub fn collect_tx_feature_ops(transaction: &TransactionTrace, timestamp: &BlockTimestamp, tx_success: bool) -> Vec<FeatureOp> {
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(),
Expand Down
7 changes: 4 additions & 3 deletions blocks/antelope/src/perm_ops.rs
Original file line number Diff line number Diff line change
@@ -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(),
Expand All @@ -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<RawPermOp> {
pub fn collect_tx_perm_ops(transaction: &TransactionTrace, timestamp: &BlockTimestamp, tx_success: bool) -> Vec<PermOp> {
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(),
Expand Down
6 changes: 3 additions & 3 deletions blocks/antelope/src/ram_ops.rs
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -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<RawRamOp> {
pub fn collect_tx_ram_ops(transaction: &TransactionTrace, timestamp: &BlockTimestamp, tx_success: bool) -> Vec<RamOp> {
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(),
Expand Down
6 changes: 3 additions & 3 deletions blocks/antelope/src/table_ops.rs
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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<RawTableOp> {
pub fn collect_tx_table_ops(transaction: &TransactionTrace, timestamp: &BlockTimestamp, tx_success: bool) -> Vec<TableOp> {
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(),
Expand Down
6 changes: 3 additions & 3 deletions blocks/antelope/src/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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(),
Expand Down

0 comments on commit ae99601

Please sign in to comment.