Skip to content

Commit

Permalink
evm: allow to filter transactions by type (#353)
Browse files Browse the repository at this point in the history
  • Loading branch information
tmcgroul authored Nov 14, 2024
1 parent 87ed765 commit e5c894c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@subsquid/evm-processor",
"comment": "allow to filter transactions by type",
"type": "minor"
}
],
"packageName": "@subsquid/evm-processor"
}
3 changes: 2 additions & 1 deletion evm/evm-processor/src/ds-rpc/filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@ function buildTransactionFilter(dataRequest: DataRequest): EntityFilter<Transact
}> {
let items = new EntityFilter()
for (let req of dataRequest.transactions || []) {
let {to, from, sighash, ...relations} = req
let {to, from, sighash, type, ...relations} = req
let filter = new FilterBuilder<Transaction>()
filter.propIn('to', to)
filter.propIn('from', from)
filter.propIn('sighash', sighash)
filter.propIn('type', type)
items.add(filter, relations)
}
return items
Expand Down
1 change: 1 addition & 0 deletions evm/evm-processor/src/interfaces/data-request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export interface TransactionRequest {
to?: Bytes20[]
from?: Bytes20[]
sighash?: Bytes[]
type?: number[]
logs?: boolean
traces?: boolean
stateDiffs?: boolean
Expand Down
4 changes: 3 additions & 1 deletion evm/evm-processor/src/processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,9 @@ function mapRequest<T extends BlockRange>(options: T): Omit<T, 'range'> {
for (let key in req) {
let val = (req as any)[key]
if (Array.isArray(val)) {
(req as any)[key] = val.map(s => s.toLowerCase())
(req as any)[key] = val.map(s => {
return typeof s == 'string' ? s.toLowerCase() : s
})
}
}
return req
Expand Down

0 comments on commit e5c894c

Please sign in to comment.