-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from blocktorch-xyz/block-1429-create-op-batch-…
…inbox-substreams Create OP batch inbox transactions module
- Loading branch information
Showing
10 changed files
with
123 additions
and
28 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
syntax = "proto3"; | ||
|
||
package eth.blocktorch.v1; | ||
|
||
message ListOfOpBatchInboxCallData { | ||
repeated OpBatchInboxCallData data = 1; | ||
} | ||
|
||
message OpBatchInboxCallData { | ||
string tx_hash = 1; | ||
string batcher_address = 2; | ||
string batch_inbox_address = 3; | ||
string call_data = 4; | ||
} |
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,20 +1,22 @@ | ||
use crate::pb::eth::blocktorch::v1::{CombinedData, AccountAbstractionTransactions, ChronicleTransactions, NitroRollups, OpRollups, ZkEvmRollups}; | ||
use crate::pb::eth::blocktorch::v1::{CombinedData, AccountAbstractionTransactions, ChronicleTransactions, NitroRollups, OpRollups, ZkEvmRollups, ListOfOpBatchInboxCallData}; | ||
|
||
#[substreams::handlers::map] | ||
fn map_combine_data( | ||
aa_trxs: AccountAbstractionTransactions, | ||
chronicle_trxs: ChronicleTransactions, | ||
nitro_rollups: NitroRollups, | ||
op_rollups: OpRollups, | ||
zk_evm_rollups: ZkEvmRollups | ||
zk_evm_rollups: ZkEvmRollups, | ||
list_of_calldata: ListOfOpBatchInboxCallData | ||
) -> Result<CombinedData, Vec<substreams::errors::Error>> { | ||
Ok( | ||
CombinedData { | ||
account_abstraction_transactions: aa_trxs.transactions, | ||
chronicle_transactions: chronicle_trxs.transactions, | ||
nitro_rollups: nitro_rollups.rollups, | ||
op_rollups: op_rollups.rollups, | ||
zk_evm_rollups: zk_evm_rollups.rollups | ||
zk_evm_rollups: zk_evm_rollups.rollups, | ||
list_of_op_batch_inbox_call_data: list_of_calldata.data | ||
} | ||
) | ||
} |
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,37 @@ | ||
use crate::pb::eth::blocktorch::v1::{OpBatchInboxCallData, ListOfOpBatchInboxCallData}; | ||
use serde::Deserialize; | ||
use substreams::Hex; | ||
use substreams_ethereum::pb::eth::v2::Block; | ||
|
||
#[derive(Debug, Deserialize)] | ||
struct Params { | ||
op_batch_inbox: String | ||
} | ||
|
||
#[substreams::handlers::map] | ||
fn map_filter_op_batch_inbox_transactions(params: String, blk: Block) -> Result<ListOfOpBatchInboxCallData, Vec<substreams::errors::Error>> { | ||
// Parse the query string parameters safely | ||
let query: Params = match serde_qs::from_str(¶ms) { | ||
Ok(query) => query, | ||
Err(_) => return Err(vec![substreams::errors::Error::msg("Failed to parse query parameters")]), | ||
}; | ||
|
||
// Decode the op_batch_inbox address | ||
let op_batch_inbox_address = match Hex::decode(&query.op_batch_inbox) { | ||
Ok(addr) => addr, | ||
Err(_) => return Err(vec![substreams::errors::Error::msg("Failed to decode op_batch_inbox address")]), | ||
}; | ||
|
||
let data: Vec<OpBatchInboxCallData> = blk | ||
.transaction_traces.iter() | ||
.filter(|tx| tx.to == op_batch_inbox_address) | ||
.map(|tx| OpBatchInboxCallData { | ||
tx_hash: Hex::encode(&tx.hash), | ||
batcher_address: Hex::encode(&tx.from), | ||
batch_inbox_address: Hex::encode(&tx.to), | ||
call_data: Hex::encode(&tx.input) | ||
}) | ||
.collect(); | ||
|
||
Ok(ListOfOpBatchInboxCallData { data }) | ||
} |
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