@@ -417,6 +417,12 @@ export class PgStore {
417
417
indexBlockHashValues . push ( indexBytea , parentBytea ) ;
418
418
blockHashValues . push ( indexBytea ) ;
419
419
} ) ;
420
+ if ( blockHashValues . length === 0 ) {
421
+ return {
422
+ results : [ ] ,
423
+ total : 0 ,
424
+ } ;
425
+ }
420
426
421
427
// get txs in those blocks
422
428
const txs = await sql < { tx_id : string ; index_block_hash : string } [ ] > `
@@ -942,6 +948,9 @@ export class PgStore {
942
948
includeUnanchored : boolean ;
943
949
includePruned ?: boolean ;
944
950
} ) : Promise < DbMempoolTx [ ] > {
951
+ if ( args . txIds . length === 0 ) {
952
+ return [ ] ;
953
+ }
945
954
return this . sql . begin ( async client => {
946
955
const result = await this . sql < MempoolTxQueryResult [ ] > `
947
956
SELECT ${ unsafeCols ( this . sql , [ ...MEMPOOL_TX_COLUMNS , abiColumn ( 'mempool_txs' ) ] ) }
@@ -1818,28 +1827,6 @@ export class PgStore {
1818
1827
return entries ;
1819
1828
}
1820
1829
1821
- async getSmartContractList ( contractIds : string [ ] ) {
1822
- const result = await this . sql <
1823
- {
1824
- contract_id : string ;
1825
- canonical : boolean ;
1826
- tx_id : string ;
1827
- block_height : number ;
1828
- source_code : string ;
1829
- abi : unknown | null ;
1830
- } [ ]
1831
- > `
1832
- SELECT DISTINCT ON (contract_id) contract_id, canonical, tx_id, block_height, source_code, abi
1833
- FROM smart_contracts
1834
- WHERE contract_id IN ${ contractIds }
1835
- ORDER BY contract_id DESC, abi != 'null' DESC, canonical DESC, microblock_canonical DESC, block_height DESC
1836
- ` ;
1837
- if ( result . length === 0 ) {
1838
- [ ] ;
1839
- }
1840
- return result . map ( r => parseQueryResultToSmartContract ( r ) ) . map ( res => res . result ) ;
1841
- }
1842
-
1843
1830
async getSmartContract ( contractId : string ) {
1844
1831
const result = await this . sql <
1845
1832
{
@@ -2879,9 +2866,10 @@ export class PgStore {
2879
2866
const nftCustody = args . includeUnanchored
2880
2867
? this . sql ( `nft_custody_unanchored` )
2881
2868
: this . sql ( `nft_custody` ) ;
2882
- const assetIdFilter = args . assetIdentifiers
2883
- ? this . sql `AND nft.asset_identifier IN ${ this . sql ( args . assetIdentifiers ) } `
2884
- : this . sql `` ;
2869
+ const assetIdFilter =
2870
+ args . assetIdentifiers && args . assetIdentifiers . length > 0
2871
+ ? this . sql `AND nft.asset_identifier IN ${ this . sql ( args . assetIdentifiers ) } `
2872
+ : this . sql `` ;
2885
2873
const nftTxResults = await this . sql <
2886
2874
( NftHoldingInfo & ContractTxQueryResult & { count : number } ) [ ]
2887
2875
> `
@@ -3122,7 +3110,10 @@ export class PgStore {
3122
3110
} : {
3123
3111
txIds : string [ ] ;
3124
3112
includeUnanchored : boolean ;
3125
- } ) {
3113
+ } ) : Promise < DbTx [ ] > {
3114
+ if ( txIds . length === 0 ) {
3115
+ return [ ] ;
3116
+ }
3126
3117
return this . sql . begin ( async sql => {
3127
3118
const maxBlockHeight = await this . getMaxBlockHeight ( sql , { includeUnanchored } ) ;
3128
3119
const result = await sql < ContractTxQueryResult [ ] > `
0 commit comments