diff --git a/common/changes/@subsquid/evm-processor/master_2024-11-14-12-00.json b/common/changes/@subsquid/evm-processor/master_2024-11-14-12-00.json new file mode 100644 index 000000000..9e9522fbf --- /dev/null +++ b/common/changes/@subsquid/evm-processor/master_2024-11-14-12-00.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@subsquid/evm-processor", + "comment": "allow to filter transactions by type", + "type": "minor" + } + ], + "packageName": "@subsquid/evm-processor" +} \ No newline at end of file diff --git a/evm/evm-processor/src/ds-rpc/filter.ts b/evm/evm-processor/src/ds-rpc/filter.ts index 1d529885c..c1554680a 100644 --- a/evm/evm-processor/src/ds-rpc/filter.ts +++ b/evm/evm-processor/src/ds-rpc/filter.ts @@ -32,11 +32,12 @@ function buildTransactionFilter(dataRequest: DataRequest): EntityFilter { 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() filter.propIn('to', to) filter.propIn('from', from) filter.propIn('sighash', sighash) + filter.propIn('type', type) items.add(filter, relations) } return items diff --git a/evm/evm-processor/src/interfaces/data-request.ts b/evm/evm-processor/src/interfaces/data-request.ts index 7082a8ab5..7b80aacb7 100644 --- a/evm/evm-processor/src/interfaces/data-request.ts +++ b/evm/evm-processor/src/interfaces/data-request.ts @@ -30,6 +30,7 @@ export interface TransactionRequest { to?: Bytes20[] from?: Bytes20[] sighash?: Bytes[] + type?: number[] logs?: boolean traces?: boolean stateDiffs?: boolean diff --git a/evm/evm-processor/src/processor.ts b/evm/evm-processor/src/processor.ts index 014d6b705..96f2aac0a 100644 --- a/evm/evm-processor/src/processor.ts +++ b/evm/evm-processor/src/processor.ts @@ -593,7 +593,9 @@ function mapRequest(options: T): Omit { 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