Skip to content

Commit

Permalink
fix filtered injective modules to return completely empty data when e…
Browse files Browse the repository at this point in the history
…vent/trx list is empty
  • Loading branch information
sduchesneau committed Jun 21, 2024
1 parent 39053df commit 7a485e8
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion injective-common/derived-substreams-example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ package:
network: injective-mainnet

imports:
injective: ./injective-common-v0.2.0.spkg
injective: ./injective-common-v0.2.1.spkg

modules:
- name: my_events
Expand Down
18 changes: 18 additions & 0 deletions injective-common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,9 @@ fn filtered_events(query: String, events: EventList) -> Result<EventList, Error>
})
.collect();

if filtered.len() == 0 {
return Ok(EventList::default());
}
Ok(EventList {
events: filtered,
clock: events.clock,
Expand Down Expand Up @@ -216,6 +219,9 @@ fn filtered_event_groups(query: String, events: EventList) -> Result<EventList,
})
.collect();

if filtered.len() == 0 {
return Ok(EventList::default());
}
Ok(EventList {
events: filtered,
clock: events.clock,
Expand Down Expand Up @@ -256,6 +262,9 @@ fn filtered_trx_by_events(query: String, trxs: TransactionList) -> Result<Transa
.filter(|t| matching_trx_hashes.contains_key(t.hash.as_str()))
.collect();

if transactions.len() == 0 {
return Ok(TransactionList::default());
}
Ok(TransactionList {
transactions: transactions,
clock: trxs.clock,
Expand All @@ -282,6 +291,9 @@ fn filtered_events_by_attribute_value(query: String, events: EventList) -> Resul
})
.collect();

if filtered.len() == 0 {
return Ok(EventList::default());
}
Ok(EventList {
events: filtered,
clock: events.clock,
Expand Down Expand Up @@ -317,6 +329,9 @@ fn filtered_event_groups_by_attribute_value(query: String, events: EventList) ->
})
.collect();

if filtered.len() == 0 {
return Ok(EventList::default());
}
Ok(EventList {
events: filtered,
clock: events.clock,
Expand Down Expand Up @@ -350,6 +365,9 @@ fn filtered_trx_by_events_attribute_value(query: String, events: EventList, trxs
.filter(|t| matching_trx_hashes.contains_key(t.hash.as_str()))
.collect();

if transactions.len() == 0 {
return Ok(TransactionList::default());
}
Ok(TransactionList {
transactions: transactions,
clock: trxs.clock,
Expand Down
4 changes: 2 additions & 2 deletions injective-common/substreams.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
specVersion: v0.1.0
package:
name: injective_common
version: v0.2.0
version: v0.2.1
url: https://github.com/streamingfast/substreams-foundational-modules/injective-common
doc: |
common Injective substreams modules to extract events and transactions with indexing
Expand Down Expand Up @@ -168,4 +168,4 @@ params:
filtered_trx_by_events: "type:wasm"
filtered_events_by_attribute_value: "type:wasm && attr:_contract_address:inj1v77y5ttah96dc9qkcpc88ad7rce8n88e99t3m5"
filtered_event_groups_by_attribute_value: "type:wasm && attr:_contract_address:inj1v77y5ttah96dc9qkcpc88ad7rce8n88e99t3m5"
filtered_trx_by_events_attribute_value: "type:wasm && attr:_contract_address:inj1v77y5ttah96dc9qkcpc88ad7rce8n88e99t3m5"
filtered_trx_by_events_attribute_value: "type:wasm && attr:_contract_address:inj1v77y5ttah96dc9qkcpc88ad7rce8n88e99t3m5"

0 comments on commit 7a485e8

Please sign in to comment.