Skip to content

Commit

Permalink
Remove NFT type filter from gateway (#672)
Browse files Browse the repository at this point in the history
  • Loading branch information
tanghel authored Jun 9, 2022
1 parent 4ece51b commit 968bda8
Showing 1 changed file with 0 additions and 25 deletions.
25 changes: 0 additions & 25 deletions src/endpoints/esdt/esdt.address.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,39 +54,14 @@ export class EsdtAddressService {
return await this.getNftsForAddressFromGateway(address, filter, pagination);
}

if (filter.type) {
return await this.getNftsForAddressWithTypeFilter(address, filter, pagination);
}

if (source === EsdtDataSource.elastic || AddressUtils.isSmartContractAddress(address)) {
return await this.getNftsForAddressFromElastic(address, filter, pagination);
}

return await this.getNftsForAddressFromGateway(address, filter, pagination);
}

private async getNftsForAddressWithTypeFilter(address: string, filter: NftFilter, pagination: QueryPagination): Promise<NftAccount[]> {
if (AddressUtils.isSmartContractAddress(address)) {
const nftType = (filter.type ?? '').split(',');
filter.type = undefined;
let allEsdts = await this.getNftsForAddressFromElastic(address, filter, { from: 0, size: 10000 });
allEsdts = allEsdts.filter(x => nftType.includes(x.type));
allEsdts = allEsdts.slice(pagination.from, pagination.from + pagination.size);
return allEsdts;
}

const allEsdts = await this.getNftsForAddressFromGateway(address, filter, pagination);
return allEsdts;
}

async getNftCountForAddressFromElastic(address: string, filter: NftFilter): Promise<number> {
// temporary fix until we have type on the accountsesdt elastic collection
if (filter.type) {
const allEsdts = await this.getNftsForAddressWithTypeFilter(address, filter, { from: 0, size: 10000 });
return allEsdts.length;
}


const elasticQuery = this.nftService.buildElasticNftFilter(filter, undefined, address);
return await this.elasticService.getCount('accountsesdt', elasticQuery);
}
Expand Down

0 comments on commit 968bda8

Please sign in to comment.