From 7ab85e634015f248cfeed80504355544726dab5d Mon Sep 17 00:00:00 2001 From: Scott Twiname Date: Wed, 7 Aug 2024 14:59:35 +1200 Subject: [PATCH] Fix filtering issue with undefined filter options --- packages/node/src/algorand/utils.algorand.spec.ts | 9 +++++++++ packages/node/src/algorand/utils.algorand.ts | 2 +- .../src/indexer/dictionary/algorandDictionary.service.ts | 1 + .../src/indexer/dictionary/v1/algorandDictionaryV1.ts | 2 -- packages/node/src/indexer/indexer.manager.ts | 1 + 5 files changed, 12 insertions(+), 3 deletions(-) diff --git a/packages/node/src/algorand/utils.algorand.spec.ts b/packages/node/src/algorand/utils.algorand.spec.ts index c93132e0..f9cfab45 100644 --- a/packages/node/src/algorand/utils.algorand.spec.ts +++ b/packages/node/src/algorand/utils.algorand.spec.ts @@ -85,5 +85,14 @@ describe('Algorand Filters', () => { }), ).toBeTruthy(); }); + + it('should not filter undefined options', () => { + expect( + filterTransaction(block.transactions![4], { + sender: 'ZW3ISEHZUHPO7OZGMKLKIIMKVICOUDRCERI454I3DB2BH52HGLSO67W754', + receiver: undefined, + }), + ).toBeTruthy(); + }); }); }); diff --git a/packages/node/src/algorand/utils.algorand.ts b/packages/node/src/algorand/utils.algorand.ts index c04b220f..e8d24d73 100644 --- a/packages/node/src/algorand/utils.algorand.ts +++ b/packages/node/src/algorand/utils.algorand.ts @@ -137,11 +137,11 @@ export function filterTransaction( for (const key in filterByKey) { if ( mappingFilterTransaction[txn.txType] && + filterByKey[key] !== undefined && !txComparator( filterByKey[key], get(txn, mappingFilterTransaction[txn.txType][key]), ) - // filterByKey[key] !== get(txn, mappingFilterTransaction[txn.txType][key]) ) { return false; } diff --git a/packages/node/src/indexer/dictionary/algorandDictionary.service.ts b/packages/node/src/indexer/dictionary/algorandDictionary.service.ts index b519233f..41cb5625 100644 --- a/packages/node/src/indexer/dictionary/algorandDictionary.service.ts +++ b/packages/node/src/indexer/dictionary/algorandDictionary.service.ts @@ -54,6 +54,7 @@ export class AlgorandDictionaryService extends DictionaryService< ); } } + this.init(dictionariesV1); } diff --git a/packages/node/src/indexer/dictionary/v1/algorandDictionaryV1.ts b/packages/node/src/indexer/dictionary/v1/algorandDictionaryV1.ts index 1a218f59..799515d3 100644 --- a/packages/node/src/indexer/dictionary/v1/algorandDictionaryV1.ts +++ b/packages/node/src/indexer/dictionary/v1/algorandDictionaryV1.ts @@ -13,7 +13,6 @@ import { AlgorandBlockFilter, AlgorandDataSource } from '@subql/types-algorand'; import { DictionaryQueryCondition, DictionaryQueryEntry as DictionaryV1QueryEntry, - DsProcessor, } from '@subql/types-core'; import { sortBy, uniqBy } from 'lodash'; import { SubqueryProject } from '../../../configure/SubqueryProject'; @@ -71,7 +70,6 @@ function buildDictionaryV1QueryEntries( const baseHandlerKind = getBaseHandlerKind(ds, handler, getDsProcessor); let filterList: AlgorandRuntimeHandlerFilter[]; if (isCustomDs(ds)) { - //const processor = plugin.handlerProcessors[handler.kind]; filterList = getBaseHandlerFilters( ds, handler.kind, diff --git a/packages/node/src/indexer/indexer.manager.ts b/packages/node/src/indexer/indexer.manager.ts index 7c5351f1..36f64738 100644 --- a/packages/node/src/indexer/indexer.manager.ts +++ b/packages/node/src/indexer/indexer.manager.ts @@ -93,6 +93,7 @@ export class IndexerManager extends BaseIndexerManager< getVM: (d: AlgorandDataSource) => Promise, ): Promise { await this.indexBlockContent(block, dataSources, getVM); + for (const tx of block.transactions ?? []) { await this.indexBlockTransactionContent(tx, dataSources, getVM); }