Skip to content

Commit

Permalink
Merge pull request #5 from blocktorch-xyz/block-1297-try-using-the-js…
Browse files Browse the repository at this point in the history
…-library-for-substreams-sink

Block 1297 try using the js library for substreams sink
  • Loading branch information
catalyst17 authored Nov 30, 2023
2 parents 32c86e2 + e90e5ba commit 65e4eab
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ build:

.PHONY: run
run: build
substreams run -e $(ENDPOINT) substreams.yaml db_out -s $(START_BLOCK) -t $(STOP_BLOCK)
substreams run -e $(ENDPOINT) substreams.yaml map_combine_transactions -s $(START_BLOCK) -t $(STOP_BLOCK)

.PHONY: sink
sink: build
Expand Down
11 changes: 11 additions & 0 deletions proto/combined_transactions.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
syntax = "proto3";

package eth.transaction.v1;

import "aa_transaction.proto";
import "chronicle_transaction.proto";

message CombinedTransactions {
repeated AccountAbstractionTransaction accountAbstractionTransactions = 1;
repeated ChronicleTransaction chronicleTransactions = 2;
}
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
mod map_filter_chronicle_transactions;
mod map_filter_aa_transactions;
mod map_combine_transactions;
mod db_out;
mod pb;
mod abi;
Expand Down
9 changes: 9 additions & 0 deletions src/map_combine_transactions.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
use crate::pb::eth::transaction::v1::{CombinedTransactions, AccountAbstractionTransactions, ChronicleTransactions};

#[substreams::handlers::map]
fn map_combine_transactions(
aa_trxs: AccountAbstractionTransactions,
chronicle_trxs: ChronicleTransactions
) -> Result<CombinedTransactions, Vec<substreams::errors::Error>> {
Ok(CombinedTransactions { account_abstraction_transactions: aa_trxs.transactions, chronicle_transactions: chronicle_trxs.transactions })
}
8 changes: 8 additions & 0 deletions src/pb/eth.transaction.v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,12 @@ pub struct AccountAbstractionTransaction {
#[prost(message, optional, tag="7")]
pub timestamp: ::core::option::Option<::prost_types::Timestamp>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CombinedTransactions {
#[prost(message, repeated, tag="1")]
pub account_abstraction_transactions: ::prost::alloc::vec::Vec<AccountAbstractionTransaction>,
#[prost(message, repeated, tag="2")]
pub chronicle_transactions: ::prost::alloc::vec::Vec<ChronicleTransaction>,
}
// @@protoc_insertion_point(module)
12 changes: 9 additions & 3 deletions substreams.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ protobuf:
files:
- chronicle_transaction.proto
- aa_transaction.proto
- combined_transactions.proto
importPaths:
- ./proto

Expand All @@ -23,23 +24,28 @@ binaries:
modules:
- name: map_filter_aa_transactions
kind: map
initialBlock: 18664500
inputs:
- source: sf.ethereum.type.v2.Block
output:
type: proto:eth.transaction.v1.AccountAbstractionTransactions

- name: map_filter_chronicle_transactions
kind: map
initialBlock: 18664500
inputs:
- source: sf.ethereum.type.v2.Block
output:
type: proto:eth.transaction.v1.ChronicleTransactions

- name: map_combine_transactions
kind: map
inputs:
- map: map_filter_aa_transactions
- map: map_filter_chronicle_transactions
output:
type: proto:eth.transaction.v1.CombinedTransactions

- name: db_out
kind: map
initialBlock: 18664500
inputs:
- map: map_filter_aa_transactions
- map: map_filter_chronicle_transactions
Expand Down

0 comments on commit 65e4eab

Please sign in to comment.