File tree 1 file changed +13
-24
lines changed
packages/cardano-services-client/src/ChainHistoryProvider
1 file changed +13
-24
lines changed Original file line number Diff line number Diff line change @@ -476,31 +476,20 @@ export class BlockfrostChainHistoryProvider extends BlockfrostProvider implement
476
476
}
477
477
478
478
public async transactionsByHashes ( { ids } : TransactionsByIdsArgs ) : Promise < Cardano . HydratedTx [ ] > {
479
- const cachedTransactions : Cardano . HydratedTx [ ] = [ ] ;
480
- const idsToFetch : Cardano . TransactionId [ ] = [ ] ;
481
-
482
- for ( const id of ids ) {
483
- if ( this . cache . has ( id ) ) {
484
- cachedTransactions . push ( this . cache . get ( id ) ! ) ;
485
- } else {
486
- idsToFetch . push ( id ) ;
487
- }
488
- }
489
-
490
- let fetchedTransactions : Cardano . HydratedTx [ ] = [ ] ;
491
- if ( idsToFetch . length > 0 ) {
492
- try {
493
- fetchedTransactions = await Promise . all ( idsToFetch . map ( ( id ) => this . fetchTransaction ( id ) ) ) ;
494
-
495
- for ( const tx of fetchedTransactions ) {
496
- this . cache . set ( tx . id , tx ) ;
479
+ return Promise . all (
480
+ ids . map ( async ( id ) => {
481
+ if ( this . cache . has ( id ) ) {
482
+ return this . cache . get ( id ) ! ;
497
483
}
498
- } catch ( error ) {
499
- throw this . toProviderError ( error ) ;
500
- }
501
- }
502
-
503
- return [ ...cachedTransactions , ...fetchedTransactions ] ;
484
+ try {
485
+ const fetchedTransaction = await this . fetchTransaction ( id ) ;
486
+ this . cache . set ( id , fetchedTransaction ) ;
487
+ return fetchedTransaction ;
488
+ } catch ( error ) {
489
+ throw this . toProviderError ( error ) ;
490
+ }
491
+ } )
492
+ ) ;
504
493
}
505
494
506
495
// eslint-disable-next-line sonarjs/cognitive-complexity
You can’t perform that action at this time.
0 commit comments